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

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

Issue 9615035: Generate dynamic type errors according to spec. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | 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 "include/dart_api.h" 5 #include "include/dart_api.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/dart.h" 10 #include "vm/dart.h"
(...skipping 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 } 939 }
940 const Object& obj = Object::Handle(Api::UnwrapHandle(object)); 940 const Object& obj = Object::Handle(Api::UnwrapHandle(object));
941 Instance& instance = Instance::Handle(); 941 Instance& instance = Instance::Handle();
942 instance ^= obj.raw(); 942 instance ^= obj.raw();
943 // Finalize all classes. 943 // Finalize all classes.
944 const char* msg = CheckIsolateState(isolate); 944 const char* msg = CheckIsolateState(isolate);
945 if (msg != NULL) { 945 if (msg != NULL) {
946 return Api::NewError(msg); 946 return Api::NewError(msg);
947 } 947 }
948 const Type& type = Type::Handle(Type::NewNonParameterizedType(cls)); 948 const Type& type = Type::Handle(Type::NewNonParameterizedType(cls));
949 *value = instance.IsInstanceOf(type, TypeArguments::Handle()); 949 Error& malformed_type_error = Error::Handle();
950 *value = instance.IsInstanceOf(
951 type, TypeArguments::Handle(), &malformed_type_error);
952 ASSERT(malformed_type_error.IsNull()); // Type was created here from a class.
950 return Api::Success(); 953 return Api::Success();
951 } 954 }
952 955
953 956
954 // --- Numbers ---- 957 // --- Numbers ----
955 958
956 959
957 // TODO(iposva): The argument should be an instance. 960 // TODO(iposva): The argument should be an instance.
958 DART_EXPORT bool Dart_IsNumber(Dart_Handle object) { 961 DART_EXPORT bool Dart_IsNumber(Dart_Handle object) {
959 DARTSCOPE(Isolate::Current()); 962 DARTSCOPE(Isolate::Current());
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1413 1416
1414 1417
1415 // --- Lists --- 1418 // --- Lists ---
1416 1419
1417 1420
1418 static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) { 1421 static RawInstance* GetListInstance(Isolate* isolate, const Object& obj) {
1419 if (obj.IsInstance()) { 1422 if (obj.IsInstance()) {
1420 Instance& instance = Instance::Handle(); 1423 Instance& instance = Instance::Handle();
1421 instance ^= obj.raw(); 1424 instance ^= obj.raw();
1422 const Type& type = Type::Handle(isolate->object_store()->list_interface()); 1425 const Type& type = Type::Handle(isolate->object_store()->list_interface());
1423 if (instance.IsInstanceOf(type, TypeArguments::Handle())) { 1426 Error& malformed_type_error = Error::Handle();
1427 if (instance.IsInstanceOf(type,
1428 TypeArguments::Handle(),
1429 &malformed_type_error)) {
1430 ASSERT(malformed_type_error.IsNull()); // Type is a raw List.
1424 return instance.raw(); 1431 return instance.raw();
1425 } 1432 }
1426 } 1433 }
1427 return Instance::null(); 1434 return Instance::null();
1428 } 1435 }
1429 1436
1430 1437
1431 DART_EXPORT bool Dart_IsList(Dart_Handle object) { 1438 DART_EXPORT bool Dart_IsList(Dart_Handle object) {
1432 Isolate* isolate = Isolate::Current(); 1439 Isolate* isolate = Isolate::Current();
1433 DARTSCOPE(isolate); 1440 DARTSCOPE(isolate);
(...skipping 1309 matching lines...) Expand 10 before | Expand all | Expand 10 after
2743 *buffer = NULL; 2750 *buffer = NULL;
2744 } 2751 }
2745 delete debug_region; 2752 delete debug_region;
2746 } else { 2753 } else {
2747 *buffer = NULL; 2754 *buffer = NULL;
2748 *buffer_size = 0; 2755 *buffer_size = 0;
2749 } 2756 }
2750 } 2757 }
2751 2758
2752 } // namespace dart 2759 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698