Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(893)

Unified Diff: src/parsing/func-name-inferrer.h

Issue 1507283003: Fix FuncNameInferrer usage in ParseAssignmentExpression (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add a basic RAII object and skip turbofan Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | src/parsing/parser.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parsing/func-name-inferrer.h
diff --git a/src/parsing/func-name-inferrer.h b/src/parsing/func-name-inferrer.h
index d0e4cad429cdc0d0264162a9b82a5c67fce2f6e2..ba38ffeb241c348ab8e285a842b08e5f12590615 100644
--- a/src/parsing/func-name-inferrer.h
+++ b/src/parsing/func-name-inferrer.h
@@ -30,17 +30,29 @@ class FuncNameInferrer : public ZoneObject {
public:
FuncNameInferrer(AstValueFactory* ast_value_factory, Zone* zone);
+ // To enter function name inference state, put a FuncNameInferrer::State
+ // on the stack.
+ class State {
+ public:
+ explicit State(FuncNameInferrer* fni) : fni_(fni) {
+ if (fni_ != nullptr) fni_->Enter();
+ }
+ ~State() {
+ if (fni_ != nullptr) fni_->Leave();
+ }
+
+ private:
+ FuncNameInferrer* fni_;
+
+ DISALLOW_COPY_AND_ASSIGN(State);
+ };
+
// Returns whether we have entered name collection state.
bool IsOpen() const { return !entries_stack_.is_empty(); }
// Pushes an enclosing the name of enclosing function onto names stack.
void PushEnclosingName(const AstRawString* name);
- // Enters name collection state.
- void Enter() {
- entries_stack_.Add(names_stack_.length(), zone());
- }
-
// Pushes an encountered name onto names stack when in collection state.
void PushLiteralName(const AstRawString* name);
@@ -67,14 +79,6 @@ class FuncNameInferrer : public ZoneObject {
}
}
- // Leaves names collection state.
- void Leave() {
- DCHECK(IsOpen());
- names_stack_.Rewind(entries_stack_.RemoveLast());
- if (entries_stack_.is_empty())
- funcs_to_infer_.Clear();
- }
-
private:
enum NameType {
kEnclosingConstructorName,
@@ -87,6 +91,14 @@ class FuncNameInferrer : public ZoneObject {
NameType type;
};
+ void Enter() { entries_stack_.Add(names_stack_.length(), zone()); }
+
+ void Leave() {
+ DCHECK(IsOpen());
+ names_stack_.Rewind(entries_stack_.RemoveLast());
+ if (entries_stack_.is_empty()) funcs_to_infer_.Clear();
+ }
+
Zone* zone() const { return zone_; }
// Constructs a full name in dotted notation from gathered names.
« no previous file with comments | « no previous file | src/parsing/parser.cc » ('j') | src/parsing/parser.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698