예제 #1
0
 protected FunctionGroup(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.parentScope = null;
     this.functions = new SimpleSet<FunctionGroupName> ();
 }
예제 #2
0
 public TypeNameMember(MemberFlags flags, string name, Scope parentScope)
     : this(parentScope.GetModule())
 {
     this.flags = flags;
     this.name = name;
     this.parentScope = parentScope;
 }
예제 #3
0
 public AstVisitor()
 {
     this.currentScope = null;
     this.currentContainer = null;
     this.unsafeCount = 0;
     this.scopeStack = new LinkedList<Scope> ();
 }
예제 #4
0
 public PropertyVariable(ChelaModule module)
     : base(module)
 {
     this.flags = MemberFlags.Default;
     this.indices = null;
     this.parentScope = null;
 }
예제 #5
0
파일: Function.cs 프로젝트: ronsaldo/chela
 public Function(string name, MemberFlags flags, Scope parentScope)
     : this(parentScope.GetModule())
 {
     this.name = name;
     this.flags = flags;
     this.parentScope = parentScope;
 }
예제 #6
0
 public PropertyVariable(string name, MemberFlags flags, IChelaType type, IChelaType[] indices, Scope parentScope)
     : base(type, parentScope.GetModule())
 {
     SetName(name);
     this.flags = flags;
     this.indices = indices;
     this.parentScope = parentScope;
 }
예제 #7
0
 public PseudoScope(PlaceHolderType placeHolder)
     : base(placeHolder.GetModule())
 {
     this.placeHolder = placeHolder;
     this.members = null;
     this.parentScope = null;
     this.chainNamespace = null;
 }
예제 #8
0
파일: TypeGroup.cs 프로젝트: ronsaldo/chela
 protected TypeGroup(TypeGroup group)
     : base(group.GetModule())
 {
     this.name = group.name;
     this.fullName = null;
     this.parentScope = group.GetParentScope();
     this.types = new SimpleSet<TypeGroupName> ();
 }
예제 #9
0
 public PseudoScope(Scope parent)
     : base(parent.GetModule())
 {
     this.placeHolder = null;
     this.parentScope = parent;
     this.members = new Dictionary<string, ScopeMember> ();
     this.chainNamespace = null;
 }
예제 #10
0
 public LexicalScope(Scope parentScope, Function parentFunction)
     : base(parentScope.GetModule())
 {
     this.members = new Dictionary<string, ScopeMember> ();
     this.parentScope = parentScope;
     this.parentFunction = parentFunction;
     this.index = parentFunction.AddLexicalScope(this);
 }
예제 #11
0
파일: TypeGroup.cs 프로젝트: ronsaldo/chela
 protected TypeGroup(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.fullName = null;
     this.parentScope = null;
     this.types = new SimpleSet<TypeGroupName> ();
 }
예제 #12
0
 public PseudoScope(Scope parent, GenericPrototype genProto)
     : this(parent)
 {
     for(int i = 0; i < genProto.GetPlaceHolderCount(); ++i)
     {
         PlaceHolderType placeHolder = genProto.GetPlaceHolder(i);
         AddAlias(placeHolder.GetName(), placeHolder);
     }
 }
예제 #13
0
 public TypeNameMember(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.parentScope = null;
     this.typedefNode = null;
     this.actualType = null;
     this.isExpanding = false;
     this.flags = MemberFlags.Default;
 }
예제 #14
0
파일: Function.cs 프로젝트: ronsaldo/chela
 protected Function(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.flags = MemberFlags.Default;
     this.parentScope = null;
     this.basicBlocks = new List<BasicBlock> ();
     this.lexicalScopes = new List<LexicalScope>();
     this.locals = new List<LocalVariable> ();
     this.position = null;
     this.exceptionContext = null;
     this.returnBlock = null;
     this.returningVar = null;
     this.returnValueVar = null;
     this.genericPrototype = GenericPrototype.Empty;
     this.arguments  = null;
 }
예제 #15
0
        public void CheckScopeVisibility(AstNode node, Scope scope)
        {
            // Check the parent scope access.
            Scope parentScope = scope.GetParentScope();
            if(parentScope != null)
                CheckScopeVisibility(node, parentScope);

            // Internal scopes module must be the current one.
            if(scope.IsInternal() && scope.GetModule() != currentModule)
                Error(node, "cannot access internal member " + scope.GetFullName() +" of another module.");
        }
예제 #16
0
 public AmbiguousStructure(string name, MemberFlags flags, Scope parentScope)
     : base(name, flags, parentScope)
 {
     this.candidates = new List<Structure> ();
 }
예제 #17
0
파일: ScopeNode.cs 프로젝트: ronsaldo/chela
 public void SetScope(Scope scope)
 {
     this.scope = scope;
 }
예제 #18
0
파일: ScopeNode.cs 프로젝트: ronsaldo/chela
 public ScopeNode(AstNode children, TokenPosition position)
     : base(position)
 {
     this.children = children;
     this.scope = null;
 }
예제 #19
0
        protected void PopScope()
        {
            // Restore the unsafe context.
            if(currentScope != null && currentScope.IsUnsafe())
                PopUnsafe();

            currentScope = scopeStack.First.Value;
            scopeStack.RemoveFirst();

            if(currentScope == null || !currentScope.IsPseudoScope())
            {
                currentContainer = currentScope;
            }
            else
            {
                // Find the closest container.
                currentContainer = null;
                foreach(Scope scope in scopeStack)
                {
                    if(!scope.IsPseudoScope())
                    {
                        currentContainer = scope;
                        break;
                    }
                }

                // Couldn't find a container.
                if(currentContainer == null)
                    throw new System.ApplicationException("couldn't find a container scope.");
            }
        }
예제 #20
0
파일: Namespace.cs 프로젝트: ronsaldo/chela
        internal override void UpdateParent(Scope parentScope)
        {
            // Store the new parent.
            this.parentScope = (Namespace)parentScope;

            // Update the children.
            foreach(ScopeMember child in members.Values)
                child.UpdateParent(this);
        }
예제 #21
0
 internal override void UpdateParent(Scope parentScope)
 {
     // Store the new parent.
     this.parentScope = parentScope;
 }
예제 #22
0
파일: TypeGroup.cs 프로젝트: ronsaldo/chela
        internal override void UpdateParent(Scope parentScope)
        {
            // Store the parent.
            this.parentScope = parentScope;

            // Update the children parent.
            if(memberList != null)
            {
                foreach(ScopeMember member in memberList)
                    member.UpdateParent (parentScope);
            }
        }
예제 #23
0
파일: TypeGroup.cs 프로젝트: ronsaldo/chela
 public TypeGroup(string name, Scope parentScope)
     : this(parentScope.GetModule())
 {
     this.name = name;
     this.parentScope = parentScope;
 }
예제 #24
0
 public void SetExpansionScope(Scope[] scope)
 {
     expansionScope = scope;
 }
예제 #25
0
        protected void PushScope(Scope scope)
        {
            scopeStack.AddFirst(currentScope);
            currentScope = scope;

            // Differentiate between pseudo-scopes.
            if(!currentScope.IsPseudoScope())
                currentContainer = currentScope;

            // Push the unsafe context.
            if(scope.IsUnsafe())
                PushUnsafe();
        }
예제 #26
0
 /// <summary>
 /// Constructs an ambiguous function description.
 /// </summary>
 public FunctionAmbiguity(string name, MemberFlags flags, Scope parentScope)
     : base(name, flags, parentScope)
 {
     candidates = new List<Function> ();
 }
예제 #27
0
        private Structure GetFirstType(Scope scope, string name)
        {
            // Get the member.
            ScopeMember member = scope.FindMember(name);

            // Use the default type of the group.
            if(member.IsTypeGroup())
            {
                TypeGroup group = (TypeGroup)member;
                foreach(TypeGroupName gname in @group.GetBuildings())
                {
                    Structure building = gname.GetBuilding();
                    if(building != null)
                        return building;
                }
                throw new ModuleException("failed to get first type in group.");
            }
            else if(!member.IsClass() && !member.IsStructure() && !member.IsInterface())
                throw new ModuleException("expected class/structure/interface.");

            // Cast the member.
            return (Structure) member;
        }
예제 #28
0
        private void ExpandTypeNode(TypedefDefinition node, bool sorted)
        {
            // Use the scope in the same place as the definition.
            Scope[] expansionScope = null;
            if(sorted)
            {
                expansionScope = node.GetExpansionScope();
                foreach(Scope scope in expansionScope)
                    PushScope(scope);
            }

            // Allow unsafe typedefs.
            PushUnsafe();

            // Get the type name member.
            TypeNameMember typeName = node.GetTypeName();

            // Parse the type expression.
            Expression typeExpr = node.GetTypeExpression();
            typeExpr.Accept(this);

            // Make sure the type expression is a type.
            IChelaType actualType = typeExpr.GetNodeType();
            actualType = ExtractActualType(typeExpr, actualType);

            // Store the type.
            typeName.SetActualType(actualType);

            // Store the incomplete typename.
            if(actualType.IsIncompleteType())
            {
                // Don't allow cyclic expansion.
                if(sorted)
                    Error(node, "typedef cannot be expanded.");

                // Store the incomplete type name.
                incompletes.Add(typeName);

                // Store the typedef scope stack.
                int numscopes = scopeStack.Count + 1;
                Scope[] scopeData = new Scope[numscopes];
                int i = numscopes - 1;
                scopeData[i--] = currentScope;
                foreach(Scope scope in scopeStack)
                    scopeData[i--] = scope;
                node.SetExpansionScope(scopeData);
            }

            // Restore the safe context.
            PopUnsafe();

            // Restore the scope.
            if(sorted)
            {
                for(int i = 0; i < expansionScope.Length; ++i)
                    PopScope();
                node.SetExpansionScope(null);
            }
        }
예제 #29
0
파일: Class.cs 프로젝트: ronsaldo/chela
 public Class(string name, MemberFlags flags, Scope parentScope)
     : base(name, flags, parentScope)
 {
 }
예제 #30
0
        private Structure GetDefaultType(Scope scope, string name)
        {
            // Get the member.
            ScopeMember member = scope.FindMember(name);

            // Use the default type of the group.
            if(member.IsTypeGroup())
            {
                TypeGroup group = (TypeGroup)member;
                return group.GetDefaultType();
            }
            else if(!member.IsClass() && !member.IsStructure() && !member.IsInterface())
                throw new ModuleException("expected class/structure/interface.");

            // Cast the member.
            return (Structure) member;
        }