Skip to content

Commit d6a6afa

Browse files
committed
---
yaml --- r: 1858 b: refs/heads/master c: 77a3373 h: refs/heads/master v: v3
1 parent 5b55090 commit d6a6afa

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 10f336055cb13518690f8d280240d30e3f13e508
2+
refs/heads/master: 77a3373d53e3b0d1b87135b21307f19922398af9

trunk/src/comp/driver/rustc.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import middle.resolve;
99
import middle.typeck;
1010
import util.common;
1111

12+
import std.map.mk_hashmap;
1213
import std.option;
1314
import std.option.some;
1415
import std.option.none;
@@ -112,7 +113,9 @@ impure fn main(vec[str] args) {
112113
uint_type = common.ty_u32,
113114
float_type = common.ty_f64 );
114115

115-
auto sess = session.session(target_cfg);
116+
auto crate_cache = common.new_int_hash[session.crate_metadata]();
117+
118+
auto sess = session.session(target_cfg, crate_cache);
116119
let option.t[str] input_file = none[str];
117120
let option.t[str] output_file = none[str];
118121
let vec[str] library_search_paths = vec();

trunk/src/comp/driver/session.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import util.common.span;
22
import util.common.ty_mach;
33
import std._uint;
4+
import std.map;
45

56
tag os {
67
os_win32;
@@ -20,7 +21,9 @@ type cfg = rec(os os,
2021
ty_mach uint_type,
2122
ty_mach float_type);
2223

23-
obj session(cfg targ) {
24+
type crate_metadata = vec[u8];
25+
26+
obj session(cfg targ, map.hashmap[int, crate_metadata] crates) {
2427

2528
fn get_targ_cfg() -> cfg {
2629
ret targ;
@@ -66,6 +69,14 @@ obj session(cfg targ) {
6669
log #fmt("error: unimplemented %s", msg);
6770
fail;
6871
}
72+
73+
fn get_external_crate(int num) -> crate_metadata {
74+
ret crates.get(num);
75+
}
76+
77+
fn set_external_crate(int num, &crate_metadata metadata) {
78+
crates.insert(num, metadata);
79+
}
6980
}
7081

7182

trunk/src/comp/middle/ty.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,11 +1530,7 @@ fn unify(@ty.t expected, @ty.t actual, &unify_handler handler)
15301530
ret ty.fold_ty(folder(bindings), typ);
15311531
}
15321532

1533-
fn hash_int(&int x) -> uint { ret x as uint; }
1534-
fn eq_int(&int a, &int b) -> bool { ret a == b; }
1535-
auto hasher = hash_int;
1536-
auto eqer = eq_int;
1537-
auto bindings = @map.mk_hashmap[int,@ty.t](hasher, eqer);
1533+
auto bindings = @common.new_int_hash[@ty.t]();
15381534

15391535
auto ures = unify_step(bindings, expected, actual, handler);
15401536
alt (ures) {

trunk/src/comp/util/common.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ fn new_def_hash[V]() -> std.map.hashmap[ast.def_id,V] {
6464
ret std.map.mk_hashmap[ast.def_id,V](hasher, eqer);
6565
}
6666

67+
fn new_int_hash[V]() -> std.map.hashmap[int,V] {
68+
fn hash_int(&int x) -> uint { ret x as uint; }
69+
fn eq_int(&int a, &int b) -> bool { ret a == b; }
70+
auto hasher = hash_int;
71+
auto eqer = eq_int;
72+
ret std.map.mk_hashmap[int,V](hasher, eqer);
73+
}
74+
6775
fn istr(int i) -> str {
6876
ret _int.to_str(i, 10u);
6977
}

0 commit comments

Comments
 (0)