@@ -2137,6 +2137,11 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, substs: [ty::t],
2137
2137
ast_map:: node_method ( m, _, pt) { ( pt, m. ident ) }
2138
2138
// We can't monomorphize native functions
2139
2139
ast_map:: node_native_item ( _, _, _) { ret none; }
2140
+ ast_map:: node_ctor ( i) {
2141
+ alt check ccx. tcx . items . get ( i. id ) {
2142
+ ast_map:: node_item ( i, pt) { ( pt, i. ident ) }
2143
+ }
2144
+ }
2140
2145
_ { fail "unexpected node type" ; }
2141
2146
} ;
2142
2147
let pt = * pt + [ path_name ( ccx. names ( name) ) ] ;
@@ -2146,26 +2151,37 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, substs: [ty::t],
2146
2151
2147
2152
let psubsts = some ( { tys: substs, dicts: dicts, bounds: tpt. bounds } ) ;
2148
2153
alt check map_node {
2149
- ast_map : : node_item( @{ node: ast:: item_fn ( decl, _, body) , _} , _) {
2154
+ ast_map : : node_item ( i @@{ node : ast:: item_fn ( decl, _, body) , _} , _) {
2155
+ set_inline_hint_if_appr ( i. attrs , lldecl) ;
2150
2156
trans_fn ( ccx, pt, decl, body, lldecl, no_self, [ ] ,
2151
2157
psubsts, fn_id. node , none) ;
2152
2158
}
2153
- ast_map:: node_item ( @{ node: ast:: item_res ( decl, _, _, _, _) , _} , _) {
2154
- trans_res_ctor ( ccx, pt, decl, fn_id. node , [ ] , psubsts, lldecl) ;
2155
- }
2156
2159
ast_map:: node_variant ( v, enum_item, _) {
2157
2160
let tvs = ty:: enum_variants ( ccx. tcx , local_def ( enum_item. id ) ) ;
2158
2161
let this_tv = option:: get ( vec:: find ( * tvs, { |tv|
2159
2162
tv. id . node == fn_id. node } ) ) ;
2163
+ set_inline_hint ( lldecl) ;
2160
2164
trans_enum_variant ( ccx, enum_item. id , v, this_tv. disr_val ,
2161
2165
( * tvs) . len ( ) == 1 u, [ ] , psubsts, lldecl) ;
2162
2166
}
2163
2167
ast_map:: node_method ( mth, impl_def_id, _) {
2168
+ set_inline_hint_if_appr ( mth. attrs , lldecl) ;
2164
2169
let selfty = ty:: node_id_to_type ( ccx. tcx , mth. self_id ) ;
2165
2170
let selfty = ty:: substitute_type_params ( ccx. tcx , substs, selfty) ;
2166
2171
trans_fn ( ccx, pt, mth. decl , mth. body , lldecl,
2167
2172
impl_self ( selfty) , [ ] , psubsts, fn_id. node , none) ;
2168
2173
}
2174
+ ast_map:: node_ctor ( i) {
2175
+ alt check ccx. tcx . items . get ( i. id ) {
2176
+ ast_map:: node_item ( @{ node: ast:: item_res ( decl, _, _, _, _) , _} , _) {
2177
+ set_inline_hint ( lldecl) ;
2178
+ trans_res_ctor ( ccx, pt, decl, fn_id. node , [ ] , psubsts, lldecl) ;
2179
+ }
2180
+ ast_map:: node_item ( @{ node: ast:: item_class ( _, _, ctor) , _} , _) {
2181
+ ccx. sess . unimpl ( "monomorphic class constructor" ) ;
2182
+ }
2183
+ }
2184
+ }
2169
2185
}
2170
2186
some( { llfn: lldecl, fty: mono_ty} )
2171
2187
}
@@ -4433,6 +4449,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
4433
4449
native:: trans_native_mod ( ccx, native_mod, abi) ;
4434
4450
}
4435
4451
ast:: item_class ( tps, items, ctor) {
4452
+ // FIXME factor our ctor translation, call from monomorphic_fn
4436
4453
let llctor_decl = get_item_val ( ccx, ctor. node . id ) ;
4437
4454
// Translate the ctor
4438
4455
// First, add a preamble that
0 commit comments