| 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_debugger_api.h" | 5 #include "include/dart_debugger_api.h" |
| 6 | 6 |
| 7 #include "vm/dart_api_impl.h" | 7 #include "vm/dart_api_impl.h" |
| 8 #include "vm/dart_api_state.h" | 8 #include "vm/dart_api_state.h" |
| 9 #include "vm/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 | 44 |
| 45 | 45 |
| 46 DART_EXPORT Dart_Handle Dart_StackTraceLength( | 46 DART_EXPORT Dart_Handle Dart_StackTraceLength( |
| 47 Dart_StackTrace trace, | 47 Dart_StackTrace trace, |
| 48 intptr_t* length) { | 48 intptr_t* length) { |
| 49 Isolate* isolate = Isolate::Current(); | 49 Isolate* isolate = Isolate::Current(); |
| 50 DARTSCOPE(isolate); | 50 DARTSCOPE(isolate); |
| 51 CHECK_NOT_NULL(length); | 51 CHECK_NOT_NULL(length); |
| 52 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 52 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
| 53 *length = stack_trace->Length(); | 53 *length = stack_trace->Length(); |
| 54 return Api::True(); | 54 return Api::True(isolate); |
| 55 } | 55 } |
| 56 | 56 |
| 57 | 57 |
| 58 DART_EXPORT Dart_Handle Dart_GetActivationFrame( | 58 DART_EXPORT Dart_Handle Dart_GetActivationFrame( |
| 59 Dart_StackTrace trace, | 59 Dart_StackTrace trace, |
| 60 int frame_index, | 60 int frame_index, |
| 61 Dart_ActivationFrame* frame) { | 61 Dart_ActivationFrame* frame) { |
| 62 Isolate* isolate = Isolate::Current(); | 62 Isolate* isolate = Isolate::Current(); |
| 63 DARTSCOPE(isolate); | 63 DARTSCOPE(isolate); |
| 64 CHECK_NOT_NULL(frame); | 64 CHECK_NOT_NULL(frame); |
| 65 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 65 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
| 66 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { | 66 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { |
| 67 return Api::NewError("argument 'frame_index' is out of range for %s", | 67 return Api::NewError("argument 'frame_index' is out of range for %s", |
| 68 CURRENT_FUNC); | 68 CURRENT_FUNC); |
| 69 } | 69 } |
| 70 *frame = reinterpret_cast<Dart_ActivationFrame>( | 70 *frame = reinterpret_cast<Dart_ActivationFrame>( |
| 71 stack_trace->ActivationFrameAt(frame_index)); | 71 stack_trace->ActivationFrameAt(frame_index)); |
| 72 return Api::True(); | 72 return Api::True(isolate); |
| 73 } | 73 } |
| 74 | 74 |
| 75 | 75 |
| 76 DART_EXPORT void Dart_SetBreakpointHandler( | 76 DART_EXPORT void Dart_SetBreakpointHandler( |
| 77 Dart_BreakpointHandler bp_handler) { | 77 Dart_BreakpointHandler bp_handler) { |
| 78 Isolate* isolate = Isolate::Current(); | 78 Isolate* isolate = Isolate::Current(); |
| 79 DARTSCOPE(isolate); | 79 DARTSCOPE(isolate); |
| 80 BreakpointHandler* handler = | 80 BreakpointHandler* handler = |
| 81 reinterpret_cast<BreakpointHandler*>(bp_handler); | 81 reinterpret_cast<BreakpointHandler*>(bp_handler); |
| 82 | 82 |
| 83 isolate->debugger()->SetBreakpointHandler(handler); | 83 isolate->debugger()->SetBreakpointHandler(handler); |
| 84 } | 84 } |
| 85 | 85 |
| 86 | 86 |
| 87 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( | 87 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( |
| 88 Dart_ActivationFrame activation_frame, | 88 Dart_ActivationFrame activation_frame, |
| 89 Dart_Handle* function_name, | 89 Dart_Handle* function_name, |
| 90 Dart_Handle* script_url, | 90 Dart_Handle* script_url, |
| 91 intptr_t* line_number) { | 91 intptr_t* line_number) { |
| 92 Isolate* isolate = Isolate::Current(); | 92 Isolate* isolate = Isolate::Current(); |
| 93 DARTSCOPE(isolate); | 93 DARTSCOPE(isolate); |
| 94 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 94 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 95 if (function_name != NULL) { | 95 if (function_name != NULL) { |
| 96 const String& name = String::Handle(frame->QualifiedFunctionName()); | 96 const String& name = String::Handle(frame->QualifiedFunctionName()); |
| 97 *function_name = Api::NewLocalHandle(name); | 97 *function_name = Api::NewLocalHandle(isolate, name); |
| 98 } | 98 } |
| 99 if (script_url != NULL) { | 99 if (script_url != NULL) { |
| 100 const String& url = String::Handle(frame->SourceUrl()); | 100 const String& url = String::Handle(frame->SourceUrl()); |
| 101 *script_url = Api::NewLocalHandle(url); | 101 *script_url = Api::NewLocalHandle(isolate, url); |
| 102 } | 102 } |
| 103 if (line_number != NULL) { | 103 if (line_number != NULL) { |
| 104 *line_number = frame->LineNumber(); | 104 *line_number = frame->LineNumber(); |
| 105 } | 105 } |
| 106 return Api::True(); | 106 return Api::True(isolate); |
| 107 } | 107 } |
| 108 | 108 |
| 109 | 109 |
| 110 DART_EXPORT Dart_Handle Dart_GetLocalVariables( | 110 DART_EXPORT Dart_Handle Dart_GetLocalVariables( |
| 111 Dart_ActivationFrame activation_frame) { | 111 Dart_ActivationFrame activation_frame) { |
| 112 Isolate* isolate = Isolate::Current(); | 112 Isolate* isolate = Isolate::Current(); |
| 113 DARTSCOPE(isolate); | 113 DARTSCOPE(isolate); |
| 114 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 114 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 115 const Array& variables = Array::Handle(frame->GetLocalVariables()); | 115 const Array& variables = Array::Handle(frame->GetLocalVariables()); |
| 116 return Api::NewLocalHandle(variables); | 116 return Api::NewLocalHandle(isolate, variables); |
| 117 } | 117 } |
| 118 | 118 |
| 119 | 119 |
| 120 DART_EXPORT Dart_Handle Dart_SetBreakpointAtLine( | 120 DART_EXPORT Dart_Handle Dart_SetBreakpointAtLine( |
| 121 Dart_Handle script_url_in, | 121 Dart_Handle script_url_in, |
| 122 Dart_Handle line_number_in, | 122 Dart_Handle line_number_in, |
| 123 Dart_Breakpoint* breakpoint) { | 123 Dart_Breakpoint* breakpoint) { |
| 124 Isolate* isolate = Isolate::Current(); | 124 Isolate* isolate = Isolate::Current(); |
| 125 DARTSCOPE(isolate); | 125 DARTSCOPE(isolate); |
| 126 | 126 |
| 127 String& script_url = String::Handle(); | 127 String& script_url = String::Handle(); |
| 128 Integer& line_number = Integer::Handle(); | 128 Integer& line_number = Integer::Handle(); |
| 129 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 129 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 130 UNWRAP_AND_CHECK_PARAM(Integer, line_number, line_number_in); | 130 UNWRAP_AND_CHECK_PARAM(Integer, line_number, line_number_in); |
| 131 CHECK_NOT_NULL(breakpoint); | 131 CHECK_NOT_NULL(breakpoint); |
| 132 | 132 |
| 133 if (!line_number.IsSmi()) { | 133 if (!line_number.IsSmi()) { |
| 134 return Api::NewError("%s: line number out of range", CURRENT_FUNC); | 134 return Api::NewError("%s: line number out of range", CURRENT_FUNC); |
| 135 } | 135 } |
| 136 intptr_t line = line_number.AsInt64Value(); | 136 intptr_t line = line_number.AsInt64Value(); |
| 137 | 137 |
| 138 const char* msg = CheckIsolateState(isolate); | 138 const char* msg = CheckIsolateState(isolate); |
| 139 if (msg != NULL) { | 139 if (msg != NULL) { |
| 140 return Api::NewError(msg); | 140 return Api::NewError(msg); |
| 141 } | 141 } |
| 142 | 142 |
| 143 Dart_Handle result = Api::True(); | 143 Dart_Handle result = Api::True(isolate); |
| 144 *breakpoint = NULL; | 144 *breakpoint = NULL; |
| 145 Debugger* debugger = isolate->debugger(); | 145 Debugger* debugger = isolate->debugger(); |
| 146 ASSERT(debugger != NULL); | 146 ASSERT(debugger != NULL); |
| 147 SourceBreakpoint* bpt = | 147 SourceBreakpoint* bpt = |
| 148 debugger->SetBreakpointAtLine(script_url, line); | 148 debugger->SetBreakpointAtLine(script_url, line); |
| 149 if (bpt == NULL) { | 149 if (bpt == NULL) { |
| 150 result = Api::NewError("%s: could not set breakpoint at line %d of '%s'", | 150 result = Api::NewError("%s: could not set breakpoint at line %d of '%s'", |
| 151 CURRENT_FUNC, line, script_url.ToCString()); | 151 CURRENT_FUNC, line, script_url.ToCString()); |
| 152 } else { | 152 } else { |
| 153 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); | 153 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 183 debugger->ResolveFunction(library, class_name, function_name)); | 183 debugger->ResolveFunction(library, class_name, function_name)); |
| 184 if (bp_target.IsNull()) { | 184 if (bp_target.IsNull()) { |
| 185 const bool toplevel = class_name.Length() == 0; | 185 const bool toplevel = class_name.Length() == 0; |
| 186 return Api::NewError("%s: could not find function '%s%s%s'", | 186 return Api::NewError("%s: could not find function '%s%s%s'", |
| 187 CURRENT_FUNC, | 187 CURRENT_FUNC, |
| 188 toplevel ? "" : class_name.ToCString(), | 188 toplevel ? "" : class_name.ToCString(), |
| 189 toplevel ? "" : ".", | 189 toplevel ? "" : ".", |
| 190 function_name.ToCString()); | 190 function_name.ToCString()); |
| 191 } | 191 } |
| 192 | 192 |
| 193 Dart_Handle result = Api::True(); | 193 Dart_Handle result = Api::True(isolate); |
| 194 *breakpoint = NULL; | 194 *breakpoint = NULL; |
| 195 | 195 |
| 196 SourceBreakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target); | 196 SourceBreakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target); |
| 197 if (bpt == NULL) { | 197 if (bpt == NULL) { |
| 198 const char* target_name = Debugger::QualifiedFunctionName(bp_target); | 198 const char* target_name = Debugger::QualifiedFunctionName(bp_target); |
| 199 result = Api::NewError("%s: no breakpoint location found in '%s'", | 199 result = Api::NewError("%s: no breakpoint location found in '%s'", |
| 200 CURRENT_FUNC, target_name); | 200 CURRENT_FUNC, target_name); |
| 201 } else { | 201 } else { |
| 202 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); | 202 *breakpoint = reinterpret_cast<Dart_Breakpoint>(bpt); |
| 203 } | 203 } |
| 204 return result; | 204 return result; |
| 205 } | 205 } |
| 206 | 206 |
| 207 | 207 |
| 208 DART_EXPORT Dart_Handle Dart_DeleteBreakpoint( | 208 DART_EXPORT Dart_Handle Dart_DeleteBreakpoint( |
| 209 Dart_Breakpoint breakpoint_in) { | 209 Dart_Breakpoint breakpoint_in) { |
| 210 Isolate* isolate = Isolate::Current(); | 210 Isolate* isolate = Isolate::Current(); |
| 211 DARTSCOPE(isolate); | 211 DARTSCOPE(isolate); |
| 212 | 212 |
| 213 CHECK_AND_CAST(SourceBreakpoint, breakpoint, breakpoint_in); | 213 CHECK_AND_CAST(SourceBreakpoint, breakpoint, breakpoint_in); |
| 214 isolate->debugger()->RemoveBreakpoint(breakpoint); | 214 isolate->debugger()->RemoveBreakpoint(breakpoint); |
| 215 return Api::True(); | 215 return Api::True(isolate); |
| 216 } | 216 } |
| 217 | 217 |
| 218 | 218 |
| 219 DART_EXPORT Dart_Handle Dart_SetStepOver() { | 219 DART_EXPORT Dart_Handle Dart_SetStepOver() { |
| 220 Isolate* isolate = Isolate::Current(); | 220 Isolate* isolate = Isolate::Current(); |
| 221 DARTSCOPE(isolate); | 221 DARTSCOPE(isolate); |
| 222 isolate->debugger()->SetStepOver(); | 222 isolate->debugger()->SetStepOver(); |
| 223 return Api::True(); | 223 return Api::True(isolate); |
| 224 } | 224 } |
| 225 | 225 |
| 226 | 226 |
| 227 DART_EXPORT Dart_Handle Dart_SetStepInto() { | 227 DART_EXPORT Dart_Handle Dart_SetStepInto() { |
| 228 Isolate* isolate = Isolate::Current(); | 228 Isolate* isolate = Isolate::Current(); |
| 229 DARTSCOPE(isolate); | 229 DARTSCOPE(isolate); |
| 230 isolate->debugger()->SetStepInto(); | 230 isolate->debugger()->SetStepInto(); |
| 231 return Api::True(); | 231 return Api::True(isolate); |
| 232 } | 232 } |
| 233 | 233 |
| 234 | 234 |
| 235 DART_EXPORT Dart_Handle Dart_SetStepOut() { | 235 DART_EXPORT Dart_Handle Dart_SetStepOut() { |
| 236 Isolate* isolate = Isolate::Current(); | 236 Isolate* isolate = Isolate::Current(); |
| 237 DARTSCOPE(isolate); | 237 DARTSCOPE(isolate); |
| 238 isolate->debugger()->SetStepOut(); | 238 isolate->debugger()->SetStepOut(); |
| 239 return Api::True(); | 239 return Api::True(isolate); |
| 240 } | 240 } |
| 241 | 241 |
| 242 | 242 |
| 243 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { | 243 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { |
| 244 Isolate* isolate = Isolate::Current(); | 244 Isolate* isolate = Isolate::Current(); |
| 245 DARTSCOPE(isolate); | 245 DARTSCOPE(isolate); |
| 246 Instance& obj = Instance::Handle(); | 246 Instance& obj = Instance::Handle(); |
| 247 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 247 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 248 Array& fields = Array::Handle(); | 248 Array& fields = Array::Handle(); |
| 249 fields = isolate->debugger()->GetInstanceFields(obj); | 249 fields = isolate->debugger()->GetInstanceFields(obj); |
| 250 return Api::NewLocalHandle(fields); | 250 return Api::NewLocalHandle(isolate, fields); |
| 251 } | 251 } |
| 252 | 252 |
| 253 | 253 |
| 254 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle cls_in) { | 254 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle cls_in) { |
| 255 Isolate* isolate = Isolate::Current(); | 255 Isolate* isolate = Isolate::Current(); |
| 256 DARTSCOPE(isolate); | 256 DARTSCOPE(isolate); |
| 257 Class& cls = Class::Handle(); | 257 Class& cls = Class::Handle(); |
| 258 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); | 258 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); |
| 259 Array& fields = Array::Handle(); | 259 Array& fields = Array::Handle(); |
| 260 fields = isolate->debugger()->GetStaticFields(cls); | 260 fields = isolate->debugger()->GetStaticFields(cls); |
| 261 return Api::NewLocalHandle(fields); | 261 return Api::NewLocalHandle(isolate, fields); |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { | 265 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { |
| 266 Isolate* isolate = Isolate::Current(); | 266 Isolate* isolate = Isolate::Current(); |
| 267 DARTSCOPE(isolate); | 267 DARTSCOPE(isolate); |
| 268 Instance& obj = Instance::Handle(); | 268 Instance& obj = Instance::Handle(); |
| 269 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 269 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 270 const Class& cls = Class::Handle(obj.clazz()); | 270 const Class& cls = Class::Handle(obj.clazz()); |
| 271 return Api::NewLocalHandle(cls); | 271 return Api::NewLocalHandle(isolate, cls); |
| 272 } | 272 } |
| 273 | 273 |
| 274 | 274 |
| 275 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { | 275 DART_EXPORT Dart_Handle Dart_GetSuperclass(Dart_Handle cls_in) { |
| 276 Isolate* isolate = Isolate::Current(); | 276 Isolate* isolate = Isolate::Current(); |
| 277 DARTSCOPE(isolate); | 277 DARTSCOPE(isolate); |
| 278 Class& cls = Class::Handle(); | 278 Class& cls = Class::Handle(); |
| 279 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); | 279 UNWRAP_AND_CHECK_PARAM(Class, cls, cls_in); |
| 280 cls = cls.SuperClass(); | 280 cls = cls.SuperClass(); |
| 281 return Api::NewLocalHandle(cls); | 281 return Api::NewLocalHandle(isolate, cls); |
| 282 } | 282 } |
| 283 | 283 |
| 284 | 284 |
| 285 DART_EXPORT Dart_Handle Dart_GetScriptSource( | 285 DART_EXPORT Dart_Handle Dart_GetScriptSource( |
| 286 Dart_Handle library_url_in, | 286 Dart_Handle library_url_in, |
| 287 Dart_Handle script_url_in) { | 287 Dart_Handle script_url_in) { |
| 288 Isolate* isolate = Isolate::Current(); | 288 Isolate* isolate = Isolate::Current(); |
| 289 DARTSCOPE(isolate); | 289 DARTSCOPE(isolate); |
| 290 String& library_url = String::Handle(); | 290 String& library_url = String::Handle(); |
| 291 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 291 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
| 292 String& script_url = String::Handle(); | 292 String& script_url = String::Handle(); |
| 293 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 293 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 294 | 294 |
| 295 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); | 295 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); |
| 296 if (library.IsNull()) { | 296 if (library.IsNull()) { |
| 297 return Api::NewError("%s: library '%s' not found", | 297 return Api::NewError("%s: library '%s' not found", |
| 298 CURRENT_FUNC, library_url.ToCString()); | 298 CURRENT_FUNC, library_url.ToCString()); |
| 299 } | 299 } |
| 300 | 300 |
| 301 const Script& script = Script::Handle(library.LookupScript(script_url)); | 301 const Script& script = Script::Handle(library.LookupScript(script_url)); |
| 302 if (script.IsNull()) { | 302 if (script.IsNull()) { |
| 303 return Api::NewError("%s: script '%s' not found in library '%s'", | 303 return Api::NewError("%s: script '%s' not found in library '%s'", |
| 304 CURRENT_FUNC, script_url.ToCString(), | 304 CURRENT_FUNC, script_url.ToCString(), |
| 305 library_url.ToCString()); | 305 library_url.ToCString()); |
| 306 } | 306 } |
| 307 | 307 |
| 308 const String& source = String::Handle(script.source()); | 308 const String& source = String::Handle(script.source()); |
| 309 return Api::NewLocalHandle(source); | 309 return Api::NewLocalHandle(isolate, source); |
| 310 } | 310 } |
| 311 | 311 |
| 312 | 312 |
| 313 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) { | 313 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) { |
| 314 Isolate* isolate = Isolate::Current(); | 314 Isolate* isolate = Isolate::Current(); |
| 315 DARTSCOPE(isolate); | 315 DARTSCOPE(isolate); |
| 316 String& library_url = String::Handle(); | 316 String& library_url = String::Handle(); |
| 317 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 317 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
| 318 | 318 |
| 319 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); | 319 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); |
| 320 if (library.IsNull()) { | 320 if (library.IsNull()) { |
| 321 return Api::NewError("%s: library '%s' not found", | 321 return Api::NewError("%s: library '%s' not found", |
| 322 CURRENT_FUNC, library_url.ToCString()); | 322 CURRENT_FUNC, library_url.ToCString()); |
| 323 } | 323 } |
| 324 const Array& loaded_scripts = Array::Handle(library.LoadedScripts()); | 324 const Array& loaded_scripts = Array::Handle(library.LoadedScripts()); |
| 325 ASSERT(!loaded_scripts.IsNull()); | 325 ASSERT(!loaded_scripts.IsNull()); |
| 326 intptr_t num_scripts = loaded_scripts.Length(); | 326 intptr_t num_scripts = loaded_scripts.Length(); |
| 327 const Array& script_list = Array::Handle(Array::New(num_scripts)); | 327 const Array& script_list = Array::Handle(Array::New(num_scripts)); |
| 328 Script& script = Script::Handle(); | 328 Script& script = Script::Handle(); |
| 329 String& url = String::Handle(); | 329 String& url = String::Handle(); |
| 330 for (int i = 0; i < num_scripts; i++) { | 330 for (int i = 0; i < num_scripts; i++) { |
| 331 script ^= loaded_scripts.At(i); | 331 script ^= loaded_scripts.At(i); |
| 332 url = script.url(); | 332 url = script.url(); |
| 333 script_list.SetAt(i, url); | 333 script_list.SetAt(i, url); |
| 334 } | 334 } |
| 335 return Api::NewLocalHandle(script_list); | 335 return Api::NewLocalHandle(isolate, script_list); |
| 336 } | 336 } |
| 337 | 337 |
| 338 | 338 |
| 339 DART_EXPORT Dart_Handle Dart_GetLibraryURLs() { | 339 DART_EXPORT Dart_Handle Dart_GetLibraryURLs() { |
| 340 Isolate* isolate = Isolate::Current(); | 340 Isolate* isolate = Isolate::Current(); |
| 341 ASSERT(isolate != NULL); | 341 ASSERT(isolate != NULL); |
| 342 DARTSCOPE(isolate); | 342 DARTSCOPE(isolate); |
| 343 | 343 |
| 344 // Find out how many libraries are loaded in this isolate. | 344 // Find out how many libraries are loaded in this isolate. |
| 345 int num_libs = 0; | 345 int num_libs = 0; |
| 346 Library &lib = Library::Handle(); | 346 Library &lib = Library::Handle(); |
| 347 lib = isolate->object_store()->registered_libraries(); | 347 lib = isolate->object_store()->registered_libraries(); |
| 348 while (!lib.IsNull()) { | 348 while (!lib.IsNull()) { |
| 349 num_libs++; | 349 num_libs++; |
| 350 lib = lib.next_registered(); | 350 lib = lib.next_registered(); |
| 351 } | 351 } |
| 352 | 352 |
| 353 // Create new list and populate with the url of loaded libraries. | 353 // Create new list and populate with the url of loaded libraries. |
| 354 const Array& library_list = Array::Handle(Array::New(num_libs)); | 354 const Array& library_list = Array::Handle(Array::New(num_libs)); |
| 355 lib = isolate->object_store()->registered_libraries(); | 355 lib = isolate->object_store()->registered_libraries(); |
| 356 String& lib_url = String::Handle(); | 356 String& lib_url = String::Handle(); |
| 357 for (int i = 0; i < num_libs; i++) { | 357 for (int i = 0; i < num_libs; i++) { |
| 358 ASSERT(!lib.IsNull()); | 358 ASSERT(!lib.IsNull()); |
| 359 lib_url = lib.url(); | 359 lib_url = lib.url(); |
| 360 library_list.SetAt(i, lib_url); | 360 library_list.SetAt(i, lib_url); |
| 361 lib = lib.next_registered(); | 361 lib = lib.next_registered(); |
| 362 } | 362 } |
| 363 return Api::NewLocalHandle(library_list); | 363 return Api::NewLocalHandle(isolate, library_list); |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace dart | 366 } // namespace dart |
| OLD | NEW |