@@ -28,6 +28,7 @@ use syntax::abi;
28
28
use syntax:: parse:: token;
29
29
use syntax;
30
30
31
+ use std:: int;
31
32
use std:: hashmap:: HashMap ;
32
33
33
34
#[ deriving( Eq ) ]
@@ -216,57 +217,58 @@ pub struct Session_ {
216
217
building_library : @mut bool ,
217
218
working_dir : Path ,
218
219
lints : @mut HashMap < ast:: NodeId , ~[ ( lint:: lint , codemap:: Span , ~str ) ] > ,
220
+ node_id : @mut uint ,
219
221
}
220
222
221
223
pub type Session = @Session_ ;
222
224
223
225
impl Session_ {
224
- pub fn span_fatal ( @ self , sp : Span , msg : & str ) -> ! {
226
+ pub fn span_fatal ( & self , sp : Span , msg : & str ) -> ! {
225
227
self . span_diagnostic . span_fatal ( sp, msg)
226
228
}
227
- pub fn fatal ( @ self , msg : & str ) -> ! {
229
+ pub fn fatal ( & self , msg : & str ) -> ! {
228
230
self . span_diagnostic . handler ( ) . fatal ( msg)
229
231
}
230
- pub fn span_err ( @ self , sp : Span , msg : & str ) {
232
+ pub fn span_err ( & self , sp : Span , msg : & str ) {
231
233
self . span_diagnostic . span_err ( sp, msg)
232
234
}
233
- pub fn err ( @ self , msg : & str ) {
235
+ pub fn err ( & self , msg : & str ) {
234
236
self . span_diagnostic . handler ( ) . err ( msg)
235
237
}
236
- pub fn err_count ( @ self ) -> uint {
238
+ pub fn err_count ( & self ) -> uint {
237
239
self . span_diagnostic . handler ( ) . err_count ( )
238
240
}
239
- pub fn has_errors ( @ self ) -> bool {
241
+ pub fn has_errors ( & self ) -> bool {
240
242
self . span_diagnostic . handler ( ) . has_errors ( )
241
243
}
242
- pub fn abort_if_errors ( @ self ) {
244
+ pub fn abort_if_errors ( & self ) {
243
245
self . span_diagnostic . handler ( ) . abort_if_errors ( )
244
246
}
245
- pub fn span_warn ( @ self , sp : Span , msg : & str ) {
247
+ pub fn span_warn ( & self , sp : Span , msg : & str ) {
246
248
self . span_diagnostic . span_warn ( sp, msg)
247
249
}
248
- pub fn warn ( @ self , msg : & str ) {
250
+ pub fn warn ( & self , msg : & str ) {
249
251
self . span_diagnostic . handler ( ) . warn ( msg)
250
252
}
251
- pub fn span_note ( @ self , sp : Span , msg : & str ) {
253
+ pub fn span_note ( & self , sp : Span , msg : & str ) {
252
254
self . span_diagnostic . span_note ( sp, msg)
253
255
}
254
- pub fn note ( @ self , msg : & str ) {
256
+ pub fn note ( & self , msg : & str ) {
255
257
self . span_diagnostic . handler ( ) . note ( msg)
256
258
}
257
- pub fn span_bug ( @ self , sp : Span , msg : & str ) -> ! {
259
+ pub fn span_bug ( & self , sp : Span , msg : & str ) -> ! {
258
260
self . span_diagnostic . span_bug ( sp, msg)
259
261
}
260
- pub fn bug ( @ self , msg : & str ) -> ! {
262
+ pub fn bug ( & self , msg : & str ) -> ! {
261
263
self . span_diagnostic . handler ( ) . bug ( msg)
262
264
}
263
- pub fn span_unimpl ( @ self , sp : Span , msg : & str ) -> ! {
265
+ pub fn span_unimpl ( & self , sp : Span , msg : & str ) -> ! {
264
266
self . span_diagnostic . span_unimpl ( sp, msg)
265
267
}
266
- pub fn unimpl ( @ self , msg : & str ) -> ! {
268
+ pub fn unimpl ( & self , msg : & str ) -> ! {
267
269
self . span_diagnostic . handler ( ) . unimpl ( msg)
268
270
}
269
- pub fn add_lint ( @ self ,
271
+ pub fn add_lint ( & self ,
270
272
lint : lint:: lint ,
271
273
id : ast:: NodeId ,
272
274
sp : Span ,
@@ -277,77 +279,85 @@ impl Session_ {
277
279
}
278
280
self . lints . insert ( id, ~[ ( lint, sp, msg) ] ) ;
279
281
}
280
- pub fn next_node_id ( @ self ) -> ast:: NodeId {
281
- return syntax :: parse :: next_node_id ( self . parse_sess ) ;
282
+ pub fn next_node_id ( & self ) -> ast:: NodeId {
283
+ self . reserve_node_ids ( 1 )
282
284
}
283
- pub fn diagnostic ( @self ) -> @mut diagnostic:: span_handler {
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 {
284
294
self . span_diagnostic
285
295
}
286
- pub fn debugging_opt ( @ self , opt : uint ) -> bool {
296
+ pub fn debugging_opt ( & self , opt : uint ) -> bool {
287
297
( self . opts . debugging_opts & opt) != 0 u
288
298
}
289
299
// This exists to help with refactoring to eliminate impossible
290
300
// cases later on
291
- pub fn impossible_case ( @ self , sp : Span , msg : & str ) -> ! {
301
+ pub fn impossible_case ( & self , sp : Span , msg : & str ) -> ! {
292
302
self . span_bug ( sp, fmt ! ( "Impossible case reached: %s" , msg) ) ;
293
303
}
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 {
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 {
297
307
self . debugging_opt ( count_llvm_insns)
298
308
}
299
- pub fn count_type_sizes ( @ self ) -> bool {
309
+ pub fn count_type_sizes ( & self ) -> bool {
300
310
self . debugging_opt ( count_type_sizes)
301
311
}
302
- pub fn time_llvm_passes ( @ self ) -> bool {
312
+ pub fn time_llvm_passes ( & self ) -> bool {
303
313
self . debugging_opt ( time_llvm_passes)
304
314
}
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 {
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 {
314
324
self . debugging_opt ( borrowck_note_pure)
315
325
}
316
- pub fn borrowck_note_loan ( @ self ) -> bool {
326
+ pub fn borrowck_note_loan ( & self ) -> bool {
317
327
self . debugging_opt ( borrowck_note_loan)
318
328
}
319
- pub fn no_monomorphic_collapse ( @ self ) -> bool {
329
+ pub fn no_monomorphic_collapse ( & self ) -> bool {
320
330
self . debugging_opt ( no_monomorphic_collapse)
321
331
}
322
- pub fn debug_borrows ( @ self ) -> bool {
332
+ pub fn debug_borrows ( & self ) -> bool {
323
333
self . opts . optimize == No && !self . debugging_opt ( no_debug_borrows)
324
334
}
325
- pub fn once_fns ( @ self ) -> bool { self . debugging_opt ( once_fns) }
326
- pub fn print_llvm_passes ( @ self ) -> bool {
335
+ pub fn once_fns ( & self ) -> bool { self . debugging_opt ( once_fns) }
336
+ pub fn print_llvm_passes ( & self ) -> bool {
327
337
self . debugging_opt ( print_llvm_passes)
328
338
}
329
- pub fn no_prepopulate_passes ( @ self ) -> bool {
339
+ pub fn no_prepopulate_passes ( & self ) -> bool {
330
340
self . debugging_opt ( no_prepopulate_passes)
331
341
}
332
- pub fn no_vectorize_loops ( @ self ) -> bool {
342
+ pub fn no_vectorize_loops ( & self ) -> bool {
333
343
self . debugging_opt ( no_vectorize_loops)
334
344
}
335
- pub fn no_vectorize_slp ( @ self ) -> bool {
345
+ pub fn no_vectorize_slp ( & self ) -> bool {
336
346
self . debugging_opt ( no_vectorize_slp)
337
347
}
338
348
339
349
// pointless function, now...
340
- pub fn str_of ( @ self , id : ast:: Ident ) -> @str {
350
+ pub fn str_of ( & self , id : ast:: Ident ) -> @str {
341
351
token:: ident_to_str ( & id)
342
352
}
343
353
344
354
// pointless function, now...
345
- pub fn ident_of ( @ self , st : & str ) -> ast:: Ident {
355
+ pub fn ident_of ( & self , st : & str ) -> ast:: Ident {
346
356
token:: str_to_ident ( st)
347
357
}
348
358
349
359
// pointless function, now...
350
- pub fn intr ( @ self ) -> @syntax:: parse:: token:: ident_interner {
360
+ pub fn intr ( & self ) -> @syntax:: parse:: token:: ident_interner {
351
361
token:: get_ident_interner ( )
352
362
}
353
363
}
0 commit comments