Browse files

reintroduce undelimited continuations for now

  • Loading branch information...
jtolds committed Jan 9, 2013
1 parent 5c8517e commit 18a07f5ce9667873a7fb4a51c489dd4f9b2539d4
Showing with 23 additions and 1 deletion.
  1. +19 −0 src/cps/
  2. +4 −1 src/cps/
@@ -92,6 +92,25 @@ def transform(self, node):
for ir_exp in reversed(expressions):
exp, comp_cont, delim_cont = self.transform_expression(
ir_exp, exp, comp_cont, delim_cont)
# this provides access to the undelimited function-specific continuation
cont = cps.Identifier("cont", True, exp.line, exp.col)
if exp.references(cont):
arg = self.gensym(exp.line, exp.col)
cont_call = cps.Call(
cps.Variable(comp_cont, comp_cont.line, comp_cont.col), [],
cps.Variable(arg, arg.line, arg.col),
arg.line, arg.col)],
cps.Variable(comp_cont, comp_cont.line, comp_cont.col),
cps.Variable(delim_cont, delim_cont.line, delim_cont.col),
exp.line, exp.col)
cont_callable = cps.Callable(
cont_call, [],
[cps.RequiredInArgument(arg, arg.line, arg.col)],
None, None, exp.line, exp.col)
exp = cps.Assignment(cont, cont_callable, True, exp, exp.line, exp.col)
return exp, comp_cont, delim_cont
def transform_expression(self, ir_exp, next_cps_exp, comp_cont, delim_cont):
@@ -108,7 +108,10 @@ def __repr__(self):
return "Assignment(%r, %r, %r, %r, %d, %d)" % (self.assignee, self.value,
self.local, self.next_expression, self.line, self.col)
def references(self, identifier):
if not self.local and self.assignee.references(identifier): return True
if self.local:
if self.assignee.references(identifier): return False
if self.assignee.references(identifier): return True
if self.value.references(identifier): return True
if self.next_expression.references(identifier): return True
return False

0 comments on commit 18a07f5

Please sign in to comment.