コード例 #1
0
ファイル: CaseLabel.cs プロジェクト: ronsaldo/chela
 public CaseLabel(Expression constant, AstNode children, TokenPosition position)
     : base(position)
 {
     this.constant = constant;
     this.children = children;
     this.block = null;
 }
コード例 #2
0
 public ConstructorInitializer(bool baseCall, AstNode arguments, TokenPosition position)
     : base(position)
 {
     this.baseCall = baseCall;
     this.arguments = arguments;
     this.ctorGroup = null;
 }
コード例 #3
0
ファイル: ClassDefinition.cs プロジェクト: ronsaldo/chela
 public ClassDefinition(MemberFlags flags, string name,
                        GenericSignature genericSignature,
                        AstNode bases, AstNode children, TokenPosition position)
     : base(flags, name, genericSignature,
            bases, children, position)
 {
 }
コード例 #4
0
ファイル: MakeFunctionPointer.cs プロジェクト: ronsaldo/chela
 public MakeFunctionPointer(Expression returnType, AstNode arguments, MemberFlags flags, TokenPosition position)
     : base(position)
 {
     this.returnType = returnType;
     this.arguments = arguments;
     this.flags = flags;
 }
コード例 #5
0
ファイル: EnumDefinition.cs プロジェクト: ronsaldo/chela
 public EnumDefinition(MemberFlags flags, string name, AstNode children,
     Expression typeExpr, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.flags = flags;
     this.typeExpr = typeExpr;
 }
コード例 #6
0
ファイル: TryStatement.cs プロジェクト: ronsaldo/chela
 public TryStatement(AstNode tryStatement, AstNode catchList,
                      AstNode finallyStatement, TokenPosition position)
     : base(position)
 {
     this.tryStatement = tryStatement;
     this.catchList = catchList;
     this.finallyStatement = finallyStatement;
 }
コード例 #7
0
ファイル: SwitchStatement.cs プロジェクト: ronsaldo/chela
 public SwitchStatement(Expression constant, AstNode cases, TokenPosition position)
     : base(position)
 {
     this.constant = constant;
     this.cases = cases;
     this.defaultCase = null;
     this.caseDictionary = new Dictionary<ConstantValue, CaseLabel> ();
 }
コード例 #8
0
ファイル: FunctionDefinition.cs プロジェクト: ronsaldo/chela
 public FunctionDefinition(FunctionPrototype prototype, AstNode children, TokenPosition position)
     : base(children, position)
 {
     this.prototype = prototype;
     this.function = null;
     this.isGenerator = false;
     this.hasReturns = false;
     this.yields = new List<ReturnStatement> ();
 }
コード例 #9
0
ファイル: CatchStatement.cs プロジェクト: ronsaldo/chela
 public CatchStatement(Expression exceptionType, string name,
                        AstNode children, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.exceptionType = exceptionType;
     this.context = null;
     this.variable = null;
 }
コード例 #10
0
ファイル: PropertyAccessor.cs プロジェクト: ronsaldo/chela
 public PropertyAccessor(MemberFlags flags, AstNode children, TokenPosition position)
     : base(null, children, position)
 {
     this.flags = flags;
     this.property = null;
     this.selfLocal = null;
     this.indices = null;
     this.indexerVariables = null;
 }
コード例 #11
0
 public EventAccessorDefinition(MemberFlags flags, string name, AstNode children, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.flags = flags;
     this.eventVariable = null;
     this.function = null;
     this.selfLocal = null;
     this.valueLocal = null;
 }
コード例 #12
0
ファイル: EventDefinition.cs プロジェクト: ronsaldo/chela
 public EventDefinition(MemberFlags flags, Expression eventType,
                         string name, AstNode accessors, TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.flags = flags;
     this.eventType = eventType;
     this.eventVariable = null;
     this.accessors = accessors;
     this.delegateType = null;
 }
コード例 #13
0
ファイル: PropertyDefinition.cs プロジェクト: ronsaldo/chela
 public PropertyDefinition(MemberFlags flags, Expression propertyType,
                           string name, AstNode indices, AstNode accessors, TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.flags = flags;
     this.propertyType = propertyType;
     this.property = null;
     this.indices = indices;
     this.accessors = accessors;
 }
コード例 #14
0
ファイル: NewArrayExpression.cs プロジェクト: ronsaldo/chela
 public NewArrayExpression(Expression typeExpression, Expression size,
                            AstNode initializers, int dimensions, TokenPosition position)
     : base(position)
 {
     this.typeExpression = typeExpression;
     this.size = size;
     this.initializers = initializers;
     this.dimensions = dimensions;
     this.objectType = null;
     this.initCoercionType = null;
 }
コード例 #15
0
ファイル: DelegateDefinition.cs プロジェクト: ronsaldo/chela
 public DelegateDefinition(MemberFlags flags, Expression returnType,
                            AstNode arguments, string name,
                            GenericSignature genericSignature,
                            TokenPosition position)
     : base(position)
 {
     SetName(name);
     this.genericSignature = genericSignature;
     this.flags = flags;
     this.returnType = returnType;
     this.arguments = arguments;
 }
コード例 #16
0
ファイル: AstNode.cs プロジェクト: ronsaldo/chela
 public AstNode(TokenPosition position)
 {
     this.position = position;
     this.prev = this;
     this.next = null;
     this.attributes = null;
     this.name = null;
     this.module = null;
     this.nodeType = null;
     this.coercionType = null;
     this.nodeValue = null;
 }
コード例 #17
0
ファイル: StructDefinition.cs プロジェクト: ronsaldo/chela
        public StructDefinition(MemberFlags flags, string name,
                                GenericSignature genericSignature,
		                        AstNode bases, AstNode children,
                                TokenPosition position)
            : base(children, position)
        {
            SetName(name);
            this.flags = flags;
            this.bases = bases;
            this.genericSignature = genericSignature;
            this.defaultConstructor = null;
            this.genericScope = null;
        }
コード例 #18
0
ファイル: ScopeNode.cs プロジェクト: ronsaldo/chela
        public void AddLast(AstNode child)
        {
            if(child == null)
                return;

            if(this.children == null)
            {
                this.children = child;
                return;
            }

            AstNode lastChild = this.children;
            while(lastChild.GetNext() != null)
                lastChild = lastChild.GetNext();
            lastChild.SetNext(child);
        }
コード例 #19
0
ファイル: ScopeNode.cs プロジェクト: ronsaldo/chela
        public void AddFirst(AstNode child)
        {
            if(child == null)
                return;

            if(this.children == null)
            {
                this.children = child;
                return;
            }

            // Add my children to the end of the list.
            AstNode lastChild = child;
            while(lastChild.GetNext() != null)
                lastChild = lastChild.GetNext();
            lastChild.SetNext(children);

            // Set the first.
            children = child;
        }
コード例 #20
0
ファイル: PropertyAccessor.cs プロジェクト: ronsaldo/chela
 public void SetIndices(AstNode indices)
 {
     this.indices = indices;
 }
コード例 #21
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
        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.");
        }
コード例 #22
0
ファイル: NamespaceDefinition.cs プロジェクト: ronsaldo/chela
 public NamespaceDefinition(string name, AstNode children, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.nspace = null;
 }
コード例 #23
0
ファイル: FinallyStatement.cs プロジェクト: ronsaldo/chela
 public FinallyStatement(AstNode children, TokenPosition position)
     : base(position)
 {
     this.children = children;
     this.context = null;
 }
コード例 #24
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
        public Structure ExtractClass(AstNode where, ScopeMember member)
        {
            // Make sure its a structure or type group.
            if(!member.IsClass() && !member.IsStructure() &&!member.IsInternal() &&
                !member.IsTypeGroup())
                Error(where, "coudn't load runtime class.");

            // Read the type group.
            if(member.IsTypeGroup())
            {
                TypeGroup group = (TypeGroup)member;
                Structure building = group.GetDefaultType();
                if(building == null)
                    Error(where, "unexpected type group {0}", @group.GetDisplayName());

                // Prevent ambiguity of merged type group.
                building.CheckAmbiguity(where.GetPosition());
                return building;
            }

            return (Structure)member;
        }
コード例 #25
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
        public void CheckMemberVisibility(AstNode node, ScopeMember member)
        {
            // Ignore placeholder types.
            if(member.IsType())
            {
                IChelaType type = (IChelaType)member;
                if(type.IsPlaceHolderType())
                    return;
            }

            // Special treatment for scope member.
            if(member.IsScope())
            {
                CheckScopeVisibility(node, (Scope)member);
                return;
            }

            // Check the parent scope access.
            Scope parentScope = member.GetParentScope();
            if(parentScope != null)
                CheckScopeVisibility(node, parentScope);

            // Check the actual member visibility.
            if(member.IsPrivate())
            {
                // Walk the scope hierarchy.
                Scope scope = currentScope;
                while(scope != null)
                {
                    // Found the defining scope, stop checking.
                    if(scope == parentScope ||
                       parentScope.IsInstanceOf(scope))
                        return;

                    // Found the scope.
                    scope = scope.GetParentScope();
                }

                // Couldn't find scope, raise error.
                Error(node, "cannot access private member " + member.GetFullName());
            }
            else if(member.IsProtected())
            {
                // The parent scope must be a Structure derivative.
                Structure parentBuilding = (Structure)parentScope;

                // Walk the scope hierarchy.
                Scope scope = currentScope;
                while(scope != null)
                {
                    // Found the defining scope, stop checking.
                    if(scope is Structure)
                    {
                        Structure derived = (Structure)scope;
                        if(derived == parentBuilding ||
                           derived.IsDerivedFrom(parentBuilding))
                            return;
                    }

                    // Found the scope.
                    scope = scope.GetParentScope();
                }

                // Couldn't find scope, raise error.
                Error(node, "cannot access protected member " + member.GetFullName());
            }
            else if(member.IsInternal())
            {
                if(member.GetModule() != currentModule)
                    Error(node, "cannot access internal member " + member.GetFullName() + " of another module.");
            }
        }
コード例 #26
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
 protected LexicalScope CreateLexicalScope(AstNode where)
 {
     return CreateLexicalScope(where, currentFunction);
 }
コード例 #27
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
 protected LexicalScope CreateLexicalScope(AstNode where, Function parentFunction)
 {
     LexicalScope ret = new LexicalScope(currentContainer, parentFunction);
     ret.Position = where.GetPosition();
     return ret;
 }
コード例 #28
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
        protected bool CheckGenericPlaceArgument(AstNode where, PlaceHolderType prototype, PlaceHolderType argument)
        {
            // Check for value type.
            if(prototype.IsValueType() && !argument.IsValueType())
                TryError(where, "expected value type argument.");

            // Get the argument top base.
            Structure topBase = currentModule.GetObjectClass();
            if(argument.IsValueType())
                topBase = currentModule.GetValueTypeClass();

            // Check for the bases.
            for(int i = 0; i < prototype.GetBaseCount(); ++i)
            {
                // Get the prototype base.
                Structure protoBase = prototype.GetBase(i);

                // Check for the top base.
                if(protoBase.IsClass() && (protoBase == topBase ||
                    topBase.IsDerivedFrom(protoBase)))
                    continue;
                else if(protoBase.IsInterface() && topBase.Implements(protoBase))
                    continue;

                // Check the argument bases until hit.
                bool found = false;
                for(int j = 0; j < argument.GetBaseCount(); ++j)
                {
                    // Get the argument base.
                    Structure argBase = argument.GetBase(j);

                    // Check the constraint.
                    if(protoBase == argBase ||
                       (protoBase.IsClass() && argBase.IsDerivedFrom(protoBase)) ||
                       (protoBase.IsInterface() && argBase.Implements(protoBase)))
                    {
                        found = true;
                        break;
                    }
                }

                // Raise the error.
                if(!found)
                    return TryError(where, "argument type {0} doesn't satisfy constraint {1}",
                        argument.GetFullName(), protoBase.GetFullName());
            }

            return true;
        }
コード例 #29
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
        protected bool CheckGenericArguments(AstNode where, GenericPrototype prototype, IChelaType[] arguments)
        {
            // The argument count must match.
            if(prototype.GetPlaceHolderCount() != arguments.Length)
                return TryError(where, "not matching generic argument count.");

            // Check each argument.
            for(int i = 0; i < arguments.Length; ++i)
            {
                // Get the placeholder and the type.
                PlaceHolderType placeHolder = prototype.GetPlaceHolder(i);
                IChelaType argument = arguments[i];

                // Check for value types.
                if(placeHolder.IsValueType() && !argument.IsFirstClass() && !argument.IsStructure() && !argument.IsPlaceHolderType())
                    return TryError(where, "the generic argument number {0} must be a value type.", i+1);

                // Get the argument structure.
                Structure argumentBuilding = null;
                if(argument.IsClass() || argument.IsStructure() || argument.IsInterface())
                    argumentBuilding = (Structure)argument;
                else if(argument.IsFirstClass())
                    argumentBuilding = currentModule.GetAssociatedClass(argument);
                else if(argument.IsPointer())
                {
                    // TODO: Support pointers.
                    argumentBuilding = currentModule.GetAssociatedClass(ChelaType.GetSizeType());
                }
                else if(argument.IsPlaceHolderType())
                {
                    // Check the place holder.
                    if(CheckGenericPlaceArgument(where, placeHolder, (PlaceHolderType)argument))
                        continue;
                    else
                        return false;
                }
                else
                    return TryError(where, "cannot get class for type {0}", argument.GetDisplayName());

                // Check for constraints.
                for(int j = 0; j < placeHolder.GetBaseCount(); ++j)
                {
                    // Get the base building.
                    Structure baseBuilding = placeHolder.GetBase(j);

                    // If the argument is the base pass.
                    if(argumentBuilding == baseBuilding)
                        continue;

                    // If the base is a class, check for inheritance.
                    if(baseBuilding.IsClass() && argumentBuilding.IsDerivedFrom(baseBuilding))
                        continue;

                    // If the base is a interface, check for implementation.
                    if(baseBuilding.IsInterface() && argumentBuilding.Implements(baseBuilding))
                        continue;

                    // The constraint couldn't be satisfied.
                    return TryError(where, "generic argument {0} of type {1} doesn't support constraint {2}",
                                    i+1, argumentBuilding.GetDisplayName(), baseBuilding.GetDisplayName());
                }
            }

            return true;
        }
コード例 #30
0
ファイル: ObjectDeclarator.cs プロジェクト: ronsaldo/chela
        public IChelaType ExtractActualType(AstNode where, IChelaType type)
        {
            // Extract from the meta type.
            if(!type.IsMetaType())
                Error(where, "expected a type.");
            type = ExtractMetaType(type);

            // Use the default element from the type group.
            if(type.IsTypeGroup())
            {
                TypeGroup group = (TypeGroup)type;
                Structure building = group.GetDefaultType();
                type = building;
                if(building == null)
                    Error(where, "unexpected type group {0}", @group.GetDisplayName());

                // Prevent ambiguity of merged type group.
                building.CheckAmbiguity(where.GetPosition());
            }
            return type;
        }