Skip to content

Commit 34ae491

Browse files
committed
Store arg mode and objfield mutability in their def
1 parent 9ba3fe5 commit 34ae491

File tree

10 files changed

+43
-43
lines changed

10 files changed

+43
-43
lines changed

src/comp/middle/alias.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ fn check_move_rhs(cx: &@ctx, src: &@ast::expr, sc: &scope, v: &vt<scope>) {
481481
alt src.node {
482482
ast::expr_path(p) {
483483
alt cx.tcx.def_map.get(src.id) {
484-
ast::def_obj_field(_) {
484+
ast::def_obj_field(_, _) {
485485
cx.tcx.sess.span_err(src.span,
486486
~"may not move out of an obj field");
487487
}
@@ -743,10 +743,10 @@ fn ty_can_unsafely_include(cx: &ctx, needle: ty::t, haystack: ty::t,
743743

744744
fn def_is_local(d: &ast::def, objfields_count: bool) -> bool {
745745
ret alt d {
746-
ast::def_local(_) | ast::def_arg(_) | ast::def_binding(_) { true }
747-
ast::def_obj_field(_) { objfields_count }
748-
_ { false }
749-
};
746+
ast::def_local(_) | ast::def_arg(_, _) | ast::def_binding(_) { true }
747+
ast::def_obj_field(_, _) { objfields_count }
748+
_ { false }
749+
};
750750
}
751751

752752
fn fty_args(cx: &ctx, fty: ty::t) -> [ty::arg] {

src/comp/middle/freevars.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ fn collect_freevars(def_map: &resolve::def_map, sess: &session::session,
6060
~"internal error in collect_freevars");
6161
}
6262
alt def_map.get(expr.id) {
63-
ast::def_arg(did) { *refs += [expr.id]; }
63+
ast::def_arg(did, _) { *refs += [expr.id]; }
6464
ast::def_local(did) { *refs += [expr.id]; }
6565
ast::def_binding(did) { *refs += [expr.id]; }
6666
_ {/* no-op */ }

src/comp/middle/resolve.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -624,13 +624,13 @@ fn scope_is_fn(sc: &scope) -> bool {
624624

625625
fn def_is_local(d: &def) -> bool {
626626
ret alt d {
627-
ast::def_arg(_) | ast::def_local(_) | ast::def_binding(_) { true }
628-
_ { false }
629-
};
627+
ast::def_arg(_, _) | ast::def_local(_) | ast::def_binding(_) { true }
628+
_ { false }
629+
};
630630
}
631631

632632
fn def_is_obj_field(d: &def) -> bool {
633-
ret alt d { ast::def_obj_field(_) { true } _ { false } };
633+
ret alt d { ast::def_obj_field(_, _) { true } _ { false } };
634634
}
635635

636636
fn def_is_ty_arg(d: &def) -> bool {
@@ -764,7 +764,7 @@ fn lookup_in_fn(name: &ident, decl: &ast::fn_decl,
764764
ns_value. {
765765
for a: ast::arg in decl.inputs {
766766
if istr::eq(a.ident, name) {
767-
ret some(ast::def_arg(local_def(a.id)));
767+
ret some(ast::def_arg(local_def(a.id), a.mode));
768768
}
769769
}
770770
ret none::<def>;
@@ -780,7 +780,7 @@ fn lookup_in_obj(name: &ident, ob: &ast::_obj, ty_params: &[ast::ty_param],
780780
ns_value. {
781781
for f: ast::obj_field in ob.fields {
782782
if istr::eq(f.ident, name) {
783-
ret some(ast::def_obj_field(local_def(f.id)));
783+
ret some(ast::def_obj_field(local_def(f.id), f.mut));
784784
}
785785
}
786786
ret none::<def>;
@@ -1170,19 +1170,19 @@ fn index_nmod(md: &ast::native_mod) -> mod_index {
11701170
// External lookups
11711171
fn ns_for_def(d: def) -> namespace {
11721172
ret alt d {
1173-
ast::def_fn(id, _) { ns_value }
1174-
ast::def_obj_field(id) { ns_value }
1175-
ast::def_mod(id) { ns_module }
1176-
ast::def_native_mod(id) { ns_module }
1177-
ast::def_const(id) { ns_value }
1178-
ast::def_arg(id) { ns_value }
1179-
ast::def_local(id) { ns_value }
1180-
ast::def_variant(_, id) { ns_value }
1181-
ast::def_ty(id) { ns_type }
1182-
ast::def_binding(id) { ns_type }
1183-
ast::def_use(id) { ns_module }
1184-
ast::def_native_ty(id) { ns_type }
1185-
ast::def_native_fn(id) { ns_value }
1173+
ast::def_fn(_, _) { ns_value }
1174+
ast::def_obj_field(_, _) { ns_value }
1175+
ast::def_mod(_) { ns_module }
1176+
ast::def_native_mod(_) { ns_module }
1177+
ast::def_const(_) { ns_value }
1178+
ast::def_arg(_, _) { ns_value }
1179+
ast::def_local(_) { ns_value }
1180+
ast::def_variant(_, _) { ns_value }
1181+
ast::def_ty(_) { ns_type }
1182+
ast::def_binding(_) { ns_type }
1183+
ast::def_use(_) { ns_module }
1184+
ast::def_native_ty(_) { ns_type }
1185+
ast::def_native_fn(_) { ns_value }
11861186
};
11871187
}
11881188

src/comp/middle/trans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3141,7 +3141,7 @@ fn trans_var(cx: &@block_ctxt, sp: &span, id: ast::node_id) -> lval_result {
31413141
assert (cx.fcx.llupvars.contains_key(did.node));
31423142
ret lval_mem(cx, cx.fcx.llupvars.get(did.node));
31433143
}
3144-
some(ast::def_arg(did)) {
3144+
some(ast::def_arg(did, _)) {
31453145
assert (cx.fcx.llargs.contains_key(did.node));
31463146
ret lval_mem(cx, cx.fcx.llargs.get(did.node));
31473147
}
@@ -3153,7 +3153,7 @@ fn trans_var(cx: &@block_ctxt, sp: &span, id: ast::node_id) -> lval_result {
31533153
assert (cx.fcx.lllocals.contains_key(did.node));
31543154
ret lval_mem(cx, cx.fcx.lllocals.get(did.node));
31553155
}
3156-
some(ast::def_obj_field(did)) {
3156+
some(ast::def_obj_field(did, _)) {
31573157
assert (cx.fcx.llobjfields.contains_key(did.node));
31583158
ret lval_mem(cx, cx.fcx.llobjfields.get(did.node));
31593159
}

src/comp/middle/tstate/auxiliary.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ fn expr_to_constr_arg(tcx: ty::ctxt, e: &@expr) -> @constr_arg_use {
625625
carg_ident({ident: p.node.idents[0],
626626
node: l_id.node}));
627627
}
628-
some(def_arg(a_id)) {
628+
some(def_arg(a_id, _)) {
629629
ret @respan(p.span,
630630
carg_ident({ident: p.node.idents[0],
631631
node: a_id.node}));
@@ -849,7 +849,7 @@ fn local_node_id_to_def_id_strict(fcx: &fn_ctxt, sp: &span, i: &node_id) ->
849849
def_id {
850850
alt local_node_id_to_def(fcx, i) {
851851
some(def_local(d_id)) { ret d_id; }
852-
some(def_arg(a_id)) { ret a_id; }
852+
some(def_arg(a_id, _)) { ret a_id; }
853853
some(_) {
854854
fcx.ccx.tcx.sess.span_fatal(sp,
855855
~"local_node_id_to_def_id: id \
@@ -871,7 +871,7 @@ fn local_node_id_to_def(fcx: &fn_ctxt, i: &node_id) -> option::t<def> {
871871
fn local_node_id_to_def_id(fcx: &fn_ctxt, i: &node_id) -> option::t<def_id> {
872872
alt local_node_id_to_def(fcx, i) {
873873
some(def_local(d_id)) { some(d_id) }
874-
some(def_arg(a_id)) { some(a_id) }
874+
some(def_arg(a_id, _)) { some(a_id) }
875875
_ { none }
876876
}
877877
}
@@ -880,7 +880,7 @@ fn local_node_id_to_local_def_id(fcx: &fn_ctxt, i: &node_id) ->
880880
option::t<node_id> {
881881
alt local_node_id_to_def(fcx, i) {
882882
some(def_local(d_id)) { some(d_id.node) }
883-
some(def_arg(a_id)) { some(a_id.node) }
883+
some(def_arg(a_id, _)) { some(a_id.node) }
884884
_ { none }
885885
}
886886
}

src/comp/middle/tstate/pre_post_conditions.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ fn handle_update(fcx: &fn_ctxt, parent: &@expr, lhs: &@expr, rhs: &@expr,
295295
fn handle_var(fcx: &fn_ctxt, rslt: &pre_and_post, id: node_id, name: ident) {
296296
let df = node_id_to_def_upvar_strict(fcx, id);
297297
alt df {
298-
def_local(d_id) | def_arg(d_id) {
298+
def_local(d_id) | def_arg(d_id, _) {
299299
let i = bit_num(fcx, ninit(d_id.node, name));
300300
use_var(fcx, d_id.node);
301301
require_and_preserve(i, rslt);

src/comp/middle/ty.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2600,10 +2600,10 @@ fn substitute_type_params(cx: &ctxt, substs: &[ty::t], typ: t) -> t {
26002600
fn def_has_ty_params(def: &ast::def) -> bool {
26012601
alt def {
26022602
ast::def_fn(_, _) { ret true; }
2603-
ast::def_obj_field(_) { ret false; }
2603+
ast::def_obj_field(_, _) { ret false; }
26042604
ast::def_mod(_) { ret false; }
26052605
ast::def_const(_) { ret false; }
2606-
ast::def_arg(_) { ret false; }
2606+
ast::def_arg(_, _) { ret false; }
26072607
ast::def_local(_) { ret false; }
26082608
ast::def_variant(_, _) { ret true; }
26092609
ast::def_ty(_) { ret false; }

src/comp/middle/typeck.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -116,8 +116,7 @@ fn ty_param_kinds_and_ty_for_def(fcx: &@fn_ctxt, sp: &span, defn: &ast::def)
116116
-> ty_param_kinds_and_ty {
117117
let no_kinds: [ast::kind] = [];
118118
alt defn {
119-
ast::def_arg(id) {
120-
119+
ast::def_arg(id, _) {
121120
assert (fcx.locals.contains_key(id.node));
122121
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
123122
ret {kinds: no_kinds, ty: typ};
@@ -127,7 +126,7 @@ fn ty_param_kinds_and_ty_for_def(fcx: &@fn_ctxt, sp: &span, defn: &ast::def)
127126
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
128127
ret {kinds: no_kinds, ty: typ};
129128
}
130-
ast::def_obj_field(id) {
129+
ast::def_obj_field(id, _) {
131130
assert (fcx.locals.contains_key(id.node));
132131
let typ = ty::mk_var(fcx.ccx.tcx, lookup_local(fcx, sp, id.node));
133132
ret {kinds: no_kinds, ty: typ};
@@ -2642,8 +2641,9 @@ fn check_constraints(fcx: &@fn_ctxt, cs: [@ast::constr], args:[ast::arg]) {
26422641
that's my justification.
26432642
*/
26442643
let arg_occ_node_id = fcx.ccx.tcx.sess.next_node_id();
2645-
fcx.ccx.tcx.def_map.insert(arg_occ_node_id,
2646-
ast::def_arg(local_def(args[i].id)));
2644+
fcx.ccx.tcx.def_map.insert
2645+
(arg_occ_node_id, ast::def_arg(local_def(args[i].id),
2646+
args[i].mode));
26472647
{id:arg_occ_node_id,
26482648
node: ast::expr_path(respan(a.span, p)),
26492649
span:a.span}

src/comp/syntax/ast.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ type ty_param = {ident: ident, kind: kind};
2929

3030
tag def {
3131
def_fn(def_id, purity);
32-
def_obj_field(def_id);
32+
def_obj_field(def_id, mutability);
3333
def_mod(def_id);
3434
def_native_mod(def_id);
3535
def_const(def_id);
36-
def_arg(def_id);
36+
def_arg(def_id, mode);
3737
def_local(def_id);
3838
def_variant(def_id, /* tag */def_id);
3939

src/comp/syntax/ast_util.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ fn variant_def_ids(d: &def) -> {tg: def_id, var: def_id} {
2929
fn def_id_of_def(d: def) -> def_id {
3030
alt d {
3131
def_fn(id, _) { ret id; }
32-
def_obj_field(id) { ret id; }
32+
def_obj_field(id, _) { ret id; }
3333
def_mod(id) { ret id; }
3434
def_native_mod(id) { ret id; }
3535
def_const(id) { ret id; }
36-
def_arg(id) { ret id; }
36+
def_arg(id, _) { ret id; }
3737
def_local(id) { ret id; }
3838
def_variant(_, id) { ret id; }
3939
def_ty(id) { ret id; }

0 commit comments

Comments
 (0)