Flutter Engine
The Flutter Engine
Classes | Public Member Functions | List of all members
dart::LocalVarDescriptorsBuilder Class Reference

#include <scopes.h>

Inheritance diagram for dart::LocalVarDescriptorsBuilder:
dart::ValueObject

Classes

struct  VarDesc
 

Public Member Functions

 LocalVarDescriptorsBuilder ()
 
void Add (const VarDesc &var_desc)
 
void AddAll (Zone *zone, const LocalVarDescriptors &var_descs)
 
void AddDeoptIdToContextLevelMappings (ZoneGrowableArray< intptr_t > *context_level_array)
 
LocalVarDescriptorsPtr Done ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 287 of file scopes.h.

Constructor & Destructor Documentation

◆ LocalVarDescriptorsBuilder()

dart::LocalVarDescriptorsBuilder::LocalVarDescriptorsBuilder ( )
inline

Definition at line 294 of file scopes.h.

294: vars_(8) {}

Member Function Documentation

◆ Add()

void dart::LocalVarDescriptorsBuilder::Add ( const VarDesc var_desc)
inline

Definition at line 297 of file scopes.h.

297{ vars_.Add(var_desc); }

◆ AddAll()

void dart::LocalVarDescriptorsBuilder::AddAll ( Zone zone,
const LocalVarDescriptors var_descs 
)

Definition at line 631 of file scopes.cc.

632 {
633 for (intptr_t i = 0, n = var_descs.Length(); i < n; ++i) {
634 VarDesc desc;
635 desc.name = &String::Handle(zone, var_descs.GetName(i));
636 var_descs.GetInfo(i, &desc.info);
637 Add(desc);
638 }
639}
void Add(const VarDesc &var_desc)
Definition: scopes.h:297
static Object & Handle()
Definition: object.h:407

◆ AddDeoptIdToContextLevelMappings()

void dart::LocalVarDescriptorsBuilder::AddDeoptIdToContextLevelMappings ( ZoneGrowableArray< intptr_t > *  context_level_array)

Definition at line 641 of file scopes.cc.

642 {
643 // Record deopt-id -> context-level mappings, using ranges of deopt-ids with
644 // the same context-level. [context_level_array] contains (deopt_id,
645 // context_level) tuples.
646 for (intptr_t start = 0; start < context_level_array->length();) {
647 intptr_t start_deopt_id = (*context_level_array)[start];
648 intptr_t start_context_level = (*context_level_array)[start + 1];
649 intptr_t end = start;
650 intptr_t end_deopt_id = start_deopt_id;
651 for (intptr_t peek = start + 2; peek < context_level_array->length();
652 peek += 2) {
653 intptr_t peek_deopt_id = (*context_level_array)[peek];
654 intptr_t peek_context_level = (*context_level_array)[peek + 1];
655 // The range encoding assumes the tuples have ascending deopt_ids.
656 ASSERT(peek_deopt_id > end_deopt_id);
657 if (peek_context_level != start_context_level) break;
658 end = peek;
659 end_deopt_id = peek_deopt_id;
660 }
661
662 VarDesc desc;
663 desc.name = &Symbols::Empty(); // No name.
665 desc.info.scope_id = 0;
666 // We repurpose the token position fields to store deopt IDs in this case.
667 desc.info.begin_pos = TokenPosition::Deserialize(start_deopt_id);
668 desc.info.end_pos = TokenPosition::Deserialize(end_deopt_id);
669 desc.info.set_index(start_context_level);
670 Add(desc);
671
672 start = end + 2;
673 }
674}
intptr_t length() const
static const String & Empty()
Definition: symbols.h:688
static TokenPosition Deserialize(int32_t value)
#define ASSERT(E)
glong glong end

◆ Done()

LocalVarDescriptorsPtr dart::LocalVarDescriptorsBuilder::Done ( )

Definition at line 676 of file scopes.cc.

676 {
677 if (vars_.is_empty()) {
678 return Object::empty_var_descriptors().ptr();
679 }
680 const LocalVarDescriptors& var_desc =
682 for (int i = 0; i < vars_.length(); i++) {
683 var_desc.SetVar(i, *(vars_[i].name), &vars_[i].info);
684 }
685 return var_desc.ptr();
686}
static void info(const char *fmt,...) SK_PRINTF_LIKE(1
Definition: DM.cpp:213
static LocalVarDescriptorsPtr New(intptr_t num_variables)
Definition: object.cc:16134
const char *const name

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