@@ -2349,7 +2349,7 @@ Thunk_statement::Thunk_statement(Statement_classification classification,
2349
2349
Call_expression* call,
2350
2350
Location location)
2351
2351
: Statement(classification, location),
2352
- call_(call), struct_type_( NULL )
2352
+ call_(call)
2353
2353
{
2354
2354
}
2355
2355
@@ -2430,15 +2430,6 @@ void
2430
2430
Thunk_statement::do_determine_types ()
2431
2431
{
2432
2432
this ->call_ ->determine_type_no_context ();
2433
-
2434
- // Now that we know the types of the call, build the struct used to
2435
- // pass parameters.
2436
- Call_expression* ce = this ->call_ ->call_expression ();
2437
- if (ce == NULL )
2438
- return ;
2439
- Function_type* fntype = ce->get_function_type ();
2440
- if (fntype != NULL && !this ->is_simple (fntype))
2441
- this ->struct_type_ = this ->build_struct (fntype);
2442
2433
}
2443
2434
2444
2435
// Check types in a thunk statement.
@@ -2581,6 +2572,8 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function,
2581
2572
if (this ->is_simple (fntype))
2582
2573
return false ;
2583
2574
2575
+ Struct_type* struct_type = this ->build_struct (fntype);
2576
+
2584
2577
Expression* fn = ce->fn ();
2585
2578
Interface_field_reference_expression* interface_method =
2586
2579
fn->interface_field_reference_expression ();
@@ -2600,7 +2593,7 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function,
2600
2593
std::string thunk_name = gogo->thunk_name ();
2601
2594
2602
2595
// Build the thunk.
2603
- this ->build_thunk (gogo, thunk_name);
2596
+ this ->build_thunk (gogo, thunk_name, struct_type );
2604
2597
2605
2598
// Generate code to call the thunk.
2606
2599
@@ -2630,8 +2623,7 @@ Thunk_statement::simplify_statement(Gogo* gogo, Named_object* function,
2630
2623
2631
2624
// Build the struct.
2632
2625
Expression* constructor =
2633
- Expression::make_struct_composite_literal (this ->struct_type_ , vals,
2634
- location);
2626
+ Expression::make_struct_composite_literal (struct_type, vals, location);
2635
2627
2636
2628
// Allocate the initialized struct on the heap.
2637
2629
constructor = Expression::make_heap_expression (constructor, location);
@@ -2745,15 +2737,6 @@ Thunk_statement::build_struct(Function_type* fntype)
2745
2737
fields->push_back (Struct_field (tid));
2746
2738
}
2747
2739
2748
- // The predeclared recover function has no argument. However, we
2749
- // add an argument when building recover thunks. Handle that here.
2750
- if (ce->is_recover_call ())
2751
- {
2752
- fields->push_back (Struct_field (Typed_identifier (" can_recover" ,
2753
- Type::lookup_bool_type (),
2754
- location)));
2755
- }
2756
-
2757
2740
const Expression_list* args = ce->args ();
2758
2741
if (args != NULL )
2759
2742
{
@@ -2781,7 +2764,8 @@ Thunk_statement::build_struct(Function_type* fntype)
2781
2764
// artificial, function.
2782
2765
2783
2766
void
2784
- Thunk_statement::build_thunk (Gogo* gogo, const std::string& thunk_name)
2767
+ Thunk_statement::build_thunk (Gogo* gogo, const std::string& thunk_name,
2768
+ Struct_type* struct_type)
2785
2769
{
2786
2770
Location location = this ->location ();
2787
2771
@@ -2807,7 +2791,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name)
2807
2791
// which is a pointer to the special structure we build.
2808
2792
const char * const parameter_name = " __go_thunk_parameter" ;
2809
2793
Typed_identifier_list* thunk_parameters = new Typed_identifier_list ();
2810
- Type* pointer_to_struct_type = Type::make_pointer_type (this -> struct_type_ );
2794
+ Type* pointer_to_struct_type = Type::make_pointer_type (struct_type );
2811
2795
thunk_parameters->push_back (Typed_identifier (parameter_name,
2812
2796
pointer_to_struct_type,
2813
2797
location));
@@ -2914,7 +2898,7 @@ Thunk_statement::build_thunk(Gogo* gogo, const std::string& thunk_name)
2914
2898
}
2915
2899
2916
2900
Expression_list* call_params = new Expression_list ();
2917
- const Struct_field_list* fields = this -> struct_type_ ->fields ();
2901
+ const Struct_field_list* fields = struct_type ->fields ();
2918
2902
Struct_field_list::const_iterator p = fields->begin ();
2919
2903
for (unsigned int i = 0 ; i < next_index; ++i)
2920
2904
++p;
0 commit comments