예제 #1
0
        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);
        }
예제 #2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="CSScriptParser.varDeclExp"/>.
 /// <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 VisitVarDeclExp([NotNull] CSScriptParser.VarDeclExpContext context)
 {
     return(VisitChildren(context));
 }