示例#1
0
        /*
         * 在codeBlock中定义的变量在出了block之后应该全部失效
         */
        public override object VisitCodeBlock([NotNull] CMMParser.CodeBlockContext context)
        {
            int tmp = curLocalVariablesTableLength;

            if (context.statements() != null)
            {
                Visit(context.statements());
            }
            // codeBlock中新定义的变量全部失效
            codes.Add(new IntermediateCode(tmp, InstructionType.delv, context.Stop.Line));
            curLocalVariablesTableLength = tmp;
            removeVariableBiggerThanK(tmp);
            return(null);
        }
示例#2
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="CMMParser.codeBlock"/>.
 /// <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 VisitCodeBlock([NotNull] CMMParser.CodeBlockContext context)
 {
     return(VisitChildren(context));
 }
示例#3
0
 public FunctionSymbol(string name, Type retType, Scope scope, LinkedHashMap <string, BuiltInTypeSymbol> orderedArgs, CMMParser.CodeBlockContext context) : base(name, retType, scope)
 {
     this.orderedArgs = orderedArgs;
     this.context     = context;
 }
示例#4
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="CMMParser.codeBlock"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitCodeBlock([NotNull] CMMParser.CodeBlockContext context)
 {
 }