about summary refs log tree commit diff
path: root/src/comp/syntax
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-09-19 15:30:58 -0700
committerBrian Anderson <banderson@mozilla.com>2011-09-19 15:32:56 -0700
commitb1bf9ef5aef81eec4a1b0e00fc179e7a0e1766b6 (patch)
tree5ebb7ff6e9943883ebd10cde9e4fb24bd5a39619 /src/comp/syntax
parent939a9dd738e2766eea7d3e012350c0484cda5fbb (diff)
Break fold's circular reference during unwinding
This converts the AST fold into a resource that breaks it's own circular
reference (just a temporary workaround until GC), so that failure during fold
will unwind correctly.

Issue #936
Diffstat (limited to 'src/comp/syntax')
-rw-r--r--src/comp/syntax/ext/expand.rs1
-rw-r--r--src/comp/syntax/ext/simplext.rs2
-rw-r--r--src/comp/syntax/fold.rs9
3 files changed, 7 insertions, 5 deletions
diff --git a/src/comp/syntax/ext/expand.rs b/src/comp/syntax/ext/expand.rs
index 5fd2b1692da..53b06824320 100644
--- a/src/comp/syntax/ext/expand.rs
+++ b/src/comp/syntax/ext/expand.rs
@@ -56,7 +56,6 @@ fn expand_crate(sess: session::session, c: @crate) -> @crate {
             with *afp};
     let f = make_fold(f_pre);
     let res = @f.fold_crate(*c);
-    dummy_out(f); //temporary: kill circular reference
     ret res;
 
 }
diff --git a/src/comp/syntax/ext/simplext.rs b/src/comp/syntax/ext/simplext.rs
index f81e101c17b..c6b6056bbc4 100644
--- a/src/comp/syntax/ext/simplext.rs
+++ b/src/comp/syntax/ext/simplext.rs
@@ -206,7 +206,6 @@ fn transcribe(cx: ext_ctxt, b: bindings, body: @expr) -> @expr {
          new_span: bind new_span(cx, _) with *afp};
     let f = make_fold(f_pre);
     let result = f.fold_expr(body);
-    dummy_out(f); //temporary: kill circular reference
     ret result;
 }
 
@@ -258,7 +257,6 @@ iter free_vars(b: bindings, e: @expr) -> ident {
             with *default_ast_fold()};
     let f = make_fold(f_pre);
     f.fold_expr(e); // ignore result
-    dummy_out(f);
     for each id: ident in idents.keys() { put id; }
 }
 
diff --git a/src/comp/syntax/fold.rs b/src/comp/syntax/fold.rs
index d3702dacfc6..23293adbd80 100644
--- a/src/comp/syntax/fold.rs
+++ b/src/comp/syntax/fold.rs
@@ -563,8 +563,13 @@ fn dummy_out(a: ast_fold) {
          new_span: noop_span};
 }
 
+// FIXME: Fold has a circular reference that has to be broken. With GC this
+// can go away
+resource foldres(f: ast_fold) {
+    dummy_out(f);
+}
 
-fn make_fold(afp: ast_fold_precursor) -> ast_fold {
+fn make_fold(afp: ast_fold_precursor) -> @foldres {
     let result: ast_fold =
         @mutable {fold_crate: nf_crate_dummy,
                   fold_crate_directive: nf_crate_directive_dummy,
@@ -699,7 +704,7 @@ fn make_fold(afp: ast_fold_precursor) -> ast_fold {
          map_exprs: afp.map_exprs,
          new_id: afp.new_id,
          new_span: afp.new_span};
-    ret result;
+    ret @foldres(result);
 }