@@ -28,6 +28,7 @@ use syntax::abi;
2828use syntax:: parse:: token;
2929use syntax;
3030
31+ use std:: int;
3132use std:: hashmap:: HashMap ;
3233
3334#[ deriving( Eq ) ]
@@ -216,57 +217,58 @@ pub struct Session_ {
216217 building_library : @mut bool ,
217218 working_dir : Path ,
218219 lints : @mut HashMap < ast:: NodeId , ~[ ( lint:: lint , codemap:: Span , ~str ) ] > ,
220+ node_id : @mut uint ,
219221}
220222
221223pub type Session = @Session_ ;
222224
223225impl Session_ {
224- pub fn span_fatal ( @ self , sp : Span , msg : & str ) -> ! {
226+ pub fn span_fatal ( & self , sp : Span , msg : & str ) -> ! {
225227 self . span_diagnostic . span_fatal ( sp, msg)
226228 }
227- pub fn fatal ( @ self , msg : & str ) -> ! {
229+ pub fn fatal ( & self , msg : & str ) -> ! {
228230 self . span_diagnostic . handler ( ) . fatal ( msg)
229231 }
230- pub fn span_err ( @ self , sp : Span , msg : & str ) {
232+ pub fn span_err ( & self , sp : Span , msg : & str ) {
231233 self . span_diagnostic . span_err ( sp, msg)
232234 }
233- pub fn err ( @ self , msg : & str ) {
235+ pub fn err ( & self , msg : & str ) {
234236 self . span_diagnostic . handler ( ) . err ( msg)
235237 }
236- pub fn err_count ( @ self ) -> uint {
238+ pub fn err_count ( & self ) -> uint {
237239 self . span_diagnostic . handler ( ) . err_count ( )
238240 }
239- pub fn has_errors ( @ self ) -> bool {
241+ pub fn has_errors ( & self ) -> bool {
240242 self . span_diagnostic . handler ( ) . has_errors ( )
241243 }
242- pub fn abort_if_errors ( @ self ) {
244+ pub fn abort_if_errors ( & self ) {
243245 self . span_diagnostic . handler ( ) . abort_if_errors ( )
244246 }
245- pub fn span_warn ( @ self , sp : Span , msg : & str ) {
247+ pub fn span_warn ( & self , sp : Span , msg : & str ) {
246248 self . span_diagnostic . span_warn ( sp, msg)
247249 }
248- pub fn warn ( @ self , msg : & str ) {
250+ pub fn warn ( & self , msg : & str ) {
249251 self . span_diagnostic . handler ( ) . warn ( msg)
250252 }
251- pub fn span_note ( @ self , sp : Span , msg : & str ) {
253+ pub fn span_note ( & self , sp : Span , msg : & str ) {
252254 self . span_diagnostic . span_note ( sp, msg)
253255 }
254- pub fn note ( @ self , msg : & str ) {
256+ pub fn note ( & self , msg : & str ) {
255257 self . span_diagnostic . handler ( ) . note ( msg)
256258 }
257- pub fn span_bug ( @ self , sp : Span , msg : & str ) -> ! {
259+ pub fn span_bug ( & self , sp : Span , msg : & str ) -> ! {
258260 self . span_diagnostic . span_bug ( sp, msg)
259261 }
260- pub fn bug ( @ self , msg : & str ) -> ! {
262+ pub fn bug ( & self , msg : & str ) -> ! {
261263 self . span_diagnostic . handler ( ) . bug ( msg)
262264 }
263- pub fn span_unimpl ( @ self , sp : Span , msg : & str ) -> ! {
265+ pub fn span_unimpl ( & self , sp : Span , msg : & str ) -> ! {
264266 self . span_diagnostic . span_unimpl ( sp, msg)
265267 }
266- pub fn unimpl ( @ self , msg : & str ) -> ! {
268+ pub fn unimpl ( & self , msg : & str ) -> ! {
267269 self . span_diagnostic . handler ( ) . unimpl ( msg)
268270 }
269- pub fn add_lint ( @ self ,
271+ pub fn add_lint ( & self ,
270272 lint : lint:: lint ,
271273 id : ast:: NodeId ,
272274 sp : Span ,
@@ -277,77 +279,85 @@ impl Session_ {
277279 }
278280 self . lints . insert ( id, ~[ ( lint, sp, msg) ] ) ;
279281 }
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 )
282284 }
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 {
284294 self . span_diagnostic
285295 }
286- pub fn debugging_opt ( @ self , opt : uint ) -> bool {
296+ pub fn debugging_opt ( & self , opt : uint ) -> bool {
287297 ( self . opts . debugging_opts & opt) != 0 u
288298 }
289299 // This exists to help with refactoring to eliminate impossible
290300 // cases later on
291- pub fn impossible_case ( @ self , sp : Span , msg : & str ) -> ! {
301+ pub fn impossible_case ( & self , sp : Span , msg : & str ) -> ! {
292302 self . span_bug ( sp, fmt ! ( "Impossible case reached: %s" , msg) ) ;
293303 }
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 {
297307 self . debugging_opt ( count_llvm_insns)
298308 }
299- pub fn count_type_sizes ( @ self ) -> bool {
309+ pub fn count_type_sizes ( & self ) -> bool {
300310 self . debugging_opt ( count_type_sizes)
301311 }
302- pub fn time_llvm_passes ( @ self ) -> bool {
312+ pub fn time_llvm_passes ( & self ) -> bool {
303313 self . debugging_opt ( time_llvm_passes)
304314 }
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 {
314324 self . debugging_opt ( borrowck_note_pure)
315325 }
316- pub fn borrowck_note_loan ( @ self ) -> bool {
326+ pub fn borrowck_note_loan ( & self ) -> bool {
317327 self . debugging_opt ( borrowck_note_loan)
318328 }
319- pub fn no_monomorphic_collapse ( @ self ) -> bool {
329+ pub fn no_monomorphic_collapse ( & self ) -> bool {
320330 self . debugging_opt ( no_monomorphic_collapse)
321331 }
322- pub fn debug_borrows ( @ self ) -> bool {
332+ pub fn debug_borrows ( & self ) -> bool {
323333 self . opts . optimize == No && !self . debugging_opt ( no_debug_borrows)
324334 }
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 {
327337 self . debugging_opt ( print_llvm_passes)
328338 }
329- pub fn no_prepopulate_passes ( @ self ) -> bool {
339+ pub fn no_prepopulate_passes ( & self ) -> bool {
330340 self . debugging_opt ( no_prepopulate_passes)
331341 }
332- pub fn no_vectorize_loops ( @ self ) -> bool {
342+ pub fn no_vectorize_loops ( & self ) -> bool {
333343 self . debugging_opt ( no_vectorize_loops)
334344 }
335- pub fn no_vectorize_slp ( @ self ) -> bool {
345+ pub fn no_vectorize_slp ( & self ) -> bool {
336346 self . debugging_opt ( no_vectorize_slp)
337347 }
338348
339349 // pointless function, now...
340- pub fn str_of ( @ self , id : ast:: Ident ) -> @str {
350+ pub fn str_of ( & self , id : ast:: Ident ) -> @str {
341351 token:: ident_to_str ( & id)
342352 }
343353
344354 // pointless function, now...
345- pub fn ident_of ( @ self , st : & str ) -> ast:: Ident {
355+ pub fn ident_of ( & self , st : & str ) -> ast:: Ident {
346356 token:: str_to_ident ( st)
347357 }
348358
349359 // pointless function, now...
350- pub fn intr ( @ self ) -> @syntax:: parse:: token:: ident_interner {
360+ pub fn intr ( & self ) -> @syntax:: parse:: token:: ident_interner {
351361 token:: get_ident_interner ( )
352362 }
353363}
0 commit comments