5#ifndef RUNTIME_VM_COMPILER_FRONTEND_SCOPE_BUILDER_H_
6#define RUNTIME_VM_COMPILER_FRONTEND_SCOPE_BUILDER_H_
8#if defined(DART_PRECOMPILED_RUNTIME)
9#error "AOT runtime should not use compiler sources (including header files)"
21class ScopeBuildingResult;
34 void VisitProcedure();
36 void VisitConstructor();
38 void VisitFunctionNode();
40 void VisitInitializer();
41 void VisitExpression();
42 void VisitStatement();
43 void VisitListOfExpressions();
44 void VisitListOfNamedExpressions();
45 void VisitArguments();
46 void VisitVariableDeclaration();
47 void VisitVariableGet(intptr_t declaration_binary_offset);
49 void VisitInterfaceType(
bool simple);
50 void VisitFunctionType(
bool simple);
51 void VisitRecordType();
52 void VisitTypeParameterType();
53 void VisitIntersectionType();
54 void VisitExtensionType();
55 void VisitFutureOrType();
56 void HandleLocalFunction(intptr_t parent_kernel_offset);
60 void EnterScope(intptr_t kernel_offset);
67 enum ParameterTypeCheckMode {
69 kTypeCheckAllParameters,
73 kTypeCheckForNonDynamicallyInvokedMethod,
78 kTypeCheckEverythingNotCheckedInNonDynamicallyInvokedMethod,
81 kTypeCheckForStaticFunction,
85 kTypeCheckForImplicitClosureFunction,
90 void AddPositionalAndNamedParameters(
92 ParameterTypeCheckMode type_check_mode,
97 void AddVariableDeclarationParameter(
99 ParameterTypeCheckMode type_check_mode,
108 bool is_late =
false,
114 intptr_t nesting_depth);
119 intptr_t nesting_depth);
121 void AddTryVariables();
122 void AddCatchVariables();
123 void FinalizeCatchVariables();
124 void AddSwitchVariable();
129 LocalVariable* LookupVariable(intptr_t declaration_binary_offset);
131 StringIndex GetNameFromVariableDeclaration(intptr_t kernel_offset,
136 void HandleLoadReceiver();
139 intptr_t kernel_offset);
144 explicit DepthState(intptr_t
function)
145 : loop_(0), function_(
function), try_(0), catch_(0), finally_(0) {}
154 ScopeBuildingResult* result_;
155 ParsedFunction* parsed_function_;
157 ActiveClass active_class_;
159 TranslationHelper translation_helper_;
162 LocalScope* current_function_scope_;
166 intptr_t name_index_;
168 bool needs_expr_temp_;
169 TokenPosition first_body_token_position_ = TokenPosition::kNoSource;
171 KernelReaderHelper helper_;
172 ConstantReader constant_reader_;
173 InferredTypeMetadataHelper inferred_type_metadata_helper_;
174 InferredTypeMetadataHelper inferred_arg_type_metadata_helper_;
175 ProcedureAttributesMetadataHelper procedure_attributes_metadata_helper_;
176 TypeTranslator type_translator_;
static constexpr intptr_t kNoKernelOffset
virtual ~ScopeBuilder()=default
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_
bool IsClosureWithEmptyContext(intptr_t function_node_offset)
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