Preparation for kind system overhaul
This goes before a snapshot, so that subsequenct patches can make the transition without breaking the build. Disables kind checking pass, makes parser accept both new and old-style kind annotation. Issue #1177
This commit is contained in:
parent
eff7fae7b9
commit
9cf48d3753
26 changed files with 78 additions and 58 deletions
|
|
@ -23,6 +23,8 @@ type def_id = {crate: crate_num, node: node_id};
|
|||
|
||||
const local_crate: crate_num = 0;
|
||||
|
||||
tag plicit<T> { explicit(T); implicit(T); }
|
||||
|
||||
type ty_param = {ident: ident, kind: plicit<kind>};
|
||||
|
||||
tag def {
|
||||
|
|
@ -99,8 +101,7 @@ tag pat_ {
|
|||
|
||||
tag mutability { mut; imm; maybe_mut; }
|
||||
|
||||
tag plicit<T> { explicit(T); implicit(T); }
|
||||
tag kind { kind_pinned; kind_shared; kind_unique; kind_auto; }
|
||||
tag kind { kind_sendable; kind_copyable; kind_noncopyable; }
|
||||
|
||||
tag _auth { auth_unsafe; }
|
||||
|
||||
|
|
|
|||
|
|
@ -229,7 +229,7 @@ fn ret_by_ref(style: ret_style) -> bool {
|
|||
}
|
||||
|
||||
fn ty_param_kind(tp: ty_param) -> kind {
|
||||
alt tp.kind { explicit(x) | implicit(x) { x } }
|
||||
alt tp.kind { ast::implicit(x) | ast::explicit(x) { x } }
|
||||
}
|
||||
|
||||
// Local Variables:
|
||||
|
|
|
|||
|
|
@ -1738,21 +1738,24 @@ fn parse_block_tail(p: parser, lo: uint, s: ast::blk_check_mode) -> ast::blk {
|
|||
ret spanned(lo, hi, bloc);
|
||||
}
|
||||
|
||||
fn parse_ty_param(default: ast::kind, p: parser) -> ast::ty_param {
|
||||
let k = if eat_word(p, "pin") { ast::explicit(ast::kind_pinned) }
|
||||
else if eat_word(p, "uniq") { ast::explicit(ast::kind_unique) }
|
||||
else if eat_word(p, "shar") { ast::explicit(ast::kind_shared) }
|
||||
// FIXME distinguish implied shared from explicit
|
||||
else { ast::implicit(default) };
|
||||
fn parse_ty_param(p: parser, def: ast::kind) -> ast::ty_param {
|
||||
// Accept both old and new kind names for now. FIXME remove this
|
||||
let k = if eat_word(p, "send") | eat_word(p, "uniq")
|
||||
{ ast::explicit(ast::kind_sendable) }
|
||||
else if eat_word(p, "copy") | eat_word(p, "shar")
|
||||
{ ast::explicit(ast::kind_copyable) }
|
||||
else if eat_word(p, "nocopy") | eat_word(p, "pin")
|
||||
{ ast::explicit(ast::kind_noncopyable) }
|
||||
else { ast::implicit(def) };
|
||||
ret {ident: parse_ident(p), kind: k};
|
||||
}
|
||||
|
||||
fn parse_ty_params(p: parser, default: ast::kind) -> [ast::ty_param] {
|
||||
fn parse_ty_params(p: parser, def: ast::kind) -> [ast::ty_param] {
|
||||
let ty_params: [ast::ty_param] = [];
|
||||
if p.peek() == token::LT {
|
||||
p.bump();
|
||||
ty_params = parse_seq_to_gt(some(token::COMMA),
|
||||
{|p| parse_ty_param(default, p)}, p);
|
||||
{|p| parse_ty_param(p, def)}, p);
|
||||
}
|
||||
ret ty_params;
|
||||
}
|
||||
|
|
@ -1805,7 +1808,7 @@ fn parse_fn(p: parser, proto: ast::proto, purity: ast::purity,
|
|||
|
||||
fn parse_fn_header(p: parser) -> {ident: ast::ident, tps: [ast::ty_param]} {
|
||||
let id = parse_value_ident(p);
|
||||
let ty_params = parse_ty_params(p, ast::kind_shared);
|
||||
let ty_params = parse_ty_params(p, ast::kind_copyable);
|
||||
ret {ident: id, tps: ty_params};
|
||||
}
|
||||
|
||||
|
|
@ -1858,7 +1861,7 @@ fn parse_method(p: parser) -> @ast::method {
|
|||
fn parse_item_obj(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
let lo = p.get_last_lo_pos();
|
||||
let ident = parse_value_ident(p);
|
||||
let ty_params = parse_ty_params(p, ast::kind_pinned);
|
||||
let ty_params = parse_ty_params(p, ast::kind_copyable);
|
||||
let fields: ast::spanned<[ast::obj_field]> =
|
||||
parse_seq(token::LPAREN, token::RPAREN, some(token::COMMA),
|
||||
parse_obj_field, p);
|
||||
|
|
@ -1875,7 +1878,7 @@ fn parse_item_obj(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
|||
fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
let lo = p.get_last_lo_pos();
|
||||
let ident = parse_value_ident(p);
|
||||
let ty_params = parse_ty_params(p, ast::kind_pinned);
|
||||
let ty_params = parse_ty_params(p, ast::kind_noncopyable);
|
||||
expect(p, token::LPAREN);
|
||||
let arg_ident = parse_value_ident(p);
|
||||
expect(p, token::COLON);
|
||||
|
|
@ -2039,7 +2042,7 @@ fn parse_type_decl(p: parser) -> {lo: uint, ident: ast::ident} {
|
|||
|
||||
fn parse_item_type(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
let t = parse_type_decl(p);
|
||||
let tps = parse_ty_params(p, ast::kind_pinned);
|
||||
let tps = parse_ty_params(p, ast::kind_noncopyable);
|
||||
expect(p, token::EQ);
|
||||
let ty = parse_ty(p, false);
|
||||
let hi = p.get_hi_pos();
|
||||
|
|
@ -2050,7 +2053,7 @@ fn parse_item_type(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
|||
fn parse_item_tag(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||
let lo = p.get_last_lo_pos();
|
||||
let id = parse_ident(p);
|
||||
let ty_params = parse_ty_params(p, ast::kind_pinned);
|
||||
let ty_params = parse_ty_params(p, ast::kind_noncopyable);
|
||||
let variants: [ast::variant] = [];
|
||||
// Newtype syntax
|
||||
if p.peek() == token::EQ {
|
||||
|
|
|
|||
|
|
@ -1168,10 +1168,10 @@ fn print_arg_mode(s: ps, m: ast::mode) {
|
|||
|
||||
fn print_kind(s: ps, kind: ast::plicit<ast::kind>) {
|
||||
alt kind {
|
||||
ast::explicit(ast::kind_sendable.) { word_nbsp(s, "send"); }
|
||||
ast::explicit(ast::kind_copyable.) { word_nbsp(s, "copy"); }
|
||||
ast::explicit(ast::kind_noncopyable.) { word_nbsp(s, "nocopy"); }
|
||||
ast::implicit(_) {}
|
||||
ast::explicit(ast::kind_unique.) { word_nbsp(s, "uniq"); }
|
||||
ast::explicit(ast::kind_pinned.) { word_nbsp(s, "pin"); }
|
||||
ast::explicit(ast::kind_shared.) { word_nbsp(s, "shar"); }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue