aboutsummaryrefslogtreecommitdiff
path: root/src/comp/front/ast.rs
diff options
context:
space:
mode:
authorGraydon Hoare <[email protected]>2010-10-18 18:19:16 -0700
committerGraydon Hoare <[email protected]>2010-10-18 18:19:16 -0700
commit4a3edb320dd515fd98431997d4bdb1ffa31446bd (patch)
tree40c4741c51e070a326cbc7643657cd288260bcbb /src/comp/front/ast.rs
parentMore work on resolving names in rustc. Basic expr_name lookup working on item... (diff)
downloadrust-4a3edb320dd515fd98431997d4bdb1ffa31446bd.tar.xz
rust-4a3edb320dd515fd98431997d4bdb1ffa31446bd.zip
Store items and decls in vecs to preserve input order, index externally. Implement block-local name lookup.
Diffstat (limited to 'src/comp/front/ast.rs')
-rw-r--r--src/comp/front/ast.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs
index 04c64bea..047bdd06 100644
--- a/src/comp/front/ast.rs
+++ b/src/comp/front/ast.rs
@@ -29,7 +29,8 @@ type crate = spanned[crate_];
type crate_ = rec(_mod module);
type block = spanned[block_];
-type block_ = vec[@stmt];
+type block_ = rec(vec[@stmt] stmts,
+ hashmap[ident,uint] index);
tag binop {
add;
@@ -69,10 +70,16 @@ tag stmt_ {
stmt_expr(@expr);
}
+type local = rec(option[@ty] ty,
+ bool infer,
+ ident ident,
+ option[@expr] init,
+ def_id id);
+
type decl = spanned[decl_];
tag decl_ {
- decl_local(ident, option[@ty], option[@expr]);
- decl_item(ident, @item);
+ decl_local(local);
+ decl_item(@item);
}
type expr = spanned[expr_];
@@ -125,16 +132,17 @@ tag mode {
type arg = rec(mode mode, @ty ty, ident ident, def_id id);
type _fn = rec(vec[arg] inputs,
- ty output,
+ @ty output,
block body);
-type _mod = hashmap[ident,@item];
+type _mod = rec(vec[@item] items,
+ hashmap[ident,uint] index);
type item = spanned[item_];
tag item_ {
- item_fn(_fn, def_id);
- item_mod(_mod, def_id);
- item_ty(@ty, def_id);
+ item_fn(ident, _fn, def_id);
+ item_mod(ident, _mod, def_id);
+ item_ty(ident, @ty, def_id);
}