@@ -7,7 +7,7 @@ import trans::common::*;
7
7
import trans:: base;
8
8
import trans:: build:: B ;
9
9
import middle:: ty;
10
- import syntax:: { ast, codemap} ;
10
+ import syntax:: { ast, codemap, ast_util } ;
11
11
import codemap:: span;
12
12
import ast:: ty;
13
13
import pat_util:: * ;
@@ -224,8 +224,17 @@ fn line_from_span(cm: codemap::codemap, sp: span) -> uint {
224
224
codemap:: lookup_char_pos ( cm, sp. lo ) . line
225
225
}
226
226
227
- fn create_block ( cx : @block_ctxt , sp : span ) -> @metadata < block_md > {
228
- //let cache = get_cache(bcx_ccx(cx));
227
+ fn create_block ( cx : @block_ctxt ) -> @metadata < block_md > {
228
+ let cache = get_cache ( bcx_ccx ( cx) ) ;
229
+ let cx = cx;
230
+ while option:: is_none ( cx. block_span ) {
231
+ alt cx. parent {
232
+ parent_none { fail "BAD" ; /*break;*/ }
233
+ parent_some ( b) { cx = b; }
234
+ }
235
+ }
236
+ let sp = option:: get ( cx. block_span ) ;
237
+
229
238
let start = codemap:: lookup_char_pos ( bcx_ccx ( cx) . sess . codemap ,
230
239
sp. lo ) ;
231
240
let fname = start. filename ;
@@ -240,25 +249,25 @@ fn create_block(cx: @block_ctxt, sp: span) -> @metadata<block_md> {
240
249
}*/
241
250
242
251
let parent = alt cx. parent {
243
- parent_none { create_function( cx. fcx , sp ) . node }
244
- parent_some ( bcx) { create_block ( bcx, sp ) . node }
252
+ parent_none { create_function( cx. fcx ) . node }
253
+ parent_some ( bcx) { create_block ( bcx) . node }
245
254
} ;
246
255
let file_node = create_file ( bcx_ccx ( cx) , fname) ;
247
- /* let unique_id = alt cache.find(LexicalBlockTag) {
256
+ let unique_id = alt cache. find ( LexicalBlockTag ) {
248
257
option:: some ( v) { vec:: len ( v) as int }
249
258
option:: none { 0 }
250
- };*/
259
+ } ;
251
260
let lldata = [ lltag ( tg) ,
252
261
parent,
253
262
lli32 ( start. line as int ) ,
254
263
lli32 ( start. col as int ) ,
255
- file_node. node /* ,
256
- lli32(unique_id)*/
264
+ file_node. node ,
265
+ lli32 ( unique_id)
257
266
] ;
258
- let val = llmdnode ( lldata) ;
259
- let mdval = @{ node: val, data : { start : start, end : end} } ;
260
- //update_cache(cache, tg, block_metadata(mdval));
261
- ret mdval;
267
+ let val = llmdnode ( lldata) ;
268
+ let mdval = @{ node: val, data : { start : start, end : end} } ;
269
+ //update_cache(cache, tg, block_metadata(mdval));
270
+ ret mdval;
262
271
}
263
272
264
273
fn size_and_align_of < T > ( ) -> ( int , int ) {
@@ -642,8 +651,8 @@ fn create_local_var(bcx: @block_ctxt, local: @ast::local)
642
651
let tymd = create_ty ( cx, ty, local. node . ty ) ;
643
652
let filemd = create_file ( cx, loc. filename ) ;
644
653
let context = alt bcx. parent {
645
- parent_none { create_function( bcx. fcx , local . span ) . node }
646
- parent_some ( _) { create_block ( bcx, local . span ) . node }
654
+ parent_none { create_function( bcx. fcx ) . node }
655
+ parent_some ( _) { create_block ( bcx) . node }
647
656
} ;
648
657
let mdnode = create_var ( tg, context, name, filemd. node ,
649
658
loc. line as int , tymd. node ) ;
@@ -684,7 +693,7 @@ fn create_arg(bcx: @block_ctxt, arg: ast::arg, sp: span)
684
693
let ty = base:: node_id_type ( cx, arg. id ) ;
685
694
let tymd = create_ty ( cx, ty, arg. ty ) ;
686
695
let filemd = create_file ( cx, loc. filename ) ;
687
- let context = create_function ( bcx. fcx , sp ) ;
696
+ let context = create_function ( bcx. fcx ) ;
688
697
let mdnode = create_var ( tg, context. node , arg. ident , filemd. node ,
689
698
loc. line as int , tymd. node ) ;
690
699
let mdval = @{ node: mdnode, data : { id : arg. id } } ;
@@ -704,7 +713,7 @@ fn update_source_pos(cx: @block_ctxt, s: span) {
704
713
ret;
705
714
}
706
715
let cm = bcx_ccx ( cx) . sess . codemap ;
707
- let blockmd = create_block ( cx, s ) ;
716
+ let blockmd = create_block ( cx) ;
708
717
let loc = codemap:: lookup_char_pos ( cm, s. lo ) ;
709
718
let scopedata = [ lli32 ( loc. line as int ) ,
710
719
lli32 ( loc. col as int ) ,
@@ -714,14 +723,15 @@ fn update_source_pos(cx: @block_ctxt, s: span) {
714
723
llvm:: LLVMSetCurrentDebugLocation ( trans:: build:: B ( cx) , dbgscope) ;
715
724
}
716
725
717
- fn create_function ( fcx : @fn_ctxt , sp : span ) -> @metadata < subprogram_md > {
726
+ fn create_function ( fcx : @fn_ctxt ) -> @metadata < subprogram_md > {
718
727
let cx = fcx_ccx ( fcx) ;
719
728
let dbg_cx = option:: get ( cx. dbg_cx ) ;
720
729
721
730
#debug ( "~~" ) ;
722
731
log ( debug, fcx. id ) ;
723
732
724
- //log(debug, codemap::span_to_str(sp, cx.sess.codemap));
733
+ let sp = option:: get ( fcx. span ) ;
734
+ log ( debug, codemap:: span_to_str ( sp, cx. sess . codemap ) ) ;
725
735
726
736
let ( ident, ret_ty, id) = alt cx. ast_map . get ( fcx. id ) {
727
737
ast_map:: node_item ( item) {
@@ -754,12 +764,12 @@ fn create_function(fcx: @fn_ctxt, sp: span) -> @metadata<subprogram_md> {
754
764
log ( debug, ident) ;
755
765
log ( debug, id) ;
756
766
757
- /* let cache = get_cache(cx);
767
+ let cache = get_cache ( cx) ;
758
768
alt cached_metadata :: < @metadata < subprogram_md > > (
759
769
cache, SubprogramTag , { |md| md. data . id == id} ) {
760
770
option:: some ( md) { ret md; }
761
771
option:: none { }
762
- }*/
772
+ }
763
773
764
774
let path = str:: connect ( fcx. lcx . path + [ ident] , "::" ) ;
765
775
@@ -805,6 +815,6 @@ fn create_function(fcx: @fn_ctxt, sp: span) -> @metadata<subprogram_md> {
805
815
let val = llmdnode ( fn_metadata) ;
806
816
add_named_metadata ( cx, "llvm.dbg.sp" , val) ;
807
817
let mdval = @{ node: val, data : { id : id} } ;
808
- // update_cache(cache, SubprogramTag, subprogram_metadata(mdval));
818
+ update_cache ( cache, SubprogramTag , subprogram_metadata ( mdval) ) ;
809
819
ret mdval;
810
820
}
0 commit comments