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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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); }
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)); }
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); }
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); }
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; }
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; }
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; }
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 ); }
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; }
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; }
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); }
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; }
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); }
internal static void AddIdent(IdentNode id, string postfix, Symbol s) { id.identifier += postfix; id.end = s.endpos; }
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); }
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); }
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); }
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; }
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; }
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; }
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; }
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; }
internal static void AddIdent( IdentNode id, string postfix, Symbol s ) { id.identifier += postfix; id.end = s.endpos; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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); }