internal static TypeExprNode TypeExpr(ExprNode expr, DimSpecNode spec, Symbol s) { TypeExprNode res = new TypeExprNode(); res.kind = Kind.DimmedExpr; res.start = s.pos; res.end = s.endpos; res.expr = expr; res.spec = spec; return(res); }
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 TypeExprNode TypeExpr( ExprNode expr, DimSpecNode spec, Symbol s ) { TypeExprNode res = new TypeExprNode(); res.kind = Kind.DimmedExpr; res.start = s.pos; res.end = s.endpos; res.expr = expr; res.spec = spec; return res; }