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

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: wip 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
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 IsSyntaxErrorObject(Zone* zone, const Object& obj) {
188 Isolate* I = Thread::Current()->isolate();
189 const Class& error_class =
190 Class::Handle(I->object_store()->syntax_error_class());
siva 2016/09/15 18:11:45 Handle(zone, I->object_store().... as the zone see
hausner 2016/09/15 21:28:28 Done.
191 ASSERT(!error_class.IsNull());
192 if (obj.GetClassId() == error_class.id()) {
193 return true;
194 }
195 return false;
196 }
197
198
187 static bool GetNativeStringArgument(NativeArguments* arguments, 199 static bool GetNativeStringArgument(NativeArguments* arguments,
188 int arg_index, 200 int arg_index,
189 Dart_Handle* str, 201 Dart_Handle* str,
190 void** peer) { 202 void** peer) {
191 ASSERT(peer != NULL); 203 ASSERT(peer != NULL);
192 if (Api::StringGetPeerHelper(arguments, arg_index, peer)) { 204 if (Api::StringGetPeerHelper(arguments, arg_index, peer)) {
193 *str = NULL; 205 *str = NULL;
194 return true; 206 return true;
195 } 207 }
196 Thread* thread = arguments->thread(); 208 Thread* thread = arguments->thread();
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
754 return Api::ClassId(object) == kApiErrorCid; 766 return Api::ClassId(object) == kApiErrorCid;
755 } 767 }
756 768
757 769
758 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) { 770 DART_EXPORT bool Dart_IsUnhandledExceptionError(Dart_Handle object) {
759 return Api::ClassId(object) == kUnhandledExceptionCid; 771 return Api::ClassId(object) == kUnhandledExceptionCid;
760 } 772 }
761 773
762 774
763 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) { 775 DART_EXPORT bool Dart_IsCompilationError(Dart_Handle object) {
776 if (Dart_IsUnhandledExceptionError(object)) {
777 DARTSCOPE(Thread::Current());
778 const UnhandledException& error =
779 UnhandledException::Cast(Object::Handle(Z, Api::UnwrapHandle(object)));
780 const Instance& exc = Instance::Handle(Z, error.exception());
781 return IsSyntaxErrorObject(Z, exc);
782 }
764 return Api::ClassId(object) == kLanguageErrorCid; 783 return Api::ClassId(object) == kLanguageErrorCid;
765 } 784 }
766 785
767 786
768 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) { 787 DART_EXPORT bool Dart_IsFatalError(Dart_Handle object) {
769 return Api::ClassId(object) == kUnwindErrorCid; 788 return Api::ClassId(object) == kUnwindErrorCid;
770 } 789 }
771 790
772 791
773 DART_EXPORT bool Dart_IsVMRestartRequest(Dart_Handle handle) { 792 DART_EXPORT bool Dart_IsVMRestartRequest(Dart_Handle handle) {
(...skipping 5810 matching lines...) Expand 10 before | Expand all | Expand 10 after
6584 6603
6585 DART_EXPORT bool Dart_IsPrecompiledRuntime() { 6604 DART_EXPORT bool Dart_IsPrecompiledRuntime() {
6586 #if defined(DART_PRECOMPILED_RUNTIME) 6605 #if defined(DART_PRECOMPILED_RUNTIME)
6587 return true; 6606 return true;
6588 #else 6607 #else
6589 return false; 6608 return false;
6590 #endif 6609 #endif
6591 } 6610 }
6592 6611
6593 } // namespace dart 6612 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698