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

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

Issue 2044753002: Make compile-time errors catchable (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Address review comments Created 4 years, 3 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/compiler.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 #include "include/dart_mirrors_api.h" 6 #include "include/dart_mirrors_api.h"
7 #include "include/dart_native_api.h" 7 #include "include/dart_native_api.h"
8 8
9 #include "platform/assert.h" 9 #include "platform/assert.h"
10 #include "lib/stacktrace.h" 10 #include "lib/stacktrace.h"
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 NULL, 177 NULL,
178 Heap::kNew)) { 178 Heap::kNew)) {
179 ASSERT(malformed_type_error.IsNull()); // Type is a raw Map. 179 ASSERT(malformed_type_error.IsNull()); // Type is a raw Map.
180 return instance.raw(); 180 return instance.raw();
181 } 181 }
182 } 182 }
183 return Instance::null(); 183 return Instance::null();
184 } 184 }
185 185
186 186
187 static bool IsCompiletimeErrorObject(Zone* zone, const Object& obj) {
188 Isolate* I = Thread::Current()->isolate();
189 const Class& error_class =
190 Class::Handle(zone, I->object_store()->compiletime_error_class());
191 ASSERT(!error_class.IsNull());
192 return (obj.GetClassId() == error_class.id());
193 }
194
195
187 static bool GetNativeStringArgument(NativeArguments* arguments, 196 static bool GetNativeStringArgument(NativeArguments* arguments,
188 int arg_index, 197 int arg_index,
189 Dart_Handle* str, 198 Dart_Handle* str,
190 void** peer) { 199 void** peer) {
191 ASSERT(peer != NULL); 200 ASSERT(peer != NULL);
192 if (Api::StringGetPeerHelper(arguments, arg_index, peer)) { 201 if (Api::StringGetPeerHelper(arguments, arg_index, peer)) {
193 *str = NULL; 202 *str = NULL;
194 return true; 203 return true;
195 } 204 }
196 Thread* thread = arguments->thread(); 205 Thread* thread = arguments->thread();
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 return Api::ClassId(object) == kApiErrorCid; 763 return Api::ClassId(object) == kApiErrorCid;
755 } 764 }
756 765
757 766
758 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) { 767 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) {
759 return Api::ClassId(object) == kUnhandledExceptionCid; 768 return Api::ClassId(object) == kUnhandledExceptionCid;
760 } 769 }
761 770
762 771
763 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) { 772 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) {
773 if (Dart_IsUnhandledExceptionError(object)) {
774 DARTSCOPE(Thread::Current());
775 const UnhandledException& error =
776 UnhandledException::Cast(Object::Handle(Z, Api::UnwrapHandle(object)));
777 const Instance& exc = Instance::Handle(Z, error.exception());
778 return IsCompiletimeErrorObject(Z, exc);
779 }
764 return Api::ClassId(object) == kLanguageErrorCid; 780 return Api::ClassId(object) == kLanguageErrorCid;
765 } 781 }
766 782
767 783
768 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) { 784 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) {
769 return Api::ClassId(object) == kUnwindErrorCid; 785 return Api::ClassId(object) == kUnwindErrorCid;
770 } 786 }
771 787
772 788
773 DART_EXPORT bool Dart_IsVMRestartRequest(Dart_Handle handle) { 789 DART_EXPORT bool Dart_IsVMRestartRequest(Dart_Handle handle) {
(...skipping 5810 matching lines...) Expand 10 before | Expand all | Expand 10 after
6584 6600
6585 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6601 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6586 #if defined(DART_PRECOMPILED_RUNTIME) 6602 #if defined(DART_PRECOMPILED_RUNTIME)
6587 return true; 6603 return true;
6588 #else 6604 #else
6589 return false; 6605 return false;
6590 #endif 6606 #endif
6591 } 6607 }
6592 6608
6593 } // namespace dart 6609 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/compiler.cc ('k') | runtime/vm/dart_api_impl_test.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698