public ProgNode Check(ProgNode node, List <string> errors, IScope scope) { this.errors = errors; this.scope = scope; node.Accept(this); return(node); }
public CodeGenVisitor(ProgNode node, IScope Scope) { this.Scope = Scope; ClassManager = new ClassMgr(Scope); VariableManager = new ThreeAddressHandler(); Code = new List <CodeLine>(); VariableManager.PushVariableCounter(); StepOne(); VariableManager.PopVariableCounter(); node.Accept(this); VariableManager.PushVariableCounter(); Code.Add(new LabelCodeLine("start")); int size = ClassManager.GetClassSize("Main"); Code.Add(new AllocateCodeLine(VariableManager.PeekVariableCounter(), size)); Code.Add(new PushParamCodeLine(VariableManager.PeekVariableCounter())); Code.Add(new CallLblCodeLine(new LabelCodeLine("Main", "constructor"))); Code.Add(new PopParamCodeLine(1)); Code.Add(new PushParamCodeLine(VariableManager.PeekVariableCounter())); Code.Add(new CallLblCodeLine(new LabelCodeLine("Main", "main"))); Code.Add(new PopParamCodeLine(1)); VariableManager.PopVariableCounter(); }