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

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

Issue 1534533002: Version 4.8.271.10 (cherry-pick) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@4.8
Patch Set: Bump patch level 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 | « include/v8-version.h ('k') | src/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/func-name-inferrer.h
diff --git a/src/func-name-inferrer.h b/src/func-name-inferrer.h
index 8bc0e6c81ee9c682489a936f99ae45d68b9a2878..c17acf52f2ec205ea2ff650e9e7540165856c426 100644
--- a/src/func-name-inferrer.h
+++ b/src/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 | « include/v8-version.h ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698