Improve name nodes to ast, teach to parse qualified names, put out flaming tinderbox.

This commit is contained in:
Graydon Hoare 2010-10-04 17:25:52 -07:00
parent 44e4b2d63a
commit 19d0fa107a
3 changed files with 36 additions and 4 deletions

View File

@ -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);
}

View File

@ -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 (_) {

View File

@ -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,