From 358a1aeec99ba6bf3c3f6bc5886e4dddf647a75a Mon Sep 17 00:00:00 2001 From: Marijn Haverbeke Date: Thu, 12 May 2011 13:25:18 +0200 Subject: Keep resolve data in external hash table, rather than embedded defs One step closer to removing fold and having a single, immutable AST. Resolve still uses fold, because it has to detect and transform expr_field expressions. If we go through on our plan of moving to a different syntax for module dereferencing, the parser can spit out expr_field expressions, and resolve can move to walk. (I am truly sorry for the things I did in typestate_check.rs. I expect we'll want to change that to walk as well in the near future, at which point it should probably pass around a context record, which could hold the def_map.) --- src/comp/front/eval.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/comp/front/eval.rs') diff --git a/src/comp/front/eval.rs b/src/comp/front/eval.rs index 1d708f17..c03e313d 100644 --- a/src/comp/front/eval.rs +++ b/src/comp/front/eval.rs @@ -34,7 +34,8 @@ type ctx = @rec(parser p, eval_mode mode, mutable vec[str] deps, session.session sess, - mutable uint chpos); + mutable uint chpos, + mutable uint next_ann); fn mk_env() -> env { let env e = vec(); @@ -113,7 +114,7 @@ fn eval_lit(ctx cx, span sp, @ast.lit lit) -> val { fn eval_expr(ctx cx, env e, @ast.expr x) -> val { alt (x.node) { - case (ast.expr_path(?pth, _, _)) { + case (ast.expr_path(?pth, _)) { if (Vec.len[ident](pth.node.idents) == 1u && Vec.len[@ast.ty](pth.node.types) == 0u) { ret lookup(cx.sess, e, x.span, pth.node.idents.(0)); @@ -383,12 +384,14 @@ fn eval_crate_directive(ctx cx, } auto start_id = cx.p.next_def_id(); - auto p0 = new_parser(cx.sess, e, start_id, full_path, cx.chpos); + auto p0 = new_parser(cx.sess, e, start_id, full_path, cx.chpos, + cx.next_ann); auto m0 = parse_mod_items(p0, token.EOF); auto next_id = p0.next_def_id(); // Thread defids and chpos through the parsers cx.p.set_def(next_id._1); cx.chpos = p0.get_chpos(); + cx.next_ann = p0.next_ann_num(); auto im = ast.item_mod(id, m0, next_id); auto i = @spanned(cdir.span.lo, cdir.span.hi, im); Vec.push[@ast.item](items, i); -- cgit v1.2.3