public virtual void Define(VariableSymbol varSym) { this.Define((Symbol)varSym); if (!(varSym is ConstantSymbol)) { varSym.ScopeIndex = CurrentVariableIndex++; } }
private void varDeclaration() { EnterRule_varDeclaration(); EnterRule("varDeclaration", 16); TraceIn("varDeclaration", 16); LSLAst ID10 = default(LSLAst); ISymbolType type11 = default(ISymbolType); try { DebugEnterRule(GrammarFileName, "varDeclaration"); DebugLocation(185, 4); try { // Def.g:186:5: ( ^( VAR_DECL type ID ( . )* ) ) DebugEnterAlt(1); // Def.g:186:9: ^( VAR_DECL type ID ( . )* ) { DebugLocation(186, 9); DebugLocation(186, 11); Match(input,VAR_DECL,Follow._VAR_DECL_in_varDeclaration427); if (state.failed) return; Match(input, TokenTypes.Down, null); if (state.failed) return; DebugLocation(186, 20); PushFollow(Follow._type_in_varDeclaration429); type11=type(); PopFollow(); if (state.failed) return; DebugLocation(186, 25); ID10=(LSLAst)Match(input,ID,Follow._ID_in_varDeclaration431); if (state.failed) return; DebugLocation(186, 28); // Def.g:186:28: ( . )* try { DebugEnterSubRule(8); while (true) { int alt8=2; try { DebugEnterDecision(8, false); int LA8_0 = input.LA(1); if (((LA8_0>=ASSIGN_EQ && LA8_0<=95))) { alt8 = 1; } else if ((LA8_0==UP)) { alt8 = 2; } } finally { DebugExitDecision(8); } switch ( alt8 ) { case 1: DebugEnterAlt(1); // Def.g:186:28: . { DebugLocation(186, 28); MatchAny(input); if (state.failed) return; } break; default: goto loop8; } } loop8: ; } finally { DebugExitSubRule(8); } Match(input, TokenTypes.Up, null); if (state.failed) return; DebugLocation(187, 9); if (state.backtracking == 1) { //System.out.println("line "+ID10.getLine()+": def "+(ID10!=null?ID10.Text:null)); VariableSymbol vs = new VariableSymbol((ID10!=null?ID10.Text:null),type11); vs.Def = ID10; // track AST location of def's ID ID10.symbol = vs; // track in AST symtab.Define(vs, currentScope); } } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { TraceOut("varDeclaration", 16); LeaveRule("varDeclaration", 16); LeaveRule_varDeclaration(); } DebugLocation(195, 4); } finally { DebugExitRule(GrammarFileName, "varDeclaration"); } return; }
private void methodDefParam() { EnterRule_methodDefParam(); EnterRule("methodDefParam", 10); TraceIn("methodDefParam", 10); LSLAst ID8 = default(LSLAst); ISymbolType type9 = default(ISymbolType); try { DebugEnterRule(GrammarFileName, "methodDefParam"); DebugLocation(131, 1); try { // Def.g:132:2: ( ^( PARAM_DECL type ID ) ) DebugEnterAlt(1); // Def.g:132:4: ^( PARAM_DECL type ID ) { DebugLocation(132, 4); DebugLocation(132, 6); Match(input,PARAM_DECL,Follow._PARAM_DECL_in_methodDefParam284); if (state.failed) return; Match(input, TokenTypes.Down, null); if (state.failed) return; DebugLocation(132, 17); PushFollow(Follow._type_in_methodDefParam286); type9=type(); PopFollow(); if (state.failed) return; DebugLocation(132, 22); ID8=(LSLAst)Match(input,ID,Follow._ID_in_methodDefParam288); if (state.failed) return; Match(input, TokenTypes.Up, null); if (state.failed) return; DebugLocation(133, 3); if (state.backtracking == 1) { VariableSymbol varSym = new VariableSymbol((ID8!=null?ID8.Text:null), type9); symtab.Define(varSym, currentScope); varSym.Def = ID8; // track AST location of def's ID ID8.symbol = varSym; // track in AST } } } catch (RecognitionException re) { ReportError(re); Recover(input,re); } finally { TraceOut("methodDefParam", 10); LeaveRule("methodDefParam", 10); LeaveRule_methodDefParam(); } DebugLocation(139, 1); } finally { DebugExitRule(GrammarFileName, "methodDefParam"); } return; }
public void Define(VariableSymbol varSym, IScope currentScope) { if (TestForDefineErrors(varSym, currentScope)) { return; } currentScope.Define(varSym); }
public void Define(VariableSymbol sym) { this.Define((Symbol)sym); if (!(sym is ConstantSymbol)) { sym.ScopeIndex = CurrentVariableIndex++; } }
public override void Define(VariableSymbol varSym) { varSym.IsGlobal = true; base.Define(varSym); }