diff options
| author | Graydon Hoare <[email protected]> | 2010-10-04 17:25:52 -0700 |
|---|---|---|
| committer | Graydon Hoare <[email protected]> | 2010-10-04 17:25:52 -0700 |
| commit | 19d0fa107aeb79e7d2e1e4222fad4be8addf679d (patch) | |
| tree | 6fee0ba2f8b477af142a2ca5a0d228e29ef56573 /src | |
| parent | Teach rustc about phi nodes, block relationships. Translate if- and block-exp... (diff) | |
| download | rust-19d0fa107aeb79e7d2e1e4222fad4be8addf679d.tar.xz rust-19d0fa107aeb79e7d2e1e4222fad4be8addf679d.zip | |
Improve name nodes to ast, teach to parse qualified names, put out flaming tinderbox.
Diffstat (limited to 'src')
| -rw-r--r-- | src/comp/front/ast.rs | 17 | ||||
| -rw-r--r-- | src/comp/front/parser.rs | 20 | ||||
| -rw-r--r-- | src/comp/lib/llvm.rs | 3 |
3 files changed, 36 insertions, 4 deletions
diff --git a/src/comp/front/ast.rs b/src/comp/front/ast.rs index 48ba9187..e115087e 100644 --- a/src/comp/front/ast.rs +++ b/src/comp/front/ast.rs @@ -8,6 +8,19 @@ import util.common.none; type ident = str; +type name = rec(ident ident, vec[ty] types); +type path = vec[name]; + +type crate_id = int; +type slot_id = int; +type item_id = int; + +tag referent { + ref_slot(crate_id, slot_id); + ref_item(crate_id, item_id); +} + + type crate = rec(_mod module); type block = vec[@stmt]; @@ -62,7 +75,7 @@ tag expr { expr_binary(binop, @expr, @expr); expr_unary(unop, @expr); expr_lit(@lit); - expr_ident(ident); + expr_name(name, option[referent]); expr_field(@expr, ident); expr_index(@expr, @expr); expr_cast(@expr, ty); @@ -88,6 +101,7 @@ tag ty { ty_char; ty_str; ty_box(@ty); + ty_path(path, option[referent]); } tag mode { @@ -106,6 +120,7 @@ type _mod = hashmap[ident,item]; tag item { item_fn(@_fn); item_mod(@_mod); + item_ty(@ty); } diff --git a/src/comp/front/parser.rs b/src/comp/front/parser.rs index 12a1f072..c939764b 100644 --- a/src/comp/front/parser.rs +++ b/src/comp/front/parser.rs @@ -153,7 +153,24 @@ io fn parse_lit(parser p) -> @ast.lit { fail; } +io fn parse_name(parser p, ast.ident id) -> ast.name { + p.bump(); + let vec[ast.ty] tys = vec(); + + alt (p.peek()) { + case (token.LBRACKET) { + auto pf = parse_ty; + tys = parse_seq[ast.ty](token.LBRACKET, + token.RBRACKET, + some(token.COMMA), + pf, p); + } + case (_) { + } + } + ret rec(ident=id, types=tys); +} io fn parse_bottom_expr(parser p) -> @ast.expr { alt (p.peek()) { @@ -203,8 +220,7 @@ io fn parse_bottom_expr(parser p) -> @ast.expr { } case (token.IDENT(?i)) { - p.bump(); - ret @ast.expr_ident(i); + ret @ast.expr_name(parse_name(p, i), none[ast.referent]); } case (_) { diff --git a/src/comp/lib/llvm.rs b/src/comp/lib/llvm.rs index 220af154..456b82cd 100644 --- a/src/comp/lib/llvm.rs +++ b/src/comp/lib/llvm.rs @@ -1006,7 +1006,8 @@ obj builder(BuilderRef B) { /* Miscellaneous instructions */ - fn Phi(TypeRef Ty, vec[ValueRef] vals, vec[BasicBlockRef] bbs) -> ValueRef { + fn Phi(TypeRef Ty, vec[ValueRef] vals, + vec[BasicBlockRef] bbs) -> ValueRef { auto phi = llvm.LLVMBuildPhi(B, Ty, _str.buf("")); check (_vec.len[ValueRef](vals) == _vec.len[BasicBlockRef](bbs)); llvm.LLVMAddIncoming(phi, |