parent
856a544d0c
commit
2dbaa05af8
18 changed files with 17 additions and 124 deletions
|
@ -198,7 +198,6 @@ fn lookup_def(cnum: ast::crate_num, data: @[u8], did_: ast::def_id) ->
|
||||||
'f' { ast::def_fn(did, ast::impure_fn) }
|
'f' { ast::def_fn(did, ast::impure_fn) }
|
||||||
'p' { ast::def_fn(did, ast::pure_fn) }
|
'p' { ast::def_fn(did, ast::pure_fn) }
|
||||||
'y' { ast::def_ty(did) }
|
'y' { ast::def_ty(did) }
|
||||||
'T' { ast::def_native_ty(did) }
|
|
||||||
't' { ast::def_ty(did) }
|
't' { ast::def_ty(did) }
|
||||||
'm' { ast::def_mod(did) }
|
'm' { ast::def_mod(did) }
|
||||||
'n' { ast::def_native_mod(did) }
|
'n' { ast::def_native_mod(did) }
|
||||||
|
|
|
@ -423,12 +423,6 @@ fn encode_info_for_native_item(ecx: @encode_ctxt, ebml_w: ebml::writer,
|
||||||
nitem: @native_item) {
|
nitem: @native_item) {
|
||||||
ebml::start_tag(ebml_w, tag_items_data_item);
|
ebml::start_tag(ebml_w, tag_items_data_item);
|
||||||
alt nitem.node {
|
alt nitem.node {
|
||||||
native_item_ty {
|
|
||||||
encode_def_id(ebml_w, local_def(nitem.id));
|
|
||||||
encode_family(ebml_w, 'T' as u8);
|
|
||||||
encode_type(ecx, ebml_w,
|
|
||||||
ty::mk_native(ecx.ccx.tcx, local_def(nitem.id)));
|
|
||||||
}
|
|
||||||
native_item_fn(fn_decl, tps) {
|
native_item_fn(fn_decl, tps) {
|
||||||
let letter = alt fn_decl.purity {
|
let letter = alt fn_decl.purity {
|
||||||
unsafe_fn { 'u' }
|
unsafe_fn { 'u' }
|
||||||
|
|
|
@ -255,7 +255,6 @@ fn parse_ty(st: @pstate, conv: conv_did) -> ty::t {
|
||||||
ret ty::mk_res(st.tcx, def, inner, params);
|
ret ty::mk_res(st.tcx, def, inner, params);
|
||||||
}
|
}
|
||||||
'X' { ret ty::mk_var(st.tcx, parse_int(st)); }
|
'X' { ret ty::mk_var(st.tcx, parse_int(st)); }
|
||||||
'E' { let def = parse_def(st, conv); ret ty::mk_native(st.tcx, def); }
|
|
||||||
'Y' { ret ty::mk_type(st.tcx); }
|
'Y' { ret ty::mk_type(st.tcx); }
|
||||||
'y' { ret ty::mk_send_type(st.tcx); }
|
'y' { ret ty::mk_send_type(st.tcx); }
|
||||||
'C' {
|
'C' {
|
||||||
|
|
|
@ -163,11 +163,6 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
||||||
w.write_char(']');
|
w.write_char(']');
|
||||||
}
|
}
|
||||||
ty::ty_var(id) { w.write_char('X'); w.write_str(int::str(id)); }
|
ty::ty_var(id) { w.write_char('X'); w.write_str(int::str(id)); }
|
||||||
ty::ty_native(def) {
|
|
||||||
w.write_char('E');
|
|
||||||
w.write_str(cx.ds(def));
|
|
||||||
w.write_char('|');
|
|
||||||
}
|
|
||||||
ty::ty_param(id, did) {
|
ty::ty_param(id, did) {
|
||||||
w.write_char('p');
|
w.write_char('p');
|
||||||
w.write_str(cx.ds(did));
|
w.write_str(cx.ds(did));
|
||||||
|
|
|
@ -560,7 +560,7 @@ fn copy_is_expensive(tcx: ty::ctxt, ty: ty::t) -> bool {
|
||||||
fn score_ty(tcx: ty::ctxt, ty: ty::t) -> uint {
|
fn score_ty(tcx: ty::ctxt, ty: ty::t) -> uint {
|
||||||
ret alt ty::struct(tcx, ty) {
|
ret alt ty::struct(tcx, ty) {
|
||||||
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
|
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
|
||||||
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type | ty::ty_native(_) |
|
ty::ty_uint(_) | ty::ty_float(_) | ty::ty_type |
|
||||||
ty::ty_ptr(_) { 1u }
|
ty::ty_ptr(_) { 1u }
|
||||||
ty::ty_box(_) | ty::ty_iface(_, _) { 3u }
|
ty::ty_box(_) | ty::ty_iface(_, _) { 3u }
|
||||||
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
|
ty::ty_constr(t, _) | ty::ty_res(_, t, _) { score_ty(tcx, t) }
|
||||||
|
|
|
@ -103,7 +103,7 @@ fn type_is_gc_relevant(cx: ty::ctxt, ty: ty::t) -> bool {
|
||||||
alt ty::struct(cx, ty) {
|
alt ty::struct(cx, ty) {
|
||||||
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
|
ty::ty_nil | ty::ty_bot | ty::ty_bool | ty::ty_int(_) |
|
||||||
ty::ty_float(_) | ty::ty_uint(_) | ty::ty_str |
|
ty::ty_float(_) | ty::ty_uint(_) | ty::ty_str |
|
||||||
ty::ty_type | ty::ty_send_type | ty::ty_ptr(_) | ty::ty_native(_) {
|
ty::ty_type | ty::ty_send_type | ty::ty_ptr(_) {
|
||||||
ret false;
|
ret false;
|
||||||
}
|
}
|
||||||
ty::ty_rec(fields) {
|
ty::ty_rec(fields) {
|
||||||
|
|
|
@ -1358,11 +1358,6 @@ fn lookup_in_mie(e: env, mie: mod_index_entry, ns: namespace) ->
|
||||||
}
|
}
|
||||||
mie_native_item(native_item) {
|
mie_native_item(native_item) {
|
||||||
alt native_item.node {
|
alt native_item.node {
|
||||||
ast::native_item_ty {
|
|
||||||
if ns == ns_type {
|
|
||||||
ret some(ast::def_native_ty(local_def(native_item.id)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ast::native_item_fn(decl, _) {
|
ast::native_item_fn(decl, _) {
|
||||||
if ns == ns_val(ns_any_value) {
|
if ns == ns_val(ns_any_value) {
|
||||||
ret some(ast::def_fn(local_def(native_item.id),
|
ret some(ast::def_fn(local_def(native_item.id),
|
||||||
|
@ -1467,7 +1462,6 @@ fn ns_for_def(d: def) -> namespace {
|
||||||
ast::def_upvar(_, _, _) | ast::def_self(_) { ns_val(ns_any_value) }
|
ast::def_upvar(_, _, _) | ast::def_self(_) { ns_val(ns_any_value) }
|
||||||
ast::def_mod(_) | ast::def_native_mod(_) { ns_module }
|
ast::def_mod(_) | ast::def_native_mod(_) { ns_module }
|
||||||
ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) |
|
ast::def_ty(_) | ast::def_binding(_) | ast::def_use(_) |
|
||||||
ast::def_native_ty(_) { ns_type }
|
|
||||||
ast::def_ty_param(_, _) { ns_type }
|
ast::def_ty_param(_, _) { ns_type }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -324,8 +324,7 @@ fn shape_of(ccx: @crate_ctxt, t: ty::t, ty_param_map: [uint]) -> [u8] {
|
||||||
ty::ty_bot { s += [shape_u8]; }
|
ty::ty_bot { s += [shape_u8]; }
|
||||||
ty::ty_int(ast::ty_i) { s += [s_int(ccx.tcx)]; }
|
ty::ty_int(ast::ty_i) { s += [s_int(ccx.tcx)]; }
|
||||||
ty::ty_float(ast::ty_f) { s += [s_float(ccx.tcx)]; }
|
ty::ty_float(ast::ty_f) { s += [s_float(ccx.tcx)]; }
|
||||||
ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) |
|
ty::ty_uint(ast::ty_u) | ty::ty_ptr(_) { s += [s_uint(ccx.tcx)]; }
|
||||||
ty::ty_native(_) { s += [s_uint(ccx.tcx)]; }
|
|
||||||
ty::ty_type { s += [s_tydesc(ccx.tcx)]; }
|
ty::ty_type { s += [s_tydesc(ccx.tcx)]; }
|
||||||
ty::ty_send_type { s += [s_send_tydesc(ccx.tcx)]; }
|
ty::ty_send_type { s += [s_send_tydesc(ccx.tcx)]; }
|
||||||
ty::ty_int(ast::ty_i8) { s += [shape_i8]; }
|
ty::ty_int(ast::ty_i8) { s += [shape_i8]; }
|
||||||
|
|
|
@ -125,7 +125,6 @@ fn type_of_inner(cx: @crate_ctxt, t: ty::t)
|
||||||
|
|
||||||
if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); }
|
if cx.lltypes.contains_key(t) { ret cx.lltypes.get(t); }
|
||||||
let llty = alt ty::struct(cx.tcx, t) {
|
let llty = alt ty::struct(cx.tcx, t) {
|
||||||
ty::ty_native(_) { T_ptr(T_i8()) }
|
|
||||||
ty::ty_nil { T_nil() }
|
ty::ty_nil { T_nil() }
|
||||||
ty::ty_bot {
|
ty::ty_bot {
|
||||||
T_nil() /* ...I guess? */
|
T_nil() /* ...I guess? */
|
||||||
|
@ -1421,11 +1420,6 @@ fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
|
||||||
ty::ty_int(_) { ret rslt(cx, f(signed_int)); }
|
ty::ty_int(_) { ret rslt(cx, f(signed_int)); }
|
||||||
ty::ty_uint(_) { ret rslt(cx, f(unsigned_int)); }
|
ty::ty_uint(_) { ret rslt(cx, f(unsigned_int)); }
|
||||||
ty::ty_float(_) { ret rslt(cx, f(floating_point)); }
|
ty::ty_float(_) { ret rslt(cx, f(floating_point)); }
|
||||||
ty::ty_native(_) {
|
|
||||||
let cx = trans_fail(cx, none::<span>,
|
|
||||||
"attempt to compare values of type native");
|
|
||||||
ret rslt(cx, C_nil());
|
|
||||||
}
|
|
||||||
ty::ty_type {
|
ty::ty_type {
|
||||||
ret rslt(trans_fail(cx, none,
|
ret rslt(trans_fail(cx, none,
|
||||||
"attempt to compare values of type type"),
|
"attempt to compare values of type type"),
|
||||||
|
@ -1922,7 +1916,7 @@ fn copy_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
|
||||||
fn copy_val_no_check(bcx: @block_ctxt, action: copy_action, dst: ValueRef,
|
fn copy_val_no_check(bcx: @block_ctxt, action: copy_action, dst: ValueRef,
|
||||||
src: ValueRef, t: ty::t) -> @block_ctxt {
|
src: ValueRef, t: ty::t) -> @block_ctxt {
|
||||||
let ccx = bcx_ccx(bcx), bcx = bcx;
|
let ccx = bcx_ccx(bcx), bcx = bcx;
|
||||||
if ty::type_is_scalar(ccx.tcx, t) || ty::type_is_native(ccx.tcx, t) {
|
if ty::type_is_scalar(ccx.tcx, t) {
|
||||||
Store(bcx, src, dst);
|
Store(bcx, src, dst);
|
||||||
ret bcx;
|
ret bcx;
|
||||||
}
|
}
|
||||||
|
@ -1952,7 +1946,7 @@ fn move_val(cx: @block_ctxt, action: copy_action, dst: ValueRef,
|
||||||
src: lval_result, t: ty::t) -> @block_ctxt {
|
src: lval_result, t: ty::t) -> @block_ctxt {
|
||||||
let src_val = src.val;
|
let src_val = src.val;
|
||||||
let tcx = bcx_tcx(cx), cx = cx;
|
let tcx = bcx_tcx(cx), cx = cx;
|
||||||
if ty::type_is_scalar(tcx, t) || ty::type_is_native(tcx, t) {
|
if ty::type_is_scalar(tcx, t) {
|
||||||
if src.kind == owned { src_val = Load(cx, src_val); }
|
if src.kind == owned { src_val = Load(cx, src_val); }
|
||||||
Store(cx, src_val, dst);
|
Store(cx, src_val, dst);
|
||||||
ret cx;
|
ret cx;
|
||||||
|
@ -2905,8 +2899,7 @@ fn trans_cast(cx: @block_ctxt, e: @ast::expr, id: ast::node_id,
|
||||||
fn t_kind(tcx: ty::ctxt, t: ty::t) -> kind {
|
fn t_kind(tcx: ty::ctxt, t: ty::t) -> kind {
|
||||||
ret if ty::type_is_fp(tcx, t) {
|
ret if ty::type_is_fp(tcx, t) {
|
||||||
float
|
float
|
||||||
} else if ty::type_is_native(tcx, t) ||
|
} else if ty::type_is_unsafe_ptr(tcx, t) {
|
||||||
ty::type_is_unsafe_ptr(tcx, t) {
|
|
||||||
pointer
|
pointer
|
||||||
} else if ty::type_is_integral(tcx, t) {
|
} else if ty::type_is_integral(tcx, t) {
|
||||||
integral
|
integral
|
||||||
|
@ -4905,7 +4898,6 @@ fn trans_native_mod(lcx: @local_ctxt, native_mod: ast::native_mod,
|
||||||
|
|
||||||
for native_item in native_mod.items {
|
for native_item in native_mod.items {
|
||||||
alt native_item.node {
|
alt native_item.node {
|
||||||
ast::native_item_ty {}
|
|
||||||
ast::native_item_fn(fn_decl, tps) {
|
ast::native_item_fn(fn_decl, tps) {
|
||||||
let id = native_item.id;
|
let id = native_item.id;
|
||||||
let tys = c_stack_tys(ccx, id);
|
let tys = c_stack_tys(ccx, id);
|
||||||
|
@ -5144,10 +5136,6 @@ fn native_fn_ty_param_count(cx: @crate_ctxt, id: ast::node_id) -> uint {
|
||||||
_ { cx.sess.bug("native_fn_ty_param_count\
|
_ { cx.sess.bug("native_fn_ty_param_count\
|
||||||
given a non-native item"); } };
|
given a non-native item"); } };
|
||||||
alt native_item.node {
|
alt native_item.node {
|
||||||
ast::native_item_ty {
|
|
||||||
cx.sess.bug("register_native_fn(): native fn isn't \
|
|
||||||
actually a fn");
|
|
||||||
}
|
|
||||||
ast::native_item_fn(_, tps) {
|
ast::native_item_fn(_, tps) {
|
||||||
count = vec::len::<ast::ty_param>(tps);
|
count = vec::len::<ast::ty_param>(tps);
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,6 @@ export mk_vec;
|
||||||
export mk_mach_int;
|
export mk_mach_int;
|
||||||
export mk_mach_uint;
|
export mk_mach_uint;
|
||||||
export mk_mach_float;
|
export mk_mach_float;
|
||||||
export mk_native;
|
|
||||||
export mk_nil;
|
export mk_nil;
|
||||||
export mk_iface;
|
export mk_iface;
|
||||||
export mk_res;
|
export mk_res;
|
||||||
|
@ -116,7 +115,6 @@ export ty_fn_ret_style;
|
||||||
export ty_int;
|
export ty_int;
|
||||||
export ty_str;
|
export ty_str;
|
||||||
export ty_vec;
|
export ty_vec;
|
||||||
export ty_native;
|
|
||||||
export ty_nil;
|
export ty_nil;
|
||||||
export ty_iface;
|
export ty_iface;
|
||||||
export ty_res;
|
export ty_res;
|
||||||
|
@ -153,7 +151,6 @@ export type_is_fp;
|
||||||
export type_allows_implicit_copy;
|
export type_allows_implicit_copy;
|
||||||
export type_is_integral;
|
export type_is_integral;
|
||||||
export type_is_numeric;
|
export type_is_numeric;
|
||||||
export type_is_native;
|
|
||||||
export type_is_nil;
|
export type_is_nil;
|
||||||
export type_is_pod;
|
export type_is_pod;
|
||||||
export type_is_scalar;
|
export type_is_scalar;
|
||||||
|
@ -270,7 +267,6 @@ enum sty {
|
||||||
|
|
||||||
ty_type, // type_desc*
|
ty_type, // type_desc*
|
||||||
ty_send_type, // type_desc* that has been cloned into exchange heap
|
ty_send_type, // type_desc* that has been cloned into exchange heap
|
||||||
ty_native(def_id),
|
|
||||||
ty_constr(t, [@type_constr]),
|
ty_constr(t, [@type_constr]),
|
||||||
ty_opaque_closure_ptr(closure_kind), // ptr to env for fn, fn@, fn~
|
ty_opaque_closure_ptr(closure_kind), // ptr to env for fn, fn@, fn~
|
||||||
ty_named(t, @str),
|
ty_named(t, @str),
|
||||||
|
@ -458,10 +454,7 @@ fn mk_raw_ty(cx: ctxt, st: sty) -> @raw_t {
|
||||||
}
|
}
|
||||||
alt st {
|
alt st {
|
||||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||||
ty_str | ty_type | ty_send_type | ty_native(_) |
|
ty_str | ty_type | ty_send_type | ty_opaque_closure_ptr(_) {}
|
||||||
ty_opaque_closure_ptr(_) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
ty_param(_, _) { has_params = true; }
|
ty_param(_, _) { has_params = true; }
|
||||||
ty_var(_) { has_vars = true; }
|
ty_var(_) { has_vars = true; }
|
||||||
ty_enum(_, tys) | ty_iface(_, tys) {
|
ty_enum(_, tys) | ty_iface(_, tys) {
|
||||||
|
@ -607,8 +600,6 @@ fn mk_type(_cx: ctxt) -> t { ret idx_type; }
|
||||||
|
|
||||||
fn mk_send_type(_cx: ctxt) -> t { ret idx_send_type; }
|
fn mk_send_type(_cx: ctxt) -> t { ret idx_send_type; }
|
||||||
|
|
||||||
fn mk_native(cx: ctxt, did: def_id) -> t { ret gen_ty(cx, ty_native(did)); }
|
|
||||||
|
|
||||||
fn mk_opaque_closure_ptr(cx: ctxt, ck: closure_kind) -> t {
|
fn mk_opaque_closure_ptr(cx: ctxt, ck: closure_kind) -> t {
|
||||||
ret gen_ty(cx, ty_opaque_closure_ptr(ck));
|
ret gen_ty(cx, ty_opaque_closure_ptr(ck));
|
||||||
}
|
}
|
||||||
|
@ -658,7 +649,7 @@ pure fn ty_name(cx: ctxt, typ: t) -> option<@str> {
|
||||||
fn walk_ty(cx: ctxt, ty: t, f: fn(t)) {
|
fn walk_ty(cx: ctxt, ty: t, f: fn(t)) {
|
||||||
alt struct(cx, ty) {
|
alt struct(cx, ty) {
|
||||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||||
ty_str | ty_send_type | ty_type | ty_native(_) |
|
ty_str | ty_send_type | ty_type |
|
||||||
ty_opaque_closure_ptr(_) | ty_var(_) | ty_param(_, _) {}
|
ty_opaque_closure_ptr(_) | ty_var(_) | ty_param(_, _) {}
|
||||||
ty_box(tm) | ty_vec(tm) | ty_ptr(tm) { walk_ty(cx, tm.ty, f); }
|
ty_box(tm) | ty_vec(tm) | ty_ptr(tm) { walk_ty(cx, tm.ty, f); }
|
||||||
ty_enum(_, subtys) | ty_iface(_, subtys) {
|
ty_enum(_, subtys) | ty_iface(_, subtys) {
|
||||||
|
@ -702,10 +693,7 @@ fn fold_ty(cx: ctxt, fld: fold_mode, ty_0: t) -> t {
|
||||||
}
|
}
|
||||||
alt interner::get(*cx.ts, ty).struct {
|
alt interner::get(*cx.ts, ty).struct {
|
||||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||||
ty_str | ty_type | ty_send_type | ty_native(_) |
|
ty_str | ty_type | ty_send_type | ty_opaque_closure_ptr(_) {}
|
||||||
ty_opaque_closure_ptr(_) {
|
|
||||||
/* no-op */
|
|
||||||
}
|
|
||||||
ty_box(tm) {
|
ty_box(tm) {
|
||||||
ty = mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
|
ty = mk_box(cx, {ty: fold_ty(cx, fld, tm.ty), mut: tm.mut});
|
||||||
}
|
}
|
||||||
|
@ -889,7 +877,7 @@ pure fn type_is_unique(cx: ctxt, ty: t) -> bool {
|
||||||
pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
|
pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
|
||||||
alt struct(cx, ty) {
|
alt struct(cx, ty) {
|
||||||
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
ty_nil | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||||
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { true }
|
ty_send_type | ty_type | ty_ptr(_) { true }
|
||||||
_ { false }
|
_ { false }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -897,7 +885,7 @@ pure fn type_is_scalar(cx: ctxt, ty: t) -> bool {
|
||||||
// FIXME maybe inline this for speed?
|
// FIXME maybe inline this for speed?
|
||||||
fn type_is_immediate(cx: ctxt, ty: t) -> bool {
|
fn type_is_immediate(cx: ctxt, ty: t) -> bool {
|
||||||
ret type_is_scalar(cx, ty) || type_is_boxed(cx, ty) ||
|
ret type_is_scalar(cx, ty) || type_is_boxed(cx, ty) ||
|
||||||
type_is_unique(cx, ty) || type_is_native(cx, ty);
|
type_is_unique(cx, ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||||
|
@ -910,7 +898,7 @@ fn type_needs_drop(cx: ctxt, ty: t) -> bool {
|
||||||
let result = alt struct(cx, ty) {
|
let result = alt struct(cx, ty) {
|
||||||
// scalar types
|
// scalar types
|
||||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||||
ty_type | ty_native(_) | ty_ptr(_) { false }
|
ty_type | ty_ptr(_) { false }
|
||||||
ty_rec(flds) {
|
ty_rec(flds) {
|
||||||
for f in flds { if type_needs_drop(cx, f.mt.ty) { accum = true; } }
|
for f in flds { if type_needs_drop(cx, f.mt.ty) { accum = true; } }
|
||||||
accum
|
accum
|
||||||
|
@ -993,8 +981,7 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||||
let result = alt struct(cx, ty) {
|
let result = alt struct(cx, ty) {
|
||||||
// Scalar and unique types are sendable
|
// Scalar and unique types are sendable
|
||||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_uint(_) | ty_float(_) |
|
||||||
ty_native(_) | ty_ptr(_) |
|
ty_ptr(_) | ty_send_type | ty_str { kind_sendable }
|
||||||
ty_send_type | ty_str { kind_sendable }
|
|
||||||
ty_type { kind_copyable }
|
ty_type { kind_copyable }
|
||||||
ty_fn(f) { proto_kind(f.proto) }
|
ty_fn(f) { proto_kind(f.proto) }
|
||||||
ty_opaque_closure_ptr(ck_block) { kind_noncopyable }
|
ty_opaque_closure_ptr(ck_block) { kind_noncopyable }
|
||||||
|
@ -1043,12 +1030,6 @@ fn type_kind(cx: ctxt, ty: t) -> kind {
|
||||||
ret result;
|
ret result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: should we just return true for native types in
|
|
||||||
// type_is_scalar?
|
|
||||||
fn type_is_native(cx: ctxt, ty: t) -> bool {
|
|
||||||
alt struct(cx, ty) { ty_native(_) { ret true; } _ { ret false; } }
|
|
||||||
}
|
|
||||||
|
|
||||||
fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
fn type_structurally_contains(cx: ctxt, ty: t, test: fn(sty) -> bool) ->
|
||||||
bool {
|
bool {
|
||||||
let sty = struct(cx, ty);
|
let sty = struct(cx, ty);
|
||||||
|
@ -1168,7 +1149,7 @@ fn type_is_pod(cx: ctxt, ty: t) -> bool {
|
||||||
alt struct(cx, ty) {
|
alt struct(cx, ty) {
|
||||||
// Scalar types
|
// Scalar types
|
||||||
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
ty_nil | ty_bot | ty_bool | ty_int(_) | ty_float(_) | ty_uint(_) |
|
||||||
ty_send_type | ty_type | ty_native(_) | ty_ptr(_) { result = true; }
|
ty_send_type | ty_type | ty_ptr(_) { result = true; }
|
||||||
// Boxed types
|
// Boxed types
|
||||||
ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
|
ty_str | ty_box(_) | ty_uniq(_) | ty_vec(_) | ty_fn(_) |
|
||||||
ty_iface(_, _) { result = false; }
|
ty_iface(_, _) { result = false; }
|
||||||
|
@ -1359,7 +1340,6 @@ fn hash_type_structure(st: sty) -> uint {
|
||||||
ty_var(v) { ret hash_uint(30u, v as uint); }
|
ty_var(v) { ret hash_uint(30u, v as uint); }
|
||||||
ty_param(pid, _) { ret hash_uint(31u, pid); }
|
ty_param(pid, _) { ret hash_uint(31u, pid); }
|
||||||
ty_type { ret 32u; }
|
ty_type { ret 32u; }
|
||||||
ty_native(did) { ret hash_def(33u, did); }
|
|
||||||
ty_bot { ret 34u; }
|
ty_bot { ret 34u; }
|
||||||
ty_ptr(mt) { ret hash_subty(35u, mt.ty); }
|
ty_ptr(mt) { ret hash_subty(35u, mt.ty); }
|
||||||
ty_res(did, sub, tps) {
|
ty_res(did, sub, tps) {
|
||||||
|
@ -2082,16 +2062,6 @@ mod unify {
|
||||||
ty::ty_str | ty::ty_send_type {
|
ty::ty_str | ty::ty_send_type {
|
||||||
ret struct_cmp(cx, expected, actual);
|
ret struct_cmp(cx, expected, actual);
|
||||||
}
|
}
|
||||||
ty::ty_native(ex_id) {
|
|
||||||
alt struct(cx.tcx, actual) {
|
|
||||||
ty_native(act_id) {
|
|
||||||
if ex_id.crate == act_id.crate && ex_id.node == act_id.node {
|
|
||||||
ret ures_ok(actual);
|
|
||||||
} else { ret ures_err(terr_mismatch); }
|
|
||||||
}
|
|
||||||
_ { ret ures_err(terr_mismatch); }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ty::ty_param(expected_n, _) {
|
ty::ty_param(expected_n, _) {
|
||||||
alt struct(cx.tcx, actual) {
|
alt struct(cx.tcx, actual) {
|
||||||
ty::ty_param(actual_n, _) if expected_n == actual_n {
|
ty::ty_param(actual_n, _) if expected_n == actual_n {
|
||||||
|
@ -2515,7 +2485,7 @@ fn def_has_ty_params(def: ast::def) -> bool {
|
||||||
ast::def_mod(_) | ast::def_const(_) |
|
ast::def_mod(_) | ast::def_const(_) |
|
||||||
ast::def_arg(_, _) | ast::def_local(_, _) | ast::def_upvar(_, _, _) |
|
ast::def_arg(_, _) | ast::def_local(_, _) | ast::def_upvar(_, _, _) |
|
||||||
ast::def_ty_param(_, _) | ast::def_binding(_) | ast::def_use(_) |
|
ast::def_ty_param(_, _) | ast::def_binding(_) | ast::def_use(_) |
|
||||||
ast::def_native_ty(_) | ast::def_self(_) | ast::def_ty(_) { false }
|
ast::def_self(_) | ast::def_ty(_) { false }
|
||||||
ast::def_fn(_, _) | ast::def_variant(_, _) { true }
|
ast::def_fn(_, _) | ast::def_variant(_, _) { true }
|
||||||
_ { false } // ????
|
_ { false } // ????
|
||||||
}
|
}
|
||||||
|
|
|
@ -338,7 +338,6 @@ fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
|
||||||
some(ast::def_ty(id)) {
|
some(ast::def_ty(id)) {
|
||||||
typ = instantiate(tcx, ast_ty.span, mode, id, path.node.types);
|
typ = instantiate(tcx, ast_ty.span, mode, id, path.node.types);
|
||||||
}
|
}
|
||||||
some(ast::def_native_ty(id)) { typ = getter(tcx, mode, id).ty; }
|
|
||||||
some(ast::def_ty_param(id, n)) {
|
some(ast::def_ty_param(id, n)) {
|
||||||
typ = ty::mk_param(tcx, n, id);
|
typ = ty::mk_param(tcx, n, id);
|
||||||
}
|
}
|
||||||
|
@ -438,17 +437,6 @@ fn ty_of_native_item(tcx: ty::ctxt, mode: mode, it: @ast::native_item)
|
||||||
ret ty_of_native_fn_decl(tcx, mode, fn_decl, params,
|
ret ty_of_native_fn_decl(tcx, mode, fn_decl, params,
|
||||||
local_def(it.id));
|
local_def(it.id));
|
||||||
}
|
}
|
||||||
ast::native_item_ty {
|
|
||||||
alt tcx.tcache.find(local_def(it.id)) {
|
|
||||||
some(tpt) { ret tpt; }
|
|
||||||
none { }
|
|
||||||
}
|
|
||||||
let t = ty::mk_native(tcx, local_def(it.id));
|
|
||||||
let t = ty::mk_named(tcx, t, @it.ident);
|
|
||||||
let tpt = {bounds: @[], ty: t};
|
|
||||||
tcx.tcache.insert(local_def(it.id), tpt);
|
|
||||||
ret tpt;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn ty_of_arg(tcx: ty::ctxt, mode: mode, a: ast::arg) -> ty::arg {
|
fn ty_of_arg(tcx: ty::ctxt, mode: mode, a: ast::arg) -> ty::arg {
|
||||||
|
@ -762,9 +750,6 @@ mod collect {
|
||||||
// table.
|
// table.
|
||||||
let tpt = ty_of_native_item(cx.tcx, m_collect, i);
|
let tpt = ty_of_native_item(cx.tcx, m_collect, i);
|
||||||
alt i.node {
|
alt i.node {
|
||||||
ast::native_item_ty {
|
|
||||||
// FIXME: Native types have no annotation. Should they? --pcw
|
|
||||||
}
|
|
||||||
ast::native_item_fn(_, _) {
|
ast::native_item_fn(_, _) {
|
||||||
write_ty(cx.tcx, i.id, tpt.ty);
|
write_ty(cx.tcx, i.id, tpt.ty);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ enum def {
|
||||||
def_ty_param(def_id, uint),
|
def_ty_param(def_id, uint),
|
||||||
def_binding(def_id),
|
def_binding(def_id),
|
||||||
def_use(def_id),
|
def_use(def_id),
|
||||||
def_native_ty(def_id),
|
|
||||||
def_upvar(def_id, @def, node_id), // node_id == expr_fn or expr_fn_block
|
def_upvar(def_id, @def, node_id), // node_id == expr_fn or expr_fn_block
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -477,7 +476,6 @@ type native_item =
|
||||||
span: span};
|
span: span};
|
||||||
|
|
||||||
enum native_item_ {
|
enum native_item_ {
|
||||||
native_item_ty,
|
|
||||||
native_item_fn(fn_decl, [ty_param]),
|
native_item_fn(fn_decl, [ty_param]),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,7 @@ fn def_id_of_def(d: def) -> def_id {
|
||||||
def_fn(id, _) | def_self(id) | def_mod(id) |
|
def_fn(id, _) | def_self(id) | def_mod(id) |
|
||||||
def_native_mod(id) | def_const(id) | def_arg(id, _) | def_local(id, _) |
|
def_native_mod(id) | def_const(id) | def_arg(id, _) | def_local(id, _) |
|
||||||
def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
|
def_variant(_, id) | def_ty(id) | def_ty_param(id, _) |
|
||||||
def_binding(id) | def_use(id) | def_native_ty(id) |
|
def_binding(id) | def_use(id) | def_upvar(id, _, _) { id }
|
||||||
def_upvar(id, _, _) { id }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -189,7 +189,6 @@ fn noop_fold_native_item(&&ni: @native_item, fld: ast_fold) -> @native_item {
|
||||||
attrs: vec::map(ni.attrs, fold_attribute),
|
attrs: vec::map(ni.attrs, fold_attribute),
|
||||||
node:
|
node:
|
||||||
alt ni.node {
|
alt ni.node {
|
||||||
native_item_ty { native_item_ty }
|
|
||||||
native_item_fn(fdec, typms) {
|
native_item_fn(fdec, typms) {
|
||||||
native_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
|
native_item_fn({inputs: vec::map(fdec.inputs, fold_arg),
|
||||||
output: fld.fold_ty(fdec.output),
|
output: fld.fold_ty(fdec.output),
|
||||||
|
|
|
@ -1963,18 +1963,6 @@ fn parse_item_mod(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||||
ret mk_item(p, lo, hi, id, ast::item_mod(m), attrs + inner_attrs.inner);
|
ret mk_item(p, lo, hi, id, ast::item_mod(m), attrs + inner_attrs.inner);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_item_native_type(p: parser, attrs: [ast::attribute]) ->
|
|
||||||
@ast::native_item {
|
|
||||||
let t = parse_type_decl(p);
|
|
||||||
let hi = p.span.hi;
|
|
||||||
expect(p, token::SEMI);
|
|
||||||
ret @{ident: t.ident,
|
|
||||||
attrs: attrs,
|
|
||||||
node: ast::native_item_ty,
|
|
||||||
id: p.get_id(),
|
|
||||||
span: ast_util::mk_sp(t.lo, hi)};
|
|
||||||
}
|
|
||||||
|
|
||||||
fn parse_item_native_fn(p: parser, attrs: [ast::attribute],
|
fn parse_item_native_fn(p: parser, attrs: [ast::attribute],
|
||||||
purity: ast::purity) -> @ast::native_item {
|
purity: ast::purity) -> @ast::native_item {
|
||||||
let lo = p.last_span.lo;
|
let lo = p.last_span.lo;
|
||||||
|
@ -1991,9 +1979,7 @@ fn parse_item_native_fn(p: parser, attrs: [ast::attribute],
|
||||||
|
|
||||||
fn parse_native_item(p: parser, attrs: [ast::attribute]) ->
|
fn parse_native_item(p: parser, attrs: [ast::attribute]) ->
|
||||||
@ast::native_item {
|
@ast::native_item {
|
||||||
if eat_word(p, "type") {
|
if eat_word(p, "fn") {
|
||||||
ret parse_item_native_type(p, attrs);
|
|
||||||
} else if eat_word(p, "fn") {
|
|
||||||
ret parse_item_native_fn(p, attrs, ast::impure_fn);
|
ret parse_item_native_fn(p, attrs, ast::impure_fn);
|
||||||
} else if eat_word(p, "pure") {
|
} else if eat_word(p, "pure") {
|
||||||
expect_word(p, "fn");
|
expect_word(p, "fn");
|
||||||
|
|
|
@ -380,16 +380,6 @@ fn print_native_item(s: ps, item: @ast::native_item) {
|
||||||
maybe_print_comment(s, item.span.lo);
|
maybe_print_comment(s, item.span.lo);
|
||||||
print_outer_attributes(s, item.attrs);
|
print_outer_attributes(s, item.attrs);
|
||||||
alt item.node {
|
alt item.node {
|
||||||
ast::native_item_ty {
|
|
||||||
ibox(s, indent_unit);
|
|
||||||
ibox(s, 0u);
|
|
||||||
word_nbsp(s, "type");
|
|
||||||
word(s.s, item.ident);
|
|
||||||
end(s); // end the inner ibox
|
|
||||||
word(s.s, ";");
|
|
||||||
end(s); // end the outer ibox
|
|
||||||
|
|
||||||
}
|
|
||||||
ast::native_item_fn(decl, typarams) {
|
ast::native_item_fn(decl, typarams) {
|
||||||
print_fn(s, decl, item.ident, typarams);
|
print_fn(s, decl, item.ident, typarams);
|
||||||
end(s); // end head-ibox
|
end(s); // end head-ibox
|
||||||
|
|
|
@ -211,7 +211,6 @@ fn visit_native_item<E>(ni: @native_item, e: E, v: vt<E>) {
|
||||||
v.visit_ty_params(tps, e, v);
|
v.visit_ty_params(tps, e, v);
|
||||||
visit_fn_decl(fd, e, v);
|
visit_fn_decl(fd, e, v);
|
||||||
}
|
}
|
||||||
native_item_ty { }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,6 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||||
_ { }
|
_ { }
|
||||||
}
|
}
|
||||||
ret alt struct(cx, typ) {
|
ret alt struct(cx, typ) {
|
||||||
ty_native(_) { "native" }
|
|
||||||
ty_nil { "()" }
|
ty_nil { "()" }
|
||||||
ty_bot { "_|_" }
|
ty_bot { "_|_" }
|
||||||
ty_bool { "bool" }
|
ty_bool { "bool" }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue