<commit_before>/*
 * Copyright (C) 2011 <NAME>
 * Released under the MIT License.
 */

using System;
using System.Collections.Generic;
using System.Text;
using Nana.Tokens;
using Nana.IMRs;
using Nana.Infr;
using System.Diagnostics;
using System.Reflection;
using Nana.Delegates;
using System.IO;

namespace Nana.Semantics
{
    public class Attr
    {
        public bool IsStatic = false;
        public bool CanExec_ = false;
        public bool CanExec { get { return CanExec_ || CanGet || CanSet; } }
        public bool CanGet { get { return CanDo(TypGet); } }
        public bool CanSet { get { return CanDo(TypSet); } }
        public bool CanDo(Typ t)
        {
            return t != null
                && (t.IsReferencing == false
                || t.RefType != typeof(void)
                );
        }
        public Typ TypGet = null;
        public Typ TypSet = null;
    }

    public class Sema
    {
        public Attr Att = new Attr();
        public virtual void Exec(IMRGenerator gen) { }
        public virtual void Give(IMRGenerator gen) { }
        public virtual void Take(IMRGenerator gen) { }
        public virtual void Addr(IMRGenerator gen) { }
    }

    public class Member
    {
        public Typ Ty;

        public Nmd Value;
        public Sema Instance;

        public Member(Typ ty, Nmd value, Sema instance)
        {
            Ty = ty;
            Value = value;
            Instance = instance;
        }
    }

    public class Chain : LinkedList<object>
    {
        public Chain(object a)
        {
            Add(a);
        }

        public Chain(object a, object b)
        {
            Add(a);
            Add(b);
        }

        public Chain Add(object v)
        {
            if (v is Chain)
            {
                foreach (object o in v as Chain)
                { AddLast(o); }
            }
            else
            {
                AddLast(v);
            }
            return this;
        }

    }

    public class Nmd : Sema
    {
        public string Name;

        public Nmd() { }
        public Nmd(string name) { Name = name; }

        public override string ToString() { return Name + ":" + typeof(Nmd).Name; }
    }

    public class Nsp : Nmd
    {
        public List<Nmd> Members_ = new List<Nmd>();
        public List<Action<Nsp>> EnsureMembersList = new List<Action<Nsp>>();
        public bool IsReferencing = false;
        public Env E;
        public LinkedList<Custom> Customs;

        public Nsp(string name, Env env)
            : base(name)
        {
            E = env;
        }

        public void EnsureMembers()
        {
            if (EnsureMembersList.Count == 0) { return; }
            List<Action<Nsp>> tmp = EnsureMembersList;
            EnsureMembersList = new List<Action<Nsp>>();
            tmp.ForEach(delegate(Action<Nsp> a) { a(this); });
        }

        public List<Nmd> Members
        {
            get
            {
                EnsureMembers();
                return Members_;
            }
        }

        public bool HasMember(string name)
        { return Members.Exists(GetNamePredicate<Nmd>(name)); }

        public T BeAMember<T>(T member) where T : Nmd
        {
            if (member.Name == null) { return default(T); }
            Members.Add(member);
            return member;
        }

        public List<Nmd> FindDownAll(Predicate<Nmd> pred)
        {
            List<Nmd> founds = new List<Nmd>();
            founds.AddRange(Members.FindAll(pred));
            Members.ForEach(delegate(Nmd n)
            { if (n is Nsp) { founds.AddRange((n as Nsp).FindDownAll(pred)); } });
            return founds;
        }

        virtual public Nmd Find(string name)
        {
            return Members.Find(GetNamePredicate<Nmd>(name));
        }

        virtual public Nmd FindByNamePath(string namepath)
        {
            Debug.Assert(false == string.IsNullOrEmpty(namepath));
            return FindByNamePath(new Queue<string>(namepath.Split(new char[] { '/' })));
        }

        virtual public Nmd FindByNamePath(Queue<string> namepath)
        {
            Debug.Assert(namepath != null && namepath.Count > 0);

            Nmd n = Find(namepath.Dequeue());
            if (namepath.Count == 0) { return n; }
            Nsp nsp = n as Nsp;
            if (nsp == null) { return null; }
            return nsp.FindByNamePath(namepath);
        }

        public override string ToString()
        {
            return Bty.New().Add("{").Nv("Name", Name).Add("}").Add(":").Add(GetType().Name).ToS();
        }<commit_msg>remove unused method<commit_after>/*
 * Copyright (C) 2011 <NAME>
 * Released under the MIT License.
 */

using System;
using System.Collections.Generic;
using System.Text;
using Nana.Tokens;
using Nana.IMRs;
using Nana.Infr;
using System.Diagnostics;
using System.Reflection;
using Nana.Delegates;
using System.IO;

namespace Nana.Semantics
{
    public class Attr
    {
        public bool IsStatic = false;
        public bool CanExec_ = false;
        public bool CanExec { get { return CanExec_ || CanGet || CanSet; } }
        public bool CanGet { get { return CanDo(TypGet); } }
        public bool CanSet { get { return CanDo(TypSet); } }
        public bool CanDo(Typ t)
        {
            return t != null
                && (t.IsReferencing == false
                || t.RefType != typeof(void)
                );
        }
        public Typ TypGet = null;
        public Typ TypSet = null;
    }

    public class Sema
    {
        public Attr Att = new Attr();
        public virtual void Exec(IMRGenerator gen) { }
        public virtual void Give(IMRGenerator gen) { }
        public virtual void Take(IMRGenerator gen) { }
        public virtual void Addr(IMRGenerator gen) { }
    }

    public class Member
    {
        public Typ Ty;

        public Nmd Value;
        public Sema Instance;

        public Member(Typ ty, Nmd value, Sema instance)
        {
            Ty = ty;
            Value = value;
            Instance = instance;
        }
    }

    public class Chain : LinkedList<object>
    {
        public Chain(object a)
        {
            Add(a);
        }

        public Chain(object a, object b)
        {
            Add(a);
            Add(b);
        }

        public Chain Add(object v)
        {
            if (v is Chain)
            {
                foreach (object o in v as Chain)
                { AddLast(o); }
            }
            else
            {
                AddLast(v);
            }
            return this;
        }

    }

    public class Nmd : Sema
    {
        public string Name;

        public Nmd() { }
        public Nmd(string name) { Name = name; }

        public override string ToString() { return Name + ":" + typeof(Nmd).Name; }
    }

    public class Nsp : Nmd
    {
        public List<Nmd> Members_ = new List<Nmd>();
        public List<Action<Nsp>> EnsureMembersList = new List<Action<Nsp>>();
        public bool IsReferencing = false;
        public Env E;
        public LinkedList<Custom> Customs;

        public Nsp(string name, Env env)
            : base(name)
        {
            E = env;
        }

        public void EnsureMembers()
        {
            if (EnsureMembersList.Count == 0) { return; }
            List<Action<Nsp>> tmp = EnsureMembersList;
            EnsureMembersList = new List<Action<Nsp>>();
            tmp.ForEach(delegate(Action<Nsp> a) { a(this); });
        }

        public List<Nmd> Members
        {
            get
            {
                EnsureMembers();
                return Members_;
            }
        }

        public bool HasMember(string name)
        { return Members.Exists(GetNamePredicate<Nmd>(name)); }

        public T BeAMember<T>(T member) where T : Nmd
        {
            if (member.Name == null) { return default(T); }
            Members.Add(member);
            return member;
        }

        public List<Nmd> FindDownAll(Predicate<Nmd> pred)
        {
            List<Nmd> founds = new List<Nmd>();
            founds.AddRange(Members.FindAll(pred));
            Members.ForEach(delegate(Nmd n)
            { if (n is Nsp) { founds.AddRange((n as Nsp).FindDownAll(pred)); } });
            return founds;
        }

        virtual public Nmd Find(string name)
        {
            return Members.Find(GetNamePredicate<Nmd>(name));
        }

        public override string ToString()
        {
            return Bty.New().Add("{").Nv("Name", Name).Add("}").Add(":").Add(GetType().Name).ToS();
        }
{'fraction_non_alphanumeric': 0.10614525139664804, 'fraction_numerical': 0.0013966480446927375, 'mean_word_length': 1.562015503875969, 'pattern_counts': {'":': 4, '<': 49, '<?xml version=': 0, '>': 50, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3371743', 'n_tokens_mistral': 2495, 'n_tokens_neox': 2435, 'n_words': 644}