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

Unified Diff: runtime/vm/parser.cc

Issue 8602004: Fix code generation issue with new factory syntax. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years, 1 month 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 | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 1661)
+++ runtime/vm/parser.cc (working copy)
@@ -599,9 +599,7 @@
// The instantiator may be required at run time for generic type checks or
// allocation of generic types.
- if ((parser.current_class().NumTypeParameters() > 0) &&
- (!parser.current_function().is_static() ||
- parser.current_function().IsInFactoryScope())) {
+ if (parser.IsInstantiatorRequired()) {
// In the case of a local function, only set the instantiator if the
// receiver was captured.
const bool kTestOnly = true;
@@ -1827,9 +1825,7 @@
(current_block_->scope->function_level() > 0)) {
// We are parsing, but not compiling, a local function.
// The instantiator may be required at run time for generic type checks.
- if ((current_class().NumTypeParameters() > 0) &&
- (!current_function().is_static() ||
- current_function().IsInFactoryScope())) {
+ if (IsInstantiatorRequired()) {
// Make sure that the receiver of the enclosing instance function
// (or implicit first parameter of an enclosing factory) is marked as
// captured if type checks are enabled, because they may access the
@@ -6068,6 +6064,24 @@
}
+bool Parser::IsInstantiatorRequired() const {
+ ASSERT(!current_function().IsNull());
+ Function& outer_function = Function::Handle(current_function().raw());
+ while (outer_function.IsLocalFunction()) {
+ outer_function = outer_function.parent_function();
+ }
+ if (outer_function.IsFactory()) {
+ const Class& signature_class =
+ Class::Handle(outer_function.signature_class());
+ return signature_class.NumTypeParameters() > 0;
+ }
+ if (!outer_function.is_static()) {
+ return current_class().NumTypeParameters() > 0;
+ }
+ return false;
+}
+
+
void Parser::RunStaticFieldInitializer(const Field& field) {
ASSERT(field.is_static());
const Instance& value = Instance::Handle(field.value());
« no previous file with comments | « runtime/vm/parser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698