Prohibit trailing whitespace under 'tidy' script. Clean up all caught cases.
This commit is contained in:
parent
04b239f3cb
commit
39151f2ad8
105 changed files with 393 additions and 390 deletions
|
@ -257,6 +257,7 @@ include $(CFG_SRC_DIR)/mk/docs.mk
|
||||||
ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
|
ifneq ($(strip $(findstring dist,$(MAKECMDGOALS)) \
|
||||||
$(findstring check,$(MAKECMDGOALS)) \
|
$(findstring check,$(MAKECMDGOALS)) \
|
||||||
$(findstring test,$(MAKECMDGOALS)) \
|
$(findstring test,$(MAKECMDGOALS)) \
|
||||||
|
$(findstring tidy,$(MAKECMDGOALS)) \
|
||||||
$(findstring clean,$(MAKECMDGOALS))),)
|
$(findstring clean,$(MAKECMDGOALS))),)
|
||||||
CFG_INFO := $(info cfg: including dist rules)
|
CFG_INFO := $(info cfg: including dist rules)
|
||||||
include $(CFG_SRC_DIR)/mk/dist.mk
|
include $(CFG_SRC_DIR)/mk/dist.mk
|
||||||
|
|
|
@ -325,7 +325,7 @@ fn build_link_meta(&session::session sess, &ast::crate c,
|
||||||
fn len_and_str_lit(&ast::lit l) -> str {
|
fn len_and_str_lit(&ast::lit l) -> str {
|
||||||
ret len_and_str(pprust::lit_to_str(@l));
|
ret len_and_str(pprust::lit_to_str(@l));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto cmh_items = attr::sort_meta_items(metas.cmh_items);
|
auto cmh_items = attr::sort_meta_items(metas.cmh_items);
|
||||||
|
|
||||||
sha.reset();
|
sha.reset();
|
||||||
|
|
|
@ -199,7 +199,7 @@ fn require_unique_names(&session::session sess, &(@ast::meta_item)[] metas) {
|
||||||
for (@ast::meta_item meta in metas) {
|
for (@ast::meta_item meta in metas) {
|
||||||
auto name = get_meta_item_name(meta);
|
auto name = get_meta_item_name(meta);
|
||||||
if (map.contains_key(name)) {
|
if (map.contains_key(name)) {
|
||||||
sess.span_fatal(meta.span,
|
sess.span_fatal(meta.span,
|
||||||
#fmt("duplicate meta item `%s`", name));
|
#fmt("duplicate meta item `%s`", name));
|
||||||
}
|
}
|
||||||
map.insert(name, ());
|
map.insert(name, ());
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn fold_item(&test_ctxt cx, &@ast::item i,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_test_fn(&@ast::item i) -> bool {
|
fn is_test_fn(&@ast::item i) -> bool {
|
||||||
auto has_test_attr =
|
auto has_test_attr =
|
||||||
ivec::len(attr::find_attrs_by_name(i.attrs, "test")) > 0u;
|
ivec::len(attr::find_attrs_by_name(i.attrs, "test")) > 0u;
|
||||||
|
|
||||||
fn has_test_signature(&@ast::item i) -> bool {
|
fn has_test_signature(&@ast::item i) -> bool {
|
||||||
|
@ -173,7 +173,7 @@ fn mk_tests(&test_ctxt cx) -> @ast::item {
|
||||||
cf = ast::return,
|
cf = ast::return,
|
||||||
constraints = ~[]);
|
constraints = ~[]);
|
||||||
auto proto = ast::proto_fn;
|
auto proto = ast::proto_fn;
|
||||||
|
|
||||||
// The vector of test_descs for this crate
|
// The vector of test_descs for this crate
|
||||||
auto test_descs = mk_test_desc_vec(cx);
|
auto test_descs = mk_test_desc_vec(cx);
|
||||||
|
|
||||||
|
@ -352,7 +352,7 @@ fn mk_test_main_call(&test_ctxt cx) -> @ast::expr {
|
||||||
node = test_main_path_expr_,
|
node = test_main_path_expr_,
|
||||||
span = rec(lo=0u, hi=0u));
|
span = rec(lo=0u, hi=0u));
|
||||||
|
|
||||||
let ast::expr_ test_main_call_expr_
|
let ast::expr_ test_main_call_expr_
|
||||||
= ast::expr_call(@test_main_path_expr, ~[@args_path_expr,
|
= ast::expr_call(@test_main_path_expr, ~[@args_path_expr,
|
||||||
@test_call_expr]);
|
@test_call_expr]);
|
||||||
|
|
||||||
|
|
|
@ -889,7 +889,7 @@ native mod llvm = "rustllvm" {
|
||||||
* BuilderRef B into place. A BuilderRef is a cursor-like LLVM value that
|
* BuilderRef B into place. A BuilderRef is a cursor-like LLVM value that
|
||||||
* inserts instructions for a particular BasicBlockRef at a particular
|
* inserts instructions for a particular BasicBlockRef at a particular
|
||||||
* position; for our purposes, it always inserts at the end of the basic block
|
* position; for our purposes, it always inserts at the end of the basic block
|
||||||
* it's attached to.
|
* it's attached to.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// FIXME: Do we want to support mutable object fields?
|
// FIXME: Do we want to support mutable object fields?
|
||||||
|
@ -1524,9 +1524,9 @@ fn type_to_str_inner(type_names names, &TypeRef[] outer0, TypeRef ty) -> str {
|
||||||
ret s;
|
ret s;
|
||||||
}
|
}
|
||||||
|
|
||||||
case (10) {
|
case (10) {
|
||||||
auto el_ty = llvm::LLVMGetElementType(ty);
|
auto el_ty = llvm::LLVMGetElementType(ty);
|
||||||
ret "[" + type_to_str_inner(names, outer, el_ty) + "]";
|
ret "[" + type_to_str_inner(names, outer, el_ty) + "]";
|
||||||
}
|
}
|
||||||
|
|
||||||
case (11) {
|
case (11) {
|
||||||
|
|
|
@ -236,7 +236,7 @@ fn enc_constr(&io::writer w, &@ctxt cx, &@ty::constr_def c) {
|
||||||
if (semi) { w.write_char(';'); } else { semi = true; }
|
if (semi) { w.write_char(';'); } else { semi = true; }
|
||||||
alt (a.node) {
|
alt (a.node) {
|
||||||
case (carg_base) { w.write_char('*'); }
|
case (carg_base) { w.write_char('*'); }
|
||||||
case (carg_ident(?i)) {
|
case (carg_ident(?i)) {
|
||||||
w.write_uint(i);
|
w.write_uint(i);
|
||||||
}
|
}
|
||||||
case (carg_lit(?l)) { w.write_str(lit_to_str(l)); }
|
case (carg_lit(?l)) { w.write_str(lit_to_str(l)); }
|
||||||
|
|
|
@ -156,7 +156,7 @@ fn map_crate(&@env e, &@ast::crate c) {
|
||||||
with *visit::default_visitor[scopes]());
|
with *visit::default_visitor[scopes]());
|
||||||
visit::visit_crate(*c, cons(scope_crate, @nil),
|
visit::visit_crate(*c, cons(scope_crate, @nil),
|
||||||
visit::mk_vt(v_map_mod));
|
visit::mk_vt(v_map_mod));
|
||||||
// Register the top-level mod
|
// Register the top-level mod
|
||||||
|
|
||||||
e.mod_map.insert(-1,
|
e.mod_map.insert(-1,
|
||||||
@rec(m=some(c.node.module),
|
@rec(m=some(c.node.module),
|
||||||
|
@ -342,7 +342,7 @@ fn visit_fn_with_scope(&@env e, &ast::_fn f, &ast::ty_param[] tp, &span sp,
|
||||||
// for f's constrs in the table.
|
// for f's constrs in the table.
|
||||||
|
|
||||||
for (@ast::constr c in f.decl.constraints) {
|
for (@ast::constr c in f.decl.constraints) {
|
||||||
resolve_constr(e, id, c, sc, v);
|
resolve_constr(e, id, c, sc, v);
|
||||||
}
|
}
|
||||||
visit::visit_fn(f, tp, sp, name, id,
|
visit::visit_fn(f, tp, sp, name, id,
|
||||||
cons(scope_fn(f.decl, tp), @sc), v);
|
cons(scope_fn(f.decl, tp), @sc), v);
|
||||||
|
@ -1294,7 +1294,7 @@ fn check_arm(@env e, &ast::arm a, &() x, &vt[()] v) {
|
||||||
// Fight the alias checker
|
// Fight the alias checker
|
||||||
auto name_ = name;
|
auto name_ = name;
|
||||||
e.sess.span_err
|
e.sess.span_err
|
||||||
(a.pats.(i).span, "binding " + name_ +
|
(a.pats.(i).span, "binding " + name_ +
|
||||||
" does not occur in first pattern");
|
" does not occur in first pattern");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2726,7 +2726,7 @@ fn iter_structural_ty_full(&@block_ctxt cx, ValueRef av, ValueRef bv,
|
||||||
}
|
}
|
||||||
ret rslt(cx, C_nil());
|
ret rslt(cx, C_nil());
|
||||||
}
|
}
|
||||||
|
|
||||||
let result r = rslt(cx, C_nil());
|
let result r = rslt(cx, C_nil());
|
||||||
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
|
alt (ty::struct(cx.fcx.lcx.ccx.tcx, t)) {
|
||||||
case (ty::ty_tup(?args)) {
|
case (ty::ty_tup(?args)) {
|
||||||
|
@ -4481,7 +4481,7 @@ fn collect_upvars(&@block_ctxt cx, &ast::block bloc,
|
||||||
|
|
||||||
// Given a block context and a list of upvars, construct a closure that
|
// Given a block context and a list of upvars, construct a closure that
|
||||||
// contains pointers to all of the upvars and all of the tydescs in
|
// contains pointers to all of the upvars and all of the tydescs in
|
||||||
// scope. Return the ValueRef and TypeRef corresponding to the closure.
|
// scope. Return the ValueRef and TypeRef corresponding to the closure.
|
||||||
fn build_environment(&@block_ctxt cx, &ast::node_id[] upvars) ->
|
fn build_environment(&@block_ctxt cx, &ast::node_id[] upvars) ->
|
||||||
tup(ValueRef, TypeRef) {
|
tup(ValueRef, TypeRef) {
|
||||||
auto upvar_count = std::ivec::len(upvars);
|
auto upvar_count = std::ivec::len(upvars);
|
||||||
|
@ -5149,8 +5149,8 @@ fn trans_cast(&@block_ctxt cx, &@ast::expr e, ast::node_id id) -> result {
|
||||||
int_cast(e_res.bcx, lldsttype, llsrctype, e_res.val,
|
int_cast(e_res.bcx, lldsttype, llsrctype, e_res.val,
|
||||||
ty::type_is_signed(cx.fcx.lcx.ccx.tcx, t)));
|
ty::type_is_signed(cx.fcx.lcx.ccx.tcx, t)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx,
|
if (ty::type_is_integral(cx.fcx.lcx.ccx.tcx,
|
||||||
ty::expr_ty(cx.fcx.lcx.ccx.tcx, e))) {
|
ty::expr_ty(cx.fcx.lcx.ccx.tcx, e))) {
|
||||||
if (ty::type_is_signed(cx.fcx.lcx.ccx.tcx,
|
if (ty::type_is_signed(cx.fcx.lcx.ccx.tcx,
|
||||||
|
@ -5748,7 +5748,7 @@ fn trans_call(&@block_ctxt cx, &@ast::expr f, &option::t[ValueRef] lliterbody,
|
||||||
auto llretslot = args_res._2;
|
auto llretslot = args_res._2;
|
||||||
/*
|
/*
|
||||||
log "calling: " + val_str(cx.fcx.lcx.ccx.tn, faddr);
|
log "calling: " + val_str(cx.fcx.lcx.ccx.tn, faddr);
|
||||||
|
|
||||||
for (ValueRef arg in llargs) {
|
for (ValueRef arg in llargs) {
|
||||||
log "arg: " + val_str(cx.fcx.lcx.ccx.tn, arg);
|
log "arg: " + val_str(cx.fcx.lcx.ccx.tn, arg);
|
||||||
}
|
}
|
||||||
|
@ -6181,7 +6181,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
|
||||||
check the value of that variable, doing nothing
|
check the value of that variable, doing nothing
|
||||||
if it's set to false and acting like a check
|
if it's set to false and acting like a check
|
||||||
otherwise. */
|
otherwise. */
|
||||||
auto c = get_extern_const(cx.fcx.lcx.ccx.externs,
|
auto c = get_extern_const(cx.fcx.lcx.ccx.externs,
|
||||||
cx.fcx.lcx.ccx.llmod,
|
cx.fcx.lcx.ccx.llmod,
|
||||||
"check_claims", T_bool());
|
"check_claims", T_bool());
|
||||||
auto cond = cx.build.Load(c);
|
auto cond = cx.build.Load(c);
|
||||||
|
@ -6215,7 +6215,7 @@ fn trans_expr_out(&@block_ctxt cx, &@ast::expr e, out_method output) ->
|
||||||
}
|
}
|
||||||
case (_) {
|
case (_) {
|
||||||
// The expression is an lvalue. Fall through.
|
// The expression is an lvalue. Fall through.
|
||||||
assert (ty::is_lval(e)); // make sure it really is and that we
|
assert (ty::is_lval(e)); // make sure it really is and that we
|
||||||
// didn't forget to add a case for a new expr!
|
// didn't forget to add a case for a new expr!
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6396,7 +6396,7 @@ fn trans_fail_expr(&@block_ctxt cx, &option::t[span] sp_opt,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn trans_fail(&@block_ctxt cx, &option::t[span] sp_opt, &str fail_str)
|
fn trans_fail(&@block_ctxt cx, &option::t[span] sp_opt, &str fail_str)
|
||||||
-> result {
|
-> result {
|
||||||
auto V_fail_str = C_cstr(cx.fcx.lcx.ccx, fail_str);
|
auto V_fail_str = C_cstr(cx.fcx.lcx.ccx, fail_str);
|
||||||
|
@ -6607,7 +6607,7 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
|
||||||
// order, so that they match the expected stack layout for the spawnee)
|
// order, so that they match the expected stack layout for the spawnee)
|
||||||
//
|
//
|
||||||
// 3. Fill the tuple with the arguments we evaluated.
|
// 3. Fill the tuple with the arguments we evaluated.
|
||||||
//
|
//
|
||||||
// 3.5. Generate a wrapper function that takes the tuple and unpacks it to
|
// 3.5. Generate a wrapper function that takes the tuple and unpacks it to
|
||||||
// call the real task.
|
// call the real task.
|
||||||
//
|
//
|
||||||
|
@ -6648,12 +6648,12 @@ fn trans_spawn(&@block_ctxt cx, &ast::spawn_dom dom, &option::t[str] name,
|
||||||
auto llargs = alloc_ty(bcx, args_ty);
|
auto llargs = alloc_ty(bcx, args_ty);
|
||||||
auto i = 0u;
|
auto i = 0u;
|
||||||
for (ValueRef v in arg_vals) {
|
for (ValueRef v in arg_vals) {
|
||||||
// log_err #fmt("ty(llargs) = %s",
|
// log_err #fmt("ty(llargs) = %s",
|
||||||
// val_str(bcx.fcx.lcx.ccx.tn, llargs.val));
|
// val_str(bcx.fcx.lcx.ccx.tn, llargs.val));
|
||||||
|
|
||||||
auto target = bcx.build.GEP(llargs.val, ~[C_int(0), C_int(i as int)]);
|
auto target = bcx.build.GEP(llargs.val, ~[C_int(0), C_int(i as int)]);
|
||||||
// log_err #fmt("ty(v) = %s", val_str(bcx.fcx.lcx.ccx.tn, v));
|
// log_err #fmt("ty(v) = %s", val_str(bcx.fcx.lcx.ccx.tn, v));
|
||||||
// log_err #fmt("ty(target) = %s",
|
// log_err #fmt("ty(target) = %s",
|
||||||
// val_str(bcx.fcx.lcx.ccx.tn, target));
|
// val_str(bcx.fcx.lcx.ccx.tn, target));
|
||||||
|
|
||||||
bcx.build.Store(v, target);
|
bcx.build.Store(v, target);
|
||||||
|
@ -6728,8 +6728,8 @@ fn mk_spawn_wrapper(&@block_ctxt cx, &@ast::expr func, &ty::t args_ty) ->
|
||||||
// tasks, and for sending things through channels. There are probably some
|
// tasks, and for sending things through channels. There are probably some
|
||||||
// uniqueness optimizations and things we can do here for tasks in the same
|
// uniqueness optimizations and things we can do here for tasks in the same
|
||||||
// domain.
|
// domain.
|
||||||
fn deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t, ValueRef target_task)
|
fn deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t, ValueRef target_task)
|
||||||
-> result
|
-> result
|
||||||
{
|
{
|
||||||
// TODO: make sure all paths add any reference counting that they need to.
|
// TODO: make sure all paths add any reference counting that they need to.
|
||||||
|
|
||||||
|
@ -6747,17 +6747,17 @@ fn deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t, ValueRef target_task)
|
||||||
else if(ty::type_is_chan(tcx, t)) {
|
else if(ty::type_is_chan(tcx, t)) {
|
||||||
// If this is a channel, we need to clone it.
|
// If this is a channel, we need to clone it.
|
||||||
auto chan_ptr = bcx.build.PointerCast(v, T_opaque_chan_ptr());
|
auto chan_ptr = bcx.build.PointerCast(v, T_opaque_chan_ptr());
|
||||||
|
|
||||||
auto chan_raw_val =
|
auto chan_raw_val =
|
||||||
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.clone_chan,
|
bcx.build.Call(bcx.fcx.lcx.ccx.upcalls.clone_chan,
|
||||||
~[bcx.fcx.lltaskptr, target_task, chan_ptr]);
|
~[bcx.fcx.lltaskptr, target_task, chan_ptr]);
|
||||||
|
|
||||||
// Cast back to the type the context was expecting.
|
// Cast back to the type the context was expecting.
|
||||||
auto chan_val = bcx.build.PointerCast(chan_raw_val,
|
auto chan_val = bcx.build.PointerCast(chan_raw_val,
|
||||||
val_ty(v));
|
val_ty(v));
|
||||||
|
|
||||||
ret rslt(bcx, chan_val);
|
ret rslt(bcx, chan_val);
|
||||||
}
|
}
|
||||||
else if(ty::type_is_structural(tcx, t)) {
|
else if(ty::type_is_structural(tcx, t)) {
|
||||||
fn inner_deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t) -> result {
|
fn inner_deep_copy(&@block_ctxt bcx, ValueRef v, ty::t t) -> result {
|
||||||
log_err "Unimplemented type for deep_copy.";
|
log_err "Unimplemented type for deep_copy.";
|
||||||
|
@ -6865,7 +6865,7 @@ fn recv_val(&@block_ctxt cx, ValueRef to, &@ast::expr from, &ty::t unit_ty,
|
||||||
// function and putting it in the generated code as an object item, we are
|
// function and putting it in the generated code as an object item, we are
|
||||||
// instead "inlining" the construction of the object and returning the object
|
// instead "inlining" the construction of the object and returning the object
|
||||||
// itself.
|
// itself.
|
||||||
fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||||
&ast::ty_param[] ty_params, ast::node_id id) -> result {
|
&ast::ty_param[] ty_params, ast::node_id id) -> result {
|
||||||
|
|
||||||
// Right now, we're assuming that anon objs don't take ty params, even
|
// Right now, we're assuming that anon objs don't take ty params, even
|
||||||
|
@ -6903,12 +6903,12 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||||
|
|
||||||
// create_vtbl() wants an ast::_obj and all we have is an ast::anon_obj,
|
// create_vtbl() wants an ast::_obj and all we have is an ast::anon_obj,
|
||||||
// so we need to roll our own.
|
// so we need to roll our own.
|
||||||
fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
|
fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
|
||||||
-> ast::obj_field {
|
-> ast::obj_field {
|
||||||
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
|
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
|
||||||
}
|
}
|
||||||
let ast::_obj wrapper_obj = rec(
|
let ast::_obj wrapper_obj = rec(
|
||||||
fields = std::ivec::map(anon_obj_field_to_obj_field,
|
fields = std::ivec::map(anon_obj_field_to_obj_field,
|
||||||
additional_fields),
|
additional_fields),
|
||||||
methods = anon_obj.methods,
|
methods = anon_obj.methods,
|
||||||
dtor = none[@ast::method]);
|
dtor = none[@ast::method]);
|
||||||
|
@ -6916,7 +6916,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||||
let ty::t with_obj_ty;
|
let ty::t with_obj_ty;
|
||||||
auto vtbl;
|
auto vtbl;
|
||||||
alt (anon_obj.with_obj) {
|
alt (anon_obj.with_obj) {
|
||||||
case (none) {
|
case (none) {
|
||||||
// If there's no with_obj -- that is, if we're just adding new
|
// If there's no with_obj -- that is, if we're just adding new
|
||||||
// fields rather than extending an existing object -- then we just
|
// fields rather than extending an existing object -- then we just
|
||||||
// pass the outer object to create_vtbl(). Our vtable won't need
|
// pass the outer object to create_vtbl(). Our vtable won't need
|
||||||
|
@ -6949,16 +6949,16 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||||
// create a forwarding slot. And, of course, we need to create a
|
// create a forwarding slot. And, of course, we need to create a
|
||||||
// normal vtable entry for every method being added.
|
// normal vtable entry for every method being added.
|
||||||
vtbl = create_vtbl(bcx.fcx.lcx, sp, llouter_obj_ty, outer_obj_ty,
|
vtbl = create_vtbl(bcx.fcx.lcx, sp, llouter_obj_ty, outer_obj_ty,
|
||||||
wrapper_obj, ty_params,
|
wrapper_obj, ty_params,
|
||||||
some(with_obj_ty),
|
some(with_obj_ty),
|
||||||
additional_field_tys);
|
additional_field_tys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Allocate the object that we're going to return. It's a two-word pair
|
// Allocate the object that we're going to return. It's a two-word pair
|
||||||
// containing a vtable pointer and a body pointer.
|
// containing a vtable pointer and a body pointer.
|
||||||
auto pair =
|
auto pair =
|
||||||
alloca(bcx,
|
alloca(bcx,
|
||||||
T_struct(~[val_ty(vtbl),
|
T_struct(~[val_ty(vtbl),
|
||||||
T_obj_ptr(ccx.tn, std::ivec::len(ty_params))]));
|
T_obj_ptr(ccx.tn, std::ivec::len(ty_params))]));
|
||||||
|
|
||||||
|
@ -7003,7 +7003,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||||
// Synthesize a tuple type for typarams: [typaram, ...]
|
// Synthesize a tuple type for typarams: [typaram, ...]
|
||||||
let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
|
let ty::t typarams_ty = ty::mk_imm_tup(ccx.tcx, tps);
|
||||||
|
|
||||||
// Tuple type for body:
|
// Tuple type for body:
|
||||||
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
|
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
|
||||||
let ty::t body_ty =
|
let ty::t body_ty =
|
||||||
ty::mk_imm_tup(ccx.tcx, ~[tydesc_ty, typarams_ty,
|
ty::mk_imm_tup(ccx.tcx, ~[tydesc_ty, typarams_ty,
|
||||||
|
@ -7068,7 +7068,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||||
auto capture =
|
auto capture =
|
||||||
GEP_tup_like(bcx, typarams_ty, body_typarams.val, ~[0, i]);
|
GEP_tup_like(bcx, typarams_ty, body_typarams.val, ~[0, i]);
|
||||||
bcx = capture.bcx;
|
bcx = capture.bcx;
|
||||||
bcx = copy_val(bcx, INIT, capture.val, typaram,
|
bcx = copy_val(bcx, INIT, capture.val, typaram,
|
||||||
tydesc_ty).bcx;
|
tydesc_ty).bcx;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
@ -7091,7 +7091,7 @@ fn trans_anon_obj(@block_ctxt bcx, &span sp, &ast::anon_obj anon_obj,
|
||||||
GEP_tup_like(bcx, fields_ty, body_fields.val, ~[0, i]);
|
GEP_tup_like(bcx, fields_ty, body_fields.val, ~[0, i]);
|
||||||
bcx = field.bcx;
|
bcx = field.bcx;
|
||||||
bcx = copy_val(bcx, INIT, field.val,
|
bcx = copy_val(bcx, INIT, field.val,
|
||||||
additional_field_vals.(i).val,
|
additional_field_vals.(i).val,
|
||||||
additional_field_tys.(i)).bcx;
|
additional_field_tys.(i)).bcx;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
@ -7258,7 +7258,7 @@ fn new_raw_block_ctxt(&@fn_ctxt fcx, BasicBlockRef llbb) -> @block_ctxt {
|
||||||
|
|
||||||
|
|
||||||
// trans_block_cleanups: Go through all the cleanups attached to this
|
// trans_block_cleanups: Go through all the cleanups attached to this
|
||||||
// block_ctxt and execute them.
|
// block_ctxt and execute them.
|
||||||
//
|
//
|
||||||
// When translating a block that introdces new variables during its scope, we
|
// When translating a block that introdces new variables during its scope, we
|
||||||
// need to make sure those variables go out of scope when the block ends. We
|
// need to make sure those variables go out of scope when the block ends. We
|
||||||
|
@ -7685,7 +7685,7 @@ fn trans_fn(@local_ctxt cx, &span sp, &ast::_fn f, ValueRef llfndecl,
|
||||||
// Set up arguments to the function.
|
// Set up arguments to the function.
|
||||||
auto fcx = new_fn_ctxt(cx, sp, llfndecl);
|
auto fcx = new_fn_ctxt(cx, sp, llfndecl);
|
||||||
create_llargs_for_fn_args(fcx, f.proto, ty_self,
|
create_llargs_for_fn_args(fcx, f.proto, ty_self,
|
||||||
ty::ret_ty_of_fn(cx.ccx.tcx, id),
|
ty::ret_ty_of_fn(cx.ccx.tcx, id),
|
||||||
f.decl.inputs, ty_params);
|
f.decl.inputs, ty_params);
|
||||||
copy_any_self_to_alloca(fcx, ty_self);
|
copy_any_self_to_alloca(fcx, ty_self);
|
||||||
alt ({ fcx.llself }) {
|
alt ({ fcx.llself }) {
|
||||||
|
@ -7782,13 +7782,13 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||||
// method's return type, if necessary.
|
// method's return type, if necessary.
|
||||||
auto llretptr = fcx.llretptr;
|
auto llretptr = fcx.llretptr;
|
||||||
if (ty::type_has_dynamic_size(cx.ccx.tcx, m.output)) {
|
if (ty::type_has_dynamic_size(cx.ccx.tcx, m.output)) {
|
||||||
llretptr = bcx.build.PointerCast(llretptr,
|
llretptr = bcx.build.PointerCast(llretptr,
|
||||||
T_typaram_ptr(cx.ccx.tn));
|
T_typaram_ptr(cx.ccx.tn));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, we have to get the the with_obj's vtbl out of the self_obj. This
|
// Now, we have to get the the with_obj's vtbl out of the self_obj. This
|
||||||
// is a multi-step process:
|
// is a multi-step process:
|
||||||
|
|
||||||
// First, grab the box out of the self_obj. It contains a refcount and a
|
// First, grab the box out of the self_obj. It contains a refcount and a
|
||||||
// body.
|
// body.
|
||||||
auto llself_obj_box =
|
auto llself_obj_box =
|
||||||
|
@ -7821,7 +7821,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||||
// Synthesize a tuple type for typarams: [typaram, ...]
|
// Synthesize a tuple type for typarams: [typaram, ...]
|
||||||
let ty::t typarams_ty = ty::mk_imm_tup(cx.ccx.tcx, tps);
|
let ty::t typarams_ty = ty::mk_imm_tup(cx.ccx.tcx, tps);
|
||||||
|
|
||||||
// Tuple type for body:
|
// Tuple type for body:
|
||||||
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
|
// [tydesc_ty, [typaram, ...], [field, ...], with_obj]
|
||||||
let ty::t body_ty =
|
let ty::t body_ty =
|
||||||
ty::mk_imm_tup(cx.ccx.tcx, ~[tydesc_ty, typarams_ty,
|
ty::mk_imm_tup(cx.ccx.tcx, ~[tydesc_ty, typarams_ty,
|
||||||
|
@ -7864,7 +7864,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||||
|
|
||||||
// Pick out the original method from the vtable. The +1 is because slot
|
// Pick out the original method from the vtable. The +1 is because slot
|
||||||
// #0 contains the destructor.
|
// #0 contains the destructor.
|
||||||
auto llorig_mthd = bcx.build.GEP(llwith_obj_vtbl,
|
auto llorig_mthd = bcx.build.GEP(llwith_obj_vtbl,
|
||||||
~[C_int(0), C_int(ix + 1u as int)]);
|
~[C_int(0), C_int(ix + 1u as int)]);
|
||||||
|
|
||||||
// Set up the original method to be called.
|
// Set up the original method to be called.
|
||||||
|
@ -7876,7 +7876,7 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||||
m.inputs,
|
m.inputs,
|
||||||
m.output,
|
m.output,
|
||||||
std::ivec::len[ast::ty_param](ty_params));
|
std::ivec::len[ast::ty_param](ty_params));
|
||||||
llorig_mthd = bcx.build.PointerCast(llorig_mthd,
|
llorig_mthd = bcx.build.PointerCast(llorig_mthd,
|
||||||
T_ptr(T_ptr(llorig_mthd_ty)));
|
T_ptr(T_ptr(llorig_mthd_ty)));
|
||||||
llorig_mthd = bcx.build.Load(llorig_mthd);
|
llorig_mthd = bcx.build.Load(llorig_mthd);
|
||||||
|
|
||||||
|
@ -7886,13 +7886,13 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||||
|
|
||||||
// Copy the explicit arguments that are being passed into the forwarding
|
// Copy the explicit arguments that are being passed into the forwarding
|
||||||
// function (they're in fcx.llargs) to llorig_mthd_args.
|
// function (they're in fcx.llargs) to llorig_mthd_args.
|
||||||
|
|
||||||
let uint a = 3u; // retptr, task ptr, env come first
|
let uint a = 3u; // retptr, task ptr, env come first
|
||||||
let ValueRef passed_arg = llvm::LLVMGetParam(llforwarding_fn, a);
|
let ValueRef passed_arg = llvm::LLVMGetParam(llforwarding_fn, a);
|
||||||
for (ty::arg arg in m.inputs) {
|
for (ty::arg arg in m.inputs) {
|
||||||
if (arg.mode == ty::mo_val) {
|
if (arg.mode == ty::mo_val) {
|
||||||
passed_arg = load_if_immediate(bcx, passed_arg, arg.ty);
|
passed_arg = load_if_immediate(bcx, passed_arg, arg.ty);
|
||||||
}
|
}
|
||||||
llorig_mthd_args += ~[passed_arg];
|
llorig_mthd_args += ~[passed_arg];
|
||||||
a += 1u;
|
a += 1u;
|
||||||
}
|
}
|
||||||
|
@ -7908,8 +7908,8 @@ fn process_fwding_mthd(@local_ctxt cx, &span sp, @ty::method m,
|
||||||
|
|
||||||
// process_normal_mthd: Create the contents of a normal vtable slot. A helper
|
// process_normal_mthd: Create the contents of a normal vtable slot. A helper
|
||||||
// function for create_vtbl.
|
// function for create_vtbl.
|
||||||
fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
|
fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
|
||||||
ty::t self_ty, &ast::ty_param[] ty_params)
|
ty::t self_ty, &ast::ty_param[] ty_params)
|
||||||
-> ValueRef {
|
-> ValueRef {
|
||||||
|
|
||||||
auto llfnty = T_nil();
|
auto llfnty = T_nil();
|
||||||
|
@ -7917,7 +7917,7 @@ fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
|
||||||
case (ty::ty_fn(?proto, ?inputs, ?output, _, _)) {
|
case (ty::ty_fn(?proto, ?inputs, ?output, _, _)) {
|
||||||
llfnty =
|
llfnty =
|
||||||
type_of_fn_full(
|
type_of_fn_full(
|
||||||
cx.ccx, m.span, proto,
|
cx.ccx, m.span, proto,
|
||||||
some[TypeRef](llself_ty), inputs, output,
|
some[TypeRef](llself_ty), inputs, output,
|
||||||
std::ivec::len[ast::ty_param](ty_params));
|
std::ivec::len[ast::ty_param](ty_params));
|
||||||
}
|
}
|
||||||
|
@ -7927,14 +7927,14 @@ fn process_normal_mthd(@local_ctxt cx, @ast::method m, TypeRef llself_ty,
|
||||||
let str s = mangle_internal_name_by_path(mcx.ccx, mcx.path);
|
let str s = mangle_internal_name_by_path(mcx.ccx, mcx.path);
|
||||||
let ValueRef llfn =
|
let ValueRef llfn =
|
||||||
decl_internal_fastcall_fn(cx.ccx.llmod, s, llfnty);
|
decl_internal_fastcall_fn(cx.ccx.llmod, s, llfnty);
|
||||||
|
|
||||||
// Every method on an object gets its node_id inserted into the
|
// Every method on an object gets its node_id inserted into the
|
||||||
// crate-wide item_ids map, together with the ValueRef that points to
|
// crate-wide item_ids map, together with the ValueRef that points to
|
||||||
// where that method's definition will be in the executable.
|
// where that method's definition will be in the executable.
|
||||||
cx.ccx.item_ids.insert(m.node.id, llfn);
|
cx.ccx.item_ids.insert(m.node.id, llfn);
|
||||||
cx.ccx.item_symbols.insert(m.node.id, s);
|
cx.ccx.item_symbols.insert(m.node.id, s);
|
||||||
trans_fn(mcx, m.span, m.node.meth, llfn,
|
trans_fn(mcx, m.span, m.node.meth, llfn,
|
||||||
some[ty_self_pair](tup(llself_ty, self_ty)),
|
some[ty_self_pair](tup(llself_ty, self_ty)),
|
||||||
ty_params, m.node.id);
|
ty_params, m.node.id);
|
||||||
|
|
||||||
ret llfn;
|
ret llfn;
|
||||||
|
@ -7996,7 +7996,7 @@ fn create_vtbl(@local_ctxt cx, &span sp, TypeRef llself_ty, ty::t self_ty,
|
||||||
case (ty::ty_obj(?with_obj_methods)) {
|
case (ty::ty_obj(?with_obj_methods)) {
|
||||||
for (ty::method m in with_obj_methods) {
|
for (ty::method m in with_obj_methods) {
|
||||||
meths += ~[fwding_mthd(@m)];
|
meths += ~[fwding_mthd(@m)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case (_) {
|
case (_) {
|
||||||
// Shouldn't happen.
|
// Shouldn't happen.
|
||||||
|
@ -8008,7 +8008,7 @@ fn create_vtbl(@local_ctxt cx, &span sp, TypeRef llself_ty, ty::t self_ty,
|
||||||
// Now, filter out any methods that we don't need forwarding slots
|
// Now, filter out any methods that we don't need forwarding slots
|
||||||
// for, because they're being replaced.
|
// for, because they're being replaced.
|
||||||
fn filtering_fn(@local_ctxt cx, &vtbl_mthd m,
|
fn filtering_fn(@local_ctxt cx, &vtbl_mthd m,
|
||||||
(@ast::method)[] addtl_meths)
|
(@ast::method)[] addtl_meths)
|
||||||
-> option::t[vtbl_mthd] {
|
-> option::t[vtbl_mthd] {
|
||||||
|
|
||||||
alt (m) {
|
alt (m) {
|
||||||
|
@ -8040,15 +8040,15 @@ fn create_vtbl(@local_ctxt cx, &span sp, TypeRef llself_ty, ty::t self_ty,
|
||||||
}
|
}
|
||||||
auto f = bind filtering_fn(cx, _, ob.methods);
|
auto f = bind filtering_fn(cx, _, ob.methods);
|
||||||
meths = std::ivec::filter_map[vtbl_mthd, vtbl_mthd](f, meths);
|
meths = std::ivec::filter_map[vtbl_mthd, vtbl_mthd](f, meths);
|
||||||
|
|
||||||
// And now add the additional ones (both replacements and entirely
|
// And now add the additional ones (both replacements and entirely
|
||||||
// new ones). These'll just be normal methods.
|
// new ones). These'll just be normal methods.
|
||||||
for (@ast::method m in ob.methods) {
|
for (@ast::method m in ob.methods) {
|
||||||
meths += ~[normal_mthd(m)];
|
meths += ~[normal_mthd(m)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sort all the methods.
|
// Sort all the methods.
|
||||||
fn vtbl_mthd_lteq(&vtbl_mthd a, &vtbl_mthd b) -> bool {
|
fn vtbl_mthd_lteq(&vtbl_mthd a, &vtbl_mthd b) -> bool {
|
||||||
alt (a) {
|
alt (a) {
|
||||||
|
@ -8107,7 +8107,7 @@ fn create_vtbl(@local_ctxt cx, &span sp, TypeRef llself_ty, ty::t self_ty,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto vtbl = C_struct(llmethods);
|
auto vtbl = C_struct(llmethods);
|
||||||
auto vtbl_name = mangle_internal_name_by_path(cx.ccx,
|
auto vtbl_name = mangle_internal_name_by_path(cx.ccx,
|
||||||
cx.path + ~["vtbl"]);
|
cx.path + ~["vtbl"]);
|
||||||
|
@ -8197,7 +8197,7 @@ fn trans_obj(@local_ctxt cx, &span sp, &ast::_obj ob, ast::node_id ctor_id,
|
||||||
// It will be located in the read-only memory of the executable we're
|
// It will be located in the read-only memory of the executable we're
|
||||||
// creating and will contain ValueRefs for all of this object's methods.
|
// creating and will contain ValueRefs for all of this object's methods.
|
||||||
// create_vtbl returns a pointer to the vtable, which we store.
|
// create_vtbl returns a pointer to the vtable, which we store.
|
||||||
auto vtbl = create_vtbl(cx, sp, llself_ty, self_ty, ob, ty_params, none,
|
auto vtbl = create_vtbl(cx, sp, llself_ty, self_ty, ob, ty_params, none,
|
||||||
~[]);
|
~[]);
|
||||||
|
|
||||||
bcx.build.Store(vtbl, pair_vtbl);
|
bcx.build.Store(vtbl, pair_vtbl);
|
||||||
|
@ -8344,7 +8344,7 @@ fn trans_res_ctor(@local_ctxt cx, &span sp, &ast::_fn dtor,
|
||||||
auto llctor_decl;
|
auto llctor_decl;
|
||||||
alt (cx.ccx.item_ids.find(ctor_id)) {
|
alt (cx.ccx.item_ids.find(ctor_id)) {
|
||||||
case (some(?x)) { llctor_decl = x; }
|
case (some(?x)) { llctor_decl = x; }
|
||||||
case (_) {
|
case (_) {
|
||||||
cx.ccx.sess.span_fatal(sp, "unbound ctor_id in trans_res_ctor");
|
cx.ccx.sess.span_fatal(sp, "unbound ctor_id in trans_res_ctor");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -180,7 +180,7 @@ fn get_options(&@crate_ctxt ccx, &match m, uint col) -> opt[] {
|
||||||
for (match_branch br in m) {
|
for (match_branch br in m) {
|
||||||
alt (br.pats.(col).node) {
|
alt (br.pats.(col).node) {
|
||||||
ast::pat_lit(?l) { add_to_set(found, lit(l)); }
|
ast::pat_lit(?l) { add_to_set(found, lit(l)); }
|
||||||
ast::pat_tag(_, _) {
|
ast::pat_tag(_, _) {
|
||||||
add_to_set(found, variant_opt(ccx, br.pats.(col).id));
|
add_to_set(found, variant_opt(ccx, br.pats.(col).id));
|
||||||
}
|
}
|
||||||
_ {}
|
_ {}
|
||||||
|
@ -323,7 +323,7 @@ fn compile_submatch(@block_ctxt bcx, &match m, ValueRef[] vals, &mk_fail f,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lit(?l) {
|
lit(?l) {
|
||||||
test_val = bcx.build.Load(val);
|
test_val = bcx.build.Load(val);
|
||||||
kind = alt (l.node) {
|
kind = alt (l.node) {
|
||||||
ast::lit_str(_, _) { compare }
|
ast::lit_str(_, _) { compare }
|
||||||
_ { switch }
|
_ { switch }
|
||||||
|
@ -386,7 +386,7 @@ fn make_phi_bindings(&@block_ctxt bcx, &exit_node[] map,
|
||||||
}
|
}
|
||||||
fail;
|
fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto our_block = bcx.llbb as uint;
|
auto our_block = bcx.llbb as uint;
|
||||||
for each (@tup(ast::ident, ast::node_id) item in ids.items()) {
|
for each (@tup(ast::ident, ast::node_id) item in ids.items()) {
|
||||||
auto llbbs = ~[];
|
auto llbbs = ~[];
|
||||||
|
|
|
@ -3,7 +3,7 @@ import tritv::*;
|
||||||
|
|
||||||
type precond = t;
|
type precond = t;
|
||||||
|
|
||||||
/* 2 means "this constraint may or may not be true after execution"
|
/* 2 means "this constraint may or may not be true after execution"
|
||||||
1 means "this constraint is definitely true after execution"
|
1 means "this constraint is definitely true after execution"
|
||||||
0 means "this constraint is definitely false after execution" */
|
0 means "this constraint is definitely false after execution" */
|
||||||
type postcond = t;
|
type postcond = t;
|
||||||
|
@ -23,7 +23,7 @@ type poststate = t;
|
||||||
0 means "don't know whether this variable is
|
0 means "don't know whether this variable is
|
||||||
initialized" */
|
initialized" */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This says: this expression requires the constraints whose value is 1 in
|
This says: this expression requires the constraints whose value is 1 in
|
||||||
<pre> to be true, and given the precondition, it guarantees that the
|
<pre> to be true, and given the precondition, it guarantees that the
|
||||||
constraints in <post> whose values are 1 are true, and that the constraints
|
constraints in <post> whose values are 1 are true, and that the constraints
|
||||||
|
|
|
@ -93,7 +93,7 @@ fn tritv_to_str(fn_ctxt fcx, &tritv::t v) -> str {
|
||||||
case (?t) {
|
case (?t) {
|
||||||
s +=
|
s +=
|
||||||
if (comma) { ", " } else { comma = true; "" } +
|
if (comma) { ", " } else { comma = true; "" } +
|
||||||
if (t == tfalse) { "!" } else { "" } +
|
if (t == tfalse) { "!" } else { "" } +
|
||||||
constraint_to_str(fcx.ccx.tcx, p.c);
|
constraint_to_str(fcx.ccx.tcx, p.c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ fn log_tritv_err(fn_ctxt fcx, tritv::t v) { log_err tritv_to_str(fcx, v); }
|
||||||
|
|
||||||
fn tos(&uint[] v) -> str {
|
fn tos(&uint[] v) -> str {
|
||||||
auto rslt = "";
|
auto rslt = "";
|
||||||
for (uint i in v) { if (i == 0u) { rslt += "0"; }
|
for (uint i in v) { if (i == 0u) { rslt += "0"; }
|
||||||
else if (i == 1u) { rslt += "1"; }
|
else if (i == 1u) { rslt += "1"; }
|
||||||
else { rslt += "?"; } }
|
else { rslt += "?"; } }
|
||||||
ret rslt;
|
ret rslt;
|
||||||
|
@ -190,7 +190,7 @@ once.
|
||||||
norm_constraint, in contrast, gets used when handling an instance
|
norm_constraint, in contrast, gets used when handling an instance
|
||||||
of a constraint rather than a definition of a constraint. It can
|
of a constraint rather than a definition of a constraint. It can
|
||||||
also be init or pred (ninit or npred), but the npred case just has
|
also be init or pred (ninit or npred), but the npred case just has
|
||||||
a single argument list.
|
a single argument list.
|
||||||
|
|
||||||
The representation of constraints, where multiple instances of the
|
The representation of constraints, where multiple instances of the
|
||||||
same predicate are collapsed into one entry in the table, makes it
|
same predicate are collapsed into one entry in the table, makes it
|
||||||
|
@ -209,7 +209,7 @@ type pred_desc_ = rec((@constr_arg_use)[] args, uint bit_num);
|
||||||
type pred_desc = spanned[pred_desc_];
|
type pred_desc = spanned[pred_desc_];
|
||||||
|
|
||||||
// FIXME: Should be node_id, since we can only talk
|
// FIXME: Should be node_id, since we can only talk
|
||||||
// about locals.
|
// about locals.
|
||||||
type constr_arg_use = constr_arg_general[tup(ident, def_id)];
|
type constr_arg_use = constr_arg_general[tup(ident, def_id)];
|
||||||
|
|
||||||
tag constraint {
|
tag constraint {
|
||||||
|
@ -559,7 +559,7 @@ fn expr_to_constr_arg(ty::ctxt tcx, &@expr e) -> @constr_arg_use {
|
||||||
case (_) {
|
case (_) {
|
||||||
tcx.sess.bug("exprs_to_constr_args: non-local variable " +
|
tcx.sess.bug("exprs_to_constr_args: non-local variable " +
|
||||||
"as pred arg");
|
"as pred arg");
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -694,7 +694,7 @@ type subst = tup(inst, inst)[];
|
||||||
|
|
||||||
fn find_instances(&fn_ctxt fcx, &subst subst, &constraint c)
|
fn find_instances(&fn_ctxt fcx, &subst subst, &constraint c)
|
||||||
-> (tup(uint, uint))[] {
|
-> (tup(uint, uint))[] {
|
||||||
|
|
||||||
let (tup(uint, uint))[] rslt = ~[];
|
let (tup(uint, uint))[] rslt = ~[];
|
||||||
if (ivec::len(subst) == 0u) {
|
if (ivec::len(subst) == 0u) {
|
||||||
ret rslt;
|
ret rslt;
|
||||||
|
@ -765,7 +765,7 @@ fn replace(subst subst, pred_desc d) -> (constr_arg_general_[inst])[] {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for (constr_arg_general_[tup(ident, def_id)] p in rslt) {
|
for (constr_arg_general_[tup(ident, def_id)] p in rslt) {
|
||||||
alt (p) {
|
alt (p) {
|
||||||
|
@ -787,12 +787,12 @@ fn path_to_ident(&ty::ctxt cx, &path p) -> ident {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tag if_ty {
|
tag if_ty {
|
||||||
if_check;
|
if_check;
|
||||||
plain_if;
|
plain_if;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn local_node_id_to_def_id_strict(&fn_ctxt fcx, &span sp, &node_id i)
|
fn local_node_id_to_def_id_strict(&fn_ctxt fcx, &span sp, &node_id i)
|
||||||
-> def_id {
|
-> def_id {
|
||||||
alt (local_node_id_to_def(fcx, i)) {
|
alt (local_node_id_to_def(fcx, i)) {
|
||||||
case (some(def_local(?d_id))) {
|
case (some(def_local(?d_id))) {
|
||||||
|
@ -819,7 +819,7 @@ fn local_node_id_to_def(&fn_ctxt fcx, &node_id i) -> option::t[def]
|
||||||
fn local_node_id_to_def_id(&fn_ctxt fcx, &node_id i) -> option::t[def_id] {
|
fn local_node_id_to_def_id(&fn_ctxt fcx, &node_id i) -> option::t[def_id] {
|
||||||
alt (local_node_id_to_def(fcx, i)) {
|
alt (local_node_id_to_def(fcx, i)) {
|
||||||
case (some(def_local(?d_id))) { some(d_id) }
|
case (some(def_local(?d_id))) { some(d_id) }
|
||||||
case (some (def_arg(?a_id))) { some(a_id) }
|
case (some (def_arg(?a_id))) { some(a_id) }
|
||||||
case (_) { none }
|
case (_) { none }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -865,7 +865,7 @@ fn copy_in_poststate_two(&fn_ctxt fcx, &poststate src_post,
|
||||||
// dest def_id
|
// dest def_id
|
||||||
auto instances = find_instances(fcx, subst, p._1);
|
auto instances = find_instances(fcx, subst, p._1);
|
||||||
|
|
||||||
for (tup(uint,uint) p in instances) {
|
for (tup(uint,uint) p in instances) {
|
||||||
if (promises_(p._0, src_post)) {
|
if (promises_(p._0, src_post)) {
|
||||||
set_in_poststate_(p._1, target_post);
|
set_in_poststate_(p._1, target_post);
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ fn seq_preconds(&fn_ctxt fcx, &pre_and_post[] pps) -> precond {
|
||||||
auto next_first = clone(first.precondition);
|
auto next_first = clone(first.precondition);
|
||||||
union(next_first, second_pre);
|
union(next_first, second_pre);
|
||||||
auto next_first_post = clone(first.postcondition);
|
auto next_first_post = clone(first.postcondition);
|
||||||
seq_tritv(next_first_post, second.postcondition);
|
seq_tritv(next_first_post, second.postcondition);
|
||||||
ret seq_preconds_go(fcx, ivec::slice(pps, 1u, sz),
|
ret seq_preconds_go(fcx, ivec::slice(pps, 1u, sz),
|
||||||
@rec(precondition=next_first,
|
@rec(precondition=next_first,
|
||||||
postcondition=next_first_post));
|
postcondition=next_first_post));
|
||||||
|
@ -189,7 +189,7 @@ fn relax_precond_stmt(&fn_ctxt fcx, node_id i, &@stmt s) {
|
||||||
fn relax_precond_block(&fn_ctxt fcx, node_id i, &block b) {
|
fn relax_precond_block(&fn_ctxt fcx, node_id i, &block b) {
|
||||||
relax_precond_block_non_recursive(fcx, i, b);
|
relax_precond_block_non_recursive(fcx, i, b);
|
||||||
// FIXME: should use visit instead
|
// FIXME: should use visit instead
|
||||||
// could at least generalize this pattern
|
// could at least generalize this pattern
|
||||||
// (also seen in ck::check_states_against_conditions)
|
// (also seen in ck::check_states_against_conditions)
|
||||||
let @mutable bool keepgoing = @mutable true;
|
let @mutable bool keepgoing = @mutable true;
|
||||||
|
|
||||||
|
@ -238,7 +238,7 @@ fn clear_in_poststate_expr(&fn_ctxt fcx, &@expr e, &poststate t) {
|
||||||
c=ninit(i))), t);
|
c=ninit(i))), t);
|
||||||
}
|
}
|
||||||
case (some(_)) { /* ignore args (for now...) */ }
|
case (some(_)) { /* ignore args (for now...) */ }
|
||||||
case (_) {
|
case (_) {
|
||||||
fcx.ccx.tcx.sess.bug("clear_in_poststate_expr: \
|
fcx.ccx.tcx.sess.bug("clear_in_poststate_expr: \
|
||||||
unbound var"); }
|
unbound var"); }
|
||||||
}
|
}
|
||||||
|
|
|
@ -187,7 +187,7 @@ fn fn_states(&_fn f, &ast::ty_param[] tps,
|
||||||
&visit::vt[crate_ctxt] v) {
|
&visit::vt[crate_ctxt] v) {
|
||||||
visit::visit_fn(f, tps, sp, i, id, ccx, v);
|
visit::visit_fn(f, tps, sp, i, id, ccx, v);
|
||||||
/* Look up the var-to-bit-num map for this function */
|
/* Look up the var-to-bit-num map for this function */
|
||||||
|
|
||||||
assert (ccx.fm.contains_key(id));
|
assert (ccx.fm.contains_key(id));
|
||||||
auto f_info = ccx.fm.get(id);
|
auto f_info = ccx.fm.get(id);
|
||||||
auto name = option::from_maybe("anon", i);
|
auto name = option::from_maybe("anon", i);
|
||||||
|
|
|
@ -47,7 +47,7 @@ fn collect_pred(&@expr e, &ctxt cx, &visit::vt[ctxt] v) {
|
||||||
// visit subexpressions
|
// visit subexpressions
|
||||||
visit::visit_expr(e, cx, v);
|
visit::visit_expr(e, cx, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_locals(&ty::ctxt tcx, &_fn f, &ty_param[] tps, &span sp, &fn_ident i,
|
fn find_locals(&ty::ctxt tcx, &_fn f, &ty_param[] tps, &span sp, &fn_ident i,
|
||||||
node_id id) -> ctxt {
|
node_id id) -> ctxt {
|
||||||
let ctxt cx = rec(cs=@mutable ~[], tcx=tcx);
|
let ctxt cx = rec(cs=@mutable ~[], tcx=tcx);
|
||||||
|
|
|
@ -112,7 +112,7 @@ fn find_pre_post_item(&crate_ctxt ccx, &item i) {
|
||||||
|
|
||||||
/* Finds the pre and postcondition for each expr in <args>;
|
/* Finds the pre and postcondition for each expr in <args>;
|
||||||
sets the precondition in a to be the result of combining
|
sets the precondition in a to be the result of combining
|
||||||
the preconditions for <args>, and the postcondition in a to
|
the preconditions for <args>, and the postcondition in a to
|
||||||
be the union of all postconditions for <args> */
|
be the union of all postconditions for <args> */
|
||||||
fn find_pre_post_exprs(&fn_ctxt fcx, &(@expr)[] args, node_id id) {
|
fn find_pre_post_exprs(&fn_ctxt fcx, &(@expr)[] args, node_id id) {
|
||||||
if (ivec::len[@expr](args) > 0u) {
|
if (ivec::len[@expr](args) > 0u) {
|
||||||
|
@ -137,7 +137,7 @@ fn find_pre_post_loop(&fn_ctxt fcx, &@local l, &@expr index, &block body,
|
||||||
find_pre_post_block(fcx, body);
|
find_pre_post_block(fcx, body);
|
||||||
auto v_init = rec(id=l.node.id, c=ninit(l.node.ident));
|
auto v_init = rec(id=l.node.id, c=ninit(l.node.ident));
|
||||||
relax_precond_block(fcx, bit_num(fcx, v_init) as node_id, body);
|
relax_precond_block(fcx, bit_num(fcx, v_init) as node_id, body);
|
||||||
|
|
||||||
// Hack: for-loop index variables are frequently ignored,
|
// Hack: for-loop index variables are frequently ignored,
|
||||||
// so we pretend they're used
|
// so we pretend they're used
|
||||||
use_var(fcx, l.node.id);
|
use_var(fcx, l.node.id);
|
||||||
|
@ -149,7 +149,7 @@ fn find_pre_post_loop(&fn_ctxt fcx, &@local l, &@expr index, &block body,
|
||||||
copy_pre_post_(fcx.ccx, id, loop_precond, loop_postcond);
|
copy_pre_post_(fcx.ccx, id, loop_precond, loop_postcond);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generates a pre/post assuming that a is the
|
// Generates a pre/post assuming that a is the
|
||||||
// annotation for an if-expression with consequent conseq
|
// annotation for an if-expression with consequent conseq
|
||||||
// and alternative maybe_alt
|
// and alternative maybe_alt
|
||||||
fn join_then_else(&fn_ctxt fcx, &@expr antec, &block conseq,
|
fn join_then_else(&fn_ctxt fcx, &@expr antec, &block conseq,
|
||||||
|
@ -236,7 +236,7 @@ fn handle_update(&fn_ctxt fcx, &@expr parent,
|
||||||
case (expr_path(?p)) {
|
case (expr_path(?p)) {
|
||||||
auto post = expr_postcond(fcx.ccx, parent);
|
auto post = expr_postcond(fcx.ccx, parent);
|
||||||
auto tmp = tritv_clone(post);
|
auto tmp = tritv_clone(post);
|
||||||
|
|
||||||
alt (ty) {
|
alt (ty) {
|
||||||
case (oper_move) {
|
case (oper_move) {
|
||||||
if (is_path(rhs)) {
|
if (is_path(rhs)) {
|
||||||
|
@ -255,7 +255,7 @@ fn handle_update(&fn_ctxt fcx, &@expr parent,
|
||||||
auto df = node_id_to_def_strict(fcx.ccx.tcx, lhs.id);
|
auto df = node_id_to_def_strict(fcx.ccx.tcx, lhs.id);
|
||||||
alt (df) {
|
alt (df) {
|
||||||
case (def_local(?d_id)) {
|
case (def_local(?d_id)) {
|
||||||
auto i =
|
auto i =
|
||||||
bit_num(fcx,
|
bit_num(fcx,
|
||||||
rec(id=d_id._1,
|
rec(id=d_id._1,
|
||||||
c=ninit(path_to_ident(fcx.ccx.tcx, p))));
|
c=ninit(path_to_ident(fcx.ccx.tcx, p))));
|
||||||
|
@ -293,7 +293,7 @@ fn handle_update(&fn_ctxt fcx, &@expr parent,
|
||||||
case (_) { /* do nothing */ }
|
case (_) { /* do nothing */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case (_) {
|
case (_) {
|
||||||
find_pre_post_expr(fcx, lhs);
|
find_pre_post_expr(fcx, lhs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -597,7 +597,7 @@ fn find_pre_post_stmt(&fn_ctxt fcx, &stmt s) {
|
||||||
whether or not this is a move */
|
whether or not this is a move */
|
||||||
|
|
||||||
find_pre_post_expr(fcx, an_init.expr);
|
find_pre_post_expr(fcx, an_init.expr);
|
||||||
copy_pre_post(fcx.ccx, alocal.node.id,
|
copy_pre_post(fcx.ccx, alocal.node.id,
|
||||||
an_init.expr);
|
an_init.expr);
|
||||||
/* Inherit ann from initializer, and add var being
|
/* Inherit ann from initializer, and add var being
|
||||||
initialized to the postcondition */
|
initialized to the postcondition */
|
||||||
|
@ -617,7 +617,7 @@ fn find_pre_post_stmt(&fn_ctxt fcx, &stmt s) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gen(fcx, id,
|
gen(fcx, id,
|
||||||
rec(id=alocal.node.id,
|
rec(id=alocal.node.id,
|
||||||
c=ninit(alocal.node.ident)));
|
c=ninit(alocal.node.ident)));
|
||||||
|
|
||||||
if (an_init.op == init_move &&
|
if (an_init.op == init_move &&
|
||||||
|
@ -650,7 +650,7 @@ fn find_pre_post_stmt(&fn_ctxt fcx, &stmt s) {
|
||||||
fn find_pre_post_block(&fn_ctxt fcx, block b) {
|
fn find_pre_post_block(&fn_ctxt fcx, block b) {
|
||||||
/* Want to say that if there is a break or cont in this
|
/* Want to say that if there is a break or cont in this
|
||||||
block, then that invalidates the poststate upheld by
|
block, then that invalidates the poststate upheld by
|
||||||
any of the stmts after it.
|
any of the stmts after it.
|
||||||
Given that the typechecker has run, we know any break will be in
|
Given that the typechecker has run, we know any break will be in
|
||||||
a block that forms a loop body. So that's ok. There'll never be an
|
a block that forms a loop body. So that's ok. There'll never be an
|
||||||
expr_break outside a loop body, therefore, no expr_break outside a block.
|
expr_break outside a loop body, therefore, no expr_break outside a block.
|
||||||
|
@ -661,7 +661,7 @@ fn find_pre_post_block(&fn_ctxt fcx, block b) {
|
||||||
This will mean that:
|
This will mean that:
|
||||||
x = 0;
|
x = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
won't have a postcondition that says x is initialized, but that's ok.
|
won't have a postcondition that says x is initialized, but that's ok.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
@ -98,7 +98,7 @@ fn find_pre_post_state_two(&fn_ctxt fcx, &prestate pres, &@expr lhs,
|
||||||
// tmp remembers "old" constraints we'd otherwise forget,
|
// tmp remembers "old" constraints we'd otherwise forget,
|
||||||
// for substitution purposes
|
// for substitution purposes
|
||||||
auto tmp = tritv_clone(post);
|
auto tmp = tritv_clone(post);
|
||||||
|
|
||||||
alt (ty) {
|
alt (ty) {
|
||||||
case (oper_move) {
|
case (oper_move) {
|
||||||
if (is_path(rhs)) {
|
if (is_path(rhs)) {
|
||||||
|
@ -166,7 +166,7 @@ fn find_pre_post_state_exprs(&fn_ctxt fcx, &prestate pres, node_id id,
|
||||||
changed |= set_poststate_ann
|
changed |= set_poststate_ann
|
||||||
(fcx.ccx, id, false_postcond(num_constraints(fcx.enclosing)));
|
(fcx.ccx, id, false_postcond(num_constraints(fcx.enclosing)));
|
||||||
}
|
}
|
||||||
case (_) {
|
case (_) {
|
||||||
changed |= set_poststate_ann(fcx.ccx, id, rs._1);
|
changed |= set_poststate_ann(fcx.ccx, id, rs._1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -188,7 +188,7 @@ fn find_pre_post_state_loop(&fn_ctxt fcx, prestate pres, &@local l,
|
||||||
|
|
||||||
changed |= find_pre_post_state_block(fcx, index_post, body);
|
changed |= find_pre_post_state_block(fcx, index_post, body);
|
||||||
|
|
||||||
if (has_nonlocal_exits(body)) {
|
if (has_nonlocal_exits(body)) {
|
||||||
// See [Break-unsound]
|
// See [Break-unsound]
|
||||||
ret (changed | set_poststate_ann(fcx.ccx, id, pres));
|
ret (changed | set_poststate_ann(fcx.ccx, id, pres));
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ fn find_pre_post_state_loop(&fn_ctxt fcx, prestate pres, &@local l,
|
||||||
|
|
||||||
fn gen_if_local(&fn_ctxt fcx, &poststate p, &@expr e) -> bool {
|
fn gen_if_local(&fn_ctxt fcx, &poststate p, &@expr e) -> bool {
|
||||||
alt (e.node) {
|
alt (e.node) {
|
||||||
case (expr_path(?pth)) {
|
case (expr_path(?pth)) {
|
||||||
alt (node_id_to_def(fcx.ccx, e.id)) {
|
alt (node_id_to_def(fcx.ccx, e.id)) {
|
||||||
case (some(def_local(?loc))) {
|
case (some(def_local(?loc))) {
|
||||||
ret set_in_poststate_ident(fcx, loc._1,
|
ret set_in_poststate_ident(fcx, loc._1,
|
||||||
|
@ -219,7 +219,7 @@ fn join_then_else(&fn_ctxt fcx, &@expr antec, &block conseq,
|
||||||
&prestate pres) -> bool {
|
&prestate pres) -> bool {
|
||||||
auto changed = set_prestate_ann(fcx.ccx, id, pres) |
|
auto changed = set_prestate_ann(fcx.ccx, id, pres) |
|
||||||
find_pre_post_state_expr(fcx, pres, antec);
|
find_pre_post_state_expr(fcx, pres, antec);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
log_err("join_then_else:");
|
log_err("join_then_else:");
|
||||||
log_expr_err(*antec);
|
log_expr_err(*antec);
|
||||||
|
@ -259,7 +259,7 @@ fn join_then_else(&fn_ctxt fcx, &@expr antec, &block conseq,
|
||||||
|
|
||||||
changed |=
|
changed |=
|
||||||
find_pre_post_state_block(fcx, conseq_prestate, conseq);
|
find_pre_post_state_block(fcx, conseq_prestate, conseq);
|
||||||
|
|
||||||
auto poststate_res =
|
auto poststate_res =
|
||||||
intersect_states(block_poststate(fcx.ccx, conseq),
|
intersect_states(block_poststate(fcx.ccx, conseq),
|
||||||
expr_poststate(fcx.ccx, altern));
|
expr_poststate(fcx.ccx, altern));
|
||||||
|
@ -271,7 +271,7 @@ fn join_then_else(&fn_ctxt fcx, &@expr antec, &block conseq,
|
||||||
aux::tritv_to_str(fcx, expr_poststate(fcx.ccx, altern)));
|
aux::tritv_to_str(fcx, expr_poststate(fcx.ccx, altern)));
|
||||||
fcx.ccx.tcx.sess.span_note(antec.span,
|
fcx.ccx.tcx.sess.span_note(antec.span,
|
||||||
"conseq poststate = " + aux::tritv_to_str(fcx,
|
"conseq poststate = " + aux::tritv_to_str(fcx,
|
||||||
block_poststate(fcx.ccx, conseq)));
|
block_poststate(fcx.ccx, conseq)));
|
||||||
*/
|
*/
|
||||||
|
|
||||||
changed |= set_poststate_ann(fcx.ccx, id, poststate_res);
|
changed |= set_poststate_ann(fcx.ccx, id, poststate_res);
|
||||||
|
@ -373,7 +373,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
|
||||||
(fcx, expr_poststate(fcx.ccx, lhs), rhs);
|
(fcx, expr_poststate(fcx.ccx, lhs), rhs);
|
||||||
auto post = tritv_clone(expr_poststate(fcx.ccx, rhs));
|
auto post = tritv_clone(expr_poststate(fcx.ccx, rhs));
|
||||||
forget_in_poststate_still_init(fcx, post, rhs.id);
|
forget_in_poststate_still_init(fcx, post, rhs.id);
|
||||||
gen_if_local(fcx, post, rhs);
|
gen_if_local(fcx, post, rhs);
|
||||||
ret changed | set_poststate_ann(fcx.ccx, e.id, post);
|
ret changed | set_poststate_ann(fcx.ccx, e.id, post);
|
||||||
}
|
}
|
||||||
case (expr_ret(?maybe_ret_val)) {
|
case (expr_ret(?maybe_ret_val)) {
|
||||||
|
@ -452,7 +452,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
|
||||||
/* conservative approximation: if a loop contains a break
|
/* conservative approximation: if a loop contains a break
|
||||||
or cont, we assume nothing about the poststate */
|
or cont, we assume nothing about the poststate */
|
||||||
/* which is still unsound -- see [Break-unsound] */
|
/* which is still unsound -- see [Break-unsound] */
|
||||||
if (has_nonlocal_exits(body)) {
|
if (has_nonlocal_exits(body)) {
|
||||||
ret changed | set_poststate_ann(fcx.ccx, e.id, pres);
|
ret changed | set_poststate_ann(fcx.ccx, e.id, pres);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -580,7 +580,7 @@ fn find_pre_post_state_expr(&fn_ctxt fcx, &prestate pres, @expr e) -> bool {
|
||||||
fn find_pre_post_state_stmt(&fn_ctxt fcx, &prestate pres, @stmt s) -> bool {
|
fn find_pre_post_state_stmt(&fn_ctxt fcx, &prestate pres, @stmt s) -> bool {
|
||||||
auto stmt_ann = stmt_to_ann(fcx.ccx, *s);
|
auto stmt_ann = stmt_to_ann(fcx.ccx, *s);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
log_err "*At beginning: stmt = ";
|
log_err "*At beginning: stmt = ";
|
||||||
log_stmt_err(*s);
|
log_stmt_err(*s);
|
||||||
log_err "*prestate = ";
|
log_err "*prestate = ";
|
||||||
|
@ -613,7 +613,7 @@ fn find_pre_post_state_stmt(&fn_ctxt fcx, &prestate pres, @stmt s) -> bool {
|
||||||
an_init.expr.id);
|
an_init.expr.id);
|
||||||
alt (rhs_d) {
|
alt (rhs_d) {
|
||||||
case (some(?rhsid)) {
|
case (some(?rhsid)) {
|
||||||
auto instrhs =
|
auto instrhs =
|
||||||
tup(path_to_ident(fcx.ccx.tcx,
|
tup(path_to_ident(fcx.ccx.tcx,
|
||||||
p), rhsid);
|
p), rhsid);
|
||||||
copy_in_poststate(fcx, post,
|
copy_in_poststate(fcx, post,
|
||||||
|
|
|
@ -19,7 +19,7 @@ export tritv_clear;
|
||||||
export tritv_doesntcare;
|
export tritv_doesntcare;
|
||||||
export to_str;
|
export to_str;
|
||||||
|
|
||||||
/* for a fixed index:
|
/* for a fixed index:
|
||||||
10 = "this constraint may or may not be true after execution"
|
10 = "this constraint may or may not be true after execution"
|
||||||
01 = "this constraint is definitely true"
|
01 = "this constraint is definitely true"
|
||||||
00 = "this constraint is definitely false"
|
00 = "this constraint is definitely false"
|
||||||
|
@ -165,7 +165,7 @@ fn tritv_get(&t v, uint i) -> trit {
|
||||||
else if (b2) { ttrue }
|
else if (b2) { ttrue }
|
||||||
else { tfalse}
|
else { tfalse}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn tritv_set(uint i, &t v, trit t) -> bool {
|
fn tritv_set(uint i, &t v, trit t) -> bool {
|
||||||
auto old = tritv_get(v, i);
|
auto old = tritv_get(v, i);
|
||||||
alt (t) {
|
alt (t) {
|
||||||
|
|
|
@ -2328,7 +2328,7 @@ mod unify {
|
||||||
}
|
}
|
||||||
case (_) { ret ures_err(terr_mismatch); }
|
case (_) { ret ures_err(terr_mismatch); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case (ty::ty_param(_)) { ret struct_cmp(cx, expected, actual); }
|
case (ty::ty_param(_)) { ret struct_cmp(cx, expected, actual); }
|
||||||
case (ty::ty_tag(?expected_id, ?expected_tps)) {
|
case (ty::ty_tag(?expected_id, ?expected_tps)) {
|
||||||
alt (struct(cx.tcx, actual)) {
|
alt (struct(cx.tcx, actual)) {
|
||||||
|
|
|
@ -95,7 +95,7 @@ fn ty_param_count_and_ty_for_def(&@fn_ctxt fcx, &span sp, &ast::def defn) ->
|
||||||
alt (defn) {
|
alt (defn) {
|
||||||
case (ast::def_arg(?id)) {
|
case (ast::def_arg(?id)) {
|
||||||
assert (fcx.locals.contains_key(id._1));
|
assert (fcx.locals.contains_key(id._1));
|
||||||
auto typ = ty::mk_var(fcx.ccx.tcx,
|
auto typ = ty::mk_var(fcx.ccx.tcx,
|
||||||
lookup_local(fcx, sp, id._1));
|
lookup_local(fcx, sp, id._1));
|
||||||
ret tup(0u, typ);
|
ret tup(0u, typ);
|
||||||
}
|
}
|
||||||
|
@ -1616,7 +1616,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
check_expr(fcx, e);
|
check_expr(fcx, e);
|
||||||
demand::simple(fcx, e.span, ty::mk_bool(fcx.ccx.tcx),
|
demand::simple(fcx, e.span, ty::mk_bool(fcx.ccx.tcx),
|
||||||
expr_ty(fcx.ccx.tcx, e));
|
expr_ty(fcx.ccx.tcx, e));
|
||||||
|
|
||||||
/* e must be a call expr where all arguments are either
|
/* e must be a call expr where all arguments are either
|
||||||
literals or slots */
|
literals or slots */
|
||||||
alt (e.node) {
|
alt (e.node) {
|
||||||
|
@ -1625,7 +1625,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
case (ast::expr_path(?oper_name)) {
|
case (ast::expr_path(?oper_name)) {
|
||||||
alt (fcx.ccx.tcx.def_map.find(operator.id)) {
|
alt (fcx.ccx.tcx.def_map.find(operator.id)) {
|
||||||
case (some(ast::def_fn(?_d_id,
|
case (some(ast::def_fn(?_d_id,
|
||||||
ast::pure_fn))) {
|
ast::pure_fn))) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
case (_) {
|
case (_) {
|
||||||
|
@ -1678,7 +1678,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
write::ty_only_fixup(fcx, id, if_t);
|
write::ty_only_fixup(fcx, id, if_t);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks the compatibility
|
// Checks the compatibility
|
||||||
fn check_binop_type_compat(&@fn_ctxt fcx, span span,
|
fn check_binop_type_compat(&@fn_ctxt fcx, span span,
|
||||||
ty::t ty, ast::binop binop) {
|
ty::t ty, ast::binop binop) {
|
||||||
auto resolved_t = resolve_type_vars_if_possible(fcx, ty);
|
auto resolved_t = resolve_type_vars_if_possible(fcx, ty);
|
||||||
|
@ -1745,7 +1745,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
case (ty::ty_ptr(?inner)) { oper_t = inner.ty; }
|
case (ty::ty_ptr(?inner)) { oper_t = inner.ty; }
|
||||||
case (_) {
|
case (_) {
|
||||||
fcx.ccx.tcx.sess.span_fatal
|
fcx.ccx.tcx.sess.span_fatal
|
||||||
(expr.span, "dereferencing non-" +
|
(expr.span, "dereferencing non-" +
|
||||||
"dereferenceable type: " +
|
"dereferenceable type: " +
|
||||||
ty_to_str(fcx.ccx.tcx, oper_t));
|
ty_to_str(fcx.ccx.tcx, oper_t));
|
||||||
}
|
}
|
||||||
|
@ -2191,7 +2191,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
alt (base) {
|
alt (base) {
|
||||||
case (none) {
|
case (none) {
|
||||||
fn get_node(&spanned[field] f) -> field { f.node }
|
fn get_node(&spanned[field] f) -> field { f.node }
|
||||||
auto typ = ty::mk_rec(fcx.ccx.tcx,
|
auto typ = ty::mk_rec(fcx.ccx.tcx,
|
||||||
ivec::map(get_node, fields_t));
|
ivec::map(get_node, fields_t));
|
||||||
write::ty_only_fixup(fcx, id, typ);
|
write::ty_only_fixup(fcx, id, typ);
|
||||||
}
|
}
|
||||||
|
@ -2313,8 +2313,8 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
auto t = next_ty_var(fcx);
|
auto t = next_ty_var(fcx);
|
||||||
alt(typ) {
|
alt(typ) {
|
||||||
case (some(?_t)) {
|
case (some(?_t)) {
|
||||||
demand::simple(fcx, expr.span,
|
demand::simple(fcx, expr.span,
|
||||||
ast_ty_to_ty_crate(fcx.ccx, _t),
|
ast_ty_to_ty_crate(fcx.ccx, _t),
|
||||||
t);
|
t);
|
||||||
}
|
}
|
||||||
case (none) {}
|
case (none) {}
|
||||||
|
@ -2352,7 +2352,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
|
|
||||||
// FIXME: this is duplicated between here and trans -- it should
|
// FIXME: this is duplicated between here and trans -- it should
|
||||||
// appear in one place
|
// appear in one place
|
||||||
fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
|
fn anon_obj_field_to_obj_field(&ast::anon_obj_field f)
|
||||||
-> ast::obj_field {
|
-> ast::obj_field {
|
||||||
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
|
ret rec(mut=f.mut, ty=f.ty, ident=f.ident, id=f.id);
|
||||||
}
|
}
|
||||||
|
@ -2417,7 +2417,7 @@ fn check_expr(&@fn_ctxt fcx, &@ast::expr expr) {
|
||||||
// The user is trying to extend a non-object.
|
// The user is trying to extend a non-object.
|
||||||
fcx.ccx.tcx.sess.span_fatal(
|
fcx.ccx.tcx.sess.span_fatal(
|
||||||
e.span,
|
e.span,
|
||||||
syntax::print::pprust::expr_to_str(e) +
|
syntax::print::pprust::expr_to_str(e) +
|
||||||
" does not have object type");
|
" does not have object type");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,7 @@ fn is_exported(ident i, _mod m) -> bool {
|
||||||
case (_) {/* fall through */ }
|
case (_) {/* fall through */ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If there are no declared exports then
|
// If there are no declared exports then
|
||||||
// everything not imported is exported
|
// everything not imported is exported
|
||||||
|
|
||||||
ret count == 0u && !nonlocal;
|
ret count == 0u && !nonlocal;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import codemap::span;
|
||||||
import std::map::new_str_hash;
|
import std::map::new_str_hash;
|
||||||
import codemap;
|
import codemap;
|
||||||
|
|
||||||
type syntax_expander =
|
type syntax_expander =
|
||||||
fn(&ext_ctxt, span, &(@ast::expr)[], option::t[str]) -> @ast::expr;
|
fn(&ext_ctxt, span, &(@ast::expr)[], option::t[str]) -> @ast::expr;
|
||||||
type macro_definer = fn(&ext_ctxt, span, &(@ast::expr)[],
|
type macro_definer = fn(&ext_ctxt, span, &(@ast::expr)[],
|
||||||
option::t[str]) -> tup(str, syntax_extension);
|
option::t[str]) -> tup(str, syntax_extension);
|
||||||
|
@ -22,7 +22,7 @@ fn syntax_expander_table() -> hashmap[str, syntax_extension] {
|
||||||
auto syntax_expanders = new_str_hash[syntax_extension]();
|
auto syntax_expanders = new_str_hash[syntax_extension]();
|
||||||
syntax_expanders.insert("fmt", normal(ext::fmt::expand_syntax_ext));
|
syntax_expanders.insert("fmt", normal(ext::fmt::expand_syntax_ext));
|
||||||
syntax_expanders.insert("env", normal(ext::env::expand_syntax_ext));
|
syntax_expanders.insert("env", normal(ext::env::expand_syntax_ext));
|
||||||
syntax_expanders.insert("macro",
|
syntax_expanders.insert("macro",
|
||||||
macro_defining(ext::simplext::add_new_extension));
|
macro_defining(ext::simplext::add_new_extension));
|
||||||
ret syntax_expanders;
|
ret syntax_expanders;
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ fn expr_to_str(&ext_ctxt cx, @ast::expr expr, str error) -> str {
|
||||||
fn expr_to_ident(&ext_ctxt cx, @ast::expr expr, str error) -> ast::ident {
|
fn expr_to_ident(&ext_ctxt cx, @ast::expr expr, str error) -> ast::ident {
|
||||||
alt(expr.node) {
|
alt(expr.node) {
|
||||||
case (ast::expr_path(?p)) {
|
case (ast::expr_path(?p)) {
|
||||||
if (ivec::len(p.node.types) > 0u
|
if (ivec::len(p.node.types) > 0u
|
||||||
|| ivec::len(p.node.idents) != 1u) {
|
|| ivec::len(p.node.idents) != 1u) {
|
||||||
cx.span_fatal(expr.span, error);
|
cx.span_fatal(expr.span, error);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -13,8 +13,8 @@ import std::option::some;
|
||||||
import std::map::hashmap;
|
import std::map::hashmap;
|
||||||
import std::ivec;
|
import std::ivec;
|
||||||
|
|
||||||
fn expand_expr(&hashmap[str, base::syntax_extension] exts,
|
fn expand_expr(&hashmap[str, base::syntax_extension] exts,
|
||||||
&session::session sess, &expr_ e, ast_fold fld,
|
&session::session sess, &expr_ e, ast_fold fld,
|
||||||
&fn(&ast::expr_, ast_fold) -> expr_ orig) -> expr_ {
|
&fn(&ast::expr_, ast_fold) -> expr_ orig) -> expr_ {
|
||||||
ret alt(e) {
|
ret alt(e) {
|
||||||
case (expr_mac(?mac)) {
|
case (expr_mac(?mac)) {
|
||||||
|
@ -25,18 +25,18 @@ fn expand_expr(&hashmap[str, base::syntax_extension] exts,
|
||||||
auto ext_cx = base::mk_ctxt(sess);
|
auto ext_cx = base::mk_ctxt(sess);
|
||||||
alt (exts.find(extname)) {
|
alt (exts.find(extname)) {
|
||||||
case (none) {
|
case (none) {
|
||||||
emit_error(some(pth.span),
|
emit_error(some(pth.span),
|
||||||
"unknown syntax expander: '"
|
"unknown syntax expander: '"
|
||||||
+ extname + "'", sess.get_codemap());
|
+ extname + "'", sess.get_codemap());
|
||||||
fail
|
fail
|
||||||
}
|
}
|
||||||
case (some(base::normal(?ext))) {
|
case (some(base::normal(?ext))) {
|
||||||
//keep going, outside-in
|
//keep going, outside-in
|
||||||
fld.fold_expr(ext(ext_cx, pth.span,
|
fld.fold_expr(ext(ext_cx, pth.span,
|
||||||
args, body)).node
|
args, body)).node
|
||||||
}
|
}
|
||||||
case (some(base::macro_defining(?ext))) {
|
case (some(base::macro_defining(?ext))) {
|
||||||
auto named_extension
|
auto named_extension
|
||||||
= ext(ext_cx, pth.span, args, body);
|
= ext(ext_cx, pth.span, args, body);
|
||||||
exts.insert(named_extension._0,
|
exts.insert(named_extension._0,
|
||||||
named_extension._1);
|
named_extension._1);
|
||||||
|
@ -65,7 +65,7 @@ fn expand_crate(&session::session sess, &@crate c) -> @crate {
|
||||||
auto res = @f.fold_crate(*c);
|
auto res = @f.fold_crate(*c);
|
||||||
dummy_out(f); //temporary: kill circular reference
|
dummy_out(f); //temporary: kill circular reference
|
||||||
ret res;
|
ret res;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Local Variables:
|
// Local Variables:
|
||||||
|
|
|
@ -61,8 +61,8 @@ fn subst_path(&ext_ctxt cx, &(invk_binding)[] ibs, &path_ p, ast_fold fld)
|
||||||
// Don't substitute into qualified names.
|
// Don't substitute into qualified names.
|
||||||
if (ivec::len(p.types) > 0u || ivec::len(p.idents) != 1u) { ret p; }
|
if (ivec::len(p.types) > 0u || ivec::len(p.idents) != 1u) { ret p; }
|
||||||
ret alt (lookup(ibs, p.idents.(0))) {
|
ret alt (lookup(ibs, p.idents.(0))) {
|
||||||
case (some(ident_binding(_, ?id))) {
|
case (some(ident_binding(_, ?id))) {
|
||||||
rec(global=false, idents=~[id.node], types=~[])
|
rec(global=false, idents=~[id.node], types=~[])
|
||||||
}
|
}
|
||||||
case (some(path_binding(_, ?a_pth))) { a_pth.node }
|
case (some(path_binding(_, ?a_pth))) { a_pth.node }
|
||||||
case (some(expr_binding(_, ?expr))) {
|
case (some(expr_binding(_, ?expr))) {
|
||||||
|
@ -74,18 +74,18 @@ fn subst_path(&ext_ctxt cx, &(invk_binding)[] ibs, &path_ p, ast_fold fld)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fn subst_expr(&ext_ctxt cx, &(invk_binding)[] ibs, &ast::expr_ e,
|
fn subst_expr(&ext_ctxt cx, &(invk_binding)[] ibs, &ast::expr_ e,
|
||||||
ast_fold fld, fn(&ast::expr_, ast_fold) -> ast::expr_ orig)
|
ast_fold fld, fn(&ast::expr_, ast_fold) -> ast::expr_ orig)
|
||||||
-> ast::expr_ {
|
-> ast::expr_ {
|
||||||
ret alt(e) {
|
ret alt(e) {
|
||||||
case (expr_path(?p)){
|
case (expr_path(?p)){
|
||||||
// Don't substitute into qualified names.
|
// Don't substitute into qualified names.
|
||||||
if (ivec::len(p.node.types) > 0u ||
|
if (ivec::len(p.node.types) > 0u ||
|
||||||
ivec::len(p.node.idents) != 1u) { e }
|
ivec::len(p.node.idents) != 1u) { e }
|
||||||
alt (lookup(ibs, p.node.idents.(0))) {
|
alt (lookup(ibs, p.node.idents.(0))) {
|
||||||
case (some(ident_binding(_, ?id))) {
|
case (some(ident_binding(_, ?id))) {
|
||||||
expr_path(respan(id.span,
|
expr_path(respan(id.span,
|
||||||
rec(global=false,
|
rec(global=false,
|
||||||
idents=~[id.node],types=~[])))
|
idents=~[id.node],types=~[])))
|
||||||
}
|
}
|
||||||
case (some(path_binding(_, ?a_pth))) { expr_path(*a_pth) }
|
case (some(path_binding(_, ?a_pth))) { expr_path(*a_pth) }
|
||||||
|
@ -107,7 +107,7 @@ tag invk_binding {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_to_ident(&path pth) -> option::t[ident] {
|
fn path_to_ident(&path pth) -> option::t[ident] {
|
||||||
if (ivec::len(pth.node.idents) == 1u
|
if (ivec::len(pth.node.idents) == 1u
|
||||||
&& ivec::len(pth.node.types) == 0u) {
|
&& ivec::len(pth.node.types) == 0u) {
|
||||||
ret some(pth.node.idents.(0u));
|
ret some(pth.node.idents.(0u));
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,7 @@ fn path_to_ident(&path pth) -> option::t[ident] {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_clause(&ext_ctxt cx, &mutable vec[pat_ext] pes,
|
fn process_clause(&ext_ctxt cx, &mutable vec[pat_ext] pes,
|
||||||
&mutable option::t[str] macro_name, &path pth,
|
&mutable option::t[str] macro_name, &path pth,
|
||||||
&(@ast::expr)[] invoc_args, @ast::expr body) {
|
&(@ast::expr)[] invoc_args, @ast::expr body) {
|
||||||
let str clause_name = alt(path_to_ident(pth)) {
|
let str clause_name = alt(path_to_ident(pth)) {
|
||||||
case (some(?id)) { id }
|
case (some(?id)) { id }
|
||||||
|
@ -139,10 +139,10 @@ fn add_new_extension(&ext_ctxt cx, span sp, &(@ast::expr)[] args,
|
||||||
for (@ast::expr arg in args) {
|
for (@ast::expr arg in args) {
|
||||||
alt(arg.node) {
|
alt(arg.node) {
|
||||||
case(expr_vec(?elts, ?mut, ?seq_kind)) {
|
case(expr_vec(?elts, ?mut, ?seq_kind)) {
|
||||||
|
|
||||||
if (ivec::len(elts) != 2u) {
|
if (ivec::len(elts) != 2u) {
|
||||||
cx.span_fatal((*arg).span,
|
cx.span_fatal((*arg).span,
|
||||||
"extension clause must consist of [" +
|
"extension clause must consist of [" +
|
||||||
"macro invocation, expansion body]");
|
"macro invocation, expansion body]");
|
||||||
}
|
}
|
||||||
alt(elts.(0u).node) {
|
alt(elts.(0u).node) {
|
||||||
|
@ -168,10 +168,10 @@ fn add_new_extension(&ext_ctxt cx, span sp, &(@ast::expr)[] args,
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ext = bind generic_extension(_,_,_,_,@pat_exts);
|
auto ext = bind generic_extension(_,_,_,_,@pat_exts);
|
||||||
|
|
||||||
ret tup(alt (macro_name) {
|
ret tup(alt (macro_name) {
|
||||||
case (some(?id)) { id }
|
case (some(?id)) { id }
|
||||||
case (none) {
|
case (none) {
|
||||||
cx.span_fatal(sp, "macro definition must have "
|
cx.span_fatal(sp, "macro definition must have "
|
||||||
+ "at least one clause")
|
+ "at least one clause")
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ fn add_new_extension(&ext_ctxt cx, span sp, &(@ast::expr)[] args,
|
||||||
case (expr_vec(?p_elts, _, _)) {
|
case (expr_vec(?p_elts, _, _)) {
|
||||||
alt (arg) {
|
alt (arg) {
|
||||||
case (expr_vec(?a_elts, _, _)) {
|
case (expr_vec(?a_elts, _, _)) {
|
||||||
if (ivec::len(p_elts) != ivec::len(a_elts)) {
|
if (ivec::len(p_elts) != ivec::len(a_elts)) {
|
||||||
none[vec[invk_binding]]
|
none[vec[invk_binding]]
|
||||||
}
|
}
|
||||||
let uint i = 0u;
|
let uint i = 0u;
|
||||||
|
@ -218,12 +218,12 @@ fn add_new_extension(&ext_ctxt cx, span sp, &(@ast::expr)[] args,
|
||||||
alt (path_to_ident(a_pth)) {
|
alt (path_to_ident(a_pth)) {
|
||||||
case (some(?a_id)) {
|
case (some(?a_id)) {
|
||||||
some(~[ident_binding
|
some(~[ident_binding
|
||||||
(p_id,
|
(p_id,
|
||||||
respan(argument.span,
|
respan(argument.span,
|
||||||
a_id))])
|
a_id))])
|
||||||
}
|
}
|
||||||
case (none) {
|
case (none) {
|
||||||
some(~[path_binding(p_id,
|
some(~[path_binding(p_id,
|
||||||
@a_pth)])
|
@a_pth)])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,9 +18,9 @@ type ast_fold = @mutable a_f;
|
||||||
|
|
||||||
// We may eventually want to be able to fold over type parameters, too
|
// We may eventually want to be able to fold over type parameters, too
|
||||||
|
|
||||||
type ast_fold_precursor =
|
type ast_fold_precursor =
|
||||||
rec(fn (&crate_ c, ast_fold) -> crate_ fold_crate,
|
rec(fn (&crate_ c, ast_fold) -> crate_ fold_crate,
|
||||||
fn (&crate_directive_ cd, ast_fold) -> crate_directive_
|
fn (&crate_directive_ cd, ast_fold) -> crate_directive_
|
||||||
fold_crate_directive,
|
fold_crate_directive,
|
||||||
fn (&view_item_ i, ast_fold) -> view_item_ fold_view_item,
|
fn (&view_item_ i, ast_fold) -> view_item_ fold_view_item,
|
||||||
fn (&@native_item i, ast_fold) -> @native_item fold_native_item,
|
fn (&@native_item i, ast_fold) -> @native_item fold_native_item,
|
||||||
|
@ -72,27 +72,27 @@ type a_f =
|
||||||
|
|
||||||
//fn nf_dummy[T](&T node) -> T { fail; }
|
//fn nf_dummy[T](&T node) -> T { fail; }
|
||||||
fn nf_crate_dummy(&crate c) -> crate { fail; }
|
fn nf_crate_dummy(&crate c) -> crate { fail; }
|
||||||
fn nf_crate_directive_dummy(&@crate_directive c)
|
fn nf_crate_directive_dummy(&@crate_directive c)
|
||||||
-> @crate_directive { fail; }
|
-> @crate_directive { fail; }
|
||||||
fn nf_view_item_dummy(&@view_item v) -> @view_item { fail; }
|
fn nf_view_item_dummy(&@view_item v) -> @view_item { fail; }
|
||||||
fn nf_native_item_dummy(&@native_item n) -> @native_item { fail; }
|
fn nf_native_item_dummy(&@native_item n) -> @native_item { fail; }
|
||||||
fn nf_item_dummy(&@item i) -> @item { fail; }
|
fn nf_item_dummy(&@item i) -> @item { fail; }
|
||||||
fn nf_item_underscore_dummy(&item_ i) -> item_ { fail; }
|
fn nf_item_underscore_dummy(&item_ i) -> item_ { fail; }
|
||||||
fn nf_method_dummy(&@method m) -> @method { fail; }
|
fn nf_method_dummy(&@method m) -> @method { fail; }
|
||||||
fn nf_block_dummy(&block b) -> block { fail; }
|
fn nf_block_dummy(&block b) -> block { fail; }
|
||||||
fn nf_stmt_dummy(&@stmt s) -> @stmt { fail; }
|
fn nf_stmt_dummy(&@stmt s) -> @stmt { fail; }
|
||||||
fn nf_arm_dummy(&arm a) -> arm { fail; }
|
fn nf_arm_dummy(&arm a) -> arm { fail; }
|
||||||
fn nf_pat_dummy(&@pat p) -> @pat { fail; }
|
fn nf_pat_dummy(&@pat p) -> @pat { fail; }
|
||||||
fn nf_decl_dummy(&@decl d) -> @decl { fail; }
|
fn nf_decl_dummy(&@decl d) -> @decl { fail; }
|
||||||
fn nf_expr_dummy(&@expr e) -> @expr { fail; }
|
fn nf_expr_dummy(&@expr e) -> @expr { fail; }
|
||||||
fn nf_ty_dummy(&@ty t) -> @ty { fail; }
|
fn nf_ty_dummy(&@ty t) -> @ty { fail; }
|
||||||
fn nf_constr_dummy(&@constr c) -> @constr { fail; }
|
fn nf_constr_dummy(&@constr c) -> @constr { fail; }
|
||||||
fn nf_fn_dummy(&_fn f) -> _fn { fail; }
|
fn nf_fn_dummy(&_fn f) -> _fn { fail; }
|
||||||
fn nf_mod_dummy(&_mod m) -> _mod { fail; }
|
fn nf_mod_dummy(&_mod m) -> _mod { fail; }
|
||||||
fn nf_native_mod_dummy(&native_mod n) -> native_mod { fail; }
|
fn nf_native_mod_dummy(&native_mod n) -> native_mod { fail; }
|
||||||
fn nf_variant_dummy(&variant v) -> variant { fail; }
|
fn nf_variant_dummy(&variant v) -> variant { fail; }
|
||||||
fn nf_ident_dummy(&ident i) -> ident { fail; }
|
fn nf_ident_dummy(&ident i) -> ident { fail; }
|
||||||
fn nf_path_dummy(&path p) -> path { fail; }
|
fn nf_path_dummy(&path p) -> path { fail; }
|
||||||
fn nf_obj_field_dummy(&obj_field o) -> obj_field { fail; }
|
fn nf_obj_field_dummy(&obj_field o) -> obj_field { fail; }
|
||||||
fn nf_local_dummy(&@local o) -> @local { fail; }
|
fn nf_local_dummy(&@local o) -> @local { fail; }
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ fn fold_meta_item_(&@meta_item mi, ast_fold fld) -> @meta_item {
|
||||||
span=mi.span);
|
span=mi.span);
|
||||||
}
|
}
|
||||||
//used in noop_fold_item and noop_fold_crate
|
//used in noop_fold_item and noop_fold_crate
|
||||||
fn fold_attribute_(&attribute at, fn(&@meta_item) -> @meta_item fmi)
|
fn fold_attribute_(&attribute at, fn(&@meta_item) -> @meta_item fmi)
|
||||||
-> attribute {
|
-> attribute {
|
||||||
ret rec(node=rec(style=at.node.style,
|
ret rec(node=rec(style=at.node.style,
|
||||||
value=*fmi(@at.node.value)),
|
value=*fmi(@at.node.value)),
|
||||||
|
@ -122,7 +122,7 @@ fn fold_attribute_(&attribute at, fn(&@meta_item) -> @meta_item fmi)
|
||||||
}
|
}
|
||||||
//used in noop_fold_native_item and noop_fold_fn
|
//used in noop_fold_native_item and noop_fold_fn
|
||||||
fn fold_arg_(&arg a, ast_fold fld) -> arg {
|
fn fold_arg_(&arg a, ast_fold fld) -> arg {
|
||||||
ret rec(mode=a.mode, ty=fld.fold_ty(a.ty),
|
ret rec(mode=a.mode, ty=fld.fold_ty(a.ty),
|
||||||
ident=fld.fold_ident(a.ident), id=a.id);
|
ident=fld.fold_ident(a.ident), id=a.id);
|
||||||
}
|
}
|
||||||
//used in noop_fold_expr, and possibly elsewhere in the future
|
//used in noop_fold_expr, and possibly elsewhere in the future
|
||||||
|
@ -130,10 +130,10 @@ fn fold_mac_(&mac m, ast_fold fld) -> mac {
|
||||||
ret rec(node=
|
ret rec(node=
|
||||||
alt(m.node) {
|
alt(m.node) {
|
||||||
case (mac_invoc(?pth,?args,?body)) {
|
case (mac_invoc(?pth,?args,?body)) {
|
||||||
mac_invoc(fld.fold_path(pth),
|
mac_invoc(fld.fold_path(pth),
|
||||||
ivec::map(fld.fold_expr, args), body)
|
ivec::map(fld.fold_expr, args), body)
|
||||||
}
|
}
|
||||||
case (mac_embed_type(?ty)) {
|
case (mac_embed_type(?ty)) {
|
||||||
mac_embed_type(fld.fold_ty(ty))
|
mac_embed_type(fld.fold_ty(ty))
|
||||||
}
|
}
|
||||||
case (mac_embed_block(?block)) {
|
case (mac_embed_block(?block)) {
|
||||||
|
@ -158,17 +158,17 @@ fn noop_fold_crate(&crate_ c, ast_fold fld) -> crate_ {
|
||||||
config=ivec::map(fold_meta_item, c.config));
|
config=ivec::map(fold_meta_item, c.config));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn noop_fold_crate_directive(&crate_directive_ cd, ast_fold fld)
|
fn noop_fold_crate_directive(&crate_directive_ cd, ast_fold fld)
|
||||||
-> crate_directive_ {
|
-> crate_directive_ {
|
||||||
ret alt(cd) {
|
ret alt(cd) {
|
||||||
case(cdir_src_mod(?id,?fname,?attrs)) {
|
case(cdir_src_mod(?id,?fname,?attrs)) {
|
||||||
cdir_src_mod(fld.fold_ident(id), fname, attrs)
|
cdir_src_mod(fld.fold_ident(id), fname, attrs)
|
||||||
}
|
}
|
||||||
case(cdir_dir_mod(?id,?fname,?cds,?attrs)) {
|
case(cdir_dir_mod(?id,?fname,?cds,?attrs)) {
|
||||||
cdir_dir_mod(fld.fold_ident(id),fname,
|
cdir_dir_mod(fld.fold_ident(id),fname,
|
||||||
ivec::map(fld.fold_crate_directive, cds), attrs)
|
ivec::map(fld.fold_crate_directive, cds), attrs)
|
||||||
}
|
}
|
||||||
case(cdir_view_item(?vi)) {
|
case(cdir_view_item(?vi)) {
|
||||||
cdir_view_item(fld.fold_view_item(vi))
|
cdir_view_item(fld.fold_view_item(vi))
|
||||||
}
|
}
|
||||||
case(cdir_syntax(_)) { cd }
|
case(cdir_syntax(_)) { cd }
|
||||||
|
@ -191,7 +191,7 @@ fn noop_fold_native_item(&@native_item ni, ast_fold fld) -> @native_item {
|
||||||
node=alt (ni.node) {
|
node=alt (ni.node) {
|
||||||
case (native_item_ty) { native_item_ty }
|
case (native_item_ty) { native_item_ty }
|
||||||
case (native_item_fn(?st, ?fdec, ?typms)) {
|
case (native_item_fn(?st, ?fdec, ?typms)) {
|
||||||
native_item_fn(st,
|
native_item_fn(st,
|
||||||
rec(inputs=ivec::map(fold_arg,
|
rec(inputs=ivec::map(fold_arg,
|
||||||
fdec.inputs),
|
fdec.inputs),
|
||||||
output=fld.fold_ty(fdec.output),
|
output=fld.fold_ty(fdec.output),
|
||||||
|
@ -217,7 +217,7 @@ fn noop_fold_item(&@item i, ast_fold fld) -> @item {
|
||||||
|
|
||||||
fn noop_fold_item_underscore(&item_ i, ast_fold fld) -> item_ {
|
fn noop_fold_item_underscore(&item_ i, ast_fold fld) -> item_ {
|
||||||
fn fold_obj_field_(&obj_field of, ast_fold fld) -> obj_field {
|
fn fold_obj_field_(&obj_field of, ast_fold fld) -> obj_field {
|
||||||
ret rec(mut=of.mut, ty=fld.fold_ty(of.ty),
|
ret rec(mut=of.mut, ty=fld.fold_ty(of.ty),
|
||||||
ident=fld.fold_ident(of.ident), id=of.id);
|
ident=fld.fold_ident(of.ident), id=of.id);
|
||||||
}
|
}
|
||||||
auto fold_obj_field = bind fold_obj_field_(_,fld);
|
auto fold_obj_field = bind fold_obj_field_(_,fld);
|
||||||
|
@ -253,7 +253,7 @@ fn noop_fold_item_underscore(&item_ i, ast_fold fld) -> item_ {
|
||||||
|
|
||||||
fn noop_fold_method(&method_ m, ast_fold fld) -> method_ {
|
fn noop_fold_method(&method_ m, ast_fold fld) -> method_ {
|
||||||
ret rec(ident=fld.fold_ident(m.ident),
|
ret rec(ident=fld.fold_ident(m.ident),
|
||||||
meth=fld.fold_fn(m.meth), id=m.id);
|
meth=fld.fold_fn(m.meth), id=m.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -319,9 +319,9 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||||
}
|
}
|
||||||
auto fold_field = bind fold_field_(_,fld);
|
auto fold_field = bind fold_field_(_,fld);
|
||||||
fn fold_anon_obj_(&anon_obj ao, ast_fold fld) -> anon_obj {
|
fn fold_anon_obj_(&anon_obj ao, ast_fold fld) -> anon_obj {
|
||||||
fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
|
fn fold_anon_obj_field_(&anon_obj_field aof, ast_fold fld)
|
||||||
-> anon_obj_field {
|
-> anon_obj_field {
|
||||||
ret rec(mut=aof.mut, ty=fld.fold_ty(aof.ty),
|
ret rec(mut=aof.mut, ty=fld.fold_ty(aof.ty),
|
||||||
expr=fld.fold_expr(aof.expr),
|
expr=fld.fold_expr(aof.expr),
|
||||||
ident=fld.fold_ident(aof.ident), id=aof.id);
|
ident=fld.fold_ident(aof.ident), id=aof.id);
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||||
with_obj=option::map(fld.fold_expr, ao.with_obj))
|
with_obj=option::map(fld.fold_expr, ao.with_obj))
|
||||||
}
|
}
|
||||||
auto fold_anon_obj = bind fold_anon_obj_(_,fld);
|
auto fold_anon_obj = bind fold_anon_obj_(_,fld);
|
||||||
|
|
||||||
auto fold_mac = bind fold_mac_(_,fld);
|
auto fold_mac = bind fold_mac_(_,fld);
|
||||||
|
|
||||||
ret alt (e) {
|
ret alt (e) {
|
||||||
|
@ -362,7 +362,7 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||||
expr_bind(fld.fold_expr(f), ivec::map(opt_map_se, args))
|
expr_bind(fld.fold_expr(f), ivec::map(opt_map_se, args))
|
||||||
}
|
}
|
||||||
case (expr_spawn(?spawn_dom, ?name, ?f, ?args)) {
|
case (expr_spawn(?spawn_dom, ?name, ?f, ?args)) {
|
||||||
expr_spawn(spawn_dom, name, fld.fold_expr(f),
|
expr_spawn(spawn_dom, name, fld.fold_expr(f),
|
||||||
ivec::map(fld.fold_expr, args))
|
ivec::map(fld.fold_expr, args))
|
||||||
}
|
}
|
||||||
case (expr_binary(?binop, ?lhs, ?rhs)) {
|
case (expr_binary(?binop, ?lhs, ?rhs)) {
|
||||||
|
@ -376,7 +376,7 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||||
expr_cast(fld.fold_expr(expr), ty)
|
expr_cast(fld.fold_expr(expr), ty)
|
||||||
}
|
}
|
||||||
case (expr_if(?cond, ?tr, ?fl)) {
|
case (expr_if(?cond, ?tr, ?fl)) {
|
||||||
expr_if(fld.fold_expr(cond), fld.fold_block(tr),
|
expr_if(fld.fold_expr(cond), fld.fold_block(tr),
|
||||||
option::map(fld.fold_expr, fl))
|
option::map(fld.fold_expr, fl))
|
||||||
}
|
}
|
||||||
case (expr_ternary(?cond, ?tr, ?fl)) {
|
case (expr_ternary(?cond, ?tr, ?fl)) {
|
||||||
|
@ -388,11 +388,11 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||||
expr_while(fld.fold_expr(cond), fld.fold_block(body))
|
expr_while(fld.fold_expr(cond), fld.fold_block(body))
|
||||||
}
|
}
|
||||||
case (expr_for(?decl, ?expr, ?block)) {
|
case (expr_for(?decl, ?expr, ?block)) {
|
||||||
expr_for(fld.fold_local(decl), fld.fold_expr(expr),
|
expr_for(fld.fold_local(decl), fld.fold_expr(expr),
|
||||||
fld.fold_block(block))
|
fld.fold_block(block))
|
||||||
}
|
}
|
||||||
case (expr_for_each(?decl, ?expr, ?block)) {
|
case (expr_for_each(?decl, ?expr, ?block)) {
|
||||||
expr_for_each(fld.fold_local(decl), fld.fold_expr(expr),
|
expr_for_each(fld.fold_local(decl), fld.fold_expr(expr),
|
||||||
fld.fold_block(block))
|
fld.fold_block(block))
|
||||||
}
|
}
|
||||||
case (expr_do_while(?block, ?expr)) {
|
case (expr_do_while(?block, ?expr)) {
|
||||||
|
@ -437,10 +437,10 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||||
case (expr_fail(?e)) { expr_fail(option::map(fld.fold_expr, e)) }
|
case (expr_fail(?e)) { expr_fail(option::map(fld.fold_expr, e)) }
|
||||||
case (expr_break()) { e }
|
case (expr_break()) { e }
|
||||||
case (expr_cont()) { e }
|
case (expr_cont()) { e }
|
||||||
case (expr_ret(?e)) {
|
case (expr_ret(?e)) {
|
||||||
expr_ret(option::map(fld.fold_expr, e))
|
expr_ret(option::map(fld.fold_expr, e))
|
||||||
}
|
}
|
||||||
case (expr_put(?e)) {
|
case (expr_put(?e)) {
|
||||||
expr_put(option::map(fld.fold_expr, e))
|
expr_put(option::map(fld.fold_expr, e))
|
||||||
}
|
}
|
||||||
case (expr_be(?e)) { expr_be(fld.fold_expr(e)) }
|
case (expr_be(?e)) { expr_be(fld.fold_expr(e)) }
|
||||||
|
@ -448,10 +448,10 @@ fn noop_fold_expr(&expr_ e, ast_fold fld) -> expr_ {
|
||||||
case (expr_assert(?e)) { expr_assert(fld.fold_expr(e)) }
|
case (expr_assert(?e)) { expr_assert(fld.fold_expr(e)) }
|
||||||
case (expr_check(?m, ?e)) { expr_check(m, fld.fold_expr(e)) }
|
case (expr_check(?m, ?e)) { expr_check(m, fld.fold_expr(e)) }
|
||||||
case (expr_if_check(?cond, ?tr, ?fl)) {
|
case (expr_if_check(?cond, ?tr, ?fl)) {
|
||||||
expr_if_check(fld.fold_expr(cond), fld.fold_block(tr),
|
expr_if_check(fld.fold_expr(cond), fld.fold_block(tr),
|
||||||
option::map(fld.fold_expr, fl))
|
option::map(fld.fold_expr, fl))
|
||||||
}
|
}
|
||||||
case (expr_port(?ot)) {
|
case (expr_port(?ot)) {
|
||||||
expr_port(alt(ot) {
|
expr_port(alt(ot) {
|
||||||
case (option::some(?t)) { option::some(fld.fold_ty(t)) }
|
case (option::some(?t)) { option::some(fld.fold_ty(t)) }
|
||||||
case (option::none) { option::none }
|
case (option::none) { option::none }
|
||||||
|
@ -531,7 +531,7 @@ fn noop_fold_local(&local_ l, ast_fold fld) -> local_ {
|
||||||
case (option::none[initializer]) { l.init }
|
case (option::none[initializer]) { l.init }
|
||||||
case (option::some[initializer](?init)) {
|
case (option::some[initializer](?init)) {
|
||||||
option::some[initializer]
|
option::some[initializer]
|
||||||
(rec(op=init.op,
|
(rec(op=init.op,
|
||||||
expr=fld.fold_expr(init.expr)))
|
expr=fld.fold_expr(init.expr)))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -591,7 +591,7 @@ fn dummy_out(ast_fold a) {
|
||||||
|
|
||||||
|
|
||||||
fn make_fold(&ast_fold_precursor afp) -> ast_fold {
|
fn make_fold(&ast_fold_precursor afp) -> ast_fold {
|
||||||
let ast_fold result =
|
let ast_fold result =
|
||||||
@mutable rec(fold_crate = nf_crate_dummy,
|
@mutable rec(fold_crate = nf_crate_dummy,
|
||||||
fold_crate_directive = nf_crate_directive_dummy,
|
fold_crate_directive = nf_crate_directive_dummy,
|
||||||
fold_view_item = nf_view_item_dummy,
|
fold_view_item = nf_view_item_dummy,
|
||||||
|
@ -620,7 +620,7 @@ fn make_fold(&ast_fold_precursor afp) -> ast_fold {
|
||||||
ret rec(node=afp.fold_crate(c.node, f),
|
ret rec(node=afp.fold_crate(c.node, f),
|
||||||
span=c.span);
|
span=c.span);
|
||||||
}
|
}
|
||||||
fn f_crate_directive(&ast_fold_precursor afp, ast_fold f,
|
fn f_crate_directive(&ast_fold_precursor afp, ast_fold f,
|
||||||
&@crate_directive c) -> @crate_directive {
|
&@crate_directive c) -> @crate_directive {
|
||||||
ret @rec(node=afp.fold_crate_directive(c.node, f),
|
ret @rec(node=afp.fold_crate_directive(c.node, f),
|
||||||
span=c.span);
|
span=c.span);
|
||||||
|
@ -669,14 +669,14 @@ fn make_fold(&ast_fold_precursor afp) -> ast_fold {
|
||||||
}
|
}
|
||||||
fn f_fn(&ast_fold_precursor afp, ast_fold f, &_fn x) -> _fn {
|
fn f_fn(&ast_fold_precursor afp, ast_fold f, &_fn x) -> _fn {
|
||||||
ret afp.fold_fn(x, f);
|
ret afp.fold_fn(x, f);
|
||||||
}
|
}
|
||||||
fn f_mod(&ast_fold_precursor afp, ast_fold f, &_mod x) -> _mod {
|
fn f_mod(&ast_fold_precursor afp, ast_fold f, &_mod x) -> _mod {
|
||||||
ret afp.fold_mod(x, f);
|
ret afp.fold_mod(x, f);
|
||||||
}
|
}
|
||||||
fn f_native_mod(&ast_fold_precursor afp, ast_fold f, &native_mod x) ->
|
fn f_native_mod(&ast_fold_precursor afp, ast_fold f, &native_mod x) ->
|
||||||
native_mod {
|
native_mod {
|
||||||
ret afp.fold_native_mod(x, f);
|
ret afp.fold_native_mod(x, f);
|
||||||
}
|
}
|
||||||
fn f_variant(&ast_fold_precursor afp, ast_fold f, &variant x)
|
fn f_variant(&ast_fold_precursor afp, ast_fold f, &variant x)
|
||||||
-> variant {
|
-> variant {
|
||||||
ret rec(node=afp.fold_variant(x.node, f), span=x.span);
|
ret rec(node=afp.fold_variant(x.node, f), span=x.span);
|
||||||
|
|
|
@ -370,8 +370,8 @@ fn next_token(&reader rdr) -> token::token {
|
||||||
case ('?') { rdr.bump(); ret token::QUES; }
|
case ('?') { rdr.bump(); ret token::QUES; }
|
||||||
case (';') { rdr.bump(); ret token::SEMI; }
|
case (';') { rdr.bump(); ret token::SEMI; }
|
||||||
case (',') { rdr.bump(); ret token::COMMA; }
|
case (',') { rdr.bump(); ret token::COMMA; }
|
||||||
case ('.') {
|
case ('.') {
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
if (rdr.curr() == '.' && rdr.next() == '.') {
|
if (rdr.curr() == '.' && rdr.next() == '.') {
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
|
@ -386,8 +386,8 @@ fn next_token(&reader rdr) -> token::token {
|
||||||
case ('[') { rdr.bump(); ret token::LBRACKET; }
|
case ('[') { rdr.bump(); ret token::LBRACKET; }
|
||||||
case (']') { rdr.bump(); ret token::RBRACKET; }
|
case (']') { rdr.bump(); ret token::RBRACKET; }
|
||||||
case ('@') { rdr.bump(); ret token::AT; }
|
case ('@') { rdr.bump(); ret token::AT; }
|
||||||
case ('#') {
|
case ('#') {
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
if (rdr.curr() == '<') {
|
if (rdr.curr() == '<') {
|
||||||
rdr.bump();
|
rdr.bump();
|
||||||
ret token::POUND_LT;
|
ret token::POUND_LT;
|
||||||
|
|
|
@ -361,7 +361,7 @@ fn parse_ty_constr(&ast::arg[] fn_args, &parser p) -> @ast::constr {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Use the args list to translate each bound variable
|
// Use the args list to translate each bound variable
|
||||||
// mentioned in a constraint to an arg index.
|
// mentioned in a constraint to an arg index.
|
||||||
// Seems weird to do this in the parser, but I'm not sure how else to.
|
// Seems weird to do this in the parser, but I'm not sure how else to.
|
||||||
fn parse_constrs(&ast::arg[] args, &parser p)
|
fn parse_constrs(&ast::arg[] args, &parser p)
|
||||||
|
@ -932,7 +932,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
||||||
ex = ast::expr_assert(e);
|
ex = ast::expr_assert(e);
|
||||||
hi = e.span.hi;
|
hi = e.span.hi;
|
||||||
} else if (eat_word(p, "check")) {
|
} else if (eat_word(p, "check")) {
|
||||||
/* Should be a predicate (pure boolean function) applied to
|
/* Should be a predicate (pure boolean function) applied to
|
||||||
arguments that are all either slot variables or literals.
|
arguments that are all either slot variables or literals.
|
||||||
but the typechecker enforces that. */
|
but the typechecker enforces that. */
|
||||||
|
|
||||||
|
@ -943,7 +943,7 @@ fn parse_bottom_expr(&parser p) -> @ast::expr {
|
||||||
/* Same rules as check, except that if check-claims
|
/* Same rules as check, except that if check-claims
|
||||||
is enabled (a command-line flag), then the parser turns
|
is enabled (a command-line flag), then the parser turns
|
||||||
claims into check */
|
claims into check */
|
||||||
|
|
||||||
auto e = parse_expr(p);
|
auto e = parse_expr(p);
|
||||||
hi = e.span.hi;
|
hi = e.span.hi;
|
||||||
ex = ast::expr_check(ast::unchecked, e);
|
ex = ast::expr_check(ast::unchecked, e);
|
||||||
|
@ -1310,7 +1310,7 @@ fn parse_else_expr(&parser p) -> @ast::expr {
|
||||||
fn parse_head_local(&parser p) -> @ast::local {
|
fn parse_head_local(&parser p) -> @ast::local {
|
||||||
if (is_word(p, "auto")) {
|
if (is_word(p, "auto")) {
|
||||||
ret parse_auto_local(p);
|
ret parse_auto_local(p);
|
||||||
} else {
|
} else {
|
||||||
ret parse_typed_local(p);
|
ret parse_typed_local(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1709,7 +1709,7 @@ fn parse_block(&parser p) -> ast::block {
|
||||||
be parse_block_tail(p);
|
be parse_block_tail(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// some blocks start with "#{"...
|
// some blocks start with "#{"...
|
||||||
fn parse_block_tail(&parser p) -> ast::block {
|
fn parse_block_tail(&parser p) -> ast::block {
|
||||||
auto lo = p.get_lo_pos();
|
auto lo = p.get_lo_pos();
|
||||||
let (@ast::stmt)[] stmts = ~[];
|
let (@ast::stmt)[] stmts = ~[];
|
||||||
|
@ -1865,7 +1865,7 @@ fn parse_dtor(&parser p) -> @ast::method {
|
||||||
purity=ast::impure_fn,
|
purity=ast::impure_fn,
|
||||||
cf=ast::return,
|
cf=ast::return,
|
||||||
|
|
||||||
// I guess dtors can't have constraints?
|
// I guess dtors can't have constraints?
|
||||||
constraints=~[]);
|
constraints=~[]);
|
||||||
let ast::_fn f = rec(decl=d, proto=ast::proto_fn, body=b);
|
let ast::_fn f = rec(decl=d, proto=ast::proto_fn, body=b);
|
||||||
let ast::method_ m =
|
let ast::method_ m =
|
||||||
|
@ -2432,7 +2432,7 @@ fn parse_crate_from_source_str(&str name, &str source, &ast::crate_cfg cfg,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parses a source module as a crate
|
// Parses a source module as a crate
|
||||||
fn parse_crate_mod(&parser p, &ast::crate_cfg cfg, parse_sess sess)
|
fn parse_crate_mod(&parser p, &ast::crate_cfg cfg, parse_sess sess)
|
||||||
-> @ast::crate {
|
-> @ast::crate {
|
||||||
auto lo = p.get_lo_pos();
|
auto lo = p.get_lo_pos();
|
||||||
auto crate_attrs = parse_inner_attrs_and_next(p);
|
auto crate_attrs = parse_inner_attrs_and_next(p);
|
||||||
|
|
|
@ -574,7 +574,7 @@ fn print_stmt(&ps s, &ast::stmt st) {
|
||||||
|
|
||||||
fn print_block(&ps s, &ast::block blk) {
|
fn print_block(&ps s, &ast::block blk) {
|
||||||
print_possibly_embedded_block(s, blk, false);
|
print_possibly_embedded_block(s, blk, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded) {
|
fn print_possibly_embedded_block(&ps s, &ast::block blk, bool embedded) {
|
||||||
maybe_print_comment(s, blk.span.lo);
|
maybe_print_comment(s, blk.span.lo);
|
||||||
|
@ -1003,13 +1003,13 @@ fn print_expr(&ps s, &@ast::expr expr) {
|
||||||
print_expr(s, field.expr);
|
print_expr(s, field.expr);
|
||||||
end(s);
|
end(s);
|
||||||
}
|
}
|
||||||
fn get_span(&ast::anon_obj_field f) -> codemap::span {
|
fn get_span(&ast::anon_obj_field f) -> codemap::span {
|
||||||
ret f.ty.span;
|
ret f.ty.span;
|
||||||
}
|
}
|
||||||
alt (anon_obj.fields) {
|
alt (anon_obj.fields) {
|
||||||
case (none) { }
|
case (none) { }
|
||||||
case (some(?fields)) {
|
case (some(?fields)) {
|
||||||
commasep_cmnt(s, consistent, fields, print_field,
|
commasep_cmnt(s, consistent, fields, print_field,
|
||||||
get_span);
|
get_span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -394,7 +394,7 @@ fn walk_expr(&ast_visitor v, @ast::expr e) {
|
||||||
alt (anon_obj.fields) {
|
alt (anon_obj.fields) {
|
||||||
case (none) { }
|
case (none) { }
|
||||||
case (some(?fields)) {
|
case (some(?fields)) {
|
||||||
for (ast::anon_obj_field f in fields) {
|
for (ast::anon_obj_field f in fields) {
|
||||||
walk_ty(v, f.ty);
|
walk_ty(v, f.ty);
|
||||||
walk_expr(v, f.expr);
|
walk_expr(v, f.expr);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,6 +25,9 @@ for line in fileinput.input(openhook=fileinput.hook_encoded("utf-8")):
|
||||||
if not autocrlf and line.find('\r') != -1:
|
if not autocrlf and line.find('\r') != -1:
|
||||||
report_err("CR character")
|
report_err("CR character")
|
||||||
|
|
||||||
|
if line.endswith(" \n") or line.endswith("\t\n"):
|
||||||
|
report_err("trailing whitespace")
|
||||||
|
|
||||||
line_len = len(line)-2 if autocrlf else len(line)-1
|
line_len = len(line)-2 if autocrlf else len(line)-1
|
||||||
if line_len > cols:
|
if line_len > cols:
|
||||||
report_err("line longer than %d chars" % cols)
|
report_err("line longer than %d chars" % cols)
|
||||||
|
|
|
@ -2,7 +2,7 @@ fn to_str(u64 n, uint radix) -> str {
|
||||||
assert(0u < radix && radix <= 16u);
|
assert(0u < radix && radix <= 16u);
|
||||||
|
|
||||||
auto r64 = radix as u64;
|
auto r64 = radix as u64;
|
||||||
|
|
||||||
fn digit(u64 n) -> str {
|
fn digit(u64 n) -> str {
|
||||||
ret alt (n) {
|
ret alt (n) {
|
||||||
case (0u64) { "0" }
|
case (0u64) { "0" }
|
||||||
|
|
|
@ -300,13 +300,13 @@ fn or(&vec[bool] v) -> bool {
|
||||||
|
|
||||||
fn any[T](&fn(&T) -> bool f, &vec[T] v) -> bool {
|
fn any[T](&fn(&T) -> bool f, &vec[T] v) -> bool {
|
||||||
for (T t in v) {
|
for (T t in v) {
|
||||||
if (f(t)) { ret true; }
|
if (f(t)) { ret true; }
|
||||||
}
|
}
|
||||||
ret false;
|
ret false;
|
||||||
}
|
}
|
||||||
fn all[T](&fn(&T) -> bool f, &vec[T] v) -> bool {
|
fn all[T](&fn(&T) -> bool f, &vec[T] v) -> bool {
|
||||||
for (T t in v) {
|
for (T t in v) {
|
||||||
if (!f(t)) { ret false; }
|
if (!f(t)) { ret false; }
|
||||||
}
|
}
|
||||||
ret true;
|
ret true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ fn list_dir(str path) -> str[] {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn path_is_absolute(str p) -> bool {
|
fn path_is_absolute(str p) -> bool {
|
||||||
ret str::char_at(p, 0u) == '/'
|
ret str::char_at(p, 0u) == '/'
|
||||||
|| (str::char_at(p, 1u) == ':' && str::char_at(p, 2u) == '\\');
|
|| (str::char_at(p, 1u) == ':' && str::char_at(p, 2u) == '\\');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
extern "C" uint32_t CDECL swap_registers(registers_t *oregs,
|
extern "C" uint32_t CDECL swap_registers(registers_t *oregs,
|
||||||
registers_t *regs)
|
registers_t *regs)
|
||||||
asm ("swap_registers");
|
asm ("swap_registers");
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ class context {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
context();
|
context();
|
||||||
|
|
||||||
context *next;
|
context *next;
|
||||||
|
|
||||||
void swap(context &out);
|
void swap(context &out);
|
||||||
|
|
|
@ -45,6 +45,6 @@ extern "C" {
|
||||||
__FILE__, __LINE__, res, strerror(res)); \
|
__FILE__, __LINE__, res, strerror(res)); \
|
||||||
abort(); \
|
abort(); \
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* GLOBALS_H */
|
#endif /* GLOBALS_H */
|
||||||
|
|
|
@ -76,7 +76,7 @@ void randinit(randctx *ctx, word flag)
|
||||||
mix(a,b,c,d,e,f,g,h);
|
mix(a,b,c,d,e,f,g,h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
/* initialize using the contents of r[] as the seed */
|
/* initialize using the contents of r[] as the seed */
|
||||||
for (i=0; i<RANDSIZ; i+=8)
|
for (i=0; i<RANDSIZ; i+=8)
|
||||||
|
|
|
@ -67,7 +67,7 @@ memory_region::realloc(void *mem, size_t size) {
|
||||||
void *newMem = _srv->realloc(mem, size);
|
void *newMem = _srv->realloc(mem, size);
|
||||||
#ifdef TRACK_ALLOCATIONS
|
#ifdef TRACK_ALLOCATIONS
|
||||||
if (_allocation_list[index] != mem) {
|
if (_allocation_list[index] != mem) {
|
||||||
printf("at index %d, found %p, expected %p\n",
|
printf("at index %d, found %p, expected %p\n",
|
||||||
index, _allocation_list[index], mem);
|
index, _allocation_list[index], mem);
|
||||||
printf("realloc: ptr 0x%" PRIxPTR " is not in allocation_list\n",
|
printf("realloc: ptr 0x%" PRIxPTR " is not in allocation_list\n",
|
||||||
(uintptr_t) mem);
|
(uintptr_t) mem);
|
||||||
|
@ -76,7 +76,7 @@ memory_region::realloc(void *mem, size_t size) {
|
||||||
else {
|
else {
|
||||||
_allocation_list[index] = newMem;
|
_allocation_list[index] = newMem;
|
||||||
(*(int*)newMem) = index;
|
(*(int*)newMem) = index;
|
||||||
// printf("realloc: stored %p at index %d, replacing %p\n",
|
// printf("realloc: stored %p at index %d, replacing %p\n",
|
||||||
// newMem, index, mem);
|
// newMem, index, mem);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -101,7 +101,7 @@ memory_region::malloc(size_t size) {
|
||||||
*p = index;
|
*p = index;
|
||||||
// printf("malloc: stored %p at index %d\n", mem, index);
|
// printf("malloc: stored %p at index %d\n", mem, index);
|
||||||
#endif
|
#endif
|
||||||
// printf("malloc: ptr 0x%" PRIxPTR " region=%p\n",
|
// printf("malloc: ptr 0x%" PRIxPTR " region=%p\n",
|
||||||
// (uintptr_t) mem, this);
|
// (uintptr_t) mem, this);
|
||||||
if (_synchronized) { _lock.unlock(); }
|
if (_synchronized) { _lock.unlock(); }
|
||||||
#ifdef TRACK_ALLOCATIONS
|
#ifdef TRACK_ALLOCATIONS
|
||||||
|
|
|
@ -105,7 +105,7 @@ rust_start(uintptr_t main_fn, int argc, char **argv, void* crate_map) {
|
||||||
rust_kernel *kernel = new rust_kernel(srv);
|
rust_kernel *kernel = new rust_kernel(srv);
|
||||||
kernel->start();
|
kernel->start();
|
||||||
rust_scheduler *sched = kernel->get_scheduler();
|
rust_scheduler *sched = kernel->get_scheduler();
|
||||||
command_line_args *args
|
command_line_args *args
|
||||||
= new (kernel) command_line_args(sched->root_task, argc, argv);
|
= new (kernel) command_line_args(sched->root_task, argc, argv);
|
||||||
|
|
||||||
DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR,
|
DLOG(sched, dom, "startup: %d args in 0x%" PRIxPTR,
|
||||||
|
|
|
@ -83,7 +83,7 @@ rust_getcwd(rust_task *task) {
|
||||||
rust_str *st;
|
rust_str *st;
|
||||||
st = new (mem) rust_str(sched, alloc, fill, (const uint8_t *)cbuf);
|
st = new (mem) rust_str(sched, alloc, fill, (const uint8_t *)cbuf);
|
||||||
|
|
||||||
return st;
|
return st;
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" CDECL
|
extern "C" CDECL
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
*/
|
*/
|
||||||
rust_chan::rust_chan(rust_task *task,
|
rust_chan::rust_chan(rust_task *task,
|
||||||
maybe_proxy<rust_port> *port,
|
maybe_proxy<rust_port> *port,
|
||||||
size_t unit_sz)
|
size_t unit_sz)
|
||||||
: ref_count(1),
|
: ref_count(1),
|
||||||
kernel(task->kernel),
|
kernel(task->kernel),
|
||||||
task(task),
|
task(task),
|
||||||
|
|
|
@ -11,7 +11,7 @@ rust_kernel::rust_kernel(rust_srv *srv) :
|
||||||
_region(&srv->local_region),
|
_region(&srv->local_region),
|
||||||
_log(srv, NULL),
|
_log(srv, NULL),
|
||||||
_srv(srv),
|
_srv(srv),
|
||||||
_interrupt_kernel_loop(FALSE)
|
_interrupt_kernel_loop(FALSE)
|
||||||
{
|
{
|
||||||
sched = create_scheduler("main");
|
sched = create_scheduler("main");
|
||||||
}
|
}
|
||||||
|
@ -245,14 +245,14 @@ rust_kernel::signal_kernel_lock() {
|
||||||
int rust_kernel::start_task_threads(int num_threads)
|
int rust_kernel::start_task_threads(int num_threads)
|
||||||
{
|
{
|
||||||
rust_task_thread *thread = NULL;
|
rust_task_thread *thread = NULL;
|
||||||
|
|
||||||
// -1, because this thread will also be a thread.
|
// -1, because this thread will also be a thread.
|
||||||
for(int i = 0; i < num_threads - 1; ++i) {
|
for(int i = 0; i < num_threads - 1; ++i) {
|
||||||
thread = new rust_task_thread(i + 1, this);
|
thread = new rust_task_thread(i + 1, this);
|
||||||
thread->start();
|
thread->start();
|
||||||
threads.push(thread);
|
threads.push(thread);
|
||||||
}
|
}
|
||||||
|
|
||||||
sched->start_main_loop(0);
|
sched->start_main_loop(0);
|
||||||
|
|
||||||
while(threads.pop(&thread)) {
|
while(threads.pop(&thread)) {
|
||||||
|
|
|
@ -126,10 +126,10 @@ public:
|
||||||
class rust_task_thread : public rust_thread {
|
class rust_task_thread : public rust_thread {
|
||||||
int id;
|
int id;
|
||||||
rust_kernel *owner;
|
rust_kernel *owner;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
rust_task_thread(int id, rust_kernel *owner);
|
rust_task_thread(int id, rust_kernel *owner);
|
||||||
|
|
||||||
virtual void run();
|
virtual void run();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -106,7 +106,7 @@ void data_message::kernel_process() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rust_message_queue::rust_message_queue(rust_srv *srv, rust_kernel *kernel)
|
rust_message_queue::rust_message_queue(rust_srv *srv, rust_kernel *kernel)
|
||||||
: region(srv, true),
|
: region(srv, true),
|
||||||
kernel(kernel),
|
kernel(kernel),
|
||||||
sched_handle(NULL) {
|
sched_handle(NULL) {
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "rust_internal.h"
|
#include "rust_internal.h"
|
||||||
#include "rust_port.h"
|
#include "rust_port.h"
|
||||||
|
|
||||||
rust_port::rust_port(rust_task *task, size_t unit_sz)
|
rust_port::rust_port(rust_task *task, size_t unit_sz)
|
||||||
: maybe_proxy<rust_port>(this), kernel(task->kernel), task(task),
|
: maybe_proxy<rust_port>(this), kernel(task->kernel), task(task),
|
||||||
unit_sz(unit_sz), writers(task), chans(task) {
|
unit_sz(unit_sz), writers(task), chans(task) {
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,7 @@ void task_start_wrapper(spawn_args *a)
|
||||||
a->f(&rval, task, a->a3, a->a4);
|
a->f(&rval, task, a->a3, a->a4);
|
||||||
|
|
||||||
LOG(task, task, "task exited with value %d", rval);
|
LOG(task, task, "task exited with value %d", rval);
|
||||||
|
|
||||||
|
|
||||||
LOG(task, task, "task ref_count: %d", task->ref_count);
|
LOG(task, task, "task ref_count: %d", task->ref_count);
|
||||||
A(task->sched, task->ref_count >= 0,
|
A(task->sched, task->ref_count >= 0,
|
||||||
|
@ -147,7 +147,7 @@ rust_task::start(uintptr_t spawnee_fn,
|
||||||
LOGPTR(sched, "from spawnee", spawnee_fn);
|
LOGPTR(sched, "from spawnee", spawnee_fn);
|
||||||
|
|
||||||
I(sched, stk->data != NULL);
|
I(sched, stk->data != NULL);
|
||||||
|
|
||||||
char *sp = (char *)rust_sp;
|
char *sp = (char *)rust_sp;
|
||||||
|
|
||||||
sp -= sizeof(spawn_args);
|
sp -= sizeof(spawn_args);
|
||||||
|
@ -481,7 +481,7 @@ rust_task::get_handle() {
|
||||||
|
|
||||||
bool rust_task::can_schedule(int id)
|
bool rust_task::can_schedule(int id)
|
||||||
{
|
{
|
||||||
return yield_timer.has_timed_out() &&
|
return yield_timer.has_timed_out() &&
|
||||||
running_on == -1 &&
|
running_on == -1 &&
|
||||||
(pinned_on == -1 || pinned_on == id);
|
(pinned_on == -1 || pinned_on == id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ rust_task : public maybe_proxy<rust_task>,
|
||||||
rust_handle<rust_task> *handle;
|
rust_handle<rust_task> *handle;
|
||||||
|
|
||||||
context ctx;
|
context ctx;
|
||||||
|
|
||||||
// This flag indicates that a worker is either currently running the task
|
// This flag indicates that a worker is either currently running the task
|
||||||
// or is about to run this task.
|
// or is about to run this task.
|
||||||
int running_on;
|
int running_on;
|
||||||
|
|
|
@ -71,7 +71,7 @@ rust_timer::~rust_timer() {
|
||||||
exit_flag = 1;
|
exit_flag = 1;
|
||||||
#if defined(__WIN32__)
|
#if defined(__WIN32__)
|
||||||
sched->kernel->win32_require("WaitForSingleObject",
|
sched->kernel->win32_require("WaitForSingleObject",
|
||||||
WaitForSingleObject(thread, INFINITE) ==
|
WaitForSingleObject(thread, INFINITE) ==
|
||||||
WAIT_OBJECT_0);
|
WAIT_OBJECT_0);
|
||||||
#else
|
#else
|
||||||
pthread_join(thread, NULL);
|
pthread_join(thread, NULL);
|
||||||
|
|
|
@ -192,20 +192,20 @@ upcall_recv(rust_task *task, uintptr_t *dptr, rust_port *port) {
|
||||||
{
|
{
|
||||||
scoped_lock with(port->lock);
|
scoped_lock with(port->lock);
|
||||||
LOG_UPCALL_ENTRY(task);
|
LOG_UPCALL_ENTRY(task);
|
||||||
|
|
||||||
LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR
|
LOG(task, comm, "port: 0x%" PRIxPTR ", dptr: 0x%" PRIxPTR
|
||||||
", size: 0x%" PRIxPTR ", chan_no: %d",
|
", size: 0x%" PRIxPTR ", chan_no: %d",
|
||||||
(uintptr_t) port, (uintptr_t) dptr, port->unit_sz,
|
(uintptr_t) port, (uintptr_t) dptr, port->unit_sz,
|
||||||
port->chans.length());
|
port->chans.length());
|
||||||
|
|
||||||
if (port->receive(dptr)) {
|
if (port->receive(dptr)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// No data was buffered on any incoming channel, so block this task on
|
// No data was buffered on any incoming channel, so block this task on
|
||||||
// the port. Remember the rendezvous location so that any sender task
|
// the port. Remember the rendezvous location so that any sender task
|
||||||
// can write to it before waking up this task.
|
// can write to it before waking up this task.
|
||||||
|
|
||||||
LOG(task, comm, "<=== waiting for rendezvous data ===");
|
LOG(task, comm, "<=== waiting for rendezvous data ===");
|
||||||
task->rendezvous_ptr = dptr;
|
task->rendezvous_ptr = dptr;
|
||||||
task->block(port, "waiting for rendezvous data");
|
task->block(port, "waiting for rendezvous data");
|
||||||
|
@ -351,7 +351,6 @@ rust_str *make_str(rust_task *task, char const *s, size_t fill) {
|
||||||
extern "C" CDECL rust_str *
|
extern "C" CDECL rust_str *
|
||||||
upcall_new_str(rust_task *task, char const *s, size_t fill) {
|
upcall_new_str(rust_task *task, char const *s, size_t fill) {
|
||||||
LOG_UPCALL_ENTRY(task);
|
LOG_UPCALL_ENTRY(task);
|
||||||
|
|
||||||
return make_str(task, s, fill);
|
return make_str(task, s, fill);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -537,7 +536,7 @@ upcall_start_task(rust_task *spawner,
|
||||||
rust_scheduler *sched = spawner->sched;
|
rust_scheduler *sched = spawner->sched;
|
||||||
DLOG(sched, task,
|
DLOG(sched, task,
|
||||||
"upcall start_task(task %s @0x%" PRIxPTR
|
"upcall start_task(task %s @0x%" PRIxPTR
|
||||||
", spawnee 0x%" PRIxPTR ")",
|
", spawnee 0x%" PRIxPTR ")",
|
||||||
task->name, task,
|
task->name, task,
|
||||||
spawnee_fn);
|
spawnee_fn);
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ isaac_init(rust_scheduler *sched, randctx *rctx)
|
||||||
} else {
|
} else {
|
||||||
int fd = open("/dev/urandom", O_RDONLY);
|
int fd = open("/dev/urandom", O_RDONLY);
|
||||||
I(sched, fd > 0);
|
I(sched, fd > 0);
|
||||||
I(sched,
|
I(sched,
|
||||||
read(fd, (void*) &rctx->randrsl, sizeof(rctx->randrsl))
|
read(fd, (void*) &rctx->randrsl, sizeof(rctx->randrsl))
|
||||||
== sizeof(rctx->randrsl));
|
== sizeof(rctx->randrsl));
|
||||||
I(sched, close(fd) == 0);
|
I(sched, close(fd) == 0);
|
||||||
|
@ -175,8 +175,8 @@ rust_vec : public rc_base<rust_vec>
|
||||||
size_t fill;
|
size_t fill;
|
||||||
size_t pad; // Pad to align data[0] to 16 bytes.
|
size_t pad; // Pad to align data[0] to 16 bytes.
|
||||||
uint8_t data[];
|
uint8_t data[];
|
||||||
rust_vec(rust_scheduler *sched, size_t alloc, size_t fill,
|
rust_vec(rust_scheduler *sched, size_t alloc, size_t fill,
|
||||||
uint8_t const *d)
|
uint8_t const *d)
|
||||||
: alloc(alloc),
|
: alloc(alloc),
|
||||||
fill(fill)
|
fill(fill)
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,7 +21,7 @@ lock_and_signal::lock_and_signal() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
lock_and_signal::lock_and_signal()
|
lock_and_signal::lock_and_signal()
|
||||||
: _locked(false)
|
: _locked(false)
|
||||||
{
|
{
|
||||||
CHECKED(pthread_cond_init(&_cond, NULL));
|
CHECKED(pthread_cond_init(&_cond, NULL));
|
||||||
|
|
|
@ -30,7 +30,7 @@ public:
|
||||||
|
|
||||||
class scoped_lock {
|
class scoped_lock {
|
||||||
lock_and_signal &lock;
|
lock_and_signal &lock;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
scoped_lock(lock_and_signal &lock);
|
scoped_lock(lock_and_signal &lock);
|
||||||
~scoped_lock();
|
~scoped_lock();
|
||||||
|
|
|
@ -11,7 +11,7 @@ public:
|
||||||
T oldValue, T newValue) {
|
T oldValue, T newValue) {
|
||||||
return __sync_bool_compare_and_swap(address, oldValue, newValue);
|
return __sync_bool_compare_and_swap(address, oldValue, newValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static T increment(T *address) {
|
static T increment(T *address) {
|
||||||
return __sync_add_and_fetch(address, 1);
|
return __sync_add_and_fetch(address, 1);
|
||||||
|
@ -20,7 +20,7 @@ public:
|
||||||
template <class T>
|
template <class T>
|
||||||
static T decrement(T *address) {
|
static T decrement(T *address) {
|
||||||
return __sync_sub_and_fetch(address, 1);
|
return __sync_sub_and_fetch(address, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
static T increment(T &address) {
|
static T increment(T &address) {
|
||||||
|
@ -30,7 +30,7 @@ public:
|
||||||
template <class T>
|
template <class T>
|
||||||
static T decrement(T &address) {
|
static T decrement(T &address) {
|
||||||
return __sync_sub_and_fetch(&address, 1);
|
return __sync_sub_and_fetch(&address, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,7 +58,7 @@ S 2011-06-15 02018fe
|
||||||
macos-i386 4942eeb8897d75cbdb8cf15bef3b9bc941bc9f34
|
macos-i386 4942eeb8897d75cbdb8cf15bef3b9bc941bc9f34
|
||||||
winnt-i386 b8cf72007bf751062de0802984e7e5a68b66ae61
|
winnt-i386 b8cf72007bf751062de0802984e7e5a68b66ae61
|
||||||
|
|
||||||
S 2011-06-15 92bd350
|
S 2011-06-15 92bd350
|
||||||
linux-i386 145b68488a780623cc31c5e043c6770007273f80
|
linux-i386 145b68488a780623cc31c5e043c6770007273f80
|
||||||
macos-i386 d3149431f12603927bb211f53f8572fc188eb7d2
|
macos-i386 d3149431f12603927bb211f53f8572fc188eb7d2
|
||||||
winnt-i386 8ee37c22195ce180961db1fad013a0743cf97cdd
|
winnt-i386 8ee37c22195ce180961db1fad013a0743cf97cdd
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
||||||
* Implementation of 99 Bottles of Beer
|
* Implementation of 99 Bottles of Beer
|
||||||
* http://99-bottles-of-beer.net/
|
* http://99-bottles-of-beer.net/
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
||||||
* Implementation of 99 Bottles of Beer
|
* Implementation of 99 Bottles of Beer
|
||||||
* http://99-bottles-of-beer.net/
|
* http://99-bottles-of-beer.net/
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
||||||
* Implementation of 99 Bottles of Beer
|
* Implementation of 99 Bottles of Beer
|
||||||
* http://99-bottles-of-beer.net/
|
* http://99-bottles-of-beer.net/
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
/* -*- mode::rust;indent-tabs-mode::nil -*-
|
||||||
* Implementation of 99 Bottles of Beer
|
* Implementation of 99 Bottles of Beer
|
||||||
* http://99-bottles-of-beer.net/
|
* http://99-bottles-of-beer.net/
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -40,10 +40,10 @@ mod NBodySystem {
|
||||||
fn MakeNBodySystem() -> vec[Body::props] {
|
fn MakeNBodySystem() -> vec[Body::props] {
|
||||||
let vec[Body::props] bodies = [
|
let vec[Body::props] bodies = [
|
||||||
// these each return a Body::props
|
// these each return a Body::props
|
||||||
Body::sun(),
|
Body::sun(),
|
||||||
Body::jupiter(),
|
Body::jupiter(),
|
||||||
Body::saturn(),
|
Body::saturn(),
|
||||||
Body::uranus(),
|
Body::uranus(),
|
||||||
Body::neptune()];
|
Body::neptune()];
|
||||||
|
|
||||||
let float px = 0.0;
|
let float px = 0.0;
|
||||||
|
@ -132,7 +132,7 @@ mod NBodySystem {
|
||||||
|
|
||||||
distance = llvm::sqrt(dx*dx + dy*dy + dz*dz);
|
distance = llvm::sqrt(dx*dx + dy*dy + dz*dz);
|
||||||
e -= (bodies.(i).mass * bodies.(j).mass) / distance;
|
e -= (bodies.(i).mass * bodies.(j).mass) / distance;
|
||||||
|
|
||||||
j += 1;
|
j += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -149,12 +149,12 @@ mod Body {
|
||||||
const float SOLAR_MASS = 39.478417604357432; // was 4 * PI * PI originally
|
const float SOLAR_MASS = 39.478417604357432; // was 4 * PI * PI originally
|
||||||
const float DAYS_PER_YEAR = 365.24;
|
const float DAYS_PER_YEAR = 365.24;
|
||||||
|
|
||||||
type props = rec(mutable float x,
|
type props = rec(mutable float x,
|
||||||
mutable float y,
|
mutable float y,
|
||||||
mutable float z,
|
mutable float z,
|
||||||
mutable float vx,
|
mutable float vx,
|
||||||
mutable float vy,
|
mutable float vy,
|
||||||
mutable float vz,
|
mutable float vz,
|
||||||
float mass);
|
float mass);
|
||||||
|
|
||||||
fn jupiter() -> Body::props {
|
fn jupiter() -> Body::props {
|
||||||
|
@ -218,8 +218,8 @@ mod Body {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn offsetMomentum(&Body::props props,
|
fn offsetMomentum(&Body::props props,
|
||||||
float px,
|
float px,
|
||||||
float py,
|
float py,
|
||||||
float pz) -> () {
|
float pz) -> () {
|
||||||
props.vx = -px / SOLAR_MASS;
|
props.vx = -px / SOLAR_MASS;
|
||||||
props.vy = -py / SOLAR_MASS;
|
props.vy = -py / SOLAR_MASS;
|
||||||
|
|
|
@ -27,7 +27,7 @@ fn fib(int n) -> int {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let port[int] p = port();
|
let port[int] p = port();
|
||||||
|
|
||||||
auto t1 = spawn pfib(chan(p), n - 1);
|
auto t1 = spawn pfib(chan(p), n - 1);
|
||||||
auto t2 = spawn pfib(chan(p), n - 2);
|
auto t2 = spawn pfib(chan(p), n - 2);
|
||||||
|
|
||||||
|
@ -58,12 +58,12 @@ fn main(vec[str] argv) {
|
||||||
assert(stop >= start);
|
assert(stop >= start);
|
||||||
|
|
||||||
auto elapsed = stop - start;
|
auto elapsed = stop - start;
|
||||||
auto us_task = elapsed / (fibn as u64) / (1000 as u64);
|
auto us_task = elapsed / (fibn as u64) / (1000 as u64);
|
||||||
|
|
||||||
log_err #fmt("Determined that fib(%d) = %d in %d%d ns (%d us / task)",
|
log_err #fmt("Determined that fib(%d) = %d in %d%d ns (%d us / task)",
|
||||||
n, fibn,
|
n, fibn,
|
||||||
(elapsed / (1000000 as u64)) as int,
|
(elapsed / (1000000 as u64)) as int,
|
||||||
(elapsed % (1000000 as u64)) as int,
|
(elapsed % (1000000 as u64)) as int,
|
||||||
us_task as int);
|
us_task as int);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ fn fib(int n) -> int {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
auto p = port();
|
auto p = port();
|
||||||
|
|
||||||
auto t1 = spawn pfib(chan(p), n - 1);
|
auto t1 = spawn pfib(chan(p), n - 1);
|
||||||
auto t2 = spawn pfib(chan(p), n - 2);
|
auto t2 = spawn pfib(chan(p), n - 2);
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ fn stress(int num_tasks) {
|
||||||
}
|
}
|
||||||
for each(int i in range(0, num_tasks)) {
|
for each(int i in range(0, num_tasks)) {
|
||||||
task::join(tasks.(i));
|
task::join(tasks.(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main(vec[str] argv) {
|
fn main(vec[str] argv) {
|
||||||
|
@ -107,7 +107,7 @@ fn main(vec[str] argv) {
|
||||||
auto num_trials = 10;
|
auto num_trials = 10;
|
||||||
|
|
||||||
auto out = io::stdout();
|
auto out = io::stdout();
|
||||||
|
|
||||||
for each(int n in range(1, max + 1)) {
|
for each(int n in range(1, max + 1)) {
|
||||||
for each(int i in range(0, num_trials)) {
|
for each(int i in range(0, num_trials)) {
|
||||||
auto start = time::precise_time_ns();
|
auto start = time::precise_time_ns();
|
||||||
|
@ -115,8 +115,8 @@ fn main(vec[str] argv) {
|
||||||
auto stop = time::precise_time_ns();
|
auto stop = time::precise_time_ns();
|
||||||
|
|
||||||
auto elapsed = stop - start;
|
auto elapsed = stop - start;
|
||||||
|
|
||||||
out.write_line(#fmt("%d\t%d\t%s", n, fibn,
|
out.write_line(#fmt("%d\t%d\t%s", n, fibn,
|
||||||
u64::str(elapsed)));
|
u64::str(elapsed)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,10 +30,10 @@ mod map_reduce {
|
||||||
type mapper = fn(str, putter);
|
type mapper = fn(str, putter);
|
||||||
|
|
||||||
type getter = fn() -> option[str];
|
type getter = fn() -> option[str];
|
||||||
|
|
||||||
type reducer = fn(str, getter);
|
type reducer = fn(str, getter);
|
||||||
|
|
||||||
|
|
||||||
fn map_reduce (vec[str] inputs,
|
fn map_reduce (vec[str] inputs,
|
||||||
mapper f,
|
mapper f,
|
||||||
reducer reduce) {
|
reducer reduce) {
|
||||||
|
@ -48,7 +48,7 @@ mod map_reduce {
|
||||||
}
|
}
|
||||||
case (none) { }
|
case (none) { }
|
||||||
}
|
}
|
||||||
|
|
||||||
im.insert(key, old + [val]);
|
im.insert(key, old + [val]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ fn main(vec[str] argv) {
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
alt(read_word(f)) {
|
alt(read_word(f)) {
|
||||||
case (some(?w)) {
|
case (some(?w)) {
|
||||||
emit(w, "1");
|
emit(w, "1");
|
||||||
}
|
}
|
||||||
case (none) {
|
case (none) {
|
||||||
|
@ -98,7 +98,7 @@ fn main(vec[str] argv) {
|
||||||
|
|
||||||
fn reduce(str word, map_reduce::getter get) {
|
fn reduce(str word, map_reduce::getter get) {
|
||||||
auto count = 0;
|
auto count = 0;
|
||||||
|
|
||||||
while(true) {
|
while(true) {
|
||||||
alt(get()) {
|
alt(get()) {
|
||||||
case(some(_)) { count += 1 }
|
case(some(_)) { count += 1 }
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
fn echo[T](int c, vec[T] x) {
|
fn echo[T](int c, vec[T] x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let fn(vec[int]) -> () y = bind echo(42, _);
|
let fn(vec[int]) -> () y = bind echo(42, _);
|
||||||
|
|
||||||
y([1]);
|
y([1]);
|
||||||
|
|
|
@ -17,7 +17,7 @@ fn print_even(uint x) : even(x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(uint x) -> () {
|
fn foo(uint x) -> () {
|
||||||
if check(even(x)) {
|
if check(even(x)) {
|
||||||
fail;
|
fail;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
fn g() -> () {}
|
fn g() -> () {}
|
||||||
|
|
||||||
pred f(int q) -> bool {
|
pred f(int q) -> bool {
|
||||||
g();
|
g();
|
||||||
ret true;
|
ret true;
|
||||||
}
|
}
|
||||||
|
@ -11,5 +11,5 @@ pred f(int q) -> bool {
|
||||||
fn main() {
|
fn main() {
|
||||||
auto x = 0;
|
auto x = 0;
|
||||||
|
|
||||||
check f(x);
|
check f(x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
//error-pattern:expanded as an identifier
|
//error-pattern:expanded as an identifier
|
||||||
fn main() {
|
fn main() {
|
||||||
#macro([#mylambda(x, body), {fn f(int x) -> int {ret body}; f}]);
|
#macro([#mylambda(x, body), {fn f(int x) -> int {ret body}; f}]);
|
||||||
|
|
||||||
assert(#mylambda(y*1, y*2)(8) == 16);
|
assert(#mylambda(y*1, y*2)(8) == 16);
|
||||||
}
|
}
|
|
@ -2,6 +2,6 @@
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
#macro([#trivial(), 1*2*4*2*1]);
|
#macro([#trivial(), 1*2*4*2*1]);
|
||||||
|
|
||||||
assert(#trivial(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) == 16);
|
assert(#trivial(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16) == 16);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,5 +17,5 @@ fn main() {
|
||||||
// the next statement, since it's not true in the
|
// the next statement, since it's not true in the
|
||||||
// prestate.
|
// prestate.
|
||||||
auto d <- a;
|
auto d <- a;
|
||||||
log (safe_slice("kitties", b, d));
|
log (safe_slice("kitties", b, d));
|
||||||
}
|
}
|
|
@ -6,5 +6,5 @@ fn f(int q) -> bool { ret true; }
|
||||||
fn main() {
|
fn main() {
|
||||||
auto x = 0;
|
auto x = 0;
|
||||||
|
|
||||||
check f(x);
|
check f(x);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,5 +6,5 @@ pred f(int q) -> bool { ret true; }
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// should fail to typecheck, as pred args must be slot variables or literals
|
// should fail to typecheck, as pred args must be slot variables or literals
|
||||||
check f(42 * 17);
|
check f(42 * 17);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ fn main() {
|
||||||
self();
|
self();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto a = foo;
|
auto a = foo;
|
||||||
a.m();
|
a.m();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,6 @@ fn f(int a) {
|
||||||
log a;
|
log a;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
f(fail "woe");
|
f(fail "woe");
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ pred even(uint x) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(uint x) -> () {
|
fn foo(uint x) -> () {
|
||||||
if check(even(x)) {
|
if check(even(x)) {
|
||||||
log x;
|
log x;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -12,9 +12,9 @@ io fn main() {
|
||||||
i = i - 1;
|
i = i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawned tasks are likely killed before they get a chance to send
|
// Spawned tasks are likely killed before they get a chance to send
|
||||||
// anything back, so we deadlock here.
|
// anything back, so we deadlock here.
|
||||||
|
|
||||||
i = 10;
|
i = 10;
|
||||||
let int value = 0;
|
let int value = 0;
|
||||||
while (i > 0) {
|
while (i > 0) {
|
||||||
|
@ -22,7 +22,7 @@ io fn main() {
|
||||||
po |> value;
|
po |> value;
|
||||||
i = i - 1;
|
i = i - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
log "main thread exiting";
|
log "main thread exiting";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ import std::option::some;
|
||||||
fn foo[T](&option::t[T] y) {
|
fn foo[T](&option::t[T] y) {
|
||||||
let int x;
|
let int x;
|
||||||
let vec[int] rs = [];
|
let vec[int] rs = [];
|
||||||
/* tests that x doesn't get put in the precondition for the
|
/* tests that x doesn't get put in the precondition for the
|
||||||
entire if expression */
|
entire if expression */
|
||||||
|
|
||||||
if (true) {
|
if (true) {
|
||||||
|
|
|
@ -9,5 +9,5 @@ fn main() {
|
||||||
let uint c = 17u;
|
let uint c = 17u;
|
||||||
check le(a, b);
|
check le(a, b);
|
||||||
c <- a;
|
c <- a;
|
||||||
log (safe_slice("kitties", c, b));
|
log (safe_slice("kitties", c, b));
|
||||||
}
|
}
|
|
@ -8,5 +8,5 @@ fn main() {
|
||||||
let uint b = 4u;
|
let uint b = 4u;
|
||||||
check le(a, b);
|
check le(a, b);
|
||||||
auto c <- a;
|
auto c <- a;
|
||||||
log (safe_slice("kitties", c, b));
|
log (safe_slice("kitties", c, b));
|
||||||
}
|
}
|
|
@ -8,5 +8,5 @@ fn main() {
|
||||||
let uint b = 1u;
|
let uint b = 1u;
|
||||||
check le(b, a);
|
check le(b, a);
|
||||||
b <-> a;
|
b <-> a;
|
||||||
log (safe_slice("kitties", a, b));
|
log (safe_slice("kitties", a, b));
|
||||||
}
|
}
|
|
@ -8,5 +8,5 @@ fn main() {
|
||||||
let uint b = 4u;
|
let uint b = 4u;
|
||||||
check le(a, b);
|
check le(a, b);
|
||||||
auto c = b;
|
auto c = b;
|
||||||
log (safe_slice("kitties", a, c));
|
log (safe_slice("kitties", a, c));
|
||||||
}
|
}
|
|
@ -6,5 +6,5 @@ fn main() {
|
||||||
let uint a = 1u;
|
let uint a = 1u;
|
||||||
let uint b = 4u;
|
let uint b = 4u;
|
||||||
check le(a, b);
|
check le(a, b);
|
||||||
log (safe_slice("kitties", a, b));
|
log (safe_slice("kitties", a, b));
|
||||||
}
|
}
|
|
@ -16,7 +16,7 @@ fn print_even(uint x) : even(x) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(uint x) -> () {
|
fn foo(uint x) -> () {
|
||||||
if check(even(x)) {
|
if check(even(x)) {
|
||||||
print_even(x);
|
print_even(x);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -12,7 +12,7 @@ pred even(uint x) -> bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn foo(uint x) -> () {
|
fn foo(uint x) -> () {
|
||||||
if check(even(x)) {
|
if check(even(x)) {
|
||||||
log x;
|
log x;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import a1::b1::word_traveler;
|
import a1::b1::word_traveler;
|
||||||
|
|
||||||
mod a1 { //
|
mod a1 { //
|
||||||
mod b1 { //
|
mod b1 { //
|
||||||
import a2::b1::*; // <-\
|
import a2::b1::*; // <-\
|
||||||
export word_traveler; // |
|
export word_traveler; // |
|
||||||
} // |
|
} // |
|
||||||
mod b2 { // |
|
mod b2 { // |
|
||||||
|
|
|
@ -48,7 +48,7 @@ mod test2 {
|
||||||
//assert(f1() == 1u);
|
//assert(f1() == 1u);
|
||||||
assert(f2() == 2u);
|
assert(f2() == 2u);
|
||||||
assert(f2() == 2u);
|
assert(f2() == 2u);
|
||||||
assert(common() == 2u);
|
assert(common() == 2u);
|
||||||
assert(common() == 2u);
|
assert(common() == 2u);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This is a test case for Issue 507.
|
This is a test case for Issue 507.
|
||||||
|
|
||||||
https://github.com/graydon/rust/issues/507
|
https://github.com/graydon/rust/issues/507
|
||||||
|
@ -22,7 +22,7 @@ fn main() {
|
||||||
let port[int] p = port();
|
let port[int] p = port();
|
||||||
|
|
||||||
auto _child = spawn child(chan(p));
|
auto _child = spawn child(chan(p));
|
||||||
|
|
||||||
let int x;
|
let int x;
|
||||||
p |> x;
|
p |> x;
|
||||||
|
|
||||||
|
|
|
@ -190,7 +190,7 @@ fn main() {
|
||||||
two(17, 42));
|
two(17, 42));
|
||||||
/*
|
/*
|
||||||
* FIXME: Segfault. Also appears to be caused only after upcall_grow_task
|
* FIXME: Segfault. Also appears to be caused only after upcall_grow_task
|
||||||
|
|
||||||
log "*** test parameterized: taggypar[int]";
|
log "*** test parameterized: taggypar[int]";
|
||||||
let eqfn[taggypar[int]] eq4 = taggypareq[int];
|
let eqfn[taggypar[int]] eq4 = taggypareq[int];
|
||||||
test_parameterized[taggypar[int]](eq4,
|
test_parameterized[taggypar[int]](eq4,
|
||||||
|
@ -199,7 +199,7 @@ fn main() {
|
||||||
threepar[int](1, 2, 3),
|
threepar[int](1, 2, 3),
|
||||||
twopar[int](17, 42));
|
twopar[int](17, 42));
|
||||||
log "*** end test parameterized: taggypar[int]";
|
log "*** end test parameterized: taggypar[int]";
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
log "*** test parameterized: reccy";
|
log "*** test parameterized: reccy";
|
||||||
|
|
|
@ -194,7 +194,7 @@ fn test_removal() {
|
||||||
/**
|
/**
|
||||||
* FIXME (issue #150): we want to check the removed value as in the
|
* FIXME (issue #150): we want to check the removed value as in the
|
||||||
* following:
|
* following:
|
||||||
|
|
||||||
let util.option[uint] v = hm.remove(i);
|
let util.option[uint] v = hm.remove(i);
|
||||||
alt (v) {
|
alt (v) {
|
||||||
case (util.some[uint](u)) {
|
case (util.some[uint](u)) {
|
||||||
|
@ -202,7 +202,7 @@ fn test_removal() {
|
||||||
}
|
}
|
||||||
case (util.none[uint]()) { fail; }
|
case (util.none[uint]()) { fail; }
|
||||||
}
|
}
|
||||||
|
|
||||||
* but we util.option is a tag type so util.some and util.none are
|
* but we util.option is a tag type so util.some and util.none are
|
||||||
* off limits until we parse the dwarf for tag types.
|
* off limits until we parse the dwarf for tag types.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
#macro([#mylambda(x,body), {fn f(int x) -> int { ret body }; f}]);
|
#macro([#mylambda(x,body), {fn f(int x) -> int { ret body }; f}]);
|
||||||
|
|
||||||
assert(#mylambda(y,y*2)(8) == 16);
|
assert(#mylambda(y,y*2)(8) == 16);
|
||||||
}
|
}
|
|
@ -1,5 +1,5 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
#macro([#trivial(), 1*2*4*2*1]);
|
#macro([#trivial(), 1*2*4*2*1]);
|
||||||
|
|
||||||
assert(#trivial() == 16);
|
assert(#trivial() == 16);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
fn main() {
|
fn main() {
|
||||||
#macro([#m1(a), a*4]);
|
#macro([#m1(a), a*4]);
|
||||||
assert (#m1(2) == 8);
|
assert (#m1(2) == 8);
|
||||||
}
|
}
|
|
@ -7,8 +7,8 @@ fn main() {
|
||||||
auto my_normal_obj = normal();
|
auto my_normal_obj = normal();
|
||||||
|
|
||||||
// Extending an object with a new method
|
// Extending an object with a new method
|
||||||
auto my_anon_obj = obj {
|
auto my_anon_obj = obj {
|
||||||
fn bar() -> int {
|
fn bar() -> int {
|
||||||
ret 3;
|
ret 3;
|
||||||
}
|
}
|
||||||
with my_normal_obj
|
with my_normal_obj
|
||||||
|
|
|
@ -13,7 +13,7 @@ fn child(int i1,
|
||||||
int i6,
|
int i6,
|
||||||
int i7,
|
int i7,
|
||||||
int i8,
|
int i8,
|
||||||
int i9)
|
int i9)
|
||||||
{
|
{
|
||||||
log_err i1;
|
log_err i1;
|
||||||
log_err i2;
|
log_err i2;
|
||||||
|
|
|
@ -14,7 +14,7 @@ fn main() {
|
||||||
|
|
||||||
test(#fmt("test"), "test");
|
test(#fmt("test"), "test");
|
||||||
|
|
||||||
// a quadratic optimization in LLVM (jump-threading) makes this test a
|
// a quadratic optimization in LLVM (jump-threading) makes this test a
|
||||||
// bit slow to compile unless we break it up
|
// bit slow to compile unless we break it up
|
||||||
part1();
|
part1();
|
||||||
part2();
|
part2();
|
||||||
|
@ -133,10 +133,10 @@ fn part4() {
|
||||||
// conversions support precision - it's not standard printf so we
|
// conversions support precision - it's not standard printf so we
|
||||||
// can do whatever. For now I'm making it behave the same as string
|
// can do whatever. For now I'm making it behave the same as string
|
||||||
// conversions.
|
// conversions.
|
||||||
|
|
||||||
test(#fmt("%.b", true), "");
|
test(#fmt("%.b", true), "");
|
||||||
test(#fmt("%.0b", true), "");
|
test(#fmt("%.0b", true), "");
|
||||||
test(#fmt("%.1b", true), "t");
|
test(#fmt("%.1b", true), "t");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn part5() {
|
fn part5() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ use std;
|
||||||
import std::task::join;
|
import std::task::join;
|
||||||
|
|
||||||
fn main() -> () {
|
fn main() -> () {
|
||||||
test00();
|
test00();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn start() {
|
fn start() {
|
||||||
|
|
|
@ -10,16 +10,16 @@ fn main() -> () {
|
||||||
fn start(int task_number) {
|
fn start(int task_number) {
|
||||||
log "Started / Finished task.";
|
log "Started / Finished task.";
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test00() {
|
fn test00() {
|
||||||
let int i = 0;
|
let int i = 0;
|
||||||
let task t = spawn start(i);
|
let task t = spawn start(i);
|
||||||
|
|
||||||
// Sleep long enough for the task to finish.
|
// Sleep long enough for the task to finish.
|
||||||
task::sleep(10000u);
|
task::sleep(10000u);
|
||||||
|
|
||||||
// Try joining tasks that have already finished.
|
// Try joining tasks that have already finished.
|
||||||
task::join(t);
|
task::join(t);
|
||||||
|
|
||||||
log "Joined task.";
|
log "Joined task.";
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ fn start(chan[int] c, int start, int number_of_messages) {
|
||||||
while (i < number_of_messages) {
|
while (i < number_of_messages) {
|
||||||
c <| start + i;
|
c <| start + i;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() -> () {
|
fn main() -> () {
|
||||||
|
|
|
@ -4,7 +4,7 @@ use std;
|
||||||
|
|
||||||
import std::task;
|
import std::task;
|
||||||
|
|
||||||
fn main() -> () {
|
fn main() -> () {
|
||||||
log "===== SPAWNING and JOINING THREAD TASKS =====";
|
log "===== SPAWNING and JOINING THREAD TASKS =====";
|
||||||
test00();
|
test00();
|
||||||
}
|
}
|
||||||
|
@ -17,20 +17,20 @@ fn start(int task_number) {
|
||||||
}
|
}
|
||||||
log "Finished task.";
|
log "Finished task.";
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test00() {
|
fn test00() {
|
||||||
let int number_of_tasks = 8;
|
let int number_of_tasks = 8;
|
||||||
|
|
||||||
let int i = 0;
|
let int i = 0;
|
||||||
let vec[task] tasks = [];
|
let vec[task] tasks = [];
|
||||||
while (i < number_of_tasks) {
|
while (i < number_of_tasks) {
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
tasks += [spawn start(i)];
|
tasks += [spawn start(i)];
|
||||||
}
|
}
|
||||||
|
|
||||||
for (task t in tasks) {
|
for (task t in tasks) {
|
||||||
task::join(t);
|
task::join(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
log "Joined all task.";
|
log "Joined all task.";
|
||||||
}
|
}
|
|
@ -22,21 +22,21 @@ fn test00_start(chan[int] ch, int message, int count) {
|
||||||
fn test00() {
|
fn test00() {
|
||||||
let int number_of_tasks = 16;
|
let int number_of_tasks = 16;
|
||||||
let int number_of_messages = 4;
|
let int number_of_messages = 4;
|
||||||
|
|
||||||
log "Creating tasks";
|
log "Creating tasks";
|
||||||
|
|
||||||
let port[int] po = port();
|
let port[int] po = port();
|
||||||
let chan[int] ch = chan(po);
|
let chan[int] ch = chan(po);
|
||||||
|
|
||||||
let int i = 0;
|
let int i = 0;
|
||||||
|
|
||||||
// Create and spawn tasks...
|
// Create and spawn tasks...
|
||||||
let vec[task] tasks = [];
|
let vec[task] tasks = [];
|
||||||
while (i < number_of_tasks) {
|
while (i < number_of_tasks) {
|
||||||
tasks += [spawn test00_start(ch, i, number_of_messages)];
|
tasks += [spawn test00_start(ch, i, number_of_messages)];
|
||||||
i = i + 1;
|
i = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read from spawned tasks...
|
// Read from spawned tasks...
|
||||||
let int sum = 0;
|
let int sum = 0;
|
||||||
for (task t in tasks) {
|
for (task t in tasks) {
|
||||||
|
@ -52,9 +52,9 @@ fn test00() {
|
||||||
for (task t in tasks) {
|
for (task t in tasks) {
|
||||||
task::join(t);
|
task::join(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
log "Completed: Final number is: ";
|
log "Completed: Final number is: ";
|
||||||
// assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) *
|
// assert (sum == (((number_of_tasks * (number_of_tasks - 1)) / 2) *
|
||||||
// number_of_messages));
|
// number_of_messages));
|
||||||
assert (sum == 480);
|
assert (sum == 480);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ fn test00() {
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
assert (sum == 1998000);
|
assert (sum == 1998000);
|
||||||
// assert (sum == 4 * ((number_of_messages *
|
// assert (sum == 4 * ((number_of_messages *
|
||||||
// (number_of_messages - 1)) / 2));
|
// (number_of_messages - 1)) / 2));
|
||||||
|
|
||||||
}
|
}
|
|
@ -12,24 +12,24 @@ fn test00_start(chan[int] c, int start, int number_of_messages) {
|
||||||
while (i < number_of_messages) {
|
while (i < number_of_messages) {
|
||||||
c <| start + i;
|
c <| start + i;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test00() {
|
fn test00() {
|
||||||
let int r = 0;
|
let int r = 0;
|
||||||
let int sum = 0;
|
let int sum = 0;
|
||||||
let port[int] p = port();
|
let port[int] p = port();
|
||||||
let int number_of_messages = 10;
|
let int number_of_messages = 10;
|
||||||
|
|
||||||
let task t0 = spawn test00_start(chan(p),
|
let task t0 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 0, number_of_messages);
|
number_of_messages * 0, number_of_messages);
|
||||||
let task t1 = spawn test00_start(chan(p),
|
let task t1 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 1, number_of_messages);
|
number_of_messages * 1, number_of_messages);
|
||||||
let task t2 = spawn test00_start(chan(p),
|
let task t2 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 2, number_of_messages);
|
number_of_messages * 2, number_of_messages);
|
||||||
let task t3 = spawn test00_start(chan(p),
|
let task t3 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 3, number_of_messages);
|
number_of_messages * 3, number_of_messages);
|
||||||
|
|
||||||
let int i = 0;
|
let int i = 0;
|
||||||
while (i < number_of_messages) {
|
while (i < number_of_messages) {
|
||||||
p |> r; sum += r;
|
p |> r; sum += r;
|
||||||
|
@ -38,12 +38,12 @@ fn test00() {
|
||||||
p |> r; sum += r;
|
p |> r; sum += r;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
task::join(t0);
|
task::join(t0);
|
||||||
task::join(t1);
|
task::join(t1);
|
||||||
task::join(t2);
|
task::join(t2);
|
||||||
task::join(t3);
|
task::join(t3);
|
||||||
|
|
||||||
assert (sum == (((number_of_messages * 4) *
|
assert (sum == (((number_of_messages * 4) *
|
||||||
((number_of_messages * 4) - 1)) / 2));
|
((number_of_messages * 4) - 1)) / 2));
|
||||||
}
|
}
|
|
@ -12,24 +12,24 @@ fn test00_start(chan[int] c, int start, int number_of_messages) {
|
||||||
while (i < number_of_messages) {
|
while (i < number_of_messages) {
|
||||||
c <| start + i;
|
c <| start + i;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test00() {
|
fn test00() {
|
||||||
let int r = 0;
|
let int r = 0;
|
||||||
let int sum = 0;
|
let int sum = 0;
|
||||||
let port[int] p = port();
|
let port[int] p = port();
|
||||||
let int number_of_messages = 10;
|
let int number_of_messages = 10;
|
||||||
|
|
||||||
let task t0 = spawn test00_start(chan(p),
|
let task t0 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 0, number_of_messages);
|
number_of_messages * 0, number_of_messages);
|
||||||
let task t1 = spawn test00_start(chan(p),
|
let task t1 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 1, number_of_messages);
|
number_of_messages * 1, number_of_messages);
|
||||||
let task t2 = spawn test00_start(chan(p),
|
let task t2 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 2, number_of_messages);
|
number_of_messages * 2, number_of_messages);
|
||||||
let task t3 = spawn test00_start(chan(p),
|
let task t3 = spawn test00_start(chan(p),
|
||||||
number_of_messages * 3, number_of_messages);
|
number_of_messages * 3, number_of_messages);
|
||||||
|
|
||||||
let int i = 0;
|
let int i = 0;
|
||||||
while (i < number_of_messages) {
|
while (i < number_of_messages) {
|
||||||
p |> r; sum += r;
|
p |> r; sum += r;
|
||||||
|
@ -38,12 +38,12 @@ fn test00() {
|
||||||
p |> r; sum += r;
|
p |> r; sum += r;
|
||||||
i += 1;
|
i += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
task::join(t0);
|
task::join(t0);
|
||||||
task::join(t1);
|
task::join(t1);
|
||||||
task::join(t2);
|
task::join(t2);
|
||||||
task::join(t3);
|
task::join(t3);
|
||||||
|
|
||||||
assert (sum == (((number_of_messages * 4) *
|
assert (sum == (((number_of_messages * 4) *
|
||||||
((number_of_messages * 4) - 1)) / 2));
|
((number_of_messages * 4) - 1)) / 2));
|
||||||
}
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Reference in a new issue