@@ -23,6 +23,7 @@ use middle::trans::common::*;
23
23
use middle:: trans:: datum:: { Datum , INIT , ByRef , ByValue , FromLvalue } ;
24
24
use middle:: trans:: expr;
25
25
use middle:: trans:: glue;
26
+ use middle:: trans:: machine;
26
27
use middle:: trans:: type_of:: * ;
27
28
use util:: ppaux:: ty_to_str;
28
29
@@ -103,7 +104,7 @@ use syntax::print::pprust::expr_to_str;
103
104
//
104
105
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
105
106
106
- enum EnvAction {
107
+ pub enum EnvAction {
107
108
/// Copy the value from this llvm ValueRef into the environment.
108
109
EnvStore ,
109
110
@@ -114,12 +115,12 @@ enum EnvAction {
114
115
EnvRef
115
116
}
116
117
117
- struct EnvValue {
118
+ pub struct EnvValue {
118
119
action : EnvAction ,
119
120
datum : Datum
120
121
}
121
122
122
- impl EnvAction {
123
+ pub impl EnvAction {
123
124
fn to_str ( ) -> ~str {
124
125
match self {
125
126
EnvStore => ~"EnvStore ",
@@ -129,21 +130,21 @@ impl EnvAction {
129
130
}
130
131
}
131
132
132
- impl EnvValue {
133
+ pub impl EnvValue {
133
134
fn to_str ( ccx : @crate_ctxt ) -> ~str {
134
135
fmt ! ( "%s(%s)" , self . action. to_str( ) , self . datum. to_str( ccx) )
135
136
}
136
137
}
137
138
138
- fn mk_tuplified_uniq_cbox_ty ( tcx : ty:: ctxt , cdata_ty : ty:: t ) -> ty:: t {
139
+ pub fn mk_tuplified_uniq_cbox_ty ( tcx : ty:: ctxt , cdata_ty : ty:: t ) -> ty:: t {
139
140
let cbox_ty = tuplify_box_ty ( tcx, cdata_ty) ;
140
141
return ty:: mk_imm_uniq ( tcx, cbox_ty) ;
141
142
}
142
143
143
144
// Given a closure ty, emits a corresponding tuple ty
144
- fn mk_closure_tys ( tcx : ty:: ctxt ,
145
- bound_values : ~[ EnvValue ] )
146
- -> ty:: t {
145
+ pub fn mk_closure_tys ( tcx : ty:: ctxt ,
146
+ bound_values : ~[ EnvValue ] )
147
+ -> ty:: t {
147
148
// determine the types of the values in the env. Note that this
148
149
// is the actual types that will be stored in the map, not the
149
150
// logical types as the user sees them, so by-ref upvars must be
@@ -159,9 +160,8 @@ fn mk_closure_tys(tcx: ty::ctxt,
159
160
return cdata_ty;
160
161
}
161
162
162
- fn allocate_cbox ( bcx : block , proto : ast:: Proto , cdata_ty : ty:: t )
163
- -> Result
164
- {
163
+ pub fn allocate_cbox ( bcx : block , proto : ast:: Proto , cdata_ty : ty:: t )
164
+ -> Result {
165
165
let _icx = bcx. insn_ctxt ( "closure::allocate_cbox" ) ;
166
166
let ccx = bcx. ccx ( ) , tcx = ccx. tcx ;
167
167
@@ -196,7 +196,7 @@ fn allocate_cbox(bcx: block, proto: ast::Proto, cdata_ty: ty::t)
196
196
}
197
197
}
198
198
199
- type closure_result = {
199
+ pub type closure_result = {
200
200
llbox : ValueRef , // llvalue of ptr to closure
201
201
cdata_ty : ty:: t , // type of the closure data
202
202
bcx : block // final bcx
@@ -206,9 +206,9 @@ type closure_result = {
206
206
// construct a closure out of them. If copying is true, it is a
207
207
// heap allocated closure that copies the upvars into environment.
208
208
// Otherwise, it is stack allocated and copies pointers to the upvars.
209
- fn store_environment ( bcx : block ,
210
- bound_values : ~[ EnvValue ] ,
211
- proto : ast:: Proto ) -> closure_result {
209
+ pub fn store_environment ( bcx : block ,
210
+ bound_values : ~[ EnvValue ] ,
211
+ proto : ast:: Proto ) -> closure_result {
212
212
let _icx = bcx. insn_ctxt ( "closure::store_environment" ) ;
213
213
let ccx = bcx. ccx ( ) , tcx = ccx. tcx ;
214
214
@@ -263,10 +263,10 @@ fn store_environment(bcx: block,
263
263
264
264
// Given a context and a list of upvars, build a closure. This just
265
265
// collects the upvars and packages them up for store_environment.
266
- fn build_closure ( bcx0 : block ,
267
- cap_vars : ~[ capture:: capture_var ] ,
268
- proto : ast:: Proto ,
269
- include_ret_handle : Option < ValueRef > ) -> closure_result {
266
+ pub fn build_closure ( bcx0 : block ,
267
+ cap_vars : ~[ capture:: capture_var ] ,
268
+ proto : ast:: Proto ,
269
+ include_ret_handle : Option < ValueRef > ) -> closure_result {
270
270
let _icx = bcx0. insn_ctxt ( "closure::build_closure" ) ;
271
271
// If we need to, package up the iterator body to call
272
272
let mut bcx = bcx0; ;
@@ -326,11 +326,11 @@ fn build_closure(bcx0: block,
326
326
// Given an enclosing block context, a new function context, a closure type,
327
327
// and a list of upvars, generate code to load and populate the environment
328
328
// with the upvars and type descriptors.
329
- fn load_environment ( fcx : fn_ctxt ,
330
- cdata_ty : ty:: t ,
331
- cap_vars : ~[ capture:: capture_var ] ,
332
- load_ret_handle : bool ,
333
- proto : ast:: Proto ) {
329
+ pub fn load_environment ( fcx : fn_ctxt ,
330
+ cdata_ty : ty:: t ,
331
+ cap_vars : ~[ capture:: capture_var ] ,
332
+ load_ret_handle : bool ,
333
+ proto : ast:: Proto ) {
334
334
let _icx = fcx. insn_ctxt ( "closure::load_environment" ) ;
335
335
336
336
let llloadenv = match fcx. llloadenv {
@@ -377,16 +377,15 @@ fn load_environment(fcx: fn_ctxt,
377
377
}
378
378
}
379
379
380
- fn trans_expr_fn ( bcx : block ,
381
- proto : ast:: Proto ,
382
- +decl : ast:: fn_decl ,
383
- +body : ast:: blk ,
384
- outer_id : ast:: node_id ,
385
- user_id : ast:: node_id ,
386
- cap_clause : ast:: capture_clause ,
387
- is_loop_body : Option < Option < ValueRef > > ,
388
- dest : expr:: Dest ) -> block
389
- {
380
+ pub fn trans_expr_fn ( bcx : block ,
381
+ proto : ast:: Proto ,
382
+ +decl : ast:: fn_decl ,
383
+ +body : ast:: blk ,
384
+ outer_id : ast:: node_id ,
385
+ user_id : ast:: node_id ,
386
+ cap_clause : ast:: capture_clause ,
387
+ is_loop_body : Option < Option < ValueRef > > ,
388
+ dest : expr:: Dest ) -> block {
390
389
/*!
391
390
*
392
391
* Translates the body of a closure expression.
@@ -462,13 +461,11 @@ fn trans_expr_fn(bcx: block,
462
461
return bcx;
463
462
}
464
463
465
- fn make_fn_glue (
466
- cx : block ,
467
- v : ValueRef ,
468
- t : ty:: t ,
469
- glue_fn : fn @( block , v : ValueRef , t : ty:: t ) -> block )
470
- -> block
471
- {
464
+ pub fn make_fn_glue ( cx : block ,
465
+ v : ValueRef ,
466
+ t : ty:: t ,
467
+ glue_fn : fn @( block , v : ValueRef , t : ty:: t ) -> block )
468
+ -> block {
472
469
let _icx = cx. insn_ctxt ( "closure::make_fn_glue" ) ;
473
470
let bcx = cx;
474
471
let tcx = cx. tcx ( ) ;
@@ -487,12 +484,11 @@ fn make_fn_glue(
487
484
}
488
485
}
489
486
490
- fn make_opaque_cbox_take_glue (
487
+ pub fn make_opaque_cbox_take_glue (
491
488
bcx : block ,
492
489
proto : ast:: Proto ,
493
490
cboxptr : ValueRef ) // ptr to ptr to the opaque closure
494
- -> block
495
- {
491
+ -> block {
496
492
// Easy cases:
497
493
let _icx = bcx. insn_ctxt ( "closure::make_opaque_cbox_take_glue" ) ;
498
494
match proto {
@@ -521,7 +517,7 @@ fn make_opaque_cbox_take_glue(
521
517
let sz = Load ( bcx, GEPi ( bcx, tydesc, [ 0 u, abi:: tydesc_field_size] ) ) ;
522
518
523
519
// Adjust sz to account for the rust_opaque_box header fields
524
- let sz = Add ( bcx, sz, shape :: llsize_of ( ccx, T_box_header ( ccx) ) ) ;
520
+ let sz = Add ( bcx, sz, machine :: llsize_of ( ccx, T_box_header ( ccx) ) ) ;
525
521
526
522
// Allocate memory, update original ptr, and copy existing data
527
523
let opaque_tydesc = PointerCast ( bcx, tydesc, T_ptr ( T_i8 ( ) ) ) ;
@@ -547,7 +543,7 @@ fn make_opaque_cbox_take_glue(
547
543
}
548
544
}
549
545
550
- fn make_opaque_cbox_drop_glue (
546
+ pub fn make_opaque_cbox_drop_glue (
551
547
bcx : block ,
552
548
proto : ast:: Proto ,
553
549
cboxptr : ValueRef ) // ptr to the opaque closure
@@ -568,7 +564,7 @@ fn make_opaque_cbox_drop_glue(
568
564
}
569
565
}
570
566
571
- fn make_opaque_cbox_free_glue (
567
+ pub fn make_opaque_cbox_free_glue (
572
568
bcx : block ,
573
569
proto : ast:: Proto ,
574
570
cbox : ValueRef ) // ptr to ptr to the opaque closure
0 commit comments