/* * 在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); }
/// <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)); }
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; }
/// <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) { }