Skip to content

Commit dda12f8

Browse files
bleibigbrson
authored andcommitted
Replace much of the REPL run code with a call to compile_upto
1 parent 11a9918 commit dda12f8

File tree

2 files changed

+9
-112
lines changed

2 files changed

+9
-112
lines changed

src/librusti/rusti.rc

Lines changed: 8 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ fn run(repl: Repl, input: ~str) -> Repl {
134134
crate_type: session::unknown_crate,
135135
binary: repl.binary,
136136
addl_lib_search_paths: repl.lib_search_paths.map(|p| Path(*p)),
137+
jit: true,
137138
.. *session::basic_options()
138139
};
139140

@@ -153,8 +154,12 @@ fn run(repl: Repl, input: ~str) -> Repl {
153154
repl.binary,
154155
wrapped);
155156

156-
debug!("parsing");
157-
let mut crate = driver::parse_input(sess, cfg, wrapped);
157+
let outputs = driver::build_output_filenames(wrapped, &None, &None, sess);
158+
debug!("calling compile_upto");
159+
let {crate: crate, tcx: _} = driver::compile_upto(sess, cfg, wrapped,
160+
driver::cu_everything,
161+
Some(outputs));
162+
158163
let mut opt = None;
159164

160165
for crate.node.module.items.each |item| {
@@ -177,114 +182,6 @@ fn run(repl: Repl, input: ~str) -> Repl {
177182
}
178183
_ => fail
179184
};
180-
181-
debug!("configuration");
182-
crate = front::config::strip_unconfigured_items(crate);
183-
184-
debug!("maybe building test harness");
185-
crate = front::test::modify_for_testing(sess, crate);
186-
187-
debug!("expansion");
188-
crate = syntax::ext::expand::expand_crate(sess.parse_sess,
189-
sess.opts.cfg,
190-
crate);
191-
192-
debug!("intrinsic injection");
193-
crate = front::intrinsic_inject::inject_intrinsic(sess, crate);
194-
195-
debug!("core injection");
196-
crate = front::core_inject::maybe_inject_libcore_ref(sess, crate);
197-
198-
debug!("building lint settings table");
199-
lint::build_settings_crate(sess, crate);
200-
201-
debug!("ast indexing");
202-
let ast_map = syntax::ast_map::map_crate(sess.diagnostic(), *crate);
203-
204-
debug!("external crate/lib resolution");
205-
creader::read_crates(sess.diagnostic(), *crate, sess.cstore,
206-
sess.filesearch,
207-
session::sess_os_to_meta_os(sess.targ_cfg.os),
208-
sess.opts.static, sess.parse_sess.interner);
209-
210-
debug!("language item collection");
211-
let lang_items = middle::lang_items::collect_language_items(crate, sess);
212-
213-
debug!("resolution");
214-
let {def_map: def_map,
215-
exp_map2: exp_map2,
216-
trait_map: trait_map} = middle::resolve::resolve_crate(sess,
217-
lang_items,
218-
crate);
219-
220-
debug!("freevar finding");
221-
let freevars = freevars::annotate_freevars(def_map, crate);
222-
223-
debug!("region_resolution");
224-
let region_map = middle::region::resolve_crate(sess, def_map, crate);
225-
226-
debug!("region paramaterization inference");
227-
let rp_set = middle::region::determine_rp_in_crate(sess, ast_map,
228-
def_map, crate);
229-
230-
debug!("typechecking");
231-
let ty_cx = ty::mk_ctxt(sess, def_map, ast_map, freevars,
232-
region_map, rp_set, move lang_items, crate);
233-
let (method_map, vtable_map) = typeck::check_crate(ty_cx, trait_map,
234-
crate);
235-
236-
debug!("const marking");
237-
middle::const_eval::process_crate(crate, def_map, ty_cx);
238-
239-
debug!("const checking");
240-
middle::check_const::check_crate(sess, crate, ast_map, def_map,
241-
method_map, ty_cx);
242-
243-
debug!("privacy checking");
244-
middle::privacy::check_crate(ty_cx, &method_map, crate);
245-
246-
debug!("loop checking");
247-
middle::check_loop::check_crate(ty_cx, crate);
248-
249-
debug!("mode computation");
250-
middle::mode::compute_modes(ty_cx, method_map, crate);
251-
252-
debug!("alt checking");
253-
middle::check_alt::check_crate(ty_cx, method_map, crate);
254-
255-
debug!("liveness checking");
256-
let last_use_map = middle::liveness::check_crate(ty_cx,
257-
method_map, crate);
258-
259-
debug!("borrow checking");
260-
let (root_map, mutbl_map) = middle::borrowck::check_crate(ty_cx,
261-
method_map,
262-
last_use_map,
263-
crate);
264-
265-
debug!("kind checking");
266-
kind::check_crate(ty_cx, method_map, last_use_map, crate);
267-
268-
debug!("lint checking");
269-
lint::check_crate(ty_cx, crate);
270-
271-
let maps = {mutbl_map: mutbl_map,
272-
root_map: root_map,
273-
last_use_map: last_use_map,
274-
method_map: method_map,
275-
vtable_map: vtable_map};
276-
277-
debug!("translation");
278-
let path = ~path::GenericPath::from_str("<repl>");
279-
let (llmod, _) = trans::base::trans_crate(sess, crate, ty_cx,
280-
path,
281-
exp_map2, maps);
282-
let pm = llvm::LLVMCreatePassManager();
283-
284-
debug!("executing jit");
285-
back::link::jit::exec(sess, pm, llmod, 0, false);
286-
llvm::LLVMDisposePassManager(pm);
287-
288185
debug!("recording input into repl history");
289186
record(repl, blk, sess.parse_sess.interner)
290187
}
@@ -380,7 +277,7 @@ fn run_cmd(repl: &mut Repl, _in: io::Reader, _out: io::Writer,
380277
io::println(
381278
~":{\\n ..lines.. \\n:}\\n - execute multiline command\n" +
382279
~":load <crate> ... - \
383-
loads given crates as dynamic libraries" +
280+
loads given crates as dynamic libraries\n" +
384281
~":clear - clear the screen\n" +
385282
~":exit - exit from the repl\n" +
386283
~":help - show this message");

src/rustllvm/RustWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ void *RustMCJITMemoryManager::getPointerToNamedFunction(const std::string &Name,
281281
if (Name == "mknod") return (void*)(intptr_t)&mknod;
282282
#endif
283283

284-
if (Name == "__morestack") return &__morestack;
284+
if (Name == "__morestack" || Name == "___morestack") return &__morestack;
285285

286286
const char *NameStr = Name.c_str();
287287

0 commit comments

Comments
 (0)