summary refs log tree commit diff
path: root/src/libsyntax/ext
diff options
context:
space:
mode:
authorTim Chevalier <chevalier@alum.wellesley.edu>2012-07-11 14:31:35 -0700
committerTim Chevalier <chevalier@alum.wellesley.edu>2012-07-12 19:02:07 -0700
commit78ec6fe30cf2b1e85db76107154d315fde6af8bd (patch)
treee4c4b54ea819d68c8fd7d5a2b5055364488bf15b /src/libsyntax/ext
parentfec8059ed5cf756adf25742c96f82bf3a240513e (diff)
downloadrust-78ec6fe30cf2b1e85db76107154d315fde6af8bd.tar.gz
rust-78ec6fe30cf2b1e85db76107154d315fde6af8bd.zip
Obliterate the callee_id hack
Exprs that could be applications of overloaded operators
(expr_unary, expr_binary, expr_index) relied on the previous node ID
being "reserved" to carry extra typechecking info. This was
incredibly error-prone. Fixed it; now all exprs have two node IDs
(which will be wasted in some cases; future work could make this
an option instead if the extra int field ends up being a performance
problem).

Closes #2804
Diffstat (limited to 'src/libsyntax/ext')
-rw-r--r--src/libsyntax/ext/auto_serialize.rs3
-rw-r--r--src/libsyntax/ext/build.rs7
-rw-r--r--src/libsyntax/ext/concat_idents.rs1
-rw-r--r--src/libsyntax/ext/log_syntax.rs4
-rw-r--r--src/libsyntax/ext/simplext.rs2
5 files changed, 10 insertions, 7 deletions
diff --git a/src/libsyntax/ext/auto_serialize.rs b/src/libsyntax/ext/auto_serialize.rs
index e32ebf4eae5..119dbb59109 100644
--- a/src/libsyntax/ext/auto_serialize.rs
+++ b/src/libsyntax/ext/auto_serialize.rs
@@ -172,7 +172,8 @@ impl helpers for ext_ctxt {
     }
 
     fn expr(span: span, node: ast::expr_) -> @ast::expr {
-        @{id: self.next_id(), node: node, span: span}
+        @{id: self.next_id(), callee_id: self.next_id(),
+          node: node, span: span}
     }
 
     fn var_ref(span: span, name: ast::ident) -> @ast::expr {
diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs
index 872d1f5eff6..342ecac2262 100644
--- a/src/libsyntax/ext/build.rs
+++ b/src/libsyntax/ext/build.rs
@@ -3,12 +3,13 @@ import base::ext_ctxt;
 
 fn mk_expr(cx: ext_ctxt, sp: codemap::span, expr: ast::expr_) ->
     @ast::expr {
-    ret @{id: cx.next_id(), node: expr, span: sp};
+    ret @{id: cx.next_id(), callee_id: cx.next_id(),
+          node: expr, span: sp};
 }
 
 fn mk_lit(cx: ext_ctxt, sp: span, lit: ast::lit_) -> @ast::expr {
     let sp_lit = @{node: lit, span: sp};
-    ret @{id: cx.next_id(), node: ast::expr_lit(sp_lit), span: sp};
+    mk_expr(cx, sp, ast::expr_lit(sp_lit))
 }
 fn mk_str(cx: ext_ctxt, sp: span, s: str) -> @ast::expr {
     let lit = ast::lit_str(@s);
@@ -62,7 +63,7 @@ fn mk_call(cx: ext_ctxt, sp: span, fn_path: ~[ast::ident],
 fn mk_base_vec_e(cx: ext_ctxt, sp: span, exprs: ~[@ast::expr]) ->
    @ast::expr {
     let vecexpr = ast::expr_vec(exprs, ast::m_imm);
-    ret @{id: cx.next_id(), node: vecexpr, span: sp};
+    mk_expr(cx, sp, vecexpr)
 }
 fn mk_vstore_e(cx: ext_ctxt, sp: span, expr: @ast::expr, vst: ast::vstore) ->
    @ast::expr {
diff --git a/src/libsyntax/ext/concat_idents.rs b/src/libsyntax/ext/concat_idents.rs
index a678304725d..f5d13df75d6 100644
--- a/src/libsyntax/ext/concat_idents.rs
+++ b/src/libsyntax/ext/concat_idents.rs
@@ -9,6 +9,7 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
     }
 
     ret @{id: cx.next_id(),
+          callee_id: cx.next_id(),
           node: ast::expr_path(@{span: sp, global: false, idents: ~[@res],
                                  rp: none, types: ~[]}),
           span: sp};
diff --git a/src/libsyntax/ext/log_syntax.rs b/src/libsyntax/ext/log_syntax.rs
index d237cd33839..06941fc5d38 100644
--- a/src/libsyntax/ext/log_syntax.rs
+++ b/src/libsyntax/ext/log_syntax.rs
@@ -11,6 +11,6 @@ fn expand_syntax_ext(cx: ext_ctxt, sp: codemap::span, arg: ast::mac_arg,
     );
 
     //trivial expression
-    ret @{id: cx.next_id(), node: ast::expr_rec(~[], option::none),
-          span: sp};
+    ret @{id: cx.next_id(), callee_id: cx.next_id(),
+          node: ast::expr_rec(~[], option::none), span: sp};
 }
diff --git a/src/libsyntax/ext/simplext.rs b/src/libsyntax/ext/simplext.rs
index 0d415ccfc43..6ccbabd748e 100644
--- a/src/libsyntax/ext/simplext.rs
+++ b/src/libsyntax/ext/simplext.rs
@@ -7,7 +7,7 @@ import base::*;
 import fold::*;
 import ast_util::respan;
 import ast::{ident, path, ty, blk_, expr, expr_path,
-             expr_vec, expr_mac, mac_invoc, node_id};
+             expr_vec, expr_mac, mac_invoc, node_id, expr_index};
 
 export add_new_extension;