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

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

Issue 1778133002: Enumerate URIs of all types in type errors in order to help the user diagnose (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 4 years, 9 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/symbols.h » ('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 #include "vm/flags.h" 6 #include "vm/flags.h"
7 7
8 #ifndef DART_PRECOMPILED_RUNTIME 8 #ifndef DART_PRECOMPILED_RUNTIME
9 9
10 #include "lib/invocation_mirror.h" 10 #include "lib/invocation_mirror.h"
(...skipping 10260 matching lines...) Expand 10 before | Expand all | Expand 10 after
10271 } else { 10271 } else {
10272 arguments->Add(new(Z) LiteralNode(type_pos, *prefix)); 10272 arguments->Add(new(Z) LiteralNode(type_pos, *prefix));
10273 method_name = Library::PrivateCoreLibName( 10273 method_name = Library::PrivateCoreLibName(
10274 Symbols::ThrowNewIfNotLoaded()).raw(); 10274 Symbols::ThrowNewIfNotLoaded()).raw();
10275 } 10275 }
10276 // Location argument. 10276 // Location argument.
10277 arguments->Add(new(Z) LiteralNode( 10277 arguments->Add(new(Z) LiteralNode(
10278 type_pos, Integer::ZoneHandle(Z, Integer::New(type_pos.value())))); 10278 type_pos, Integer::ZoneHandle(Z, Integer::New(type_pos.value()))));
10279 // Src value argument. 10279 // Src value argument.
10280 arguments->Add(new(Z) LiteralNode(type_pos, Object::null_instance())); 10280 arguments->Add(new(Z) LiteralNode(type_pos, Object::null_instance()));
10281 // Dst type name argument. 10281 // Dst type argument.
10282 arguments->Add(new(Z) LiteralNode(type_pos, Symbols::Malformed())); 10282 arguments->Add(new(Z) LiteralNode(type_pos, type));
10283 // Dst name argument. 10283 // Dst name argument.
10284 arguments->Add(new(Z) LiteralNode(type_pos, Symbols::Empty())); 10284 arguments->Add(new(Z) LiteralNode(type_pos, Symbols::Empty()));
10285 // Malformed type error or malbounded type error. 10285 // Bound error msg argument.
10286 const Error& error = Error::Handle(Z, type.error()); 10286 arguments->Add(new(Z) LiteralNode(type_pos, Object::null_instance()));
10287 ASSERT(!error.IsNull());
10288 arguments->Add(new(Z) LiteralNode(type_pos, String::ZoneHandle(Z,
10289 Symbols::New(error.ToErrorCString()))));
10290 return MakeStaticCall(Symbols::TypeError(), method_name, arguments); 10287 return MakeStaticCall(Symbols::TypeError(), method_name, arguments);
10291 } 10288 }
10292 10289
10293 10290
10294 // Call _throwNewIfNotLoaded if prefix is not NULL, otherwise call _throwNew. 10291 // Call _throwNewIfNotLoaded if prefix is not NULL, otherwise call _throwNew.
10295 AstNode* Parser::ThrowNoSuchMethodError(TokenPosition call_pos, 10292 AstNode* Parser::ThrowNoSuchMethodError(TokenPosition call_pos,
10296 const Class& cls, 10293 const Class& cls,
10297 const String& function_name, 10294 const String& function_name,
10298 ArgumentListNode* function_arguments, 10295 ArgumentListNode* function_arguments,
10299 InvocationMirror::Call im_call, 10296 InvocationMirror::Call im_call,
(...skipping 2981 matching lines...) Expand 10 before | Expand all | Expand 10 after
13281 ReportError("type name expected"); 13278 ReportError("type name expected");
13282 } 13279 }
13283 TokenPosition type_pos = TokenPos(); 13280 TokenPosition type_pos = TokenPos();
13284 // Can't allocate const objects of a deferred type. 13281 // Can't allocate const objects of a deferred type.
13285 const bool allow_deferred_type = !is_const; 13282 const bool allow_deferred_type = !is_const;
13286 const Token::Kind la3 = LookaheadToken(3); 13283 const Token::Kind la3 = LookaheadToken(3);
13287 const bool consume_unresolved_prefix = 13284 const bool consume_unresolved_prefix =
13288 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH); 13285 (la3 == Token::kLT) || (la3 == Token::kPERIOD) || (la3 == Token::kHASH);
13289 13286
13290 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z); 13287 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle(Z);
13291 AbstractType& type = AbstractType::Handle(Z, 13288 AbstractType& type = AbstractType::ZoneHandle(Z,
13292 ParseType(ClassFinalizer::kCanonicalizeWellFormed, 13289 ParseType(ClassFinalizer::kCanonicalizeWellFormed,
13293 allow_deferred_type, 13290 allow_deferred_type,
13294 consume_unresolved_prefix, 13291 consume_unresolved_prefix,
13295 &prefix)); 13292 &prefix));
13296 13293
13297 if (FLAG_load_deferred_eagerly && 13294 if (FLAG_load_deferred_eagerly &&
13298 !prefix.IsNull() && prefix.is_deferred_load() && !prefix.is_loaded()) { 13295 !prefix.IsNull() && prefix.is_deferred_load() && !prefix.is_loaded()) {
13299 // Add runtime check. 13296 // Add runtime check.
13300 Type& malformed_type = Type::Handle(Z); 13297 Type& malformed_type = Type::Handle(Z);
13301 malformed_type = ClassFinalizer::NewFinalizedMalformedType( 13298 malformed_type = ClassFinalizer::NewFinalizedMalformedType(
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
13410 } 13407 }
13411 return ThrowNoSuchMethodError(call_pos, 13408 return ThrowNoSuchMethodError(call_pos,
13412 type_class, 13409 type_class,
13413 external_constructor_name, 13410 external_constructor_name,
13414 arguments, 13411 arguments,
13415 InvocationMirror::kConstructor, 13412 InvocationMirror::kConstructor,
13416 InvocationMirror::kMethod, 13413 InvocationMirror::kMethod,
13417 NULL); // No existing function. 13414 NULL); // No existing function.
13418 } else if (constructor.IsRedirectingFactory()) { 13415 } else if (constructor.IsRedirectingFactory()) {
13419 ClassFinalizer::ResolveRedirectingFactory(type_class, constructor); 13416 ClassFinalizer::ResolveRedirectingFactory(type_class, constructor);
13420 Type& redirect_type = Type::Handle(Z, constructor.RedirectionType()); 13417 Type& redirect_type = Type::ZoneHandle(Z, constructor.RedirectionType());
13421 if (!redirect_type.IsMalformedOrMalbounded() && 13418 if (!redirect_type.IsMalformedOrMalbounded() &&
13422 !redirect_type.IsInstantiated()) { 13419 !redirect_type.IsInstantiated()) {
13423 // The type arguments of the redirection type are instantiated from the 13420 // The type arguments of the redirection type are instantiated from the
13424 // type arguments of the parsed type of the 'new' or 'const' expression. 13421 // type arguments of the parsed type of the 'new' or 'const' expression.
13425 Error& error = Error::Handle(Z); 13422 Error& error = Error::Handle(Z);
13426 redirect_type ^= redirect_type.InstantiateFrom( 13423 redirect_type ^= redirect_type.InstantiateFrom(
13427 type_arguments, 13424 type_arguments,
13428 &error, 13425 &error,
13429 NULL, // instantiation_trail 13426 NULL, // instantiation_trail
13430 NULL, // bound_trail 13427 NULL, // bound_trail
(...skipping 1016 matching lines...) Expand 10 before | Expand all | Expand 10 after
14447 const ArgumentListNode& function_args, 14444 const ArgumentListNode& function_args,
14448 const LocalVariable* temp_for_last_arg, 14445 const LocalVariable* temp_for_last_arg,
14449 bool is_super_invocation) { 14446 bool is_super_invocation) {
14450 UNREACHABLE(); 14447 UNREACHABLE();
14451 return NULL; 14448 return NULL;
14452 } 14449 }
14453 14450
14454 } // namespace dart 14451 } // namespace dart
14455 14452
14456 #endif // DART_PRECOMPILED_RUNTIME 14453 #endif // DART_PRECOMPILED_RUNTIME
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/symbols.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698