Пример #1
0
        internal static TypeName TypeName(IdentNode typename, Symbol s)
        {
            TypeName res = new TypeName();

            res.kind     = Kind.TypeName;
            res.start    = s.pos;
            res.end      = s.endpos;
            res.typename = typename;
            return(res);
        }
Пример #2
0
        internal static IdentNode Ident(string identifier, Symbol s)
        {
            IdentNode res = new IdentNode();

            res.kind       = Kind.Identifier;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.identifier = identifier;
            return(res);
        }
Пример #3
0
        internal static VariableNode Variable(IdentNode name, InitializerNode init, Symbol s)
        {
            VariableNode res = new VariableNode();

            res.kind  = Kind.Variable;
            res.start = s.pos;
            res.end   = s.endpos;
            res.name  = name;
            res.init  = init;
            return(res);
        }
Пример #4
0
        internal static ConstantNode Constant(IdentNode name, ExprNode constant, Symbol s)
        {
            ConstantNode res = new ConstantNode();

            res.kind     = Kind.Constant;
            res.start    = s.pos;
            res.end      = s.endpos;
            res.name     = name;
            res.constant = constant;
            return(res);
        }
Пример #5
0
        internal static UsingNode Using(Kind k, IdentNode alias_id, IdentNode type_name, Symbol s)
        {
            UsingNode res = new UsingNode();

            res.kind      = k;
            res.start     = s.pos;
            res.end       = s.endpos;
            res.alias_id  = alias_id;
            res.type_name = type_name;
            return(res);
        }
Пример #6
0
        internal static AttributeSectionNode AttributeSection(IdentNode target, ListNode attrs, Symbol s)
        {
            AttributeSectionNode res = new AttributeSectionNode();

            res.kind   = Kind.AttributeSection;
            res.start  = s.pos;
            res.end    = s.endpos;
            res.target = target;
            res.attrs  = attrs;
            return(res);
        }
Пример #7
0
        internal static AttributeNode Attribute(IdentNode name, ListNode parms, Symbol s)
        {
            AttributeNode res = new AttributeNode();

            res.kind  = Kind.Attribute;
            res.start = s.pos;
            res.end   = s.endpos;
            res.name  = name;
            res.parms = parms;
            return(res);
        }
Пример #8
0
        internal static EnumValueNode EnumValue(ListNode attributes, IdentNode name, ExprNode expr, Symbol s)
        {
            EnumValueNode res = new EnumValueNode();

            res.kind       = Kind.EnumValue;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.attributes = attributes;
            res.name       = name;
            res.expr       = expr;
            return(res);
        }
Пример #9
0
        internal static AccessorNode Accessor(ListNode attributes, IdentNode name, StatementNode body, Symbol s)
        {
            AccessorNode res = new AccessorNode();

            res.kind       = Kind.Accessor;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.attributes = attributes;
            res.name       = name;
            res.body       = body;
            return(res);
        }
Пример #10
0
        internal static NamespaceDecl Namespace(IdentNode name, ListNode usings, ListNode members, Symbol s)
        {
            NamespaceDecl res = new NamespaceDecl();

            res.kind    = Kind.Namespace;
            res.start   = s.pos;
            res.end     = s.endpos;
            res.name    = name;
            res.usings  = usings;
            res.members = members;
            return(res);
        }
Пример #11
0
        internal static EnumDecl Enum(ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode basetype, ListNode children, Symbol s)
        {
            EnumDecl res = new EnumDecl();

            res.kind       = Kind.Enum;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.attributes = attributes;
            res.modifiers  = modifiers;
            res.name       = name;
            res.basetype   = basetype;
            res.children   = children;
            return(res);
        }
Пример #12
0
        internal static StatementNode Statement(Kind k, ExprNode expr, IdentNode label, StatementNode stmt1, StatementNode stmt2, ListNode stmts, Symbol s)
        {
            StatementNode res = new StatementNode();

            res.kind  = k;
            res.start = s.pos;
            res.end   = s.endpos;
            res.expr  = expr;
            res.label = label;
            res.stmt1 = stmt1;
            res.stmt2 = stmt2;
            res.stmts = stmts;
            return(res);
        }
Пример #13
0
        internal static TypedStatementNode TypedStatement(Kind k, ExprNode expr, IdentNode label, StatementNode stmt1, StatementNode stmt2, ListNode stmts, TypeNode type, Symbol s)
        {
            TypedStatementNode res = new TypedStatementNode();

            res.kind  = k;
            res.start = s.pos;
            res.end   = s.endpos;
            res.expr  = expr;
            res.label = label;
            res.stmt1 = stmt1;
            res.stmt2 = stmt2;
            res.stmts = stmts;
            res.type  = type;
            return(res);
        }
Пример #14
0
        internal static MethodDecl Operator(ModifiersNode mod, TypeNode type, IdentNode name, ParameterNode op1, ParameterNode op2, Symbol s)
        {
            ListNode ln = new ListNode();

            ln.nodes = new ArrayList();
            ln.nodes.Add(op1);
            if (op2 != null)
            {
                ln.nodes.Add(op2);
            }
            ln.start = op1.start;
            ln.end   = op2 != null ? op2.end : op1.end;
            ln.kind  = Kind.List;
            return(Method(name == null ? Kind.ConversionOperator : op2 == null ? Kind.UnaryOperator : Kind.BinaryOperator, null, mod, name, type, ln, null, null, s));
        }
Пример #15
0
        internal static TypeNode type_from_expr(ExprNode expr)
        {
            Symbol s = new Symbol();

            s.pos    = expr.start;
            s.endpos = expr.end;

            switch (expr.kind)
            {
            case Kind.Identifier:
                return(Make.TypeName((IdentNode)expr, s));

            case Kind.Dot:
            case Kind.TypeDot:
                string id = String.Empty;
                while (expr.kind == Kind.Dot)
                {
                    IdentNode idn = ((BinaryNode)expr).right as IdentNode;
                    id   = "." + idn.identifier + id;
                    expr = ((BinaryNode)expr).left;
                }
                if (expr.kind == Kind.TypeDot)
                {
                    // types like: int.A
                    ExprAndTypeNode etn = (ExprAndTypeNode)expr;
                    id = (etn.type as BaseType).typeid.ToString().Substring(1) + "." + (etn.expr as IdentNode).identifier + id;
                    return(Make.TypeName(Make.Ident(id, s), s));
                }
                else if (expr.kind == Kind.Identifier)
                {
                    // types like: a.b.c
                    ((IdentNode)expr).identifier += id;
                    return(Make.TypeName((IdentNode)expr, s));
                }
                return(null);

            case Kind.DimmedExpr:
                TypeExprNode ten = (TypeExprNode)expr;
                return(Make.OneArrayType(type_from_expr(ten.expr), ten.spec, s));
            }
            return(null);
        }
Пример #16
0
        internal static EventNode Event(Kind k, ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, ListNode vars, Symbol s)
        {
            EventNode res = new EventNode();

            res.kind       = k;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.attributes = attributes;
            res.modifiers  = modifiers;
            res.type       = type;
            res.name       = name;
            res.accessors  = accessors;
            res.vars       = vars;
            return(res);
        }
Пример #17
0
 internal static PropertyNode Property( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, Symbol s )
 {
     PropertyNode res = new PropertyNode();
     res.kind = Kind.Property;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.accessors = accessors;
     return res;
 }
Пример #18
0
 internal static TypedStatementNode TypedStatement( Kind k, ExprNode expr, IdentNode label, StatementNode stmt1, StatementNode stmt2, ListNode stmts, TypeNode type, Symbol s )
 {
     TypedStatementNode res = new TypedStatementNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.label = label;
     res.stmt1 = stmt1;
     res.stmt2 = stmt2;
     res.stmts = stmts;
     res.type = type;
     return res;
 }
Пример #19
0
 internal static MethodDecl Method( Kind k, ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode return_type, ListNode parameters, StatementNode body, ConstructorInitializerNode base_init, Symbol s )
 {
     MethodDecl res = new MethodDecl();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.return_type = return_type;
     res.parameters = parameters;
     res.body = body;
     res.base_init = base_init;
     return res;
 }
Пример #20
0
 internal static MethodDecl Operator( ModifiersNode mod, TypeNode type, IdentNode name, ParameterNode op1, ParameterNode op2, Symbol s )
 {
     ListNode ln = new ListNode();
     ln.nodes = new ArrayList();
     ln.nodes.Add( op1 );
     if( op2 != null )
         ln.nodes.Add( op2 );
     ln.start = op1.start;
     ln.end = op2 != null ? op2.end : op1.end;
     ln.kind = Kind.List;
     return Method( name == null ? Kind.ConversionOperator : op2 == null ? Kind.UnaryOperator : Kind.BinaryOperator, null, mod, name, type, ln, null, null, s );
 }
Пример #21
0
 internal static EnumValueNode EnumValue( ListNode attributes, IdentNode name, ExprNode expr, Symbol s )
 {
     EnumValueNode res = new EnumValueNode();
     res.kind = Kind.EnumValue;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.name = name;
     res.expr = expr;
     return res;
 }
Пример #22
0
 internal static IdentNode Ident( string identifier, Symbol s )
 {
     IdentNode res = new IdentNode();
     res.kind = Kind.Identifier;
     res.start = s.pos;
     res.end = s.endpos;
     res.identifier = identifier;
     return res;
 }
Пример #23
0
        internal static MethodDecl Method(Kind k, ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode return_type, ListNode parameters, StatementNode body, ConstructorInitializerNode base_init, Symbol s)
        {
            MethodDecl res = new MethodDecl();

            res.kind        = k;
            res.start       = s.pos;
            res.end         = s.endpos;
            res.attributes  = attributes;
            res.modifiers   = modifiers;
            res.name        = name;
            res.return_type = return_type;
            res.parameters  = parameters;
            res.body        = body;
            res.base_init   = base_init;
            return(res);
        }
Пример #24
0
 internal static UsingNode Using( Kind k, IdentNode alias_id, IdentNode type_name, Symbol s )
 {
     UsingNode res = new UsingNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.alias_id = alias_id;
     res.type_name = type_name;
     return res;
 }
Пример #25
0
        internal static DelegateNode Delegate(ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode return_type, ListNode parameters, Symbol s)
        {
            DelegateNode res = new DelegateNode();

            res.kind        = Kind.Delegate;
            res.start       = s.pos;
            res.end         = s.endpos;
            res.attributes  = attributes;
            res.modifiers   = modifiers;
            res.name        = name;
            res.return_type = return_type;
            res.parameters  = parameters;
            return(res);
        }
Пример #26
0
 internal static void AddIdent(IdentNode id, string postfix, Symbol s)
 {
     id.identifier += postfix;
     id.end         = s.endpos;
 }
Пример #27
0
        internal static ClassDecl Class(Kind k, ListNode attributes, ModifiersNode modifiers, IdentNode name, ListNode inheritance, ListNode members, Symbol s)
        {
            ClassDecl res = new ClassDecl();

            res.kind        = k;
            res.start       = s.pos;
            res.end         = s.endpos;
            res.attributes  = attributes;
            res.modifiers   = modifiers;
            res.name        = name;
            res.inheritance = inheritance;
            res.members     = members;
            return(res);
        }
Пример #28
0
        internal static ParameterNode Parameter(ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, Symbol s)
        {
            ParameterNode res = new ParameterNode();

            res.kind       = Kind.Param;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.attributes = attributes;
            res.modifiers  = modifiers;
            res.type       = type;
            res.name       = name;
            return(res);
        }
Пример #29
0
        internal static PropertyNode Property(ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, Symbol s)
        {
            PropertyNode res = new PropertyNode();

            res.kind       = Kind.Property;
            res.start      = s.pos;
            res.end        = s.endpos;
            res.attributes = attributes;
            res.modifiers  = modifiers;
            res.type       = type;
            res.name       = name;
            res.accessors  = accessors;
            return(res);
        }
Пример #30
0
 internal static DelegateNode Delegate( ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode return_type, ListNode parameters, Symbol s )
 {
     DelegateNode res = new DelegateNode();
     res.kind = Kind.Delegate;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.return_type = return_type;
     res.parameters = parameters;
     return res;
 }
Пример #31
0
 internal static VariableNode Variable( IdentNode name, InitializerNode init, Symbol s )
 {
     VariableNode res = new VariableNode();
     res.kind = Kind.Variable;
     res.start = s.pos;
     res.end = s.endpos;
     res.name = name;
     res.init = init;
     return res;
 }
Пример #32
0
 internal static EnumDecl Enum( ListNode attributes, ModifiersNode modifiers, IdentNode name, TypeNode basetype, ListNode children, Symbol s )
 {
     EnumDecl res = new EnumDecl();
     res.kind = Kind.Enum;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.basetype = basetype;
     res.children = children;
     return res;
 }
Пример #33
0
 internal static AccessorNode Accessor( ListNode attributes, IdentNode name, StatementNode body, Symbol s )
 {
     AccessorNode res = new AccessorNode();
     res.kind = Kind.Accessor;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.name = name;
     res.body = body;
     return res;
 }
Пример #34
0
 internal static EventNode Event( Kind k, ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode accessors, ListNode vars, Symbol s )
 {
     EventNode res = new EventNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.accessors = accessors;
     res.vars = vars;
     return res;
 }
Пример #35
0
 internal static void AddIdent( IdentNode id, string postfix, Symbol s )
 {
     id.identifier += postfix;
     id.end = s.endpos;
 }
Пример #36
0
 internal static IndexerNode Indexer( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode formal_params, ListNode accessors, Symbol s )
 {
     IndexerNode res = new IndexerNode();
     res.kind = Kind.Indexer;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     res.formal_params = formal_params;
     res.accessors = accessors;
     return res;
 }
Пример #37
0
 internal static AttributeNode Attribute( IdentNode name, ListNode parms, Symbol s )
 {
     AttributeNode res = new AttributeNode();
     res.kind = Kind.Attribute;
     res.start = s.pos;
     res.end = s.endpos;
     res.name = name;
     res.parms = parms;
     return res;
 }
Пример #38
0
 internal static NamespaceDecl Namespace( IdentNode name, ListNode usings, ListNode members, Symbol s )
 {
     NamespaceDecl res = new NamespaceDecl();
     res.kind = Kind.Namespace;
     res.start = s.pos;
     res.end = s.endpos;
     res.name = name;
     res.usings = usings;
     res.members = members;
     return res;
 }
Пример #39
0
 internal static AttributeSectionNode AttributeSection( IdentNode target, ListNode attrs, Symbol s )
 {
     AttributeSectionNode res = new AttributeSectionNode();
     res.kind = Kind.AttributeSection;
     res.start = s.pos;
     res.end = s.endpos;
     res.target = target;
     res.attrs = attrs;
     return res;
 }
Пример #40
0
 internal static ParameterNode Parameter( ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, Symbol s )
 {
     ParameterNode res = new ParameterNode();
     res.kind = Kind.Param;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.type = type;
     res.name = name;
     return res;
 }
Пример #41
0
 internal static ClassDecl Class( Kind k, ListNode attributes, ModifiersNode modifiers, IdentNode name, ListNode inheritance, ListNode members, Symbol s )
 {
     ClassDecl res = new ClassDecl();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.attributes = attributes;
     res.modifiers = modifiers;
     res.name = name;
     res.inheritance = inheritance;
     res.members = members;
     return res;
 }
Пример #42
0
 internal static StatementNode Statement( Kind k, ExprNode expr, IdentNode label, StatementNode stmt1, StatementNode stmt2, ListNode stmts, Symbol s )
 {
     StatementNode res = new StatementNode();
     res.kind = k;
     res.start = s.pos;
     res.end = s.endpos;
     res.expr = expr;
     res.label = label;
     res.stmt1 = stmt1;
     res.stmt2 = stmt2;
     res.stmts = stmts;
     return res;
 }
Пример #43
0
 internal static ConstantNode Constant( IdentNode name, ExprNode constant, Symbol s )
 {
     ConstantNode res = new ConstantNode();
     res.kind = Kind.Constant;
     res.start = s.pos;
     res.end = s.endpos;
     res.name = name;
     res.constant = constant;
     return res;
 }
Пример #44
0
 internal static TypeName TypeName( IdentNode typename, Symbol s )
 {
     TypeName res = new TypeName();
     res.kind = Kind.TypeName;
     res.start = s.pos;
     res.end = s.endpos;
     res.typename = typename;
     return res;
 }
Пример #45
0
        internal static IndexerNode Indexer(ListNode attributes, ModifiersNode modifiers, TypeNode type, IdentNode name, ListNode formal_params, ListNode accessors, Symbol s)
        {
            IndexerNode res = new IndexerNode();

            res.kind          = Kind.Indexer;
            res.start         = s.pos;
            res.end           = s.endpos;
            res.attributes    = attributes;
            res.modifiers     = modifiers;
            res.type          = type;
            res.name          = name;
            res.formal_params = formal_params;
            res.accessors     = accessors;
            return(res);
        }