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

Unified Diff: src/parser.h

Issue 13542002: Calling a generator function returns a generator object (Closed) Base URL: git://github.com/v8/v8.git@master
Patch Set: Fix nits; generator object fields are undefined if not set Created 7 years, 8 months 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 | « src/objects-visiting.cc ('k') | src/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/parser.h
diff --git a/src/parser.h b/src/parser.h
index 8a3be4ef16cb5daf00e788e3c457da80c11f7ab1..acf47bbcd3d5f435896d1611c4e3d8b579944f50 100644
--- a/src/parser.h
+++ b/src/parser.h
@@ -488,7 +488,6 @@ class Parser BASE_EMBEDDED {
public:
FunctionState(Parser* parser,
Scope* scope,
- bool is_generator,
Isolate* isolate);
~FunctionState();
@@ -519,7 +518,17 @@ class Parser BASE_EMBEDDED {
void AddProperty() { expected_property_count_++; }
int expected_property_count() { return expected_property_count_; }
- bool is_generator() const { return is_generator_; }
+ void set_generator_object_variable(Variable *variable) {
+ ASSERT(variable != NULL);
+ ASSERT(!is_generator());
+ generator_object_variable_ = variable;
+ }
+ Variable* generator_object_variable() const {
+ return generator_object_variable_;
+ }
+ bool is_generator() const {
+ return generator_object_variable_ != NULL;
+ }
AstNodeFactory<AstConstructionVisitor>* factory() { return &factory_; }
@@ -535,14 +544,16 @@ class Parser BASE_EMBEDDED {
// Properties count estimation.
int expected_property_count_;
- // Indicates that this function is a generator.
- bool is_generator_;
-
// Keeps track of assignments to properties of this. Used for
// optimizing constructors.
bool only_simple_this_property_assignments_;
Handle<FixedArray> this_property_assignments_;
+ // For generators, the variable that holds the generator object. This
+ // variable is used by yield expressions and return statements. NULL
+ // indicates that this function is not a generator.
+ Variable* generator_object_variable_;
+
Parser* parser_;
FunctionState* outer_function_state_;
Scope* outer_scope_;
« no previous file with comments | « src/objects-visiting.cc ('k') | src/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698