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

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
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | tests/language/class_literal_test.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/parser.cc
===================================================================
--- runtime/vm/parser.cc (revision 16343)
+++ runtime/vm/parser.cc (working copy)
@@ -7480,12 +7480,14 @@
// Treat as implicit closure.
left = LoadClosure(primary);
} else if (left->AsPrimaryNode()->primary().IsClass()) {
Ivan Posva 2012/12/21 00:14:27 left->AsPrimaryNode() can be short-circuited to pr
Tom Ball 2012/12/21 22:24:11 Done.
- 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());
+ Class& type_class = Class::Handle();
+ type_class ^= primary->primary().raw();
+ Type& type = Type::ZoneHandle(
+ Type::New(type_class, TypeArguments::Handle(),
Ivan Posva 2012/12/21 00:14:27 Instead of the acrobatics creating a type_class ha
Tom Ball 2012/12/21 22:24:11 Done.
+ primary->token_pos()));
+ type ^= ClassFinalizer::FinalizeType(
+ current_class(), type, ClassFinalizer::kCanonicalize);
+ left = new LiteralNode(primary->token_pos(), type);
} else if (primary->IsSuper()) {
// Return "super" to handle unary super operator calls,
// or to report illegal use of "super" otherwise.
@@ -8333,17 +8335,6 @@
AstNode* resolved = NULL;
ResolveIdentInLocalScope(ident_pos, ident, &resolved);
if (resolved == NULL) {
- // Check whether the identifier is a type parameter. Type parameters
- // can never be used in primary expressions.
- if (!current_class().IsNull()) {
- TypeParameter& type_param = TypeParameter::Handle(
- current_class().LookupTypeParameter(ident, ident_pos));
- if (!type_param.IsNull()) {
- String& type_param_name = String::Handle(type_param.name());
- ErrorMsg(ident_pos, "illegal use of type parameter %s",
- type_param_name.ToCString());
- }
- }
regis 2012/12/21 00:09:10 Removing this code cannot be correct. The identifi
Tom Ball 2012/12/21 22:24:11 I restored this block and the next, and restored t
// Not found in the local scope, and the name is not a type parameter.
// Try finding the variable in the library scope (current library
// and all libraries imported by it without a library prefix).
@@ -9276,19 +9267,6 @@
if (!ResolveIdentInLocalScope(qual_ident.ident_pos,
*qual_ident.ident,
&primary)) {
- // Check whether the identifier is a type parameter. Type parameters
- // can never be used as part of primary expressions.
- if (!current_class().IsNull()) {
- TypeParameter& type_param = TypeParameter::ZoneHandle(
- current_class().LookupTypeParameter(*(qual_ident.ident),
- TokenPos()));
- if (!type_param.IsNull()) {
- const String& type_param_name = String::Handle(type_param.name());
- ErrorMsg(qual_ident.ident_pos,
- "illegal use of type parameter %s",
- type_param_name.ToCString());
- }
- }
regis 2012/12/21 00:09:10 ditto
// This is a non-local unqualified identifier so resolve the
// identifier locally in the main app library and all libraries
// imported by it.
« no previous file with comments | « no previous file | tests/co19/co19-runtime.status » ('j') | tests/language/class_literal_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698