5 #ifndef V8_PARSING_FUNC_NAME_INFERRER_H_ 6 #define V8_PARSING_FUNC_NAME_INFERRER_H_ 10 #include "src/base/macros.h" 11 #include "src/pointer-with-payload.h" 18 class AstValueFactory;
19 class FunctionLiteral;
21 enum class InferName { kYes, kNo };
25 static constexpr
int value = 2;
47 : fni_(fni), top_(fni->names_stack_.size()) {
51 DCHECK(fni_->IsOpen());
52 fni_->names_stack_.resize(top_);
60 DISALLOW_COPY_AND_ASSIGN(
State);
64 bool IsOpen()
const {
return scope_depth_ > 0; }
77 funcs_to_infer_.push_back(func_to_infer);
81 void RemoveLastFunction() {
82 if (IsOpen() && !funcs_to_infer_.empty()) funcs_to_infer_.pop_back();
85 void RemoveAsyncKeywordFromEnd();
90 if (!funcs_to_infer_.empty()) InferFunctionsNames();
94 enum NameType : uint8_t {
95 kEnclosingConstructorName,
101 Name() { UNREACHABLE(); }
102 Name(
const AstRawString* name, NameType type)
103 : name_and_type_(name, type) {}
105 PointerWithPayload<const AstRawString, NameType, 2> name_and_type_;
106 inline const AstRawString* name()
const {
107 return name_and_type_.GetPointer();
109 inline NameType type()
const {
return name_and_type_.GetPayload(); }
113 const AstConsString* MakeNameFromStack();
116 void InferFunctionsNames();
118 AstValueFactory* ast_value_factory_;
119 std::vector<Name> names_stack_;
120 std::vector<FunctionLiteral*> funcs_to_infer_;
121 size_t scope_depth_ = 0;
123 DISALLOW_COPY_AND_ASSIGN(FuncNameInferrer);
130 #endif // V8_PARSING_FUNC_NAME_INFERRER_H_