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
This commit is contained in:
parent
fec8059ed5
commit
78ec6fe30c
21 changed files with 148 additions and 57 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue