public override void gen(int begin, int after) { CurrentGenerator.Goto(after); foreach (var item in Params.ParamList) { if (item is OptParam) { CurrentGenerator.OptParam(item as OptParam, (item as OptParam).DefaultValue, item.ParamType); } else { CurrentGenerator.Param(item, item.ParamType); } } int label = CurrentGenerator.AllocLabel(); int label2 = CurrentGenerator.AllocLabel(); ExitLabel = label2; CurrentGenerator.Label(label); CurrentGenerator.LabelFunc(this); Stmt.gen(begin, after); CurrentGenerator.LabelFuncEnd(this); CurrentGenerator.Label(ExitLabel); //CurrentGenerator.Return(null); }
public override void gen(int begin, int after) { int label = CurrentGenerator.AllocLabel(); Expr.jumping(0, after); CurrentGenerator.Label(label); Stmt.gen(label, after); }
public override void gen(int begin, int after) { this.after = after; this.begin = begin; int label = CurrentGenerator.AllocLabel(); Stmt.gen(label, begin); CurrentGenerator.Label(label); Expr.jumping(begin, 0); }
public override void gen(int begin, int after) { int label1 = CurrentGenerator.AllocLabel(); int label2 = CurrentGenerator.AllocLabel(); Expr.jumping(0, label2); CurrentGenerator.Label(label1); Stmt1.gen(label1, after); CurrentGenerator.Goto(after); CurrentGenerator.Label(label2); Stmt2.gen(label2, after); }
public override void jumping(int t, int f) { int l = f != 0 ? f : CurrentGenerator.AllocLabel(); First.jumping(0, l); Second.jumping(t, f); if (f == 0) { CurrentGenerator.Label(l); } }
public override void jumping(int t, int f) { int label = t != 0 ? t : CurrentGenerator.AllocLabel(); First.jumping(label, 0); Second.jumping(t, f); if (t == 0) { CurrentGenerator.Label(label); } }
//Program -> Block public void Program() { move(); s = Modules(); CurrentGenerator.Start(top.SubTables.First()); int begin = CurrentGenerator.AllocLabel(), after = CurrentGenerator.AllocLabel(); CurrentGenerator.Label(begin); s.gen(begin, after); CurrentGenerator.Label(after); CurrentGenerator.End(); }
public override Expr gen() { int f = CurrentGenerator.AllocLabel(); int a = CurrentGenerator.AllocLabel(); Temp t = new Temp(Type); CurrentGenerator.Temp(t); jumping(0, f); CurrentGenerator.Set(t, Constant.True); CurrentGenerator.Goto(a); CurrentGenerator.Label(f); CurrentGenerator.Set(t, Constant.False); CurrentGenerator.Label(a); return(t); }
public override void gen(int begin, int after) { if (First == Null) { Second.gen(begin, after); } else if (Second == Null) { First.gen(begin, after); } else { int label = CurrentGenerator.AllocLabel(); First.gen(begin, label); CurrentGenerator.Label(label); Second.gen(label, after); } }
public override void gen(int begin, int after) { if (Caller.FunParams.Count() > 0) { foreach (var item in Caller.FunParams) { if (item.Param is FuncCall) { Temp t = new Temp(Caller.Func.Params.ReturnType); CurrentGenerator.Temp(t); emitfunSet(item.Param, t); CurrentGenerator.Param(t); } else { CurrentGenerator.Param(item); } } } CurrentGenerator.Label(CurrentGenerator.AllocLabel()); CurrentGenerator.Call(Caller); CurrentGenerator.CallEnd(); }