15#define H (translation_helper_)
16#define T (type_translator_)
17#define I Isolate::Current()
18#define IG IsolateGroup::Current()
22 parsed_function_(parsed_function),
23 translation_helper_(
Thread::Current()),
24 zone_(translation_helper_.zone()),
25 current_function_scope_(nullptr),
29 needs_expr_temp_(
false),
34 parsed_function->
function().KernelLibraryOffset()),
35 constant_reader_(&helper_, &active_class_),
36 inferred_type_metadata_helper_(&helper_, &constant_reader_),
37 inferred_arg_type_metadata_helper_(
41 procedure_attributes_metadata_helper_(&helper_),
42 type_translator_(&helper_,
48 H.InitFromKernelProgramInfo(kernel_program_info);
49 ASSERT(type_translator_.active_class_ == &active_class_);
53 if (result_ !=
nullptr)
return result_;
55 ASSERT(scope_ ==
nullptr && depth_.loop_ == 0 && depth_.function_ == 0);
79 Type& klass_type =
H.GetDeclarationType(klass);
81 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
85 enclosing_scope =
new (
Z)
LocalScope(
nullptr, 0, 0);
93 current_function_scope_ = scope_ =
new (
Z)
LocalScope(enclosing_scope, 0, 0);
97 if (
function.IsSuspendableFunction()) {
99 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
100 Symbols::SuspendStateVar(), AbstractType::dynamic_type());
110 TokenPosition::kNoSource, TokenPosition::kNoSource,
111 Symbols::FunctionTypeArgumentsVar(), AbstractType::dynamic_type());
134 case UntaggedFunction::kImplicitClosureFunction: {
142 (parent.num_fixed_parameters() !=
target.num_fixed_parameters())) {
143 needs_expr_temp_ =
true;
147 case UntaggedFunction::kClosureFunction:
148 case UntaggedFunction::kRegularFunction:
149 case UntaggedFunction::kGetterFunction:
150 case UntaggedFunction::kSetterFunction:
151 case UntaggedFunction::kConstructor: {
159 needs_expr_temp_ =
true;
161 if (
function.FfiCSignatureContainsHandles()) {
167 FinalizeCatchVariables();
174 needs_expr_temp_ =
true;
179 TokenPosition::kNoSource, TokenPosition::kNoSource,
180 Symbols::ClosureParameter(), AbstractType::dynamic_type());
187 Type& klass_type =
H.GetDeclarationType(klass);
189 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
196 if (tag == kConstructor) {
200 for (intptr_t
i = 0;
i < class_fields.
Length(); ++
i) {
201 class_field ^= class_fields.
At(
i);
203 const auto& kernel_data =
205 ASSERT(!kernel_data.IsNull());
208 &helper_.
reader_, &kernel_data, field_offset);
211 Tag initializer_tag =
213 if (initializer_tag == kSomething) {
214 EnterScope(field_offset);
223 TokenPosition::kNoSource, TokenPosition::kNoSource,
224 Symbols::TypeArgumentsParameter(), AbstractType::dynamic_type());
229 ParameterTypeCheckMode type_check_mode =
230 kTypeCheckForNonDynamicallyInvokedMethod;
233 type_check_mode = kTypeCheckForStaticFunction;
234 }
else if (
function.IsImplicitClosureFunction()) {
240 type_check_mode = kTypeCheckForImplicitClosureFunction;
245 AddPositionalAndNamedParameters(
pos, type_check_mode, attrs);
247 if (
function.IsSuspendableFunction()) {
254 if (helper_.
ReadTag() == kSomething) {
262 if (!
function.IsImplicitClosureFunction()) {
264 first_body_token_position_ = TokenPosition::kNoSource;
275 if (first_body_token_position_.
IsReal()) {
284 case UntaggedFunction::kImplicitGetter:
285 case UntaggedFunction::kImplicitSetter: {
287 const bool is_setter =
function.IsImplicitSetterFunction();
288 const bool is_method = !
function.IsStaticFunction();
293 Type& klass_type =
H.GetDeclarationType(klass);
295 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
302 const intptr_t kernel_offset = field.kernel_offset();
306 TokenPosition::kNoSource, TokenPosition::kNoSource,
314 TokenPosition::kNoSource, TokenPosition::kNoSource,
321 if (field.is_covariant()) {
323 }
else if (!field.is_generic_covariant_impl() ||
332 case UntaggedFunction::kImplicitStaticGetter: {
343 case UntaggedFunction::kFieldInitializer: {
347 Type& klass_type =
H.GetDeclarationType(klass);
349 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
357 case UntaggedFunction::kDynamicInvocationForwarder: {
367 needs_expr_temp_ =
true;
370 if (helper_.
PeekTag() == kField) {
374 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
379 if (
target.IsImplicitSetterFunction()) {
381 TokenPosition::kNoSource, TokenPosition::kNoSource,
401 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
406 AddPositionalAndNamedParameters(
407 pos, kTypeCheckEverythingNotCheckedInNonDynamicallyInvokedMethod,
411 case UntaggedFunction::kMethodExtractor: {
416 Type& klass_type =
H.GetDeclarationType(klass);
418 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
424 case UntaggedFunction::kFfiTrampoline: {
425 needs_expr_temp_ =
true;
432 FinalizeCatchVariables();
436 case UntaggedFunction::kInvokeFieldDispatcher: {
437 if (
function.IsDynamicClosureCallDispatcher()) {
440#define ADD_VAR(Name, _, __) scope_->AddVariable(vars->Name);
443 for (
auto const& v :
vars->named_argument_parameter_indices) {
449 case UntaggedFunction::kNoSuchMethodDispatcher: {
450 for (intptr_t
i = 0;
i <
function.NumParameters(); ++
i) {
452 TokenPosition::kNoSource, TokenPosition::kNoSource,
456 : Object::dynamic_type().ptr()));
462 case UntaggedFunction::kRecordFieldGetter: {
463 needs_expr_temp_ =
true;
467 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
472 case UntaggedFunction::kIrregexpFunction:
475 if (needs_expr_temp_) {
498 H.ReportError(
script, TokenPosition::kNoSource,
499 "Unexpected tag %d (%s) in %s, expected %s", tag,
504void ScopeBuilder::VisitNode() {
525void ScopeBuilder::VisitConstructor() {
531 ConstructorHelper constructor_helper(&helper_);
538 for (intptr_t
i = 0;
i < class_fields.Length(); ++
i) {
539 class_field ^= class_fields.At(
i);
540 if (!class_field.is_static()) {
541 const auto& kernel_data =
543 ASSERT(!kernel_data.IsNull());
544 intptr_t field_offset = class_field.kernel_offset();
545 AlternativeReadingScopeWithNewData alt(&helper_.
reader_, &kernel_data,
547 FieldHelper field_helper(&helper_);
550 if (initializer_tag == kSomething) {
559 intptr_t list_length =
561 for (intptr_t
i = 0;
i < list_length;
i++) {
566void ScopeBuilder::VisitProcedure() {
567 ProcedureHelper procedure_helper(&helper_);
572void ScopeBuilder::VisitField() {
573 FieldHelper field_helper(&helper_);
577 if (tag == kSomething) {
582void ScopeBuilder::VisitFunctionNode() {
583 FunctionNodeHelper function_node_helper(&helper_);
586 intptr_t list_length =
588 for (intptr_t
i = 0;
i < list_length; ++
i) {
589 TypeParameterHelper helper(&helper_);
602 if (helper_.
ReadTag() == kSomething) {
603 PositionScope scope(&helper_.
reader_);
609void ScopeBuilder::VisitInitializer() {
613 case kInvalidInitializer:
615 case kFieldInitializer:
620 case kSuperInitializer:
625 case kRedirectingInitializer:
630 case kLocalInitializer:
631 VisitVariableDeclaration();
633 case kAssertInitializer:
642void ScopeBuilder::VisitExpression() {
646 case kInvalidExpression:
649 if (helper_.
ReadTag() == kSomething) {
655 intptr_t variable_kernel_offset =
659 VisitVariableGet(variable_kernel_offset);
662 case kSpecializedVariableGet: {
664 intptr_t variable_kernel_offset =
666 VisitVariableGet(variable_kernel_offset);
671 intptr_t variable_kernel_offset =
674 LookupVariable(variable_kernel_offset);
678 case kSpecializedVariableSet: {
680 intptr_t variable_kernel_offset =
682 LookupVariable(variable_kernel_offset);
701 case kInstanceTearOff:
710 case kFunctionTearOff:
730 case kAbstractSuperPropertyGet:
735 case kAbstractSuperPropertySet:
740 case kSuperPropertyGet:
741 HandleLoadReceiver();
746 case kSuperPropertySet:
747 HandleLoadReceiver();
762 case kInstanceInvocation:
773 case kDynamicInvocation:
781 case kLocalFunctionInvocation: {
783 intptr_t variable_kernel_offset =
788 VisitVariableGet(variable_kernel_offset);
791 case kFunctionInvocation:
810 case kAbstractSuperMethodInvocation:
815 case kSuperMethodInvocation:
816 HandleLoadReceiver();
823 case kStaticInvocation:
828 case kConstructorInvocation:
841 case kLogicalExpression:
842 needs_expr_temp_ =
true;
848 case kConditionalExpression: {
849 needs_expr_temp_ =
true;
857 case kStringConcatenation: {
859 VisitListOfExpressions();
863 needs_expr_temp_ =
true;
878 case kThisExpression:
879 HandleLoadReceiver();
893 VisitListOfExpressions();
907 for (intptr_t
i = 0;
i < list_length; ++
i) {
915 VisitListOfExpressions();
916 VisitListOfNamedExpressions();
919 case kRecordIndexGet:
931 case kFunctionExpression: {
934 HandleLocalFunction(
offset);
938 PositionScope scope(&helper_.
reader_);
944 VisitVariableDeclaration();
950 case kBlockExpression: {
951 PositionScope scope(&helper_.
reader_);
957 intptr_t list_length =
959 for (intptr_t
i = 0;
i < list_length; ++
i) {
975 case kSpecializedIntLiteral:
978 case kNegativeIntLiteral:
982 case kPositiveIntLiteral:
999 case kConstantExpression:
1004 case kFileUriConstantExpression:
1010 case kInstantiation: {
1013 const intptr_t list_length =
1015 for (intptr_t
i = 0;
i < list_length; ++
i) {
1021 case kCheckLibraryIsLoaded:
1025 case kAwaitExpression:
1028 if (helper_.
ReadTag() == kSomething) {
1032 case kFileUriExpression:
1037 case kConstStaticInvocation:
1038 case kConstConstructorInvocation:
1039 case kConstListLiteral:
1040 case kConstSetLiteral:
1041 case kConstMapLiteral:
1042 case kSymbolLiteral:
1043 case kListConcatenation:
1044 case kSetConcatenation:
1045 case kMapConcatenation:
1046 case kInstanceCreation:
1047 case kStaticTearOff:
1048 case kSwitchExpression:
1049 case kPatternAssignment:
1058void ScopeBuilder::VisitStatement() {
1061 case kExpressionStatement:
1065 PositionScope scope(&helper_.
reader_);
1071 intptr_t list_length =
1073 for (intptr_t
i = 0;
i < list_length; ++
i) {
1080 case kEmptyStatement:
1083 if (
IG->asserts()) {
1084 PositionScope scope(&helper_.
reader_);
1090 intptr_t list_length =
1092 for (intptr_t
i = 0;
i < list_length; ++
i) {
1102 case kAssertStatement:
1103 if (
IG->asserts()) {
1108 if (tag == kSomething) {
1116 if (tag == kSomething) {
1121 case kLabeledStatement:
1125 case kBreakStatement:
1129 case kWhileStatement:
1143 case kForStatement: {
1144 PositionScope scope(&helper_.
reader_);
1152 intptr_t list_length =
1154 for (intptr_t
i = 0;
i < list_length; ++
i) {
1155 VisitVariableDeclaration();
1159 if (tag == kSomething) {
1162 VisitListOfExpressions();
1169 case kSwitchStatement: {
1170 AddSwitchVariable();
1176 for (intptr_t
i = 0;
i < case_count; ++
i) {
1178 int expression_count =
1180 for (intptr_t j = 0; j < expression_count; ++j) {
1189 case kContinueSwitchStatement:
1199 case kReturnStatement: {
1200 if ((depth_.function_ == 0) && (depth_.finally_ > 0) &&
1202 const String&
name = Symbols::TryFinallyReturnValue();
1203 LocalVariable* variable =
1204 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
1205 name, AbstractType::dynamic_type());
1212 if (tag == kSomething) {
1225 AddCatchVariables();
1228 intptr_t catch_count =
1230 for (intptr_t
i = 0;
i < catch_count; ++
i) {
1231 PositionScope scope(&helper_.
reader_);
1239 if (tag == kSomething) {
1240 VisitVariableDeclaration();
1243 if (tag == kSomething) {
1244 VisitVariableDeclaration();
1252 FinalizeCatchVariables();
1268 AddCatchVariables();
1272 FinalizeCatchVariables();
1277 case kYieldStatement: {
1283 case kVariableDeclaration:
1284 VisitVariableDeclaration();
1289 VisitVariableDeclaration();
1290 HandleLocalFunction(
offset);
1293 case kForInStatement:
1294 case kAsyncForInStatement:
1295 case kIfCaseStatement:
1296 case kPatternSwitchStatement:
1297 case kPatternVariableDeclaration:
1306void ScopeBuilder::VisitListOfExpressions() {
1308 for (intptr_t
i = 0;
i < list_length; ++
i) {
1313void ScopeBuilder::VisitListOfNamedExpressions() {
1315 for (intptr_t
i = 0;
i < list_length; ++
i) {
1321void ScopeBuilder::VisitArguments() {
1326 for (intptr_t
i = 0;
i < list_length; ++
i) {
1330 VisitListOfExpressions();
1331 VisitListOfNamedExpressions();
1334void ScopeBuilder::VisitVariableDeclaration() {
1335 PositionScope scope(&helper_.
reader_);
1337 const intptr_t kernel_offset =
1340 const InferredTypeMetadata inferred_type =
1342 VariableDeclarationHelper helper(&helper_);
1344 const intptr_t annotations_offset = helper_.
ReaderOffset();
1346 AbstractType&
type = BuildAndVisitVariableType();
1348 const String&
name = (
H.StringSize(helper.name_index_) == 0)
1349 ? GenerateName(
":var", name_index_++)
1350 :
H.DartSymbolObfuscate(helper.name_index_);
1354 if (tag == kSomething) {
1361 if (end_position.IsReal()) {
1362 end_position = end_position.
Next();
1364 LocalVariable* variable =
1365 MakeVariable(helper.position_, end_position,
name,
type, kernel_offset,
1366 helper.IsLate(), &inferred_type);
1367 if (helper.annotation_count_ > 0) {
1368 variable->set_annotations_offset(annotations_offset);
1370 if (helper.IsFinal()) {
1371 variable->set_is_final();
1373 if (helper.IsLate()) {
1374 variable->set_is_late();
1375 variable->set_late_init_offset(initializer_offset);
1377 if (helper.IsSynthesized()) {
1378 variable->set_invisible(
true);
1382 result_->
locals.Insert(kernel_offset, variable);
1385AbstractType& ScopeBuilder::BuildAndVisitVariableType() {
1387 AbstractType&
type =
T.BuildType();
1393void ScopeBuilder::VisitDartType() {
1405 case kInterfaceType:
1406 VisitInterfaceType(
false);
1408 case kSimpleInterfaceType:
1409 VisitInterfaceType(
true);
1412 VisitFunctionType(
false);
1414 case kSimpleFunctionType:
1415 VisitFunctionType(
true);
1420 case kTypeParameterType:
1421 VisitTypeParameterType();
1423 case kIntersectionType:
1424 VisitIntersectionType();
1426 case kExtensionType:
1427 VisitExtensionType();
1430 VisitFutureOrType();
1438void ScopeBuilder::VisitInterfaceType(
bool simple) {
1449void ScopeBuilder::VisitFunctionType(
bool simple) {
1453 intptr_t list_length =
1455 for (
int i = 0;
i < list_length; ++
i) {
1456 TypeParameterHelper helper(&helper_);
1459 helper.ReadUntilExcludingAndSetJustRead(
1468 const intptr_t positional_count =
1470 for (intptr_t
i = 0;
i < positional_count; ++
i) {
1475 const intptr_t named_count =
1477 for (intptr_t
i = 0;
i < named_count; ++
i) {
1488void ScopeBuilder::VisitRecordType() {
1490 const intptr_t positional_count =
1492 for (intptr_t
i = 0;
i < positional_count; ++
i) {
1495 const intptr_t named_count =
1497 for (intptr_t
i = 0;
i < named_count; ++
i) {
1504void ScopeBuilder::VisitTypeParameterType() {
1514 intptr_t index = helper_.
ReadUInt();
1516 if (!
function.IsImplicitStaticClosureFunction()) {
1517 while (
function.IsClosureFunction()) {
1525 Symbols::TypeArgumentsParameter(),
1533 if (index < parent_class.NumTypeParameters()) {
1534 HandleLoadReceiver();
1540void ScopeBuilder::VisitIntersectionType() {
1545void ScopeBuilder::VisitExtensionType() {
1553void ScopeBuilder::VisitFutureOrType() {
1558void ScopeBuilder::HandleLocalFunction(intptr_t parent_kernel_offset) {
1562 FunctionNodeHelper function_node_helper(&helper_);
1565 LocalScope* saved_function_scope = current_function_scope_;
1566 DepthState saved_depth_state = depth_;
1567 depth_ = DepthState(depth_.function_ + 1);
1568 EnterScope(parent_kernel_offset);
1569 current_function_scope_ = scope_;
1570 if (depth_.function_ == 1) {
1571 FunctionScope function_scope = {
offset, scope_};
1575 int num_type_params = 0;
1577 AlternativeReadingScope _(&helper_.
reader_);
1584 TypeTranslator::TypeParameterScope scope(&type_translator_, num_type_params);
1587 function_node_helper.ReadUntilExcluding(
1590 ProcedureAttributesMetadata default_attrs;
1591 AddPositionalAndNamedParameters(0, kTypeCheckForNonDynamicallyInvokedMethod,
1604 VisitFunctionNode();
1614 ExitScope(function_node_helper.position_, function_node_helper.end_position_);
1615 depth_ = saved_depth_state;
1616 current_function_scope_ = saved_function_scope;
1619void ScopeBuilder::EnterScope(intptr_t kernel_offset) {
1620 scope_ =
new (
Z) LocalScope(scope_, depth_.function_, depth_.loop_);
1621 ASSERT(kernel_offset >= 0);
1622 result_->
scopes.Insert(kernel_offset, scope_);
1625void ScopeBuilder::ExitScope(TokenPosition start_position,
1626 TokenPosition end_position) {
1629 scope_ = scope_->
parent();
1632void ScopeBuilder::AddPositionalAndNamedParameters(
1634 ParameterTypeCheckMode type_check_mode ,
1635 const ProcedureAttributesMetadata& attrs) {
1638 for (intptr_t
i = 0;
i < list_length; ++
i) {
1639 AddVariableDeclarationParameter(
pos++, type_check_mode, attrs);
1644 for (intptr_t
i = 0;
i < list_length; ++
i) {
1645 AddVariableDeclarationParameter(
pos++, type_check_mode, attrs);
1649void ScopeBuilder::AddVariableDeclarationParameter(
1651 ParameterTypeCheckMode type_check_mode,
1652 const ProcedureAttributesMetadata& attrs) {
1654 const intptr_t kernel_offset =
1657 const InferredTypeMetadata inferred_type =
1659 const InferredTypeMetadata inferred_arg_type =
1662 VariableDeclarationHelper helper(&helper_);
1664 const intptr_t annotations_offset = helper_.
ReaderOffset();
1666 String&
name =
H.DartSymbolObfuscate(helper.name_index_);
1668 AbstractType&
type = BuildAndVisitVariableType();
1672 LocalVariable* variable = MakeVariable(
1673 helper.position_, helper.position_,
name,
type, kernel_offset,
1674 false, &inferred_type, &inferred_arg_type);
1675 if (helper.annotation_count_ > 0) {
1676 variable->set_annotations_offset(annotations_offset);
1678 if (helper.IsFinal()) {
1679 variable->set_is_final();
1681 if (helper.IsCovariant()) {
1682 variable->set_is_explicit_covariant_parameter();
1685 const bool needs_covariant_check_in_method =
1686 helper.IsCovariant() ||
1687 (helper.IsGenericCovariantImpl() &&
1688 (attrs.has_non_this_uses || attrs.has_tearoff_uses));
1689 if (needs_covariant_check_in_method) {
1690 variable->set_needs_covariant_check_in_method();
1693 switch (type_check_mode) {
1694 case kTypeCheckAllParameters:
1697 case kTypeCheckEverythingNotCheckedInNonDynamicallyInvokedMethod:
1698 if (needs_covariant_check_in_method) {
1706 case kTypeCheckForNonDynamicallyInvokedMethod:
1707 if (needs_covariant_check_in_method) {
1715 case kTypeCheckForImplicitClosureFunction:
1716 if (needs_covariant_check_in_method) {
1726 case kTypeCheckForStaticFunction:
1733 if (inferred_arg_type.IsSkipCheck()) {
1738 result_->
locals.Insert(kernel_offset, variable);
1743 if (tag == kSomething) {
1748LocalVariable* ScopeBuilder::MakeVariable(
1749 TokenPosition declaration_pos,
1750 TokenPosition token_pos,
1752 const AbstractType& static_type,
1753 intptr_t kernel_offset ,
1755 const InferredTypeMetadata* inferred_type_md ,
1756 const InferredTypeMetadata* inferred_arg_type_md ) {
1757 CompileType* inferred_type =
nullptr;
1758 if (inferred_type_md !=
nullptr && !inferred_type_md->IsTrivial()) {
1759 inferred_type =
new (
Z)
1760 CompileType(inferred_type_md->ToCompileType(
Z, &static_type, is_late));
1765 CompileType* inferred_arg_type =
nullptr;
1766 const Object* inferred_arg_value =
nullptr;
1767 if (inferred_arg_type_md !=
nullptr && !inferred_arg_type_md->IsTrivial()) {
1769 new (
Z) CompileType(inferred_arg_type_md->ToCompileType(
Z));
1770 if (inferred_arg_type_md->IsConstant()) {
1771 inferred_arg_value = &inferred_arg_type_md->constant_value;
1774 return new (
Z) LocalVariable(declaration_pos, token_pos,
name, static_type,
1775 kernel_offset, inferred_type, inferred_arg_type,
1776 inferred_arg_value);
1779void ScopeBuilder::AddExceptionVariable(
1780 GrowableArray<LocalVariable*>* variables,
1782 intptr_t nesting_depth) {
1783 LocalVariable* v =
nullptr;
1787 if (depth_.function_ > 0)
return;
1788 if (variables->length() >= nesting_depth)
return;
1793 v = MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
1794 GenerateName(
prefix, nesting_depth - 1),
1795 AbstractType::dynamic_type());
1799 v->set_is_forced_stack();
1806void ScopeBuilder::FinalizeExceptionVariable(
1807 GrowableArray<LocalVariable*>* variables,
1808 GrowableArray<LocalVariable*>* raw_variables,
1809 const String& symbol,
1810 intptr_t nesting_depth) {
1813 if (depth_.function_ > 0)
return;
1815 LocalVariable* variable = (*variables)[nesting_depth - 1];
1816 LocalVariable* raw_variable;
1817 if (variable->is_captured()) {
1819 new LocalVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
1820 symbol, AbstractType::dynamic_type());
1821 raw_variable->set_is_forced_stack();
1825 raw_variable = variable;
1827 raw_variables->EnsureLength(nesting_depth,
nullptr);
1828 (*raw_variables)[nesting_depth - 1] = raw_variable;
1831void ScopeBuilder::AddTryVariables() {
1833 ":saved_try_context_var", depth_.try_);
1836void ScopeBuilder::AddCatchVariables() {
1843void ScopeBuilder::FinalizeCatchVariables() {
1845 FinalizeExceptionVariable(
1847 GenerateName(
":raw_exception", unique_id), depth_.catch_);
1848 FinalizeExceptionVariable(
1850 GenerateName(
":raw_stacktrace", unique_id), depth_.catch_);
1853void ScopeBuilder::AddSwitchVariable() {
1854 if ((depth_.function_ == 0) && (result_->
switch_variable ==
nullptr)) {
1855 LocalVariable* variable =
1856 MakeVariable(TokenPosition::kNoSource, TokenPosition::kNoSource,
1857 Symbols::SwitchExpr(), AbstractType::dynamic_type());
1858 variable->set_is_forced_stack();
1864void ScopeBuilder::VisitVariableGet(intptr_t declaration_binary_offset) {
1865 LocalVariable* variable = LookupVariable(declaration_binary_offset);
1866 if (variable->is_late()) {
1869 AlternativeReadingScope alt(&helper_.
reader_, variable->late_init_offset());
1870 if (helper_.
ReadTag() != kNothing) {
1876LocalVariable* ScopeBuilder::LookupVariable(
1877 intptr_t declaration_binary_offset) {
1878 LocalVariable* variable = result_->
locals.Lookup(declaration_binary_offset);
1879 if (variable ==
nullptr) {
1885 StringIndex var_name = GetNameFromVariableDeclaration(
1889 const String&
name =
H.DartSymbolObfuscate(var_name);
1891 name, declaration_binary_offset,
true);
1892 ASSERT(variable !=
nullptr);
1893 result_->
locals.Insert(declaration_binary_offset, variable);
1896 ASSERT(variable->owner() !=
nullptr);
1897 if (variable->owner()->function_level() < scope_->
function_level()) {
1917StringIndex ScopeBuilder::GetNameFromVariableDeclaration(
1918 intptr_t kernel_offset,
1921 ASSERT(!kernel_data.IsNull());
1924 AlternativeReadingScopeWithNewData alt(&helper_.
reader_, &kernel_data,
1926 VariableDeclarationHelper helper(&helper_);
1928 return helper.name_index_;
1931const String& ScopeBuilder::GenerateName(
const char*
prefix, intptr_t
suffix) {
1934 return H.DartSymbolObfuscate(
name);
1937void ScopeBuilder::HandleLoadReceiver() {
1939 current_function_scope_->
parent() !=
nullptr) {
1946 if ((current_function_scope_->
parent() !=
nullptr) ||
1957void ScopeBuilder::HandleSpecialLoad(LocalVariable** variable,
1958 const String& symbol,
1959 intptr_t kernel_offset) {
1960 if (current_function_scope_->
parent() !=
nullptr) {
1963 if (*variable ==
nullptr) {
1965 symbol, kernel_offset,
true);
1966 ASSERT(*variable !=
nullptr);
1970 if ((current_function_scope_->
parent() !=
nullptr) ||
static bool ok(int result)
#define RELEASE_ASSERT(cond)
ObjectPtr At(intptr_t index) const
static constexpr bool kCanBeNull
static CompileType FromAbstractType(const AbstractType &type, bool can_be_null, bool can_be_sentinel)
static CompilerState & Current()
intptr_t kernel_offset() const
TypedDataViewPtr KernelLibrary() const
static bool IsDynamicInvocationForwarderName(const String &name)
bool MayHaveUncheckedEntryPoint() const
KernelProgramInfoPtr KernelProgramInfo() const
const char * ToQualifiedCString() const
LocalScope * parent() const
void set_begin_token_pos(TokenPosition value)
void set_end_token_pos(TokenPosition value)
TokenPosition end_token_pos() const
int NumCapturedVariables() const
int function_level() const
static LocalScope * RestoreOuterScope(const ContextScope &context_scope)
LocalVariable * LookupVariable(const String &name, intptr_t kernel_offset, bool test_only)
bool AddVariable(LocalVariable *variable)
void CaptureVariable(LocalVariable *variable)
bool InsertParameterAt(intptr_t pos, LocalVariable *parameter)
void set_context_level(int context_level)
void AddContextVariable(LocalVariable *var)
VariableIndex index() const
void set_is_explicit_covariant_parameter()
void set_type_check_mode(TypeCheckMode mode)
void set_invisible(bool value)
static constexpr intptr_t kNoKernelOffset
void set_is_forced_stack()
static Object & ZoneHandle()
void set_function_type_arguments(LocalVariable *function_type_arguments)
LocalVariable * expression_temp_var() const
const Function & function() const
LocalVariable * EnsureExpressionTemp()
LocalVariable * EnsureEntryPointsTemp()
bool has_receiver_var() const
LocalVariable * arg_desc_var() const
bool has_arg_desc_var() const
void set_receiver_var(LocalVariable *value)
void set_scope(LocalScope *scope)
LocalVariable * current_context_var() const
LocalVariable * suspend_state_var() const
LocalVariable * receiver_var() const
bool has_expression_temp_var() const
void set_suspend_state_var(LocalVariable *suspend_state_var)
DynamicClosureCallVars * EnsureDynamicClosureCallVars()
static constexpr intptr_t kSuspendStateVarIndex
static const String & This()
static int SNPrint(char *str, size_t size, const char *format,...) PRINTF_ATTRIBUTE(3
void ReadUntilExcluding(Field field)
TokenPosition end_position_
static bool IsExpressionTempVarUsedInRecognizedMethodFlowGraph(const Function &function)
static bool IsRecognizedMethodForFlowGraph(const Function &function)
void ReadUntilExcluding(Field field)
void SetOffset(intptr_t offset)
void ReadUntilFunctionNode()
void SkipOptionalDartType()
void SkipListOfDartTypes()
intptr_t data_program_offset_
void SkipConstantReference()
intptr_t ReadListLength()
TokenPosition ReadPosition()
Tag ReadTag(uint8_t *payload=nullptr)
Tag PeekTag(uint8_t *payload=nullptr)
intptr_t ReaderOffset() const
void SkipInterfaceMemberNameReference()
void SkipCanonicalNameReference()
void SkipStringReference()
void SkipBytes(intptr_t skip)
Nullability ReadNullability()
TokenPosition min_position()
TokenPosition max_position()
static const char * TagName(Tag tag)
virtual void ReportUnexpectedTag(const char *variant, Tag tag)
ScopeBuildingResult * BuildScopes()
ScopeBuilder(ParsedFunction *parsed_function)
LocalVariable * type_arguments_variable
LocalVariable * setter_value
IntMap< LocalScope * > scopes
GrowableArray< LocalVariable * > catch_context_variables
GrowableArray< LocalVariable * > stack_trace_variables
GrowableArray< LocalVariable * > raw_exception_variables
intptr_t raw_variable_counter_
LocalVariable * finally_return_variable
LocalVariable * switch_variable
GrowableArray< intptr_t > closure_offsets_without_captures
GrowableArray< LocalVariable * > exception_variables
IntMap< LocalVariable * > locals
GrowableArray< LocalVariable * > raw_stack_trace_variables
GrowableArray< FunctionScope > function_scopes
Dart_NativeFunction function
#define FOR_EACH_DYNAMIC_CLOSURE_CALL_VARIABLE(V)
#define ADD_VAR(Name, _, __)