5 #ifndef V8_OBJECTS_SCOPE_INFO_H_ 6 #define V8_OBJECTS_SCOPE_INFO_H_ 8 #include "src/globals.h" 9 #include "src/objects.h" 10 #include "src/objects/fixed-array.h" 11 #include "src/utils.h" 14 #include "src/objects/object-macros.h" 41 ScopeType scope_type()
const;
44 LanguageMode language_mode()
const;
47 bool is_declaration_scope()
const;
50 bool CallsSloppyEval()
const;
59 int ContextLength()
const;
62 bool HasReceiver()
const;
66 bool HasAllocatedReceiver()
const;
69 bool HasNewTarget()
const;
72 bool HasFunctionName()
const;
75 bool HasSharedFunctionName()
const;
77 bool HasInferredFunctionName()
const;
79 void SetFunctionName(
Object* name);
80 void SetInferredFunctionName(
String name);
83 bool HasPositionInfo()
const;
86 bool HasContext()
const;
89 inline bool IsAsmModule()
const;
91 inline bool HasSimpleParameters()
const;
94 Object* FunctionName()
const;
98 String FunctionDebugName()
const;
102 Object* InferredFunctionName()
const;
105 int StartPosition()
const;
106 int EndPosition()
const;
107 void SetPositionInfo(
int start,
int end);
112 String ContextLocalName(
int var)
const;
115 VariableMode ContextLocalMode(
int var)
const;
118 InitializationFlag ContextLocalInitFlag(
int var)
const;
120 bool ContextLocalIsParameter(
int var)
const;
121 uint32_t ContextLocalParameterNumber(
int var)
const;
124 MaybeAssignedFlag ContextLocalMaybeAssignedFlag(
int var)
const;
128 static bool VariableIsSynthetic(
String name);
136 VariableMode* mode, InitializationFlag* init_flag,
137 MaybeAssignedFlag* maybe_assigned_flag);
143 InitializationFlag* init_flag,
144 MaybeAssignedFlag* maybe_assigned_flag);
150 int FunctionContextSlotIndex(
String name)
const;
155 int ReceiverContextSlotIndex()
const;
157 FunctionKind function_kind()
const;
160 bool HasOuterScopeInfo()
const;
163 bool IsDebugEvaluateScope()
const;
167 void SetIsDebugEvaluateScope();
193 #define FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(V) \ 198 #define FIELD_ACCESSORS(name) \ 199 inline void Set##name(int value); \ 200 inline int name() const; 201 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(FIELD_ACCESSORS)
202 #undef FIELD_ACCESSORS 205 #define DECL_INDEX(name) k##name, 206 FOR_EACH_SCOPE_INFO_NUMERIC_FIELD(DECL_INDEX)
243 int ContextLocalNamesIndex()
const;
244 int ContextLocalInfosIndex()
const;
245 int ReceiverInfoIndex()
const;
246 int FunctionNameInfoIndex()
const;
247 int InferredFunctionNameIndex()
const;
248 int PositionInfoIndex()
const;
249 int OuterScopeInfoIndex()
const;
250 int ModuleInfoIndex()
const;
251 int ModuleVariableCountIndex()
const;
252 int ModuleVariablesIndex()
const;
254 static bool NeedsPositionInfo(ScopeType
type);
258 int Lookup(
Handle<String> name,
int start,
int end, VariableMode* mode,
259 VariableLocation* location, InitializationFlag* init_flag,
260 MaybeAssignedFlag* maybe_assigned_flag);
265 void ModuleVariable(
int i,
String* name,
int* index,
266 VariableMode* mode =
nullptr,
267 InitializationFlag* init_flag =
nullptr,
268 MaybeAssignedFlag* maybe_assigned_flag =
nullptr);
272 enum VariableAllocationInfo { NONE, STACK, CONTEXT, UNUSED };
274 static const int kFunctionNameEntries = 2;
275 static const int kPositionInfoEntries = 2;
278 class ScopeTypeField :
public BitField<ScopeType, 0, 4> {};
279 class CallsSloppyEvalField :
public BitField<bool, ScopeTypeField::kNext, 1> {
281 STATIC_ASSERT(LanguageModeSize == 2);
282 class LanguageModeField
283 :
public BitField<LanguageMode, CallsSloppyEvalField::kNext, 1> {};
284 class DeclarationScopeField
285 :
public BitField<bool, LanguageModeField::kNext, 1> {};
286 class ReceiverVariableField
287 :
public BitField<VariableAllocationInfo, DeclarationScopeField::kNext,
289 class HasNewTargetField
290 :
public BitField<bool, ReceiverVariableField::kNext, 1> {};
291 class FunctionVariableField
292 :
public BitField<VariableAllocationInfo, HasNewTargetField::kNext, 2> {};
295 class HasInferredFunctionNameField
296 :
public BitField<bool, FunctionVariableField::kNext, 1> {};
298 :
public BitField<bool, HasInferredFunctionNameField::kNext, 1> {};
299 class HasSimpleParametersField
300 :
public BitField<bool, AsmModuleField::kNext, 1> {};
301 class FunctionKindField
302 :
public BitField<FunctionKind, HasSimpleParametersField::kNext, 5> {};
303 class HasOuterScopeInfoField
304 :
public BitField<bool, FunctionKindField::kNext, 1> {};
305 class IsDebugEvaluateScopeField
306 :
public BitField<bool, HasOuterScopeInfoField::kNext, 1> {};
308 STATIC_ASSERT(kLastFunctionKind <= FunctionKindField::kMax);
311 class VariableModeField :
public BitField<VariableMode, 0, 3> {};
312 class InitFlagField :
public BitField<InitializationFlag, 3, 1> {};
313 class MaybeAssignedFlagField :
public BitField<MaybeAssignedFlag, 4, 1> {};
314 class ParameterNumberField
315 :
public BitField<uint32_t, MaybeAssignedFlagField::kNext, 16> {};
318 friend std::ostream& operator<<(std::ostream& os,
319 ScopeInfo::VariableAllocationInfo var);
324 std::ostream& operator<<(std::ostream& os,
325 ScopeInfo::VariableAllocationInfo var);
330 #include "src/objects/object-macros-undef.h" 332 #endif // V8_OBJECTS_SCOPE_INFO_H_