public override void gen(int begin, int after) { Expr s1 = Index.reduce(); Expr s2 = Expr.reduce(); CurrentGenerator.SetArr(Array, s1, s2); }
public override void gen(int begin, int after) { if (Expr is FuncCall) { if (t == null) { emitfunSet(Expr, Id); } else { emitfunSet(Expr, t); } } else { if (t == null) { CurrentGenerator.Set(Id, Expr.gen()); } else { CurrentGenerator.Set(t, Expr.gen()); } } }
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 Expr reduce() { Expr x = gen(); Temp t = new Temp(Type); CurrentGenerator.Temp(t); CurrentGenerator.Set(t, x); return(t); }
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) { if (this == True && t != 0) { CurrentGenerator.Goto(t); } else if (this == False && f != 0) { CurrentGenerator.Goto(f); } }
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); } }
//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 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); } }
public override Expr reduce() { foreach (var item in FunParams) { CurrentGenerator.Param(item); } Temp t = new Temp(Func.Params.ReturnType); CurrentGenerator.Temp(t); CurrentGenerator.Call(t, Func); CurrentGenerator.CallEnd(); return(t); }
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 virtual void emitjumps(Expr s, int truejump, int falsejump) { if (truejump != 0 && falsejump != 0) { CurrentGenerator.If(s, truejump); CurrentGenerator.Goto(falsejump.ToString()); } else if (truejump != 0) { CurrentGenerator.If(s, truejump); } else if (falsejump != 0) { CurrentGenerator.IfFalse(s, falsejump); } }
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 (Parent.Params.ReturnType != ReserveType.Void) { if (!ReserveType.ConvertableT1T2(Parent.Params.ReturnType, ReturnVal.Type)) { throw new TypeMisMatchException(this.lexline, ReturnVal.Type, Parent.Params.ReturnType.ToString()); } Temp t = new Temp(Parent.Params.ReturnType); CurrentGenerator.Temp(t); new Set(t, ReturnVal).gen(begin, after); CurrentGenerator.Return(t); } else { CurrentGenerator.Return(null); } //emitLabel(Parent.ExitLabel); }
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(); }
//public int newlabel() //{ // return CurrentGenerator.AllocLabel(); //} //public void emitLabel(int i) //{ // CurrentGenerator.Label("L" + i.ToString()); //} //public void emit(string s) //{ // CurrentIO.EmitLine(s); //} //public void emitSrc(string s) //{ // CurrentIO.EmitSource(s); //} public void emitfunSet(Expr exp, Expr toVar) { FuncCall c = exp as FuncCall; if (c.FunParams?.Count() > 0) { foreach (PassParam item in c.FunParams) { if (item.Param is FuncCall) { Temp t = new Temp(toVar.Type); CurrentGenerator.Temp(t); emitfunSet(item.Param, t); CurrentGenerator.Param(t); } else { CurrentGenerator.Param(item); } } } CurrentGenerator.Call(toVar, c.Func); CurrentGenerator.CallEnd(); }
public override void gen(int begin, int after) { CurrentGenerator.Goto(Stmt.begin); }
public override void gen(int begin, int after) { CurrentGenerator.EscapeScope(Symbols); }