diff options
| author | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-07-11 14:31:35 -0700 |
|---|---|---|
| committer | Tim Chevalier <chevalier@alum.wellesley.edu> | 2012-07-12 19:02:07 -0700 |
| commit | 78ec6fe30cf2b1e85db76107154d315fde6af8bd (patch) | |
| tree | e4c4b54ea819d68c8fd7d5a2b5055364488bf15b /src/libsyntax/parse | |
| parent | fec8059ed5cf756adf25742c96f82bf3a240513e (diff) | |
| download | rust-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/parse')
| -rw-r--r-- | src/libsyntax/parse/parser.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9d8458c9c60..4a013f20dfd 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1,3 +1,5 @@ +import print::pprust::expr_to_str; + import result::result; import either::{either, left, right}; import std::map::{hashmap, str_hash}; @@ -758,11 +760,13 @@ class parser { } fn mk_expr(lo: uint, hi: uint, +node: expr_) -> @expr { - ret @{id: self.get_id(), node: node, span: mk_sp(lo, hi)}; + ret @{id: self.get_id(), callee_id: self.get_id(), + node: node, span: mk_sp(lo, hi)}; } fn mk_mac_expr(lo: uint, hi: uint, m: mac_) -> @expr { ret @{id: self.get_id(), + callee_id: self.get_id(), node: expr_mac({node: m, span: mk_sp(lo, hi)}), span: mk_sp(lo, hi)}; } @@ -772,7 +776,8 @@ class parser { let lv_lit = @{node: lit_uint(i as u64, ty_u32), span: span}; - ret @{id: self.get_id(), node: expr_lit(lv_lit), span: span}; + ret @{id: self.get_id(), callee_id: self.get_id(), + node: expr_lit(lv_lit), span: span}; } fn mk_pexpr(lo: uint, hi: uint, node: expr_) -> pexpr { @@ -1112,7 +1117,6 @@ class parser { let ix = self.parse_expr(); hi = ix.span.hi; self.expect(token::RBRACKET); - self.get_id(); // see ast_util::op_expr_callee_id e = self.mk_pexpr(lo, hi, expr_index(self.to_expr(e), ix)); } |
