Skip to content

Commit 127381d

Browse files
committed
---
yaml --- r: 144928 b: refs/heads/try2 c: 959d9d6 h: refs/heads/master v: v3
1 parent 7cc5dae commit 127381d

33 files changed

+432
-603
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 753d8c226c75b72edd939793223d28f4baf932fd
8+
refs/heads/try2: 959d9d60e143fb969fa5bc778a2017a9312bd435
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/driver/driver.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,6 @@ pub fn phase_2_configure_and_expand(sess: Session,
190190
crate = time(time_passes, ~"std injection", ||
191191
front::std_inject::maybe_inject_libstd_ref(sess, crate));
192192

193-
crate = time(time_passes, ~"assigning node ids", ||
194-
front::assign_node_ids::assign_node_ids(sess, crate));
195-
196193
return crate;
197194
}
198195

@@ -210,7 +207,6 @@ pub fn phase_3_run_analysis_passes(sess: Session,
210207
crate: @ast::Crate) -> CrateAnalysis {
211208

212209
let time_passes = sess.time_passes();
213-
214210
let ast_map = time(time_passes, ~"ast indexing", ||
215211
syntax::ast_map::map_crate(sess.diagnostic(), crate));
216212

@@ -816,7 +812,6 @@ pub fn build_session_(sopts: @session::options,
816812
building_library: @mut false,
817813
working_dir: os::getcwd(),
818814
lints: @mut HashMap::new(),
819-
node_id: @mut 1
820815
}
821816
}
822817

branches/try2/src/librustc/driver/session.rs

Lines changed: 46 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ use syntax::abi;
2828
use syntax::parse::token;
2929
use syntax;
3030

31-
use std::int;
3231
use std::hashmap::HashMap;
3332

3433
#[deriving(Eq)]
@@ -217,58 +216,57 @@ pub struct Session_ {
217216
building_library: @mut bool,
218217
working_dir: Path,
219218
lints: @mut HashMap<ast::NodeId, ~[(lint::lint, codemap::Span, ~str)]>,
220-
node_id: @mut uint,
221219
}
222220

223221
pub type Session = @Session_;
224222

225223
impl Session_ {
226-
pub fn span_fatal(&self, sp: Span, msg: &str) -> ! {
224+
pub fn span_fatal(@self, sp: Span, msg: &str) -> ! {
227225
self.span_diagnostic.span_fatal(sp, msg)
228226
}
229-
pub fn fatal(&self, msg: &str) -> ! {
227+
pub fn fatal(@self, msg: &str) -> ! {
230228
self.span_diagnostic.handler().fatal(msg)
231229
}
232-
pub fn span_err(&self, sp: Span, msg: &str) {
230+
pub fn span_err(@self, sp: Span, msg: &str) {
233231
self.span_diagnostic.span_err(sp, msg)
234232
}
235-
pub fn err(&self, msg: &str) {
233+
pub fn err(@self, msg: &str) {
236234
self.span_diagnostic.handler().err(msg)
237235
}
238-
pub fn err_count(&self) -> uint {
236+
pub fn err_count(@self) -> uint {
239237
self.span_diagnostic.handler().err_count()
240238
}
241-
pub fn has_errors(&self) -> bool {
239+
pub fn has_errors(@self) -> bool {
242240
self.span_diagnostic.handler().has_errors()
243241
}
244-
pub fn abort_if_errors(&self) {
242+
pub fn abort_if_errors(@self) {
245243
self.span_diagnostic.handler().abort_if_errors()
246244
}
247-
pub fn span_warn(&self, sp: Span, msg: &str) {
245+
pub fn span_warn(@self, sp: Span, msg: &str) {
248246
self.span_diagnostic.span_warn(sp, msg)
249247
}
250-
pub fn warn(&self, msg: &str) {
248+
pub fn warn(@self, msg: &str) {
251249
self.span_diagnostic.handler().warn(msg)
252250
}
253-
pub fn span_note(&self, sp: Span, msg: &str) {
251+
pub fn span_note(@self, sp: Span, msg: &str) {
254252
self.span_diagnostic.span_note(sp, msg)
255253
}
256-
pub fn note(&self, msg: &str) {
254+
pub fn note(@self, msg: &str) {
257255
self.span_diagnostic.handler().note(msg)
258256
}
259-
pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
257+
pub fn span_bug(@self, sp: Span, msg: &str) -> ! {
260258
self.span_diagnostic.span_bug(sp, msg)
261259
}
262-
pub fn bug(&self, msg: &str) -> ! {
260+
pub fn bug(@self, msg: &str) -> ! {
263261
self.span_diagnostic.handler().bug(msg)
264262
}
265-
pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
263+
pub fn span_unimpl(@self, sp: Span, msg: &str) -> ! {
266264
self.span_diagnostic.span_unimpl(sp, msg)
267265
}
268-
pub fn unimpl(&self, msg: &str) -> ! {
266+
pub fn unimpl(@self, msg: &str) -> ! {
269267
self.span_diagnostic.handler().unimpl(msg)
270268
}
271-
pub fn add_lint(&self,
269+
pub fn add_lint(@self,
272270
lint: lint::lint,
273271
id: ast::NodeId,
274272
sp: Span,
@@ -279,85 +277,77 @@ impl Session_ {
279277
}
280278
self.lints.insert(id, ~[(lint, sp, msg)]);
281279
}
282-
pub fn next_node_id(&self) -> ast::NodeId {
283-
self.reserve_node_ids(1)
280+
pub fn next_node_id(@self) -> ast::NodeId {
281+
return syntax::parse::next_node_id(self.parse_sess);
284282
}
285-
pub fn reserve_node_ids(&self, count: uint) -> ast::NodeId {
286-
let v = *self.node_id;
287-
*self.node_id += count;
288-
if v > (int::max_value as uint) {
289-
self.bug("Input too large, ran out of node ids!");
290-
}
291-
v as int
292-
}
293-
pub fn diagnostic(&self) -> @mut diagnostic::span_handler {
283+
pub fn diagnostic(@self) -> @mut diagnostic::span_handler {
294284
self.span_diagnostic
295285
}
296-
pub fn debugging_opt(&self, opt: uint) -> bool {
286+
pub fn debugging_opt(@self, opt: uint) -> bool {
297287
(self.opts.debugging_opts & opt) != 0u
298288
}
299289
// This exists to help with refactoring to eliminate impossible
300290
// cases later on
301-
pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
291+
pub fn impossible_case(@self, sp: Span, msg: &str) -> ! {
302292
self.span_bug(sp, fmt!("Impossible case reached: %s", msg));
303293
}
304-
pub fn verbose(&self) -> bool { self.debugging_opt(verbose) }
305-
pub fn time_passes(&self) -> bool { self.debugging_opt(time_passes) }
306-
pub fn count_llvm_insns(&self) -> bool {
294+
pub fn verbose(@self) -> bool { self.debugging_opt(verbose) }
295+
pub fn time_passes(@self) -> bool { self.debugging_opt(time_passes) }
296+
pub fn count_llvm_insns(@self) -> bool {
307297
self.debugging_opt(count_llvm_insns)
308298
}
309-
pub fn count_type_sizes(&self) -> bool {
299+
pub fn count_type_sizes(@self) -> bool {
310300
self.debugging_opt(count_type_sizes)
311301
}
312-
pub fn time_llvm_passes(&self) -> bool {
302+
pub fn time_llvm_passes(@self) -> bool {
313303
self.debugging_opt(time_llvm_passes)
314304
}
315-
pub fn trans_stats(&self) -> bool { self.debugging_opt(trans_stats) }
316-
pub fn meta_stats(&self) -> bool { self.debugging_opt(meta_stats) }
317-
pub fn asm_comments(&self) -> bool { self.debugging_opt(asm_comments) }
318-
pub fn no_verify(&self) -> bool { self.debugging_opt(no_verify) }
319-
pub fn lint_llvm(&self) -> bool { self.debugging_opt(lint_llvm) }
320-
pub fn trace(&self) -> bool { self.debugging_opt(trace) }
321-
pub fn coherence(&self) -> bool { self.debugging_opt(coherence) }
322-
pub fn borrowck_stats(&self) -> bool { self.debugging_opt(borrowck_stats) }
323-
pub fn borrowck_note_pure(&self) -> bool {
305+
pub fn trans_stats(@self) -> bool { self.debugging_opt(trans_stats) }
306+
pub fn meta_stats(@self) -> bool { self.debugging_opt(meta_stats) }
307+
pub fn asm_comments(@self) -> bool { self.debugging_opt(asm_comments) }
308+
pub fn no_verify(@self) -> bool { self.debugging_opt(no_verify) }
309+
pub fn lint_llvm(@self) -> bool { self.debugging_opt(lint_llvm) }
310+
pub fn trace(@self) -> bool { self.debugging_opt(trace) }
311+
pub fn coherence(@self) -> bool { self.debugging_opt(coherence) }
312+
pub fn borrowck_stats(@self) -> bool { self.debugging_opt(borrowck_stats) }
313+
pub fn borrowck_note_pure(@self) -> bool {
324314
self.debugging_opt(borrowck_note_pure)
325315
}
326-
pub fn borrowck_note_loan(&self) -> bool {
316+
pub fn borrowck_note_loan(@self) -> bool {
327317
self.debugging_opt(borrowck_note_loan)
328318
}
329-
pub fn no_monomorphic_collapse(&self) -> bool {
319+
pub fn no_monomorphic_collapse(@self) -> bool {
330320
self.debugging_opt(no_monomorphic_collapse)
331321
}
332-
pub fn debug_borrows(&self) -> bool {
322+
pub fn debug_borrows(@self) -> bool {
333323
self.opts.optimize == No && !self.debugging_opt(no_debug_borrows)
334324
}
335-
pub fn once_fns(&self) -> bool { self.debugging_opt(once_fns) }
336-
pub fn print_llvm_passes(&self) -> bool {
325+
pub fn once_fns(@self) -> bool { self.debugging_opt(once_fns) }
326+
pub fn print_llvm_passes(@self) -> bool {
337327
self.debugging_opt(print_llvm_passes)
338328
}
339-
pub fn no_prepopulate_passes(&self) -> bool {
329+
pub fn no_prepopulate_passes(@self) -> bool {
340330
self.debugging_opt(no_prepopulate_passes)
341331
}
342-
pub fn no_vectorize_loops(&self) -> bool {
332+
pub fn no_vectorize_loops(@self) -> bool {
343333
self.debugging_opt(no_vectorize_loops)
344334
}
345-
pub fn no_vectorize_slp(&self) -> bool {
335+
pub fn no_vectorize_slp(@self) -> bool {
346336
self.debugging_opt(no_vectorize_slp)
347337
}
348338

349339
// pointless function, now...
350-
pub fn str_of(&self, id: ast::Ident) -> @str {
340+
pub fn str_of(@self, id: ast::Ident) -> @str {
351341
token::ident_to_str(&id)
352342
}
353343

354344
// pointless function, now...
355-
pub fn ident_of(&self, st: &str) -> ast::Ident {
345+
pub fn ident_of(@self, st: &str) -> ast::Ident {
356346
token::str_to_ident(st)
357347
}
358348

359349
// pointless function, now...
360-
pub fn intr(&self) -> @syntax::parse::token::ident_interner {
350+
pub fn intr(@self) -> @syntax::parse::token::ident_interner {
361351
token::get_ident_interner()
362352
}
363353
}

branches/try2/src/librustc/front/assign_node_ids.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

branches/try2/src/librustc/front/std_inject.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::Crate) -> @ast::Crate {
4545

4646
let precursor = @fold::AstFoldFns {
4747
fold_crate: |crate, fld| {
48-
let n1 = ast::DUMMY_NODE_ID;
48+
let n1 = sess.next_node_id();
4949
let vi1 = ast::view_item {
5050
node: ast::view_item_extern_mod(
5151
sess.ident_of("std"), None, ~[], n1),
@@ -86,7 +86,7 @@ fn inject_libstd_ref(sess: Session, crate: &ast::Crate) -> @ast::Crate {
8686
}
8787
},
8888
fold_mod: |module, fld| {
89-
let n2 = ast::DUMMY_NODE_ID;
89+
let n2 = sess.next_node_id();
9090

9191
let prelude_path = ast::Path {
9292
span: dummy_sp(),

branches/try2/src/librustc/front/test.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,10 +280,10 @@ fn mk_std(cx: &TestCtxt) -> ast::view_item {
280280
ast::view_item_use(
281281
~[@nospan(ast::view_path_simple(id_extra,
282282
path_node(~[id_extra]),
283-
ast::DUMMY_NODE_ID))])
283+
cx.sess.next_node_id()))])
284284
} else {
285285
let mi = attr::mk_name_value_item_str(@"vers", @"0.8-pre");
286-
ast::view_item_extern_mod(id_extra, None, ~[mi], ast::DUMMY_NODE_ID)
286+
ast::view_item_extern_mod(id_extra, None, ~[mi], cx.sess.next_node_id())
287287
};
288288
ast::view_item {
289289
node: vi,
@@ -325,7 +325,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
325325
let item = ast::item {
326326
ident: cx.sess.ident_of("__test"),
327327
attrs: ~[resolve_unexported_attr],
328-
id: ast::DUMMY_NODE_ID,
328+
id: cx.sess.next_node_id(),
329329
node: item_,
330330
vis: ast::public,
331331
span: dummy_sp(),
@@ -367,7 +367,7 @@ fn mk_test_module(cx: &TestCtxt) -> @ast::item {
367367
let item = ast::item {
368368
ident: cx.sess.ident_of("__test"),
369369
attrs: ~[resolve_unexported_attr],
370-
id: ast::DUMMY_NODE_ID,
370+
id: cx.sess.next_node_id(),
371371
node: item_,
372372
vis: ast::public,
373373
span: dummy_sp(),
@@ -448,14 +448,15 @@ fn mk_test_descs(cx: &TestCtxt) -> @ast::Expr {
448448
descs.push(mk_test_desc_and_fn_rec(cx, test));
449449
}
450450

451+
let sess = cx.sess;
451452
let inner_expr = @ast::Expr {
452-
id: ast::DUMMY_NODE_ID,
453+
id: sess.next_node_id(),
453454
node: ast::ExprVec(descs, ast::MutImmutable),
454455
span: dummy_sp(),
455456
};
456457

457458
@ast::Expr {
458-
id: ast::DUMMY_NODE_ID,
459+
id: sess.next_node_id(),
459460
node: ast::ExprVstore(inner_expr, ast::ExprVstoreSlice),
460461
span: dummy_sp(),
461462
}
@@ -474,15 +475,15 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
474475
nospan(ast::lit_str(ast_util::path_name_i(path).to_managed()));
475476

476477
let name_expr = @ast::Expr {
477-
id: ast::DUMMY_NODE_ID,
478+
id: cx.sess.next_node_id(),
478479
node: ast::ExprLit(@name_lit),
479480
span: span
480481
};
481482

482483
let fn_path = path_node_global(path);
483484

484485
let fn_expr = @ast::Expr {
485-
id: ast::DUMMY_NODE_ID,
486+
id: cx.sess.next_node_id(),
486487
node: ast::ExprPath(fn_path),
487488
span: span,
488489
};
@@ -528,15 +529,15 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> @ast::Expr {
528529
nospan(ast::lit_str(ast_util::path_name_i(path).to_managed()));
529530

530531
let name_expr = @ast::Expr {
531-
id: ast::DUMMY_NODE_ID,
532+
id: cx.sess.next_node_id(),
532533
node: ast::ExprLit(@name_lit),
533534
span: span
534535
};
535536

536537
let fn_path = path_node_global(path);
537538

538539
let fn_expr = @ast::Expr {
539-
id: ast::DUMMY_NODE_ID,
540+
id: cx.sess.next_node_id(),
540541
node: ast::ExprPath(fn_path),
541542
span: span,
542543
};

branches/try2/src/librustc/middle/astencode.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ fn reserve_id_range(sess: Session,
157157
// Handle the case of an empty range:
158158
if from_id_range.empty() { return from_id_range; }
159159
let cnt = from_id_range.max - from_id_range.min;
160-
assert!(cnt >= 0);
161-
let to_id_min = sess.reserve_node_ids(cnt as uint);
162-
let to_id_max = to_id_min + cnt;
163-
ast_util::id_range { min: to_id_min, max: to_id_max }
160+
let to_id_min = sess.parse_sess.next_id;
161+
let to_id_max = sess.parse_sess.next_id + cnt;
162+
sess.parse_sess.next_id = to_id_max;
163+
ast_util::id_range { min: to_id_min, max: to_id_min }
164164
}
165165

166166
impl ExtendedDecodeContext {

0 commit comments

Comments
 (0)