Skip to content

Commit c2945ee

Browse files
committed
---
yaml --- r: 3611 b: refs/heads/master c: b9a2117 h: refs/heads/master i: 3609: ac6f445 3607: 392b25a v: v3
1 parent 787c57e commit c2945ee

File tree

8 files changed

+57
-19
lines changed

8 files changed

+57
-19
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 0eb889f9d2512c60a8edbf2a3f06049191c07d93
2+
refs/heads/master: b9a2117475be082b2f93bbcb836b1f05ea52b5e2

trunk/src/comp/metadata/tydecode.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn parse_path(@pstate st, str_def sd) -> ast::path {
103103
}
104104

105105
fn parse_constr(@pstate st, str_def sd) -> @ty::constr_def {
106-
let vec[@ast::constr_arg] args = [];
106+
let (@ast::constr_arg)[] args = ~[];
107107
auto sp = rec(lo=0u,hi=0u); // FIXME: use a real span
108108
let ast::path pth = parse_path(st, sd);
109109
let char ignore = next(st) as char;
@@ -113,14 +113,15 @@ fn parse_constr(@pstate st, str_def sd) -> @ty::constr_def {
113113
alt (peek(st) as char) {
114114
case ('*') {
115115
st.pos += 1u;
116-
args += [@respan(sp, ast::carg_base)];
116+
args += ~[@respan(sp, ast::carg_base)];
117117
}
118118
case (?c) {
119119
/* how will we disambiguate between
120120
an arg index and a lit argument? */
121121
if (c >= '0' && c <= '9') {
122122
// FIXME
123-
args += [@respan(sp, ast::carg_ident((c as uint) - 48u))];
123+
args += ~[@respan(sp,
124+
ast::carg_ident((c as uint) - 48u))];
124125
ignore = next(st) as char;
125126
}
126127
else {

trunk/src/comp/middle/resolve.rs

+10-4
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ fn resolve_crate(session sess, &ast_map::map amap, @ast::crate crate) ->
138138
auto e =
139139
@rec(crate_map=new_int_hash[ast::crate_num](),
140140
def_map=new_int_hash[def](),
141-
fn_constrs = new_int_hash[vec[ty::constr_def]](),
141+
fn_constrs = new_int_hash[ty::constr_def[]](),
142142
ast_map=amap,
143143
imports=new_int_hash[import_state](),
144144
mod_map=new_int_hash[@indexed_mod](),
@@ -416,8 +416,14 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc,
416416
if (option::is_some(new_def)) {
417417
alt (option::get(new_def)) {
418418
case (ast::def_fn(?pred_id, ast::pure_fn)) {
419+
// FIXME: Remove this vec->ivec conversion.
420+
let (@ast::constr_arg_general[uint])[] cag_ivec = ~[];
421+
for (@ast::constr_arg_general[uint] cag in c.node.args) {
422+
cag_ivec += ~[cag];
423+
}
424+
419425
let ty::constr_general[uint] c_ =
420-
rec(path=c.node.path, args=c.node.args, id=pred_id);
426+
rec(path=c.node.path, args=cag_ivec, id=pred_id);
421427
let ty::constr_def new_constr = respan(c.span, c_);
422428
add_constr(e, id, new_constr);
423429
}
@@ -433,8 +439,8 @@ fn resolve_constr(@env e, node_id id, &@ast::constr c, &scopes sc,
433439
fn add_constr(&@env e, node_id id, &ty::constr_def c) {
434440
e.fn_constrs.insert(id,
435441
alt (e.fn_constrs.find(id)) {
436-
case (none) { [c] }
437-
case (some(?cs)) { cs + [c] }
442+
case (none) { ~[c] }
443+
case (some(?cs)) { cs + ~[c] }
438444
});
439445
}
440446

trunk/src/comp/middle/tstate/auxiliary.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,7 @@ fn constraints(&fn_ctxt fcx) -> vec[norm_constraint] {
504504
ret rslt;
505505
}
506506

507-
fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, vec[@constr_arg_use] occ) ->
507+
fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, &(@constr_arg_use)[] occ) ->
508508
uint {
509509
log "match_args: looking at " +
510510
constr_args_to_str(std::util::fst[ident, def_id], occ);
@@ -513,7 +513,13 @@ fn match_args(&fn_ctxt fcx, vec[pred_desc] occs, vec[@constr_arg_use] occ) ->
513513
fn eq(&tup(ident, def_id) p, &tup(ident, def_id) q) -> bool {
514514
ret p._1 == q._1;
515515
}
516-
if (ty::args_eq(eq, pd.node.args, occ)) { ret pd.node.bit_num; }
516+
517+
// FIXME: Remove this vec->ivec conversion.
518+
let (@constr_arg_use)[] cau_ivec = ~[];
519+
for (@constr_arg_use cau in pd.node.args) {
520+
cau_ivec += ~[cau];
521+
}
522+
if (ty::args_eq(eq, cau_ivec, occ)) { ret pd.node.bit_num; }
517523
}
518524
fcx.ccx.tcx.sess.bug("match_args: no match for occurring args");
519525
}
@@ -593,8 +599,14 @@ fn expr_to_constr(ty::ctxt tcx, &@expr e) -> constr {
593599
}
594600

595601
fn pred_desc_to_str(&pred_desc p) -> str {
602+
// FIXME: Remove this vec->ivec conversion.
603+
let (@constr_arg_use)[] cau_ivec = ~[];
604+
for (@constr_arg_use cau in p.node.args) {
605+
cau_ivec += ~[cau];
606+
}
607+
596608
ret "<" + uint::str(p.node.bit_num) + ", " +
597-
constr_args_to_str(std::util::fst[ident, def_id], p.node.args) + ">";
609+
constr_args_to_str(std::util::fst[ident, def_id], cau_ivec) + ">";
598610
}
599611

600612
fn substitute_constr_args(&ty::ctxt cx, &vec[@expr] actuals,

trunk/src/comp/middle/tstate/bitvectors.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import std::option::*;
55
import std::vec;
66
import std::vec::len;
77
import std::vec::slice;
8+
import aux::constr_arg_use;
89
import aux::local_node_id_to_def;
910
import aux::fn_ctxt;
1011
import aux::fn_info;
@@ -63,7 +64,14 @@ fn bit_num(&fn_ctxt fcx, &constr_ c) -> uint {
6364
}
6465
case (npred(_, ?args)) {
6566
alt (rslt) {
66-
case (cpred(_, ?descs)) { ret match_args(fcx, *descs, args); }
67+
case (cpred(_, ?descs)) {
68+
// FIXME: Remove this vec->ivec conversion.
69+
let (@constr_arg_use)[] cau_ivec = ~[];
70+
for (@constr_arg_use cau in args) {
71+
cau_ivec += ~[cau];
72+
}
73+
ret match_args(fcx, *descs, cau_ivec);
74+
}
6775
case (_) {
6876
fcx.ccx.tcx.sess.bug("bit_num: asked for pred constraint,"
6977
+ " found an init constraint");

trunk/src/comp/middle/ty.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ type method =
198198
controlflow cf,
199199
(@constr_def)[] constrs);
200200

201-
type constr_table = hashmap[ast::node_id, vec[constr_def]];
201+
type constr_table = hashmap[ast::node_id, constr_def[]];
202202

203203
type mt = rec(t ty, ast::mutability mut);
204204

@@ -281,7 +281,7 @@ tag sty {
281281
type constr_def = spanned[constr_general[uint]];
282282

283283
type constr_general[T] =
284-
rec(ast::path path, vec[@constr_arg_general[T]] args, def_id id);
284+
rec(ast::path path, (@constr_arg_general[T])[] args, def_id id);
285285

286286

287287
// Data structures used in type unification
@@ -1438,8 +1438,8 @@ fn arg_eq[T](&fn(&T, &T) -> bool eq, @ast::constr_arg_general[T] a,
14381438
}
14391439
}
14401440

1441-
fn args_eq[T](fn(&T, &T) -> bool eq, vec[@ast::constr_arg_general[T]] a,
1442-
vec[@ast::constr_arg_general[T]] b) -> bool {
1441+
fn args_eq[T](fn(&T, &T) -> bool eq, &(@ast::constr_arg_general[T])[] a,
1442+
&(@ast::constr_arg_general[T])[] b) -> bool {
14431443
let uint i = 0u;
14441444
for (@ast::constr_arg_general[T] arg in a) {
14451445
if (!arg_eq(eq, arg, b.(i))) { ret false; }

trunk/src/comp/middle/typeck.rs

+7-1
Original file line numberDiff line numberDiff line change
@@ -2355,7 +2355,13 @@ fn ast_constr_to_constr(ty::ctxt tcx, &@ast::constr c)
23552355
-> @ty::constr_def {
23562356
alt (tcx.def_map.find(c.node.id)) {
23572357
case (some(ast::def_fn(?pred_id, ast::pure_fn))) {
2358-
ret @respan(c.span, rec(path=c.node.path, args=c.node.args,
2358+
// FIXME: Remove this vec->ivec conversion.
2359+
let (@ast::constr_arg_general[uint])[] cag_ivec = ~[];
2360+
for (@ast::constr_arg_general[uint] cag in c.node.args) {
2361+
cag_ivec += ~[cag];
2362+
}
2363+
2364+
ret @respan(c.span, rec(path=c.node.path, args=cag_ivec,
23592365
id=pred_id));
23602366
}
23612367
case (_) {

trunk/src/comp/syntax/print/pprust.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ fn next_comment(&ps s) -> option::t[lexer::cmnt] {
14211421

14221422

14231423
fn constr_args_to_str[T](fn(&T) -> str f,
1424-
&vec[@ast::constr_arg_general[T]] args) -> str {
1424+
&(@ast::constr_arg_general[T])[] args) -> str {
14251425
auto comma = false;
14261426
auto s = "(";
14271427
for (@ast::constr_arg_general[T] a in args) {
@@ -1447,8 +1447,13 @@ fn constr_arg_to_str[T](fn(&T) -> str f, &ast::constr_arg_general_[T] c) ->
14471447
fn uint_to_str(&uint i) -> str { ret uint::str(i); }
14481448
14491449
fn ast_constr_to_str(&@ast::constr c) -> str {
1450+
// TODO: Remove this vec->ivec conversion.
1451+
auto cag_ivec = ~[];
1452+
for (@ast::constr_arg_general[uint] cag in c.node.args) {
1453+
cag_ivec += ~[cag];
1454+
}
14501455
ret ast::path_to_str(c.node.path) +
1451-
constr_args_to_str(uint_to_str, c.node.args);
1456+
constr_args_to_str(uint_to_str, cag_ivec);
14521457
}
14531458
14541459
fn ast_constrs_str(&vec[@ast::constr] constrs) -> str {

0 commit comments

Comments
 (0)