Rename ast::controlflow to ast::ret_style
It will include information about returning by alias.
This commit is contained in:
parent
f6fe07d1f3
commit
6eb9738a66
13 changed files with 58 additions and 61 deletions
|
@ -178,7 +178,7 @@ fn mk_tests(cx: test_ctxt) -> @ast::item {
|
||||||
output: ret_ty,
|
output: ret_ty,
|
||||||
purity: ast::impure_fn,
|
purity: ast::impure_fn,
|
||||||
il: ast::il_normal,
|
il: ast::il_normal,
|
||||||
cf: ast::return,
|
cf: ast::return_val,
|
||||||
constraints: []};
|
constraints: []};
|
||||||
let proto = ast::proto_fn;
|
let proto = ast::proto_fn;
|
||||||
|
|
||||||
|
@ -205,7 +205,7 @@ fn empty_fn_ty() -> ast::ty {
|
||||||
let proto = ast::proto_fn;
|
let proto = ast::proto_fn;
|
||||||
let input_ty = [];
|
let input_ty = [];
|
||||||
let ret_ty = @nospan(ast::ty_nil);
|
let ret_ty = @nospan(ast::ty_nil);
|
||||||
let cf = ast::return;
|
let cf = ast::return_val;
|
||||||
let constrs = [];
|
let constrs = [];
|
||||||
ret nospan(ast::ty_fn(proto, input_ty, ret_ty, cf, constrs));
|
ret nospan(ast::ty_fn(proto, input_ty, ret_ty, cf, constrs));
|
||||||
}
|
}
|
||||||
|
@ -298,7 +298,7 @@ fn mk_main(cx: test_ctxt) -> @ast::item {
|
||||||
output: @ret_ty,
|
output: @ret_ty,
|
||||||
purity: ast::impure_fn,
|
purity: ast::impure_fn,
|
||||||
il: ast::il_normal,
|
il: ast::il_normal,
|
||||||
cf: ast::return,
|
cf: ast::return_val,
|
||||||
constraints: []};
|
constraints: []};
|
||||||
let proto = ast::proto_fn;
|
let proto = ast::proto_fn;
|
||||||
|
|
||||||
|
|
|
@ -371,7 +371,7 @@ fn parse_hex(st: @pstate) -> uint {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_ty_fn(st: @pstate, sd: str_def) ->
|
fn parse_ty_fn(st: @pstate, sd: str_def) ->
|
||||||
{args: [ty::arg], ty: ty::t, cf: ast::controlflow, cs: [@ty::constr]} {
|
{args: [ty::arg], ty: ty::t, cf: ast::ret_style, cs: [@ty::constr]} {
|
||||||
assert (next(st) as char == '[');
|
assert (next(st) as char == '[');
|
||||||
let inputs: [ty::arg] = [];
|
let inputs: [ty::arg] = [];
|
||||||
while peek(st) as char != ']' {
|
while peek(st) as char != ']' {
|
||||||
|
@ -391,7 +391,7 @@ fn parse_ty_fn(st: @pstate, sd: str_def) ->
|
||||||
a_bang. {
|
a_bang. {
|
||||||
ret {args: inputs, ty: ty::mk_bot(st.tcx), cf: ast::noreturn, cs: cs};
|
ret {args: inputs, ty: ty::mk_bot(st.tcx), cf: ast::noreturn, cs: cs};
|
||||||
}
|
}
|
||||||
a_ty(t) { ret {args: inputs, ty: t, cf: ast::return, cs: cs}; }
|
a_ty(t) { ret {args: inputs, ty: t, cf: ast::return_val, cs: cs}; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -148,7 +148,7 @@ fn enc_sty(w: io::writer, cx: @ctxt, st: ty::sty) {
|
||||||
native_abi_llvm. { w.write_char('l'); }
|
native_abi_llvm. { w.write_char('l'); }
|
||||||
native_abi_x86stdcall. { w.write_char('s'); }
|
native_abi_x86stdcall. { w.write_char('s'); }
|
||||||
}
|
}
|
||||||
enc_ty_fn(w, cx, args, out, return, []);
|
enc_ty_fn(w, cx, args, out, return_val, []);
|
||||||
}
|
}
|
||||||
ty::ty_obj(methods) {
|
ty::ty_obj(methods) {
|
||||||
w.write_str("O[");
|
w.write_str("O[");
|
||||||
|
@ -199,7 +199,7 @@ fn enc_proto(w: io::writer, proto: proto) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn enc_ty_fn(w: io::writer, cx: @ctxt, args: [ty::arg], out: ty::t,
|
fn enc_ty_fn(w: io::writer, cx: @ctxt, args: [ty::arg], out: ty::t,
|
||||||
cf: controlflow, constrs: [@ty::constr]) {
|
cf: ret_style, constrs: [@ty::constr]) {
|
||||||
w.write_char('[');
|
w.write_char('[');
|
||||||
for arg: ty::arg in args {
|
for arg: ty::arg in args {
|
||||||
alt arg.mode {
|
alt arg.mode {
|
||||||
|
@ -219,7 +219,6 @@ fn enc_ty_fn(w: io::writer, cx: @ctxt, args: [ty::arg], out: ty::t,
|
||||||
enc_constr(w, cx, c);
|
enc_constr(w, cx, c);
|
||||||
}
|
}
|
||||||
alt cf { noreturn. { w.write_char('!'); } _ { enc_ty(w, cx, out); } }
|
alt cf { noreturn. { w.write_char('!'); } _ { enc_ty(w, cx, out); } }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME less copy-and-paste
|
// FIXME less copy-and-paste
|
||||||
|
|
|
@ -254,7 +254,7 @@ type fn_info =
|
||||||
// Doesn't seem to work without the @ -- bug
|
// Doesn't seem to work without the @ -- bug
|
||||||
{constrs: constr_map,
|
{constrs: constr_map,
|
||||||
num_constraints: uint,
|
num_constraints: uint,
|
||||||
cf: controlflow,
|
cf: ret_style,
|
||||||
i_return: tsconstr,
|
i_return: tsconstr,
|
||||||
i_diverge: tsconstr,
|
i_diverge: tsconstr,
|
||||||
used_vars: @mutable [node_id]};
|
used_vars: @mutable [node_id]};
|
||||||
|
@ -489,10 +489,10 @@ fn new_crate_ctxt(cx: ty::ctxt) -> crate_ctxt {
|
||||||
/* Use e's type to determine whether it returns.
|
/* Use e's type to determine whether it returns.
|
||||||
If it has a function type with a ! annotation,
|
If it has a function type with a ! annotation,
|
||||||
the answer is noreturn. */
|
the answer is noreturn. */
|
||||||
fn controlflow_expr(ccx: crate_ctxt, e: @expr) -> controlflow {
|
fn controlflow_expr(ccx: crate_ctxt, e: @expr) -> ret_style {
|
||||||
alt ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, e.id)) {
|
alt ty::struct(ccx.tcx, ty::node_id_to_type(ccx.tcx, e.id)) {
|
||||||
ty::ty_fn(_, _, _, cf, _) { ret cf; }
|
ty::ty_fn(_, _, _, cf, _) { ret cf; }
|
||||||
_ { ret return; }
|
_ { ret return_val; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
|
|
||||||
import syntax::ast;
|
import syntax::ast;
|
||||||
import ast::{method, item, item_fn, _fn, obj_field, _obj, stmt, ident,
|
import ast::{method, item, item_fn, _fn, obj_field, _obj, stmt, ident,
|
||||||
fn_ident, node_id, def_id, ty_param, crate, return, noreturn,
|
fn_ident, node_id, def_id, ty_param, crate, return_val, noreturn,
|
||||||
expr};
|
expr};
|
||||||
import syntax::ast_util::local_def;
|
import syntax::ast_util::local_def;
|
||||||
import syntax::visit;
|
import syntax::visit;
|
||||||
|
@ -119,7 +119,7 @@ fn check_states_against_conditions(fcx: fn_ctxt, f: _fn, tps: [ast::ty_param],
|
||||||
if f.proto != ast::proto_iter &&
|
if f.proto != ast::proto_iter &&
|
||||||
!promises(fcx, post, fcx.enclosing.i_return) &&
|
!promises(fcx, post, fcx.enclosing.i_return) &&
|
||||||
!type_is_nil(fcx.ccx.tcx, ret_ty_of_fn(fcx.ccx.tcx, id)) &&
|
!type_is_nil(fcx.ccx.tcx, ret_ty_of_fn(fcx.ccx.tcx, id)) &&
|
||||||
f.decl.cf == return {
|
f.decl.cf == return_val {
|
||||||
fcx.ccx.tcx.sess.span_err(f.body.span,
|
fcx.ccx.tcx.sess.span_err(f.body.span,
|
||||||
"In function " + fcx.name +
|
"In function " + fcx.name +
|
||||||
", not all control paths \
|
", not all control paths \
|
||||||
|
|
|
@ -52,7 +52,7 @@ fn find_pre_post_item(ccx: crate_ctxt, i: item) {
|
||||||
enclosing:
|
enclosing:
|
||||||
{constrs: @new_def_hash::<constraint>(),
|
{constrs: @new_def_hash::<constraint>(),
|
||||||
num_constraints: 0u,
|
num_constraints: 0u,
|
||||||
cf: return,
|
cf: return_val,
|
||||||
i_return: ninit(0, ""),
|
i_return: ninit(0, ""),
|
||||||
i_diverge: ninit(0, ""),
|
i_diverge: ninit(0, ""),
|
||||||
used_vars: v},
|
used_vars: v},
|
||||||
|
|
|
@ -169,7 +169,7 @@ fn find_pre_post_state_two(fcx: fn_ctxt, pres: prestate, lhs: @expr,
|
||||||
|
|
||||||
fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr,
|
fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr,
|
||||||
id: node_id, ops: [init_op], bs: [@expr],
|
id: node_id, ops: [init_op], bs: [@expr],
|
||||||
cf: controlflow) -> bool {
|
cf: ret_style) -> bool {
|
||||||
let changed = find_pre_post_state_expr(fcx, pres, a);
|
let changed = find_pre_post_state_expr(fcx, pres, a);
|
||||||
// FIXME: This could be a typestate constraint
|
// FIXME: This could be a typestate constraint
|
||||||
if vec::len(bs) != vec::len(ops) {
|
if vec::len(bs) != vec::len(ops) {
|
||||||
|
@ -183,7 +183,7 @@ fn find_pre_post_state_call(fcx: fn_ctxt, pres: prestate, a: @expr,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id,
|
fn find_pre_post_state_exprs(fcx: fn_ctxt, pres: prestate, id: node_id,
|
||||||
ops: [init_op], es: [@expr], cf: controlflow) ->
|
ops: [init_op], es: [@expr], cf: ret_style) ->
|
||||||
bool {
|
bool {
|
||||||
let rs = seq_states(fcx, pres, anon_bindings(ops, es));
|
let rs = seq_states(fcx, pres, anon_bindings(ops, es));
|
||||||
let changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres);
|
let changed = rs.changed | set_prestate_ann(fcx.ccx, id, pres);
|
||||||
|
@ -333,7 +333,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||||
ret find_pre_post_state_exprs(fcx, pres, e.id,
|
ret find_pre_post_state_exprs(fcx, pres, e.id,
|
||||||
vec::init_elt(init_assign,
|
vec::init_elt(init_assign,
|
||||||
vec::len(elts)), elts,
|
vec::len(elts)), elts,
|
||||||
return);
|
return_val);
|
||||||
}
|
}
|
||||||
expr_call(operator, operands) {
|
expr_call(operator, operands) {
|
||||||
ret find_pre_post_state_call(fcx, pres, operator, e.id,
|
ret find_pre_post_state_call(fcx, pres, operator, e.id,
|
||||||
|
@ -354,7 +354,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
ret find_pre_post_state_call(fcx, pres, operator, e.id, ops, args,
|
ret find_pre_post_state_call(fcx, pres, operator, e.id, ops, args,
|
||||||
return);
|
return_val);
|
||||||
}
|
}
|
||||||
expr_path(_) { ret pure_exp(fcx.ccx, e.id, pres); }
|
expr_path(_) { ret pure_exp(fcx.ccx, e.id, pres); }
|
||||||
expr_log(_, ex) {
|
expr_log(_, ex) {
|
||||||
|
@ -381,7 +381,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||||
find_pre_post_state_exprs(fcx, pres, e.id,
|
find_pre_post_state_exprs(fcx, pres, e.id,
|
||||||
vec::init_elt(init_assign,
|
vec::init_elt(init_assign,
|
||||||
vec::len(fields)),
|
vec::len(fields)),
|
||||||
field_exprs(fields), return);
|
field_exprs(fields), return_val);
|
||||||
alt maybe_base {
|
alt maybe_base {
|
||||||
none. {/* do nothing */ }
|
none. {/* do nothing */ }
|
||||||
some(base) {
|
some(base) {
|
||||||
|
@ -397,7 +397,7 @@ fn find_pre_post_state_expr(fcx: fn_ctxt, pres: prestate, e: @expr) -> bool {
|
||||||
ret find_pre_post_state_exprs(fcx, pres, e.id,
|
ret find_pre_post_state_exprs(fcx, pres, e.id,
|
||||||
vec::init_elt(init_assign,
|
vec::init_elt(init_assign,
|
||||||
vec::len(elts)), elts,
|
vec::len(elts)), elts,
|
||||||
return);
|
return_val);
|
||||||
}
|
}
|
||||||
expr_copy(a) { ret find_pre_post_state_sub(fcx, pres, a, e.id, none); }
|
expr_copy(a) { ret find_pre_post_state_sub(fcx, pres, a, e.id, none); }
|
||||||
expr_move(lhs, rhs) {
|
expr_move(lhs, rhs) {
|
||||||
|
|
|
@ -185,7 +185,7 @@ type method =
|
||||||
ident: ast::ident,
|
ident: ast::ident,
|
||||||
inputs: [arg],
|
inputs: [arg],
|
||||||
output: t,
|
output: t,
|
||||||
cf: controlflow,
|
cf: ret_style,
|
||||||
constrs: [@constr]};
|
constrs: [@constr]};
|
||||||
|
|
||||||
type constr_table = hashmap<ast::node_id, [constr]>;
|
type constr_table = hashmap<ast::node_id, [constr]>;
|
||||||
|
@ -255,7 +255,7 @@ tag sty {
|
||||||
ty_vec(mt);
|
ty_vec(mt);
|
||||||
ty_ptr(mt);
|
ty_ptr(mt);
|
||||||
ty_rec([field]);
|
ty_rec([field]);
|
||||||
ty_fn(ast::proto, [arg], t, controlflow, [@constr]);
|
ty_fn(ast::proto, [arg], t, ret_style, [@constr]);
|
||||||
ty_native_fn(ast::native_abi, [arg], t);
|
ty_native_fn(ast::native_abi, [arg], t);
|
||||||
ty_obj([method]);
|
ty_obj([method]);
|
||||||
ty_res(def_id, t, [t]);
|
ty_res(def_id, t, [t]);
|
||||||
|
@ -556,7 +556,7 @@ fn mk_constr(cx: ctxt, t: t, cs: [@type_constr]) -> t {
|
||||||
|
|
||||||
fn mk_tup(cx: ctxt, ts: [t]) -> t { ret gen_ty(cx, ty_tup(ts)); }
|
fn mk_tup(cx: ctxt, ts: [t]) -> t { ret gen_ty(cx, ty_tup(ts)); }
|
||||||
|
|
||||||
fn mk_fn(cx: ctxt, proto: ast::proto, args: [arg], ty: t, cf: controlflow,
|
fn mk_fn(cx: ctxt, proto: ast::proto, args: [arg], ty: t, cf: ret_style,
|
||||||
constrs: [@constr]) -> t {
|
constrs: [@constr]) -> t {
|
||||||
ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs));
|
ret gen_ty(cx, ty_fn(proto, args, ty, cf, constrs));
|
||||||
}
|
}
|
||||||
|
@ -583,7 +583,7 @@ fn mk_native(cx: ctxt, did: def_id) -> t { ret gen_ty(cx, ty_native(did)); }
|
||||||
|
|
||||||
fn mk_iter_body_fn(cx: ctxt, output: t) -> t {
|
fn mk_iter_body_fn(cx: ctxt, output: t) -> t {
|
||||||
ret mk_fn(cx, ast::proto_block, [{mode: ast::by_ref, ty: output}],
|
ret mk_fn(cx, ast::proto_block, [{mode: ast::by_ref, ty: output}],
|
||||||
ty::mk_nil(cx), ast::return, []);
|
ty::mk_nil(cx), ast::return_val, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the one-level-deep type structure of the given type.
|
// Returns the one-level-deep type structure of the given type.
|
||||||
|
@ -1948,16 +1948,12 @@ mod unify {
|
||||||
fn unify_fn(cx: @ctxt, e_proto: ast::proto, a_proto: ast::proto,
|
fn unify_fn(cx: @ctxt, e_proto: ast::proto, a_proto: ast::proto,
|
||||||
expected: t, actual: t, expected_inputs: [arg],
|
expected: t, actual: t, expected_inputs: [arg],
|
||||||
expected_output: t, actual_inputs: [arg], actual_output: t,
|
expected_output: t, actual_inputs: [arg], actual_output: t,
|
||||||
expected_cf: controlflow, actual_cf: controlflow,
|
expected_cf: ret_style, actual_cf: ret_style,
|
||||||
_expected_constrs: [@constr], actual_constrs: [@constr]) ->
|
_expected_constrs: [@constr], actual_constrs: [@constr]) ->
|
||||||
result {
|
result {
|
||||||
if e_proto != a_proto { ret ures_err(terr_mismatch); }
|
if e_proto != a_proto { ret ures_err(terr_mismatch); }
|
||||||
alt expected_cf {
|
alt expected_cf {
|
||||||
ast::return. { }
|
ast::return_val. { }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ok
|
// ok
|
||||||
ast::noreturn. {
|
ast::noreturn. {
|
||||||
alt actual_cf {
|
alt actual_cf {
|
||||||
|
|
|
@ -593,8 +593,8 @@ mod collect {
|
||||||
}
|
}
|
||||||
|
|
||||||
let t_fn =
|
let t_fn =
|
||||||
ty::mk_fn(cx.tcx, ast::proto_fn, t_inputs, t_obj.ty, ast::return,
|
ty::mk_fn(cx.tcx, ast::proto_fn, t_inputs, t_obj.ty,
|
||||||
[]);
|
ast::return_val, []);
|
||||||
let tpt = {kinds: ty_param_kinds(ty_params), ty: t_fn};
|
let tpt = {kinds: ty_param_kinds(ty_params), ty: t_fn};
|
||||||
cx.tcx.tcache.insert(local_def(ctor_id), tpt);
|
cx.tcx.tcache.insert(local_def(ctor_id), tpt);
|
||||||
ret tpt;
|
ret tpt;
|
||||||
|
@ -704,8 +704,8 @@ mod collect {
|
||||||
let tag_t = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
|
let tag_t = ty::mk_tag(cx.tcx, tag_id, ty_param_tys);
|
||||||
// FIXME: this will be different for constrained types
|
// FIXME: this will be different for constrained types
|
||||||
result_ty =
|
result_ty =
|
||||||
ty::mk_fn(cx.tcx, ast::proto_fn, args, tag_t, ast::return,
|
ty::mk_fn(cx.tcx, ast::proto_fn, args, tag_t,
|
||||||
[]);
|
ast::return_val, []);
|
||||||
}
|
}
|
||||||
let tpt = {kinds: ty_param_kinds(ty_params), ty: result_ty};
|
let tpt = {kinds: ty_param_kinds(ty_params), ty: result_ty};
|
||||||
cx.tcx.tcache.insert(local_def(variant.node.id), tpt);
|
cx.tcx.tcache.insert(local_def(variant.node.id), tpt);
|
||||||
|
@ -774,11 +774,11 @@ mod collect {
|
||||||
ty::mk_res(cx.tcx, local_def(it.id), t_arg.ty,
|
ty::mk_res(cx.tcx, local_def(it.id), t_arg.ty,
|
||||||
mk_ty_params(cx, tps));
|
mk_ty_params(cx, tps));
|
||||||
let t_ctor =
|
let t_ctor =
|
||||||
ty::mk_fn(cx.tcx, ast::proto_fn, [t_arg], t_res, ast::return,
|
ty::mk_fn(cx.tcx, ast::proto_fn, [t_arg], t_res,
|
||||||
[]);
|
ast::return_val, []);
|
||||||
let t_dtor =
|
let t_dtor =
|
||||||
ty::mk_fn(cx.tcx, ast::proto_fn, [t_arg], ty::mk_nil(cx.tcx),
|
ty::mk_fn(cx.tcx, ast::proto_fn, [t_arg], ty::mk_nil(cx.tcx),
|
||||||
ast::return, []);
|
ast::return_val, []);
|
||||||
write::ty_only(cx.tcx, it.id, t_res);
|
write::ty_only(cx.tcx, it.id, t_res);
|
||||||
write::ty_only(cx.tcx, ctor_id, t_ctor);
|
write::ty_only(cx.tcx, ctor_id, t_ctor);
|
||||||
cx.tcx.tcache.insert(local_def(ctor_id),
|
cx.tcx.tcache.insert(local_def(ctor_id),
|
||||||
|
@ -2010,7 +2010,7 @@ fn check_expr_with_unifier(fcx: @fn_ctxt, expr: @ast::expr, unify: unifier,
|
||||||
proto = ast::proto_fn;
|
proto = ast::proto_fn;
|
||||||
arg_tys = arg_tys_;
|
arg_tys = arg_tys_;
|
||||||
rt = rt_;
|
rt = rt_;
|
||||||
cf = ast::return;
|
cf = ast::return_val;
|
||||||
constrs = [];
|
constrs = [];
|
||||||
}
|
}
|
||||||
_ { fail "LHS of bind expr didn't have a function type?!"; }
|
_ { fail "LHS of bind expr didn't have a function type?!"; }
|
||||||
|
@ -2685,7 +2685,7 @@ fn arg_is_argv_ty(tcx: ty::ctxt, a: ty::arg) -> bool {
|
||||||
fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) {
|
fn check_main_fn_ty(tcx: ty::ctxt, main_id: ast::node_id) {
|
||||||
let main_t = ty::node_id_to_monotype(tcx, main_id);
|
let main_t = ty::node_id_to_monotype(tcx, main_id);
|
||||||
alt ty::struct(tcx, main_t) {
|
alt ty::struct(tcx, main_t) {
|
||||||
ty::ty_fn(ast::proto_fn., args, rs, ast::return., constrs) {
|
ty::ty_fn(ast::proto_fn., args, rs, ast::return_val., constrs) {
|
||||||
let ok = vec::len(constrs) == 0u;
|
let ok = vec::len(constrs) == 0u;
|
||||||
ok &= ty::type_is_nil(tcx, rs);
|
ok &= ty::type_is_nil(tcx, rs);
|
||||||
let num_args = vec::len(args);
|
let num_args = vec::len(args);
|
||||||
|
|
|
@ -261,7 +261,7 @@ type ty_method_ =
|
||||||
ident: ident,
|
ident: ident,
|
||||||
inputs: [ty_arg],
|
inputs: [ty_arg],
|
||||||
output: @ty,
|
output: @ty,
|
||||||
cf: controlflow,
|
cf: ret_style,
|
||||||
constrs: [@constr]};
|
constrs: [@constr]};
|
||||||
|
|
||||||
type ty_field = spanned<ty_field_>;
|
type ty_field = spanned<ty_field_>;
|
||||||
|
@ -311,7 +311,7 @@ tag ty_ {
|
||||||
ty_port(@ty);
|
ty_port(@ty);
|
||||||
ty_chan(@ty);
|
ty_chan(@ty);
|
||||||
ty_rec([ty_field]);
|
ty_rec([ty_field]);
|
||||||
ty_fn(proto, [ty_arg], @ty, controlflow, [@constr]);
|
ty_fn(proto, [ty_arg], @ty, ret_style, [@constr]);
|
||||||
ty_obj([ty_method]);
|
ty_obj([ty_method]);
|
||||||
ty_tup([@ty]);
|
ty_tup([@ty]);
|
||||||
ty_path(path, node_id);
|
ty_path(path, node_id);
|
||||||
|
@ -369,7 +369,7 @@ type fn_decl =
|
||||||
output: @ty,
|
output: @ty,
|
||||||
purity: purity,
|
purity: purity,
|
||||||
il: inlineness,
|
il: inlineness,
|
||||||
cf: controlflow,
|
cf: ret_style,
|
||||||
constraints: [@constr]};
|
constraints: [@constr]};
|
||||||
|
|
||||||
tag purity {
|
tag purity {
|
||||||
|
@ -377,14 +377,11 @@ tag purity {
|
||||||
impure_fn; // declared with "fn"
|
impure_fn; // declared with "fn"
|
||||||
}
|
}
|
||||||
|
|
||||||
tag controlflow {
|
tag ret_style {
|
||||||
noreturn; // functions with return type _|_ that always
|
noreturn; // functions with return type _|_ that always
|
||||||
// raise an error or exit (i.e. never return to the caller)
|
// raise an error or exit (i.e. never return to the caller)
|
||||||
|
return_val; // everything else
|
||||||
|
return_alias;
|
||||||
|
|
||||||
|
|
||||||
return; // everything else
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type _fn = {decl: fn_decl, proto: proto, body: blk};
|
type _fn = {decl: fn_decl, proto: proto, body: blk};
|
||||||
|
|
|
@ -289,10 +289,10 @@ fn parse_ty_fn(proto: ast::proto, p: parser) -> ast::ty_ {
|
||||||
// auto constrs = parse_constrs(~[], p);
|
// auto constrs = parse_constrs(~[], p);
|
||||||
let constrs: [@ast::constr] = [];
|
let constrs: [@ast::constr] = [];
|
||||||
let output: @ast::ty;
|
let output: @ast::ty;
|
||||||
let cf = ast::return;
|
let cf = ast::return_val;
|
||||||
if p.peek() == token::RARROW {
|
if p.peek() == token::RARROW {
|
||||||
p.bump();
|
p.bump();
|
||||||
let tmp = parse_ty_or_bang(p);
|
let tmp = parse_ret_ty(p);
|
||||||
alt tmp {
|
alt tmp {
|
||||||
a_ty(t) { output = t; }
|
a_ty(t) { output = t; }
|
||||||
a_bang. {
|
a_bang. {
|
||||||
|
@ -452,7 +452,12 @@ fn parse_ty_postfix(orig_t: ast::ty_, p: parser, colons_before_params: bool)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_ty_or_bang(p: parser) -> ty_or_bang {
|
fn parse_ret_ty(p: parser) -> ty_or_bang {
|
||||||
|
/* if eat(p, token::RARROW) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
}*/
|
||||||
alt p.peek() {
|
alt p.peek() {
|
||||||
token::NOT. { p.bump(); ret a_bang; }
|
token::NOT. { p.bump(); ret a_bang; }
|
||||||
_ { ret a_ty(parse_ty(p, false)); }
|
_ { ret a_ty(parse_ty(p, false)); }
|
||||||
|
@ -1766,7 +1771,7 @@ fn parse_fn_decl(p: parser, purity: ast::purity, il: ast::inlineness) ->
|
||||||
}
|
}
|
||||||
if p.peek() == token::RARROW {
|
if p.peek() == token::RARROW {
|
||||||
p.bump();
|
p.bump();
|
||||||
rslt = parse_ty_or_bang(p);
|
rslt = parse_ret_ty(p);
|
||||||
} else {
|
} else {
|
||||||
rslt = a_ty(@spanned(inputs.span.lo, inputs.span.hi, ast::ty_nil));
|
rslt = a_ty(@spanned(inputs.span.lo, inputs.span.hi, ast::ty_nil));
|
||||||
}
|
}
|
||||||
|
@ -1776,7 +1781,7 @@ fn parse_fn_decl(p: parser, purity: ast::purity, il: ast::inlineness) ->
|
||||||
output: t,
|
output: t,
|
||||||
purity: purity,
|
purity: purity,
|
||||||
il: il,
|
il: il,
|
||||||
cf: ast::return,
|
cf: ast::return_val,
|
||||||
constraints: constrs};
|
constraints: constrs};
|
||||||
}
|
}
|
||||||
a_bang. {
|
a_bang. {
|
||||||
|
@ -1803,7 +1808,7 @@ fn parse_fn_block_decl(p: parser) -> ast::fn_decl {
|
||||||
output: @spanned(p.get_lo_pos(), p.get_hi_pos(), ast::ty_infer),
|
output: @spanned(p.get_lo_pos(), p.get_hi_pos(), ast::ty_infer),
|
||||||
purity: ast::impure_fn,
|
purity: ast::impure_fn,
|
||||||
il: ast::il_normal,
|
il: ast::il_normal,
|
||||||
cf: ast::return,
|
cf: ast::return_val,
|
||||||
constraints: []};
|
constraints: []};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1899,7 +1904,7 @@ fn parse_item_res(p: parser, attrs: [ast::attribute]) -> @ast::item {
|
||||||
output: @spanned(lo, lo, ast::ty_nil),
|
output: @spanned(lo, lo, ast::ty_nil),
|
||||||
purity: ast::impure_fn,
|
purity: ast::impure_fn,
|
||||||
il: ast::il_normal,
|
il: ast::il_normal,
|
||||||
cf: ast::return,
|
cf: ast::return_val,
|
||||||
constraints: []};
|
constraints: []};
|
||||||
let f = {decl: decl, proto: ast::proto_fn, body: dtor};
|
let f = {decl: decl, proto: ast::proto_fn, body: dtor};
|
||||||
ret mk_item(p, lo, dtor.span.hi, ident,
|
ret mk_item(p, lo, dtor.span.hi, ident,
|
||||||
|
|
|
@ -1401,7 +1401,7 @@ fn print_mt(s: ps, mt: ast::mt) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_ty_fn(s: ps, proto: ast::proto, id: option::t<ast::ident>,
|
fn print_ty_fn(s: ps, proto: ast::proto, id: option::t<ast::ident>,
|
||||||
inputs: [ast::ty_arg], output: @ast::ty, cf: ast::controlflow,
|
inputs: [ast::ty_arg], output: @ast::ty, cf: ast::ret_style,
|
||||||
constrs: [@ast::constr]) {
|
constrs: [@ast::constr]) {
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
word(s.s, proto_to_str(proto));
|
word(s.s, proto_to_str(proto));
|
||||||
|
@ -1420,7 +1420,7 @@ fn print_ty_fn(s: ps, proto: ast::proto, id: option::t<ast::ident>,
|
||||||
ibox(s, indent_unit);
|
ibox(s, indent_unit);
|
||||||
word_space(s, "->");
|
word_space(s, "->");
|
||||||
alt cf {
|
alt cf {
|
||||||
ast::return. { print_type(s, output); }
|
ast::return_val. { print_type(s, output); }
|
||||||
ast::noreturn. { word_nbsp(s, "!"); }
|
ast::noreturn. { word_nbsp(s, "!"); }
|
||||||
}
|
}
|
||||||
end(s);
|
end(s);
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||||
ret s + ty_to_str(cx, input.ty);
|
ret s + ty_to_str(cx, input.ty);
|
||||||
}
|
}
|
||||||
fn fn_to_str(cx: ctxt, proto: ast::proto, ident: option::t<ast::ident>,
|
fn fn_to_str(cx: ctxt, proto: ast::proto, ident: option::t<ast::ident>,
|
||||||
inputs: [arg], output: t, cf: ast::controlflow,
|
inputs: [arg], output: t, cf: ast::ret_style,
|
||||||
constrs: [@constr]) -> str {
|
constrs: [@constr]) -> str {
|
||||||
let s = proto_to_str(proto);
|
let s = proto_to_str(proto);
|
||||||
alt ident { some(i) { s += " "; s += i; } _ { } }
|
alt ident { some(i) { s += " "; s += i; } _ { } }
|
||||||
|
@ -60,7 +60,7 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||||
if struct(cx, output) != ty_nil {
|
if struct(cx, output) != ty_nil {
|
||||||
alt cf {
|
alt cf {
|
||||||
ast::noreturn. { s += " -> !"; }
|
ast::noreturn. { s += " -> !"; }
|
||||||
ast::return. { s += " -> " + ty_to_str(cx, output); }
|
ast::return_val. { s += " -> " + ty_to_str(cx, output); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s += constrs_str(constrs);
|
s += constrs_str(constrs);
|
||||||
|
@ -121,8 +121,8 @@ fn ty_to_str(cx: ctxt, typ: t) -> str {
|
||||||
fn_to_str(cx, proto, none, inputs, output, cf, constrs)
|
fn_to_str(cx, proto, none, inputs, output, cf, constrs)
|
||||||
}
|
}
|
||||||
ty_native_fn(_, inputs, output) {
|
ty_native_fn(_, inputs, output) {
|
||||||
fn_to_str(cx, ast::proto_fn, none, inputs, output, ast::return,
|
fn_to_str(cx, ast::proto_fn, none, inputs, output,
|
||||||
[])
|
ast::return_val, [])
|
||||||
}
|
}
|
||||||
ty_obj(meths) {
|
ty_obj(meths) {
|
||||||
let strs = [];
|
let strs = [];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue