public ClassDescriptor(InternalType t, string name, Scope s)
     : base(t)
 {
     Methods = new List<MethodDescriptor>();
     Fields = new List<MemberDescriptor>();
     Name = name;
     Scope = s;
 }
 private void AddCtorIfNone(Scope classScope, string name)
 {
     var ctor = _currentClass.Descriptor.Methods.SingleOrDefault(p => p.Name.Equals(_currentClass.ClassName, StringComparison.OrdinalIgnoreCase));
     if (ctor == null)
     {
         var func = new TypeFunction(name) { ReturnType = new TypeVoid(), IsConstructor = true, Scope = classScope };
         _mgr.AddMethod(name, func, _currentClass);
     }
 }
 public Scope(string name, Scope parent)
 {
     Parent = parent;
     Name = name;
     Descriptors = new Dictionary<string, Descriptor>();
 }
 public bool HasSymbol(string identifier, Scope s)
 {
     return Find(identifier, d => true, s) != null;
 }
 public ScopeManager()
 {
     CurrentScope = new Scope("top", null);
     TopScope = CurrentScope;
 }
        private static Descriptor Find(string name, Func<Descriptor, bool> pred, Scope s, bool currentOnly = false)
        {
            var checkScope = s;

            while (checkScope != null)
            {
                if (checkScope.HasSymbol(name))
                {
                    var d = checkScope.Descriptors[name];
                    if (pred(d))
                        return d;
                }
                checkScope = !currentOnly ? checkScope.Parent : null;
            }

            return null;
        }
 public Scope PushScope(string name)
 {
     CurrentScope = new Scope(name, CurrentScope);
     return CurrentScope;
 }