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

Side by Side Diff: runtime/vm/parser.cc

Issue 10161030: Canonicalize type arguments lazily. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/parser.h" 5 #include "vm/parser.h"
6 6
7 #include "vm/bigint_operations.h" 7 #include "vm/bigint_operations.h"
8 #include "vm/class_finalizer.h" 8 #include "vm/class_finalizer.h"
9 #include "vm/compiler.h" 9 #include "vm/compiler.h"
10 #include "vm/compiler_stats.h" 10 #include "vm/compiler_stats.h"
(...skipping 6847 matching lines...) Expand 10 before | Expand all | Expand 10 after
6858 ArgumentListNode* arguments) { 6858 ArgumentListNode* arguments) {
6859 // +2 for implicit receiver and construction phase arguments. 6859 // +2 for implicit receiver and construction phase arguments.
6860 GrowableArray<const Object*> arg_values(arguments->length() + 2); 6860 GrowableArray<const Object*> arg_values(arguments->length() + 2);
6861 Instance& instance = Instance::Handle(); 6861 Instance& instance = Instance::Handle();
6862 if (!constructor.IsFactory()) { 6862 if (!constructor.IsFactory()) {
6863 instance = Instance::New(type_class); 6863 instance = Instance::New(type_class);
6864 if (!type_arguments.IsNull()) { 6864 if (!type_arguments.IsNull()) {
6865 if (!type_arguments.IsInstantiated()) { 6865 if (!type_arguments.IsInstantiated()) {
6866 ErrorMsg("type must be constant in const constructor"); 6866 ErrorMsg("type must be constant in const constructor");
6867 } 6867 }
6868 instance.SetTypeArguments(type_arguments); 6868 instance.SetTypeArguments(
6869 AbstractTypeArguments::Handle(type_arguments.Canonicalize()));
6869 } 6870 }
6870 arg_values.Add(&instance); 6871 arg_values.Add(&instance);
6871 arg_values.Add(&Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll))); 6872 arg_values.Add(&Smi::ZoneHandle(Smi::New(Function::kCtorPhaseAll)));
6872 } else { 6873 } else {
6873 // Prepend type_arguments to list of arguments to factory. 6874 // Prepend type_arguments to list of arguments to factory.
6874 ASSERT(type_arguments.IsZoneHandle()); 6875 ASSERT(type_arguments.IsZoneHandle());
6875 arg_values.Add(&type_arguments); 6876 arg_values.Add(&type_arguments);
6876 } 6877 }
6877 for (int i = 0; i < arguments->length(); i++) { 6878 for (int i = 0; i < arguments->length(); i++) {
6878 AstNode* arg = arguments->NodeAt(i); 6879 AstNode* arg = arguments->NodeAt(i);
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
7319 } 7320 }
7320 } 7321 }
7321 ExpectToken(Token::kRBRACK); 7322 ExpectToken(Token::kRBRACK);
7322 SetAllowFunctionLiterals(saved_mode); 7323 SetAllowFunctionLiterals(saved_mode);
7323 } 7324 }
7324 7325
7325 if (is_const) { 7326 if (is_const) {
7326 // Allocate and initialize the const list at compile time. 7327 // Allocate and initialize the const list at compile time.
7327 Array& const_list = 7328 Array& const_list =
7328 Array::ZoneHandle(Array::New(list->length(), Heap::kOld)); 7329 Array::ZoneHandle(Array::New(list->length(), Heap::kOld));
7329 const_list.SetTypeArguments(type_arguments); 7330 const_list.SetTypeArguments(
7331 AbstractTypeArguments::Handle(type_arguments.Canonicalize()));
7330 Error& malformed_error = Error::Handle(); 7332 Error& malformed_error = Error::Handle();
7331 for (int i = 0; i < list->length(); i++) { 7333 for (int i = 0; i < list->length(); i++) {
7332 AstNode* elem = list->ElementAt(i); 7334 AstNode* elem = list->ElementAt(i);
7333 // Arguments have been evaluated to a literal value already. 7335 // Arguments have been evaluated to a literal value already.
7334 ASSERT(elem->IsLiteralNode()); 7336 ASSERT(elem->IsLiteralNode());
7335 if (FLAG_enable_type_checks && 7337 if (FLAG_enable_type_checks &&
7336 !element_type.IsDynamicType() && 7338 !element_type.IsDynamicType() &&
7337 (!elem->AsLiteralNode()->literal().IsNull() && 7339 (!elem->AsLiteralNode()->literal().IsNull() &&
7338 !elem->AsLiteralNode()->literal().IsInstanceOf( 7340 !elem->AsLiteralNode()->literal().IsInstanceOf(
7339 element_type, TypeArguments::Handle(), &malformed_error))) { 7341 element_type, TypeArguments::Handle(), &malformed_error))) {
(...skipping 1071 matching lines...) Expand 10 before | Expand all | Expand 10 after
8411 void Parser::SkipQualIdent() { 8413 void Parser::SkipQualIdent() {
8412 ASSERT(IsIdentifier()); 8414 ASSERT(IsIdentifier());
8413 ConsumeToken(); 8415 ConsumeToken();
8414 if (CurrentToken() == Token::kPERIOD) { 8416 if (CurrentToken() == Token::kPERIOD) {
8415 ConsumeToken(); // Consume the kPERIOD token. 8417 ConsumeToken(); // Consume the kPERIOD token.
8416 ExpectIdentifier("identifier expected after '.'"); 8418 ExpectIdentifier("identifier expected after '.'");
8417 } 8419 }
8418 } 8420 }
8419 8421
8420 } // namespace dart 8422 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698