public override CSNode VisitType(CSScriptParser.TypeContext context) { System.Type currentType; string currentTypeString = VisitTypeElements(context.type_elements(), out currentType); if (context.arraytype() != null) { currentType = ReflectionUtil.GetType(currentTypeString + "[]"); } if (currentType == null) { CSLog.E(context.Start.Line, context.Start.Column, "unknown type: " + currentTypeString); return(null); } CSTypeNode node = new CSTypeNode(context.Start.Line, context.Start.Column); node._type = currentType; node._typeString = currentType.AssemblyQualifiedName; node._assemblyName = currentType.Assembly.GetCleanName(); //CSLog.D ("full name: " + node._typeString + " in the assembly: " + node._assemblyName); return(node); }
public override CSNode VisitVarDeclExp(CSScriptParser.VarDeclExpContext context) { CSLocalVariableNode variableNode = new CSLocalVariableNode(context.Start.Line, context.Start.Column); variableNode._declaration = true; variableNode._variableName = context.NAME().GetText(); CSScriptParser.TypeContext vartypes = context.type(); if (vartypes != null) { CSTypeNode typeNode = Visit(vartypes) as CSTypeNode; if (typeNode == null) { CSLog.E(variableNode, "failed to get the type"); } variableNode._type = typeNode._type; } CSObject objForComplier = CSObject.LocalVariableObject(variableNode, variableNode._type, variableNode._variableName, null); _state.AddVariable(variableNode._variableName, objForComplier); return(variableNode); }
/// <summary> /// Visit a parse tree produced by <see cref="CSScriptParser.type"/>. /// <para> /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/> /// on <paramref name="context"/>. /// </para> /// </summary> /// <param name="context">The parse tree.</param> /// <return>The visitor result.</return> public virtual Result VisitType([NotNull] CSScriptParser.TypeContext context) { return(VisitChildren(context)); }