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

Unified Diff: runtime/vm/code_generator.cc

Issue 53583003: Implement latest spec changes regarding malformed types (see issue 14006): (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/flow_graph_compiler_arm.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 29604)
+++ runtime/vm/code_generator.cc (working copy)
@@ -638,7 +638,7 @@
// Report that the type of the given object is not bool in conditional context.
// Arg0: bad object.
// Return value: none, throws a TypeError.
-DEFINE_RUNTIME_ENTRY(ConditionTypeError, 1) {
+DEFINE_RUNTIME_ENTRY(NonBoolTypeError, 1) {
const intptr_t location = GetCallerLocation();
const Instance& src_instance = Instance::CheckedHandle(arguments.ArgAt(0));
ASSERT(src_instance.IsNull() || !src_instance.IsBool());
@@ -659,19 +659,32 @@
// types? Revisit.
// Report that the type of the type check is malformed.
// Arg0: src value.
-// Arg1: name of instance being assigned to.
-// Arg2: malformed type error message.
+// Arg1: name of destination being assigned to.
+// Arg2: type of destination being assigned to.
// Return value: none, throws an exception.
-DEFINE_RUNTIME_ENTRY(MalformedTypeError, 3) {
+DEFINE_RUNTIME_ENTRY(BadTypeError, 3) {
const intptr_t location = GetCallerLocation();
const Instance& src_value = Instance::CheckedHandle(arguments.ArgAt(0));
const String& dst_name = String::CheckedHandle(arguments.ArgAt(1));
- const String& bound_error = String::CheckedHandle(arguments.ArgAt(2));
+ const AbstractType& dst_type =
+ AbstractType::CheckedHandle(arguments.ArgAt(2));
const AbstractType& src_type = AbstractType::Handle(src_value.GetType());
const String& src_type_name = String::Handle(src_type.UserVisibleName());
- Exceptions::CreateAndThrowTypeError(location, src_type_name,
- Symbols::Malformed(),
- dst_name, bound_error);
+
+ String& dst_type_name = String::Handle();
+ Error& error = Error::Handle();
+ if (dst_type.IsMalformed()) {
+ error = dst_type.malformed_error();
+ dst_type_name = Symbols::Malformed().raw();
+ } else {
+ const bool is_malbounded = dst_type.IsMalboundedWithError(&error);
+ dst_type_name = Symbols::Malbounded().raw();
+ ASSERT(is_malbounded);
+ }
+ const String& error_message = String::ZoneHandle(
+ Symbols::New(error.ToErrorCString()));
+ Exceptions::CreateAndThrowTypeError(
+ location, src_type_name, dst_type_name, dst_name, error_message);
UNREACHABLE();
}
« no previous file with comments | « runtime/vm/code_generator.h ('k') | runtime/vm/flow_graph_compiler_arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698