Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::kernel::ActiveTypeParametersScope Class Reference

#include <kernel_translation_helper.h>

Public Member Functions

 ActiveTypeParametersScope (ActiveClass *active_class, const Function &innermost, const FunctionType *innermost_signature, Zone *Z)
 
 ActiveTypeParametersScope (ActiveClass *active_class, const FunctionType *innermost_signature, Zone *Z)
 
 ~ActiveTypeParametersScope ()
 

Detailed Description

Definition at line 1510 of file kernel_translation_helper.h.

Constructor & Destructor Documentation

◆ ActiveTypeParametersScope() [1/2]

dart::kernel::ActiveTypeParametersScope::ActiveTypeParametersScope ( ActiveClass active_class,
const Function innermost,
const FunctionType innermost_signature,
Zone Z 
)

Definition at line 3218 of file kernel_translation_helper.cc.

3223 : active_class_(active_class), saved_(*active_class), zone_(Z) {
3224 active_class_->enclosing = innermost_signature;
3225
3226 intptr_t num_params = 0;
3227
3228 Function& f = Function::Handle(Z);
3229 for (f = innermost.ptr(); f.parent_function() != Object::null();
3230 f = f.parent_function()) {
3231 num_params += f.NumTypeParameters();
3232 }
3233 if (num_params == 0) return;
3234
3235 TypeArguments& params =
3237
3238 intptr_t index = num_params;
3239 for (f = innermost.ptr(); f.parent_function() != Object::null();
3240 f = f.parent_function()) {
3241 for (intptr_t j = f.NumTypeParameters() - 1; j >= 0; --j) {
3242 const auto& type_param = TypeParameter::Handle(Z, f.TypeParameterAt(j));
3243 params.SetTypeAt(--index, type_param);
3244 }
3245 }
3246
3247 active_class_->local_type_parameters = &params;
3248}
static ObjectPtr null()
Definition: object.h:433
static Object & Handle()
Definition: object.h:407
static TypeArgumentsPtr New(intptr_t len, Heap::Space space=Heap::kOld)
Definition: object.cc:7675
const TypeArguments * local_type_parameters
const EmbeddedViewParams * params

◆ ActiveTypeParametersScope() [2/2]

dart::kernel::ActiveTypeParametersScope::ActiveTypeParametersScope ( ActiveClass active_class,
const FunctionType innermost_signature,
Zone Z 
)

Definition at line 3250 of file kernel_translation_helper.cc.

3254 : active_class_(active_class), saved_(*active_class), zone_(Z) {
3255 active_class_->enclosing = innermost_signature;
3256
3257 const intptr_t num_new_params =
3258 innermost_signature == nullptr ? active_class->klass->NumTypeParameters()
3259 : innermost_signature->NumTypeParameters();
3260 if (num_new_params == 0) return;
3261
3262 const TypeArguments* old_params = active_class->local_type_parameters;
3263 const intptr_t old_param_count =
3264 old_params == nullptr ? 0 : old_params->Length();
3265 const TypeArguments& extended_params = TypeArguments::Handle(
3266 Z, TypeArguments::New(old_param_count + num_new_params));
3267
3268 intptr_t index = 0;
3269 for (intptr_t i = 0; i < old_param_count; ++i) {
3270 extended_params.SetTypeAt(index++,
3271 AbstractType::Handle(Z, old_params->TypeAt(i)));
3272 }
3273 for (intptr_t i = 0; i < num_new_params; ++i) {
3274 const auto& type_param =
3275 TypeParameter::Handle(Z, innermost_signature == nullptr
3276 ? active_class->klass->TypeParameterAt(i)
3277 : innermost_signature->TypeParameterAt(i));
3278 extended_params.SetTypeAt(index++, type_param);
3279 }
3280
3281 active_class_->local_type_parameters = &extended_params;
3282}
intptr_t NumTypeParameters() const
Definition: object.h:9578

◆ ~ActiveTypeParametersScope()

dart::kernel::ActiveTypeParametersScope::~ActiveTypeParametersScope ( )

Definition at line 3284 of file kernel_translation_helper.cc.

3284 {
3285 *active_class_ = saved_;
3286}

The documentation for this class was generated from the following files: