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

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

Issue 11633054: Implemented class literals in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 11 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
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 6872 matching lines...) Expand 10 before | Expand all | Expand 10 after
6883 *expr = right_node; 6883 *expr = right_node;
6884 return left_node; 6884 return left_node;
6885 } 6885 }
6886 return *expr; 6886 return *expr;
6887 } 6887 }
6888 6888
6889 6889
6890 // Ensure that the expression temp is allocated for nodes that may need it. 6890 // Ensure that the expression temp is allocated for nodes that may need it.
6891 AstNode* Parser::CreateAssignmentNode(AstNode* original, AstNode* rhs) { 6891 AstNode* Parser::CreateAssignmentNode(AstNode* original, AstNode* rhs) {
6892 AstNode* result = original->MakeAssignmentNode(rhs); 6892 AstNode* result = original->MakeAssignmentNode(rhs);
6893 if ((result == NULL) && original->IsTypeNode()) {
6894 const String& type_name = String::ZoneHandle(
6895 original->AsTypeNode()->type().ClassName());
6896 // TODO(tball): determine whether NoSuchMethod should be called instead.
6897 result = ThrowNoSuchMethodError(original->token_pos(), type_name);
6898 }
6893 if ((result != NULL) && 6899 if ((result != NULL) &&
6894 (result->IsStoreIndexedNode() || 6900 (result->IsStoreIndexedNode() ||
6895 result->IsInstanceSetterNode() || 6901 result->IsInstanceSetterNode() ||
6896 result->IsStaticSetterNode() || 6902 result->IsStaticSetterNode() ||
6897 result->IsStoreStaticFieldNode() || 6903 result->IsStoreStaticFieldNode() ||
6898 result->IsStoreLocalNode())) { 6904 result->IsStoreLocalNode())) {
6899 EnsureExpressionTemp(); 6905 EnsureExpressionTemp();
6900 } 6906 }
6901 return result; 6907 return result;
6902 } 6908 }
(...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after
7475 selector = ParseClosureCall(closure); 7481 selector = ParseClosureCall(closure);
7476 } 7482 }
7477 } else { 7483 } else {
7478 // No (more) selectors to parse. 7484 // No (more) selectors to parse.
7479 left = LoadFieldIfUnresolved(left); 7485 left = LoadFieldIfUnresolved(left);
7480 if (left->IsPrimaryNode()) { 7486 if (left->IsPrimaryNode()) {
7481 PrimaryNode* primary = left->AsPrimaryNode(); 7487 PrimaryNode* primary = left->AsPrimaryNode();
7482 if (primary->primary().IsFunction()) { 7488 if (primary->primary().IsFunction()) {
7483 // Treat as implicit closure. 7489 // Treat as implicit closure.
7484 left = LoadClosure(primary); 7490 left = LoadClosure(primary);
7485 } else if (left->AsPrimaryNode()->primary().IsClass()) { 7491 } else if (primary->primary().IsClass()) {
7486 Class& cls = Class::CheckedHandle( 7492 const Class& type_class = Class::Cast(primary->primary());
7487 left->AsPrimaryNode()->primary().raw()); 7493 Type& type = Type::ZoneHandle(
7488 String& cls_name = String::Handle(cls.Name()); 7494 Type::New(type_class, TypeArguments::Handle(),
7489 ErrorMsg(left->token_pos(), 7495 primary->token_pos(), Heap::kOld));
7490 "illegal use of class name '%s'", 7496 type ^= ClassFinalizer::FinalizeType(
7491 cls_name.ToCString()); 7497 current_class(), type, ClassFinalizer::kCanonicalize);
7498 left = new TypeNode(primary->token_pos(), type);
7492 } else if (primary->IsSuper()) { 7499 } else if (primary->IsSuper()) {
7493 // Return "super" to handle unary super operator calls, 7500 // Return "super" to handle unary super operator calls,
7494 // or to report illegal use of "super" otherwise. 7501 // or to report illegal use of "super" otherwise.
7495 left = primary; 7502 left = primary;
7496 } else { 7503 } else {
7497 UNREACHABLE(); // Internal parser error. 7504 UNREACHABLE(); // Internal parser error.
7498 } 7505 }
7499 } 7506 }
7500 // Done parsing selectors. 7507 // Done parsing selectors.
7501 return left; 7508 return left;
(...skipping 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
9700 void Parser::SkipQualIdent() { 9707 void Parser::SkipQualIdent() {
9701 ASSERT(IsIdentifier()); 9708 ASSERT(IsIdentifier());
9702 ConsumeToken(); 9709 ConsumeToken();
9703 if (CurrentToken() == Token::kPERIOD) { 9710 if (CurrentToken() == Token::kPERIOD) {
9704 ConsumeToken(); // Consume the kPERIOD token. 9711 ConsumeToken(); // Consume the kPERIOD token.
9705 ExpectIdentifier("identifier expected after '.'"); 9712 ExpectIdentifier("identifier expected after '.'");
9706 } 9713 }
9707 } 9714 }
9708 9715
9709 } // namespace dart 9716 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698