diff options
Diffstat (limited to 'cps.cpp')
-rw-r--r-- | cps.cpp | 26 |
1 files changed, 8 insertions, 18 deletions
@@ -26,13 +26,13 @@ AST* AST::cps(TEnv& tenv, AST* cont) { - return new ACall(loc, cont, this, 0); + return tup<ACall>(loc, cont, this, 0); } AST* ATuple::cps(TEnv& tenv, AST* cont) { - ATuple* copy = new ATuple(loc, NULL); + ATuple* copy = tup<ATuple>(loc, NULL); FOREACH(const_iterator, p, *this) copy->push_back((*p)->cps(tenv, cont)); return copy; @@ -42,45 +42,35 @@ ATuple::cps(TEnv& tenv, AST* cont) AST* AFn::cps(TEnv& tenv, AST* cont) { - AFn* copy = new AFn(loc, tenv.penv.sym("fn"), prot()); + AFn* copy = tup<AFn>(loc, tenv.penv.sym("fn"), prot(), 0); const_iterator p = begin(); ++(++p); for (; p != end(); ++p) copy->push_back((*p)->cps(tenv, cont)); return copy; - return ATuple::cps(tenv, cont); } /** (cps (f a b ...)) => (a (fn (x) (b (fn (y) ... (cont (f x y ...)) */ AST* ACall::cps(TEnv& tenv, AST* cont) { - return new ACall(loc, cont, this, 0); + return tup<ACall>(loc, cont, this, 0); } /** (cps (def x y)) => (y (fn (x) (cont))) */ AST* ADef::cps(TEnv& tenv, AST* cont) { - ADef* copy = new ADef(loc, - ATuple(loc, tenv.penv.sym("def"), sym(), at(2)->cps(tenv, cont), 0)); - return copy; - /* - ASymbol* fnSym = tenv.penv.sym("deff"); - AFn* defFn = new AFn(loc, tenv.penv.sym("def"), - new ATuple(at(1)->loc, sym(), new ACall(loc, cont, this))); - ACall* defCall = new ACall(loc, at(2)->cps(tenv, defFn), 0); - */ + return tup<ADef>(loc, tenv.penv.sym("def"), sym(), at(2)->cps(tenv, cont), 0); } /** (cps (if c t ... e)) => */ AST* AIf::cps(TEnv& tenv, AST* cont) { - AFn* contFn = new AFn(loc, tenv.penv.sym("if0"), - new ATuple(at(1)->loc, cont, 0)); - //ACall* contCall = new ACall(loc, cont, this, 0); - ACall* condCall = new ACall(loc, contFn, 0); + AFn* contFn = tup<AFn>(loc, tenv.penv.sym("if-fn"), + new ATuple(at(1)->loc, cont, 0), 0); + ACall* condCall = tup<ACall>(loc, contFn, 0); return condCall; } |