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

Unified 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 8 years 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
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 16515)
+++ runtime/vm/parser.cc (working copy)
@@ -6890,6 +6890,12 @@
// Ensure that the expression temp is allocated for nodes that may need it.
AstNode* Parser::CreateAssignmentNode(AstNode* original, AstNode* rhs) {
AstNode* result = original->MakeAssignmentNode(rhs);
+ if ((result == NULL) && original->IsTypeNode()) {
+ const String& type_name = String::ZoneHandle(
+ original->AsTypeNode()->type().ClassName());
+ // TODO(tball): determine whether NoSuchMethod should be called instead.
+ result = ThrowNoSuchMethodError(original->token_pos(), type_name);
+ }
if ((result != NULL) &&
(result->IsStoreIndexedNode() ||
result->IsInstanceSetterNode() ||
@@ -7482,13 +7488,14 @@
if (primary->primary().IsFunction()) {
// Treat as implicit closure.
left = LoadClosure(primary);
- } else if (left->AsPrimaryNode()->primary().IsClass()) {
- Class& cls = Class::CheckedHandle(
- left->AsPrimaryNode()->primary().raw());
- String& cls_name = String::Handle(cls.Name());
- ErrorMsg(left->token_pos(),
- "illegal use of class name '%s'",
- cls_name.ToCString());
+ } else if (primary->primary().IsClass()) {
+ const Class& type_class = Class::Cast(primary->primary());
+ Type& type = Type::ZoneHandle(
+ Type::New(type_class, TypeArguments::Handle(),
+ primary->token_pos(), Heap::kOld));
+ type ^= ClassFinalizer::FinalizeType(
+ current_class(), type, ClassFinalizer::kCanonicalize);
+ left = new TypeNode(primary->token_pos(), type);
} else if (primary->IsSuper()) {
// Return "super" to handle unary super operator calls,
// or to report illegal use of "super" otherwise.

Powered by Google App Engine
This is Rietveld 408576698