OLD | NEW |
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_tools_api.h" | 5 #include "include/dart_tools_api.h" |
6 | 6 |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 ASSERT(isolate != NULL); | 115 ASSERT(isolate != NULL); |
116 Dart_EnterScope(); | 116 Dart_EnterScope(); |
117 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); | 117 Dart_IsolateId isolate_id = isolate->debugger()->GetIsolateId(); |
118 if (event->type() == DebuggerEvent::kBreakpointReached) { | 118 if (event->type() == DebuggerEvent::kBreakpointReached) { |
119 if (paused_event_handler != NULL) { | 119 if (paused_event_handler != NULL) { |
120 Dart_CodeLocation location; | 120 Dart_CodeLocation location; |
121 ActivationFrame* top_frame = event->top_frame(); | 121 ActivationFrame* top_frame = event->top_frame(); |
122 location.script_url = Api::NewHandle(thread, top_frame->SourceUrl()); | 122 location.script_url = Api::NewHandle(thread, top_frame->SourceUrl()); |
123 const Library& lib = Library::Handle(top_frame->Library()); | 123 const Library& lib = Library::Handle(top_frame->Library()); |
124 location.library_id = lib.index(); | 124 location.library_id = lib.index(); |
125 location.token_pos = top_frame->TokenPos(); | 125 location.token_pos = top_frame->TokenPos().Pos(); |
126 intptr_t bp_id = 0; | 126 intptr_t bp_id = 0; |
127 if (event->breakpoint() != NULL) { | 127 if (event->breakpoint() != NULL) { |
128 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); | 128 ASSERT(event->breakpoint()->id() != ILLEGAL_BREAKPOINT_ID); |
129 bp_id = event->breakpoint()->id(); | 129 bp_id = event->breakpoint()->id(); |
130 } | 130 } |
131 (*paused_event_handler)(isolate_id, bp_id, location); | 131 (*paused_event_handler)(isolate_id, bp_id, location); |
132 } | 132 } |
133 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { | 133 } else if (event->type() == DebuggerEvent::kBreakpointResolved) { |
134 if (bp_resolved_handler != NULL) { | 134 if (bp_resolved_handler != NULL) { |
135 Breakpoint* bpt = event->breakpoint(); | 135 Breakpoint* bpt = event->breakpoint(); |
136 ASSERT(bpt != NULL); | 136 ASSERT(bpt != NULL); |
137 Dart_CodeLocation location; | 137 Dart_CodeLocation location; |
138 Zone* zone = thread->zone(); | 138 Zone* zone = thread->zone(); |
139 Library& library = Library::Handle(zone); | 139 Library& library = Library::Handle(zone); |
140 Script& script = Script::Handle(zone); | 140 Script& script = Script::Handle(zone); |
141 intptr_t token_pos; | 141 TokenPosition token_pos; |
142 bpt->bpt_location()->GetCodeLocation(&library, &script, &token_pos); | 142 bpt->bpt_location()->GetCodeLocation(&library, &script, &token_pos); |
143 location.script_url = Api::NewHandle(thread, script.url()); | 143 location.script_url = Api::NewHandle(thread, script.url()); |
144 location.library_id = library.index(); | 144 location.library_id = library.index(); |
145 location.token_pos = token_pos; | 145 location.token_pos = token_pos.Pos(); |
146 (*bp_resolved_handler)(isolate_id, bpt->id(), location); | 146 (*bp_resolved_handler)(isolate_id, bpt->id(), location); |
147 } | 147 } |
148 } else if (event->type() == DebuggerEvent::kExceptionThrown) { | 148 } else if (event->type() == DebuggerEvent::kExceptionThrown) { |
149 if (exc_thrown_handler != NULL) { | 149 if (exc_thrown_handler != NULL) { |
150 Dart_Handle exception = | 150 Dart_Handle exception = |
151 Api::NewHandle(thread, event->exception()->raw()); | 151 Api::NewHandle(thread, event->exception()->raw()); |
152 Dart_StackTrace trace = | 152 Dart_StackTrace trace = |
153 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); | 153 reinterpret_cast<Dart_StackTrace>(isolate->debugger()->StackTrace()); |
154 (*exc_thrown_handler)(isolate_id, exception, trace); | 154 (*exc_thrown_handler)(isolate_id, exception, trace); |
155 } | 155 } |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 *function_name = Api::NewHandle(T, frame->QualifiedFunctionName()); | 285 *function_name = Api::NewHandle(T, frame->QualifiedFunctionName()); |
286 } | 286 } |
287 if (function != NULL) { | 287 if (function != NULL) { |
288 *function = Api::NewHandle(T, frame->function().raw()); | 288 *function = Api::NewHandle(T, frame->function().raw()); |
289 } | 289 } |
290 | 290 |
291 if (location != NULL) { | 291 if (location != NULL) { |
292 location->script_url = Api::NewHandle(T, frame->SourceUrl()); | 292 location->script_url = Api::NewHandle(T, frame->SourceUrl()); |
293 const Library& lib = Library::Handle(Z, frame->Library()); | 293 const Library& lib = Library::Handle(Z, frame->Library()); |
294 location->library_id = lib.index(); | 294 location->library_id = lib.index(); |
295 location->token_pos = frame->TokenPos(); | 295 location->token_pos = frame->TokenPos().Pos(); |
296 } | 296 } |
297 return Api::Success(); | 297 return Api::Success(); |
298 } | 298 } |
299 | 299 |
300 DART_EXPORT Dart_Handle Dart_ActivationFrameGetFramePointer( | 300 DART_EXPORT Dart_Handle Dart_ActivationFrameGetFramePointer( |
301 Dart_ActivationFrame activation_frame, | 301 Dart_ActivationFrame activation_frame, |
302 uintptr_t* frame_pointer) { | 302 uintptr_t* frame_pointer) { |
303 DARTSCOPE(Thread::Current()); | 303 DARTSCOPE(Thread::Current()); |
304 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 304 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
305 | 305 |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 super_type_args_array = TypeArguments::New(num_expected_type_arguments); | 645 super_type_args_array = TypeArguments::New(num_expected_type_arguments); |
646 AbstractType& type_arg = AbstractType::Handle(); | 646 AbstractType& type_arg = AbstractType::Handle(); |
647 for (intptr_t i = 0; i < num_expected_type_arguments; i++) { | 647 for (intptr_t i = 0; i < num_expected_type_arguments; i++) { |
648 type_arg ^= type_args_array.TypeAt(i); | 648 type_arg ^= type_args_array.TypeAt(i); |
649 super_type_args_array.SetTypeAt(i, type_arg); | 649 super_type_args_array.SetTypeAt(i, type_arg); |
650 } | 650 } |
651 } | 651 } |
652 | 652 |
653 // Construct the super type object, canonicalize it and return. | 653 // Construct the super type object, canonicalize it and return. |
654 Type& instantiated_type = Type::Handle( | 654 Type& instantiated_type = Type::Handle( |
655 Type::New(super_cls, super_type_args_array, Token::kNoSourcePos)); | 655 Type::New(super_cls, super_type_args_array, TokenPosition::kNoSource)); |
656 ASSERT(!instantiated_type.IsNull()); | 656 ASSERT(!instantiated_type.IsNull()); |
657 instantiated_type.SetIsFinalized(); | 657 instantiated_type.SetIsFinalized(); |
658 return Api::NewHandle(T, instantiated_type.Canonicalize()); | 658 return Api::NewHandle(T, instantiated_type.Canonicalize()); |
659 } | 659 } |
660 | 660 |
661 | 661 |
662 DART_EXPORT Dart_Handle Dart_GetClosureInfo( | 662 DART_EXPORT Dart_Handle Dart_GetClosureInfo( |
663 Dart_Handle closure, | 663 Dart_Handle closure, |
664 Dart_Handle* name, | 664 Dart_Handle* name, |
665 Dart_Handle* signature, | 665 Dart_Handle* signature, |
666 Dart_CodeLocation* location) { | 666 Dart_CodeLocation* location) { |
667 DARTSCOPE(Thread::Current()); | 667 DARTSCOPE(Thread::Current()); |
668 UNWRAP_AND_CHECK_PARAM(Instance, instance, closure); | 668 UNWRAP_AND_CHECK_PARAM(Instance, instance, closure); |
669 CHECK_NOT_NULL(location); | 669 CHECK_NOT_NULL(location); |
670 | 670 |
671 if (!instance.IsClosure()) { | 671 if (!instance.IsClosure()) { |
672 return Api::NewError("%s: parameter 0 is not a closure", CURRENT_FUNC); | 672 return Api::NewError("%s: parameter 0 is not a closure", CURRENT_FUNC); |
673 } | 673 } |
674 const Function& func = Function::Handle(Closure::Cast(instance).function()); | 674 const Function& func = Function::Handle(Closure::Cast(instance).function()); |
675 ASSERT(!func.IsNull()); | 675 ASSERT(!func.IsNull()); |
676 if (name != NULL) { | 676 if (name != NULL) { |
677 *name = Api::NewHandle(T, func.QualifiedUserVisibleName()); | 677 *name = Api::NewHandle(T, func.QualifiedUserVisibleName()); |
678 } | 678 } |
679 if (signature != NULL) { | 679 if (signature != NULL) { |
680 *signature = Api::NewHandle(T, func.UserVisibleSignature()); | 680 *signature = Api::NewHandle(T, func.UserVisibleSignature()); |
681 } | 681 } |
682 | 682 |
683 if (location != NULL) { | 683 if (location != NULL) { |
684 if (func.token_pos() >= 0) { | 684 if (func.token_pos().IsReal()) { |
685 const Class& cls = Class::Handle(Z, func.origin()); | 685 const Class& cls = Class::Handle(Z, func.origin()); |
686 ASSERT(!cls.IsNull()); | 686 ASSERT(!cls.IsNull()); |
687 const Library& lib = Library::Handle(Z, cls.library()); | 687 const Library& lib = Library::Handle(Z, cls.library()); |
688 ASSERT(!lib.IsNull()); | 688 ASSERT(!lib.IsNull()); |
689 // Note func.script() is not the same as cls.script() for eval functions. | 689 // Note func.script() is not the same as cls.script() for eval functions. |
690 const Script& script = Script::Handle(Z, func.script()); | 690 const Script& script = Script::Handle(Z, func.script()); |
691 ASSERT(!script.IsNull()); | 691 ASSERT(!script.IsNull()); |
692 location->script_url = Api::NewHandle(T, script.url()); | 692 location->script_url = Api::NewHandle(T, script.url()); |
693 location->library_id = lib.index(); | 693 location->library_id = lib.index(); |
694 location->token_pos = func.token_pos(); | 694 location->token_pos = func.token_pos().Pos(); |
695 } else { | 695 } else { |
696 location->script_url = Api::NewHandle(T, String::null()); | 696 location->script_url = Api::NewHandle(T, String::null()); |
697 location->library_id = -1; | 697 location->library_id = -1; |
698 location->token_pos = -1; | 698 location->token_pos = -1; |
699 } | 699 } |
700 } | 700 } |
701 return Api::True(); | 701 return Api::True(); |
702 } | 702 } |
703 | 703 |
704 | 704 |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
954 return Api::CastIsolate(isolate); | 954 return Api::CastIsolate(isolate); |
955 } | 955 } |
956 | 956 |
957 | 957 |
958 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 958 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
959 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 959 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
960 return isolate->debugger()->GetIsolateId(); | 960 return isolate->debugger()->GetIsolateId(); |
961 } | 961 } |
962 | 962 |
963 } // namespace dart | 963 } // namespace dart |
OLD | NEW |