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

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

Issue 26866005: Allow malbounded literal types (fix issue 13952). (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 2 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/flow_graph_builder.cc ('k') | tests/language/language.status » ('j') | 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 "lib/invocation_mirror.h" 7 #include "lib/invocation_mirror.h"
8 #include "vm/bigint_operations.h" 8 #include "vm/bigint_operations.h"
9 #include "vm/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/class_finalizer.h" 10 #include "vm/class_finalizer.h"
(...skipping 8301 matching lines...) Expand 10 before | Expand all | Expand 10 after
8312 AstNode* index = ParseExpr(kAllowConst, kConsumeCascades); 8312 AstNode* index = ParseExpr(kAllowConst, kConsumeCascades);
8313 SetAllowFunctionLiterals(saved_mode); 8313 SetAllowFunctionLiterals(saved_mode);
8314 ExpectToken(Token::kRBRACK); 8314 ExpectToken(Token::kRBRACK);
8315 AstNode* array = left; 8315 AstNode* array = left;
8316 if (left->IsPrimaryNode()) { 8316 if (left->IsPrimaryNode()) {
8317 PrimaryNode* primary = left->AsPrimaryNode(); 8317 PrimaryNode* primary = left->AsPrimaryNode();
8318 if (primary->primary().IsFunction()) { 8318 if (primary->primary().IsFunction()) {
8319 array = LoadClosure(primary); 8319 array = LoadClosure(primary);
8320 } else if (primary->primary().IsClass()) { 8320 } else if (primary->primary().IsClass()) {
8321 const Class& type_class = Class::Cast(primary->primary()); 8321 const Class& type_class = Class::Cast(primary->primary());
8322 Type& type = Type::ZoneHandle( 8322 AbstractType& type = Type::ZoneHandle(
8323 Type::New(type_class, TypeArguments::Handle(), 8323 Type::New(type_class, TypeArguments::Handle(),
8324 primary->token_pos(), Heap::kOld)); 8324 primary->token_pos(), Heap::kOld));
8325 type ^= ClassFinalizer::FinalizeType( 8325 type ^= ClassFinalizer::FinalizeType(
8326 current_class(), type, ClassFinalizer::kCanonicalize); 8326 current_class(), type, ClassFinalizer::kCanonicalize);
8327 // Type may be malbounded, but not malformed.
8327 ASSERT(!type.IsMalformed()); 8328 ASSERT(!type.IsMalformed());
8328 array = new TypeNode(primary->token_pos(), type); 8329 array = new TypeNode(primary->token_pos(), type);
8329 } else if (primary->primary().IsTypeParameter()) { 8330 } else if (primary->primary().IsTypeParameter()) {
8330 if (current_block_->scope->function_level() > 0) { 8331 if (current_block_->scope->function_level() > 0) {
8331 // Make sure that the instantiator is captured. 8332 // Make sure that the instantiator is captured.
8332 CaptureInstantiator(); 8333 CaptureInstantiator();
8333 } 8334 }
8334 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); 8335 TypeParameter& type_parameter = TypeParameter::ZoneHandle();
8335 type_parameter ^= ClassFinalizer::FinalizeType( 8336 type_parameter ^= ClassFinalizer::FinalizeType(
8336 current_class(), 8337 current_class(),
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
8393 TypeParameter::Cast(primary->primary()).name()); 8394 TypeParameter::Cast(primary->primary()).name());
8394 selector = ThrowNoSuchMethodError(primary->token_pos(), 8395 selector = ThrowNoSuchMethodError(primary->token_pos(),
8395 current_class(), 8396 current_class(),
8396 name, 8397 name,
8397 NULL, // No arguments. 8398 NULL, // No arguments.
8398 InvocationMirror::kStatic, 8399 InvocationMirror::kStatic,
8399 InvocationMirror::kMethod, 8400 InvocationMirror::kMethod,
8400 NULL); // No existing function. 8401 NULL); // No existing function.
8401 } else if (primary->primary().IsClass()) { 8402 } else if (primary->primary().IsClass()) {
8402 const Class& type_class = Class::Cast(primary->primary()); 8403 const Class& type_class = Class::Cast(primary->primary());
8403 Type& type = Type::ZoneHandle( 8404 AbstractType& type = Type::ZoneHandle(
8404 Type::New(type_class, TypeArguments::Handle(), 8405 Type::New(type_class, TypeArguments::Handle(),
8405 primary->token_pos(), Heap::kOld)); 8406 primary->token_pos(), Heap::kOld));
8406 type ^= ClassFinalizer::FinalizeType( 8407 type ^= ClassFinalizer::FinalizeType(
8407 current_class(), type, ClassFinalizer::kCanonicalize); 8408 current_class(), type, ClassFinalizer::kCanonicalize);
8409 // Type may be malbounded, but not malformed.
8408 ASSERT(!type.IsMalformed()); 8410 ASSERT(!type.IsMalformed());
8409 selector = new TypeNode(primary->token_pos(), type); 8411 selector = new TypeNode(primary->token_pos(), type);
8410 } else { 8412 } else {
8411 UNREACHABLE(); // Internal parser error. 8413 UNREACHABLE(); // Internal parser error.
8412 } 8414 }
8413 } else { 8415 } else {
8414 // Left is not a primary node; this must be a closure call. 8416 // Left is not a primary node; this must be a closure call.
8415 AstNode* closure = left; 8417 AstNode* closure = left;
8416 selector = ParseClosureCall(closure); 8418 selector = ParseClosureCall(closure);
8417 } 8419 }
8418 } else { 8420 } else {
8419 // No (more) selectors to parse. 8421 // No (more) selectors to parse.
8420 left = LoadFieldIfUnresolved(left); 8422 left = LoadFieldIfUnresolved(left);
8421 if (left->IsPrimaryNode()) { 8423 if (left->IsPrimaryNode()) {
8422 PrimaryNode* primary = left->AsPrimaryNode(); 8424 PrimaryNode* primary = left->AsPrimaryNode();
8423 if (primary->primary().IsFunction()) { 8425 if (primary->primary().IsFunction()) {
8424 // Treat as implicit closure. 8426 // Treat as implicit closure.
8425 left = LoadClosure(primary); 8427 left = LoadClosure(primary);
8426 } else if (primary->primary().IsClass()) { 8428 } else if (primary->primary().IsClass()) {
8427 const Class& type_class = Class::Cast(primary->primary()); 8429 const Class& type_class = Class::Cast(primary->primary());
8428 Type& type = Type::ZoneHandle( 8430 AbstractType& type = Type::ZoneHandle(
8429 Type::New(type_class, TypeArguments::Handle(), 8431 Type::New(type_class, TypeArguments::Handle(),
8430 primary->token_pos(), Heap::kOld)); 8432 primary->token_pos(), Heap::kOld));
8431 type ^= ClassFinalizer::FinalizeType( 8433 type = ClassFinalizer::FinalizeType(
8432 current_class(), type, ClassFinalizer::kCanonicalize); 8434 current_class(), type, ClassFinalizer::kCanonicalize);
8435 // Type may be malbounded, but not malformed.
8433 ASSERT(!type.IsMalformed()); 8436 ASSERT(!type.IsMalformed());
8434 left = new TypeNode(primary->token_pos(), type); 8437 left = new TypeNode(primary->token_pos(), type);
8435 } else if (primary->primary().IsTypeParameter()) { 8438 } else if (primary->primary().IsTypeParameter()) {
8436 if (current_block_->scope->function_level() > 0) { 8439 if (current_block_->scope->function_level() > 0) {
8437 // Make sure that the instantiator is captured. 8440 // Make sure that the instantiator is captured.
8438 CaptureInstantiator(); 8441 CaptureInstantiator();
8439 } 8442 }
8440 TypeParameter& type_parameter = TypeParameter::ZoneHandle(); 8443 TypeParameter& type_parameter = TypeParameter::ZoneHandle();
8441 type_parameter ^= ClassFinalizer::FinalizeType( 8444 type_parameter ^= ClassFinalizer::FinalizeType(
8442 current_class(), 8445 current_class(),
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after
9139 } 9142 }
9140 } else if (primary->primary().IsFunction()) { 9143 } else if (primary->primary().IsFunction()) {
9141 if (allow_closure_names) { 9144 if (allow_closure_names) {
9142 resolved = LoadClosure(primary); 9145 resolved = LoadClosure(primary);
9143 } else { 9146 } else {
9144 ErrorMsg(ident_pos, "illegal reference to method '%s'", 9147 ErrorMsg(ident_pos, "illegal reference to method '%s'",
9145 ident.ToCString()); 9148 ident.ToCString());
9146 } 9149 }
9147 } else if (primary->primary().IsClass()) { 9150 } else if (primary->primary().IsClass()) {
9148 const Class& type_class = Class::Cast(primary->primary()); 9151 const Class& type_class = Class::Cast(primary->primary());
9149 Type& type = Type::ZoneHandle( 9152 AbstractType& type = Type::ZoneHandle(
9150 Type::New(type_class, TypeArguments::Handle(), 9153 Type::New(type_class, TypeArguments::Handle(),
9151 primary->token_pos(), Heap::kOld)); 9154 primary->token_pos(), Heap::kOld));
9152 type ^= ClassFinalizer::FinalizeType( 9155 type ^= ClassFinalizer::FinalizeType(
9153 current_class(), type, ClassFinalizer::kCanonicalize); 9156 current_class(), type, ClassFinalizer::kCanonicalize);
9157 // Type may be malbounded, but not malformed.
9154 ASSERT(!type.IsMalformed()); 9158 ASSERT(!type.IsMalformed());
9155 resolved = new TypeNode(primary->token_pos(), type); 9159 resolved = new TypeNode(primary->token_pos(), type);
9156 } 9160 }
9157 } 9161 }
9158 return resolved; 9162 return resolved;
9159 } 9163 }
9160 9164
9161 9165
9162 // Parses type = [ident "."] ident ["<" type { "," type } ">"], then resolve and 9166 // Parses type = [ident "."] ident ["<" type { "," type } ">"], then resolve and
9163 // finalize it according to the given type finalization mode. 9167 // finalize it according to the given type finalization mode.
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
10619 void Parser::SkipQualIdent() { 10623 void Parser::SkipQualIdent() {
10620 ASSERT(IsIdentifier()); 10624 ASSERT(IsIdentifier());
10621 ConsumeToken(); 10625 ConsumeToken();
10622 if (CurrentToken() == Token::kPERIOD) { 10626 if (CurrentToken() == Token::kPERIOD) {
10623 ConsumeToken(); // Consume the kPERIOD token. 10627 ConsumeToken(); // Consume the kPERIOD token.
10624 ExpectIdentifier("identifier expected after '.'"); 10628 ExpectIdentifier("identifier expected after '.'");
10625 } 10629 }
10626 } 10630 }
10627 10631
10628 } // namespace dart 10632 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/flow_graph_builder.cc ('k') | tests/language/language.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698