@@ -41,7 +41,7 @@ type glue_fns = rec(ValueRef activate_glue,
41
41
ValueRef exit_task_glue ,
42
42
vec[ ValueRef ] upcall_glues ) ;
43
43
44
- state type trans_ctxt = rec ( session. session sess,
44
+ state type crate_ctxt = rec ( session. session sess,
45
45
ModuleRef llmod,
46
46
hashmap[ str, ValueRef ] upcalls,
47
47
hashmap[ str, ValueRef ] fn_names,
@@ -55,7 +55,7 @@ state type fn_ctxt = rec(ValueRef llfn,
55
55
ValueRef lltaskptr ,
56
56
hashmap[ ast. def_id, ValueRef ] llargs ,
57
57
hashmap[ ast. def_id, ValueRef ] lllocals ,
58
- @trans_ctxt tcx ) ;
58
+ @crate_ctxt ccx ) ;
59
59
60
60
tag cleanup {
61
61
clean( fn ( @block_ctxt cx) -> result) ;
@@ -238,13 +238,13 @@ fn T_taskptr() -> TypeRef {
238
238
ret T_ptr ( T_task ( ) ) ;
239
239
}
240
240
241
- fn type_of ( @trans_ctxt cx , @typeck. ty t ) -> TypeRef {
241
+ fn type_of ( @crate_ctxt cx , @typeck. ty t ) -> TypeRef {
242
242
let TypeRef llty = type_of_inner ( cx, t) ;
243
243
check ( llty as int != 0 ) ;
244
244
ret llty;
245
245
}
246
246
247
- fn type_of_inner ( @trans_ctxt cx , @typeck. ty t ) -> TypeRef {
247
+ fn type_of_inner ( @crate_ctxt cx , @typeck. ty t ) -> TypeRef {
248
248
alt ( t. struct ) {
249
249
case ( typeck. ty_nil ) { ret T_nil ( ) ; }
250
250
case ( typeck. ty_bool ) { ret T_bool ( ) ; }
@@ -334,7 +334,7 @@ fn C_int(int i) -> ValueRef {
334
334
ret C_integral ( i, T_int ( ) ) ;
335
335
}
336
336
337
- fn C_str ( @trans_ctxt cx , str s) -> ValueRef {
337
+ fn C_str ( @crate_ctxt cx , str s) -> ValueRef {
338
338
auto sc = llvm. LLVMConstString ( _str. buf ( s) , _str. byte_len ( s) , False ) ;
339
339
auto g = llvm. LLVMAddGlobal ( cx. llmod , val_ty ( sc) ,
340
340
_str. buf ( cx. names . next ( "str" ) ) ) ;
@@ -395,7 +395,7 @@ fn decl_upcall(ModuleRef llmod, uint _n) -> ValueRef {
395
395
ret decl_fastcall_fn ( llmod, s, T_fn ( args, T_int ( ) ) ) ;
396
396
}
397
397
398
- fn get_upcall ( @trans_ctxt cx , str name , int n_args ) -> ValueRef {
398
+ fn get_upcall ( @crate_ctxt cx , str name , int n_args ) -> ValueRef {
399
399
if ( cx. upcalls . contains_key ( name) ) {
400
400
ret cx. upcalls . get ( name) ;
401
401
}
@@ -409,10 +409,10 @@ fn get_upcall(@trans_ctxt cx, str name, int n_args) -> ValueRef {
409
409
410
410
fn trans_upcall ( @block_ctxt cx , str name , vec[ ValueRef ] args ) -> result {
411
411
let int n = _vec. len [ ValueRef ] ( args) as int ;
412
- let ValueRef llupcall = get_upcall ( cx. fcx . tcx , name, n) ;
412
+ let ValueRef llupcall = get_upcall ( cx. fcx . ccx , name, n) ;
413
413
llupcall = llvm. LLVMConstPointerCast ( llupcall, T_int ( ) ) ;
414
414
415
- let ValueRef llglue = cx. fcx . tcx . glues . upcall_glues . ( n) ;
415
+ let ValueRef llglue = cx. fcx . ccx . glues . upcall_glues . ( n) ;
416
416
let vec[ ValueRef ] call_args = vec ( cx. fcx . lltaskptr , llupcall) ;
417
417
for ( ValueRef a in args) {
418
418
call_args += cx. build . ZExtOrBitCast ( a, T_int ( ) ) ;
@@ -510,7 +510,7 @@ fn trans_copy_ty(@block_ctxt cx,
510
510
ret res( r. bcx , r. bcx . build . Store ( src, dst) ) ;
511
511
}
512
512
}
513
- cx. fcx . tcx . sess . unimpl ( "ty variant in trans_copy_ty" ) ;
513
+ cx. fcx . ccx . sess . unimpl ( "ty variant in trans_copy_ty" ) ;
514
514
fail;
515
515
}
516
516
@@ -541,7 +541,7 @@ impure fn trans_lit(@block_ctxt cx, &ast.lit lit) -> result {
541
541
case ( ast. lit_str ( ?s) ) {
542
542
auto len = ( _str. byte_len ( s) as int ) + 1 ;
543
543
auto sub = trans_upcall ( cx, "upcall_new_str" ,
544
- vec ( p2i ( C_str ( cx. fcx . tcx , s) ) ,
544
+ vec ( p2i ( C_str ( cx. fcx . ccx , s) ) ,
545
545
C_int ( len) ) ) ;
546
546
sub. val = sub. bcx . build . IntToPtr ( sub. val ,
547
547
T_ptr ( T_str ( len as uint ) ) ) ;
@@ -551,7 +551,7 @@ impure fn trans_lit(@block_ctxt cx, &ast.lit lit) -> result {
551
551
}
552
552
}
553
553
554
- fn node_type ( @trans_ctxt cx , & ast . ann a) -> TypeRef {
554
+ fn node_type ( @crate_ctxt cx , & ast . ann a) -> TypeRef {
555
555
alt ( a) {
556
556
case ( ast. ann_none ) {
557
557
log "missing type annotation" ;
@@ -583,7 +583,7 @@ impure fn trans_unary(@block_ctxt cx, ast.unop op,
583
583
ret sub;
584
584
}
585
585
case ( ast. box ) {
586
- auto e_ty = node_type ( cx. fcx . tcx , a) ;
586
+ auto e_ty = node_type ( cx. fcx . ccx , a) ;
587
587
auto box_ty = T_box ( e_ty) ;
588
588
sub. val = cx. build . Malloc ( box_ty) ;
589
589
auto rc = sub. bcx . build . GEP ( sub. val ,
@@ -592,7 +592,7 @@ impure fn trans_unary(@block_ctxt cx, ast.unop op,
592
592
ret res ( sub. bcx , cx. build . Store ( C_int ( 1 ) , rc) ) ;
593
593
}
594
594
}
595
- cx. fcx . tcx . sess . unimpl ( "expr variant in trans_unary" ) ;
595
+ cx. fcx . ccx . sess . unimpl ( "expr variant in trans_unary" ) ;
596
596
fail;
597
597
}
598
598
@@ -737,7 +737,7 @@ impure fn trans_binary(@block_ctxt cx, ast.binop op,
737
737
ret sub;
738
738
}
739
739
}
740
- cx. fcx . tcx . sess . unimpl ( "expr variant in trans_binary" ) ;
740
+ cx. fcx . ccx . sess . unimpl ( "expr variant in trans_binary" ) ;
741
741
fail;
742
742
}
743
743
@@ -864,21 +864,21 @@ fn trans_lval(@block_ctxt cx, &ast.expr e)
864
864
true , did) ;
865
865
}
866
866
case ( ast. def_fn ( ?did) ) {
867
- ret tup ( res ( cx, cx. fcx . tcx . fn_ids . get ( did) ) ,
867
+ ret tup ( res ( cx, cx. fcx . ccx . fn_ids . get ( did) ) ,
868
868
false , did) ;
869
869
}
870
870
case ( _) {
871
- cx. fcx . tcx . sess . unimpl ( "def variant in trans" ) ;
871
+ cx. fcx . ccx . sess . unimpl ( "def variant in trans" ) ;
872
872
}
873
873
}
874
874
}
875
875
case ( none[ ast. def ] ) {
876
- cx. fcx . tcx . sess . err ( "unresolved expr_name in trans" ) ;
876
+ cx. fcx . ccx . sess . err ( "unresolved expr_name in trans" ) ;
877
877
}
878
878
}
879
879
}
880
880
}
881
- cx. fcx . tcx . sess . unimpl ( "expr variant in trans_lval" ) ;
881
+ cx. fcx . ccx . sess . unimpl ( "expr variant in trans_lval" ) ;
882
882
fail;
883
883
}
884
884
@@ -963,7 +963,7 @@ impure fn trans_expr(@block_ctxt cx, &ast.expr e) -> result {
963
963
}
964
964
965
965
}
966
- cx. fcx . tcx . sess . unimpl ( "expr variant in trans_expr" ) ;
966
+ cx. fcx . ccx . sess . unimpl ( "expr variant in trans_expr" ) ;
967
967
fail;
968
968
}
969
969
@@ -999,8 +999,8 @@ impure fn trans_check_expr(@block_ctxt cx, &ast.expr e) -> result {
999
999
auto cond_res = trans_expr ( cx, e) ;
1000
1000
1001
1001
// FIXME: need pretty-printer.
1002
- auto V_expr_str = p2i ( C_str ( cx. fcx . tcx , "<expr>" ) ) ;
1003
- auto V_filename = p2i ( C_str ( cx. fcx . tcx , e. span . filename ) ) ;
1002
+ auto V_expr_str = p2i ( C_str ( cx. fcx . ccx , "<expr>" ) ) ;
1003
+ auto V_filename = p2i ( C_str ( cx. fcx . ccx , e. span . filename ) ) ;
1004
1004
auto V_line = e. span . lo . line as int ;
1005
1005
auto args = vec ( V_expr_str , V_filename , C_int ( V_line ) ) ;
1006
1006
@@ -1084,7 +1084,7 @@ impure fn trans_stmt(@block_ctxt cx, &ast.stmt s) -> result {
1084
1084
}
1085
1085
}
1086
1086
case ( _) {
1087
- cx. fcx . tcx . sess . unimpl ( "stmt variant" ) ;
1087
+ cx. fcx . ccx . sess . unimpl ( "stmt variant" ) ;
1088
1088
}
1089
1089
}
1090
1090
ret sub;
@@ -1103,7 +1103,7 @@ fn new_block_ctxt(@fn_ctxt cx, block_parent parent,
1103
1103
str name ) -> @block_ctxt {
1104
1104
let BasicBlockRef llbb =
1105
1105
llvm. LLVMAppendBasicBlock ( cx. llfn ,
1106
- _str. buf ( cx. tcx . names . next ( name) ) ) ;
1106
+ _str. buf ( cx. ccx . names . next ( name) ) ) ;
1107
1107
1108
1108
ret @rec( llbb=llbb,
1109
1109
build=new_builder ( llbb, name) ,
@@ -1159,7 +1159,7 @@ impure fn trans_block(@block_ctxt cx, &ast.block b) -> result {
1159
1159
auto bcx = cx;
1160
1160
1161
1161
for each ( @ast. local local in block_locals( b) ) {
1162
- auto ty = node_type( cx. fcx. tcx , local. ann) ;
1162
+ auto ty = node_type( cx. fcx. ccx , local. ann) ;
1163
1163
auto val = bcx. build. Alloca ( ty) ;
1164
1164
cx. fcx. lllocals. insert( local. id, val) ;
1165
1165
}
@@ -1179,7 +1179,7 @@ impure fn trans_block(@block_ctxt cx, &ast.block b) -> result {
1179
1179
ret res( bcx, r. val ) ;
1180
1180
}
1181
1181
1182
- fn new_fn_ctxt ( @trans_ctxt cx ,
1182
+ fn new_fn_ctxt ( @crate_ctxt cx ,
1183
1183
str name ,
1184
1184
& ast . _fn f,
1185
1185
ast. def_id fid ) -> @fn_ctxt {
@@ -1204,15 +1204,15 @@ fn new_fn_ctxt(@trans_ctxt cx,
1204
1204
lltaskptr=lltaskptr,
1205
1205
llargs=llargs,
1206
1206
lllocals=lllocals,
1207
- tcx =cx) ;
1207
+ ccx =cx) ;
1208
1208
}
1209
1209
1210
1210
fn is_terminated ( @block_ctxt cx ) -> bool {
1211
1211
auto inst = llvm. LLVMGetLastInstruction ( cx. llbb ) ;
1212
1212
ret llvm. LLVMIsATerminatorInst ( inst) as int != 0 ;
1213
1213
}
1214
1214
1215
- impure fn trans_fn ( @trans_ctxt cx , & ast . _fn f, ast. def_id fid ) {
1215
+ impure fn trans_fn ( @crate_ctxt cx , & ast . _fn f, ast. def_id fid ) {
1216
1216
1217
1217
auto fcx = new_fn_ctxt ( cx, cx. path , f, fid) ;
1218
1218
auto bcx = new_top_block_ctxt ( fcx) ;
@@ -1224,7 +1224,7 @@ impure fn trans_fn(@trans_ctxt cx, &ast._fn f, ast.def_id fid) {
1224
1224
}
1225
1225
}
1226
1226
1227
- impure fn trans_item ( @trans_ctxt cx , & ast . item item) {
1227
+ impure fn trans_item ( @crate_ctxt cx , & ast . item item) {
1228
1228
alt ( item. node ) {
1229
1229
case ( ast. item_fn ( ?name, ?f, ?fid, _) ) {
1230
1230
auto sub_cx = @rec ( path=cx. path + "." + name with * cx) ;
@@ -1237,14 +1237,14 @@ impure fn trans_item(@trans_ctxt cx, &ast.item item) {
1237
1237
}
1238
1238
}
1239
1239
1240
- impure fn trans_mod ( @trans_ctxt cx , & ast. _mod m ) {
1240
+ impure fn trans_mod ( @crate_ctxt cx , & ast. _mod m ) {
1241
1241
for ( @ast. item item in m. items) {
1242
1242
trans_item ( cx, * item) ;
1243
1243
}
1244
1244
}
1245
1245
1246
1246
1247
- fn collect_item ( & @trans_ctxt cx , @ast. item i ) -> @trans_ctxt {
1247
+ fn collect_item ( & @crate_ctxt cx , @ast. item i ) -> @crate_ctxt {
1248
1248
alt ( i. node ) {
1249
1249
case ( ast. item_fn ( ?name, ?f, ?fid, ?ann) ) {
1250
1250
cx. items . insert ( fid, i) ;
@@ -1262,22 +1262,22 @@ fn collect_item(&@trans_ctxt cx, @ast.item i) -> @trans_ctxt {
1262
1262
}
1263
1263
1264
1264
1265
- fn collect_items ( @trans_ctxt cx , @ast. crate crate) {
1265
+ fn collect_items ( @crate_ctxt cx , @ast. crate crate) {
1266
1266
1267
- let fold. ast_fold[ @trans_ctxt ] fld =
1268
- fold. new_identity_fold [ @trans_ctxt ] ( ) ;
1267
+ let fold. ast_fold[ @crate_ctxt ] fld =
1268
+ fold. new_identity_fold [ @crate_ctxt ] ( ) ;
1269
1269
1270
1270
fld = @rec ( update_env_for_item = bind collect_item ( _, _)
1271
1271
with * fld ) ;
1272
1272
1273
- fold. fold_crate [ @trans_ctxt ] ( cx, fld, crate ) ;
1273
+ fold. fold_crate [ @crate_ctxt ] ( cx, fld, crate ) ;
1274
1274
}
1275
1275
1276
1276
fn p2i ( ValueRef v) -> ValueRef {
1277
1277
ret llvm. LLVMConstPtrToInt ( v, T_int ( ) ) ;
1278
1278
}
1279
1279
1280
- fn trans_exit_task_glue ( @trans_ctxt cx ) {
1280
+ fn trans_exit_task_glue ( @crate_ctxt cx ) {
1281
1281
let vec[ TypeRef ] T_args = vec ( ) ;
1282
1282
let vec[ ValueRef ] V_args = vec ( ) ;
1283
1283
@@ -1287,14 +1287,14 @@ fn trans_exit_task_glue(@trans_ctxt cx) {
1287
1287
lltaskptr=lltaskptr,
1288
1288
llargs=new_def_hash[ ValueRef ] ( ) ,
1289
1289
lllocals=new_def_hash[ ValueRef ] ( ) ,
1290
- tcx =cx) ;
1290
+ ccx =cx) ;
1291
1291
1292
1292
auto bcx = new_top_block_ctxt ( fcx) ;
1293
1293
trans_upcall ( bcx, "upcall_exit" , V_args ) ;
1294
1294
bcx. build . RetVoid ( ) ;
1295
1295
}
1296
1296
1297
- fn crate_constant ( @trans_ctxt cx ) -> ValueRef {
1297
+ fn crate_constant ( @crate_ctxt cx ) -> ValueRef {
1298
1298
1299
1299
let ValueRef crate_ptr =
1300
1300
llvm. LLVMAddGlobal ( cx. llmod , T_crate ( ) ,
@@ -1332,7 +1332,7 @@ fn crate_constant(@trans_ctxt cx) -> ValueRef {
1332
1332
ret crate_ptr;
1333
1333
}
1334
1334
1335
- fn trans_main_fn ( @trans_ctxt cx , ValueRef llcrate) {
1335
+ fn trans_main_fn ( @crate_ctxt cx , ValueRef llcrate) {
1336
1336
auto T_main_args = vec ( T_int ( ) , T_int ( ) ) ;
1337
1337
auto T_rust_start_args = vec ( T_int ( ) , T_int ( ) , T_int ( ) , T_int ( ) ) ;
1338
1338
0 commit comments