protected FunctionGroup(ChelaModule module) : base(module) { this.name = string.Empty; this.parentScope = null; this.functions = new SimpleSet<FunctionGroupName> (); }
public TypeNameMember(MemberFlags flags, string name, Scope parentScope) : this(parentScope.GetModule()) { this.flags = flags; this.name = name; this.parentScope = parentScope; }
public AstVisitor() { this.currentScope = null; this.currentContainer = null; this.unsafeCount = 0; this.scopeStack = new LinkedList<Scope> (); }
public PropertyVariable(ChelaModule module) : base(module) { this.flags = MemberFlags.Default; this.indices = null; this.parentScope = null; }
public Function(string name, MemberFlags flags, Scope parentScope) : this(parentScope.GetModule()) { this.name = name; this.flags = flags; this.parentScope = parentScope; }
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; }
public PseudoScope(PlaceHolderType placeHolder) : base(placeHolder.GetModule()) { this.placeHolder = placeHolder; this.members = null; this.parentScope = null; this.chainNamespace = null; }
protected TypeGroup(TypeGroup group) : base(group.GetModule()) { this.name = group.name; this.fullName = null; this.parentScope = group.GetParentScope(); this.types = new SimpleSet<TypeGroupName> (); }
public PseudoScope(Scope parent) : base(parent.GetModule()) { this.placeHolder = null; this.parentScope = parent; this.members = new Dictionary<string, ScopeMember> (); this.chainNamespace = null; }
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); }
protected TypeGroup(ChelaModule module) : base(module) { this.name = string.Empty; this.fullName = null; this.parentScope = null; this.types = new SimpleSet<TypeGroupName> (); }
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); } }
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; }
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; }
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."); }
public AmbiguousStructure(string name, MemberFlags flags, Scope parentScope) : base(name, flags, parentScope) { this.candidates = new List<Structure> (); }
public void SetScope(Scope scope) { this.scope = scope; }
public ScopeNode(AstNode children, TokenPosition position) : base(position) { this.children = children; this.scope = null; }
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."); } }
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); }
internal override void UpdateParent(Scope parentScope) { // Store the new parent. this.parentScope = parentScope; }
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); } }
public TypeGroup(string name, Scope parentScope) : this(parentScope.GetModule()) { this.name = name; this.parentScope = parentScope; }
public void SetExpansionScope(Scope[] scope) { expansionScope = scope; }
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(); }
/// <summary> /// Constructs an ambiguous function description. /// </summary> public FunctionAmbiguity(string name, MemberFlags flags, Scope parentScope) : base(name, flags, parentScope) { candidates = new List<Function> (); }
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; }
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); } }
public Class(string name, MemberFlags flags, Scope parentScope) : base(name, flags, parentScope) { }
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; }