| 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" |
| 11 #include "vm/debugger.h" | 11 #include "vm/debugger.h" |
| 12 #include "vm/isolate.h" | 12 #include "vm/isolate.h" |
| 13 #include "vm/object_store.h" | 13 #include "vm/object_store.h" |
| 14 #include "vm/symbols.h" | 14 #include "vm/symbols.h" |
| 15 | 15 |
| 16 namespace dart { | 16 namespace dart { |
| 17 | 17 |
| 18 // Facilitate quick access to the current zone once we have the curren thread. |
| 19 #define Z (T->zone()) |
| 20 |
| 21 |
| 18 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \ | 22 #define UNWRAP_AND_CHECK_PARAM(type, var, param) \ |
| 19 type& var = type::Handle(); \ | 23 type& var = type::Handle(); \ |
| 20 do { \ | 24 do { \ |
| 21 const Object& tmp = Object::Handle(Api::UnwrapHandle(param)); \ | 25 const Object& tmp = Object::Handle(Api::UnwrapHandle(param)); \ |
| 22 if (tmp.IsNull()) { \ | 26 if (tmp.IsNull()) { \ |
| 23 return Api::NewError("%s expects argument '%s' to be non-null.", \ | 27 return Api::NewError("%s expects argument '%s' to be non-null.", \ |
| 24 CURRENT_FUNC, #param); \ | 28 CURRENT_FUNC, #param); \ |
| 25 } else if (tmp.IsApiError()) { \ | 29 } else if (tmp.IsApiError()) { \ |
| 26 return param; \ | 30 return param; \ |
| 27 } else if (!tmp.Is##type()) { \ | 31 } else if (!tmp.Is##type()) { \ |
| (...skipping 16 matching lines...) Expand all Loading... |
| 44 | 48 |
| 45 | 49 |
| 46 #define CHECK_NOT_NULL(param) \ | 50 #define CHECK_NOT_NULL(param) \ |
| 47 if (param == NULL) { \ | 51 if (param == NULL) { \ |
| 48 return Api::NewError("%s expects argument '%s' to be non-null.", \ | 52 return Api::NewError("%s expects argument '%s' to be non-null.", \ |
| 49 CURRENT_FUNC, #param); \ | 53 CURRENT_FUNC, #param); \ |
| 50 } | 54 } |
| 51 | 55 |
| 52 | 56 |
| 53 DART_EXPORT intptr_t Dart_CacheObject(Dart_Handle object_in) { | 57 DART_EXPORT intptr_t Dart_CacheObject(Dart_Handle object_in) { |
| 54 Isolate* isolate = Isolate::Current(); | 58 DARTSCOPE(Thread::Current()); |
| 55 DARTSCOPE(isolate); | 59 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(object_in)); |
| 56 const Object& obj = Object::Handle(Api::UnwrapHandle(object_in)); | |
| 57 if (obj.IsApiError()) { | 60 if (obj.IsApiError()) { |
| 58 return -1; | 61 return -1; |
| 59 } | 62 } |
| 60 return isolate->debugger()->CacheObject(obj); | 63 return I->debugger()->CacheObject(obj); |
| 61 } | 64 } |
| 62 | 65 |
| 63 | 66 |
| 64 DART_EXPORT Dart_Handle Dart_GetCachedObject(intptr_t obj_id) { | 67 DART_EXPORT Dart_Handle Dart_GetCachedObject(intptr_t obj_id) { |
| 65 Isolate* isolate = Isolate::Current(); | 68 DARTSCOPE(Thread::Current()); |
| 66 DARTSCOPE(isolate); | 69 if (!I->debugger()->IsValidObjectId(obj_id)) { |
| 67 if (!isolate->debugger()->IsValidObjectId(obj_id)) { | |
| 68 return Api::NewError("%s: object id %" Pd " is invalid", | 70 return Api::NewError("%s: object id %" Pd " is invalid", |
| 69 CURRENT_FUNC, obj_id); | 71 CURRENT_FUNC, obj_id); |
| 70 } | 72 } |
| 71 return Api::NewHandle(isolate, isolate->debugger()->GetCachedObject(obj_id)); | 73 return Api::NewHandle(I, I->debugger()->GetCachedObject(obj_id)); |
| 72 } | 74 } |
| 73 | 75 |
| 74 | 76 |
| 75 DART_EXPORT Dart_Handle Dart_StackTraceLength( | 77 DART_EXPORT Dart_Handle Dart_StackTraceLength( |
| 76 Dart_StackTrace trace, | 78 Dart_StackTrace trace, |
| 77 intptr_t* length) { | 79 intptr_t* length) { |
| 78 Isolate* isolate = Isolate::Current(); | 80 DARTSCOPE(Thread::Current()); |
| 79 DARTSCOPE(isolate); | |
| 80 CHECK_NOT_NULL(length); | 81 CHECK_NOT_NULL(length); |
| 81 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 82 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
| 82 *length = stack_trace->Length(); | 83 *length = stack_trace->Length(); |
| 83 return Api::Success(); | 84 return Api::Success(); |
| 84 } | 85 } |
| 85 | 86 |
| 86 | 87 |
| 87 DART_EXPORT Dart_Handle Dart_GetActivationFrame( | 88 DART_EXPORT Dart_Handle Dart_GetActivationFrame( |
| 88 Dart_StackTrace trace, | 89 Dart_StackTrace trace, |
| 89 int frame_index, | 90 int frame_index, |
| 90 Dart_ActivationFrame* frame) { | 91 Dart_ActivationFrame* frame) { |
| 91 Isolate* isolate = Isolate::Current(); | 92 DARTSCOPE(Thread::Current()); |
| 92 DARTSCOPE(isolate); | |
| 93 CHECK_NOT_NULL(frame); | 93 CHECK_NOT_NULL(frame); |
| 94 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); | 94 CHECK_AND_CAST(DebuggerStackTrace, stack_trace, trace); |
| 95 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { | 95 if ((frame_index < 0) || (frame_index >= stack_trace->Length())) { |
| 96 return Api::NewError("argument 'frame_index' is out of range for %s", | 96 return Api::NewError("argument 'frame_index' is out of range for %s", |
| 97 CURRENT_FUNC); | 97 CURRENT_FUNC); |
| 98 } | 98 } |
| 99 *frame = reinterpret_cast<Dart_ActivationFrame>( | 99 *frame = reinterpret_cast<Dart_ActivationFrame>( |
| 100 stack_trace->FrameAt(frame_index)); | 100 stack_trace->FrameAt(frame_index)); |
| 101 return Api::Success(); | 101 return Api::Success(); |
| 102 } | 102 } |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 | 189 |
| 190 | 190 |
| 191 DART_EXPORT void Dart_SetIsolateEventHandler(Dart_IsolateEventHandler handler) { | 191 DART_EXPORT void Dart_SetIsolateEventHandler(Dart_IsolateEventHandler handler) { |
| 192 isolate_event_handler = handler; | 192 isolate_event_handler = handler; |
| 193 Debugger::SetEventHandler(DebuggerEventHandler); | 193 Debugger::SetEventHandler(DebuggerEventHandler); |
| 194 } | 194 } |
| 195 | 195 |
| 196 | 196 |
| 197 DART_EXPORT Dart_Handle Dart_SetExceptionPauseInfo( | 197 DART_EXPORT Dart_Handle Dart_SetExceptionPauseInfo( |
| 198 Dart_ExceptionPauseInfo pause_info) { | 198 Dart_ExceptionPauseInfo pause_info) { |
| 199 Isolate* isolate = Isolate::Current(); | 199 DARTSCOPE(Thread::Current()); |
| 200 DARTSCOPE(isolate); | 200 I->debugger()->SetExceptionPauseInfo(pause_info); |
| 201 isolate->debugger()->SetExceptionPauseInfo(pause_info); | |
| 202 return Api::Success(); | 201 return Api::Success(); |
| 203 } | 202 } |
| 204 | 203 |
| 205 | 204 |
| 206 DART_EXPORT Dart_ExceptionPauseInfo Dart_GetExceptionPauseInfo() { | 205 DART_EXPORT Dart_ExceptionPauseInfo Dart_GetExceptionPauseInfo() { |
| 207 Isolate* isolate = Isolate::Current(); | 206 DARTSCOPE(Thread::Current()); |
| 208 DARTSCOPE(isolate); | 207 return I->debugger()->GetExceptionPauseInfo(); |
| 209 return isolate->debugger()->GetExceptionPauseInfo(); | |
| 210 } | 208 } |
| 211 | 209 |
| 212 | 210 |
| 213 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) { | 211 DART_EXPORT Dart_Handle Dart_GetStackTrace(Dart_StackTrace* trace) { |
| 214 Isolate* isolate = Isolate::Current(); | 212 DARTSCOPE(Thread::Current()); |
| 215 DARTSCOPE(isolate); | |
| 216 CHECK_NOT_NULL(trace); | 213 CHECK_NOT_NULL(trace); |
| 217 *trace = reinterpret_cast<Dart_StackTrace>( | 214 *trace = reinterpret_cast<Dart_StackTrace>( |
| 218 isolate->debugger()->CurrentStackTrace()); | 215 I->debugger()->CurrentStackTrace()); |
| 219 return Api::Success(); | 216 return Api::Success(); |
| 220 } | 217 } |
| 221 | 218 |
| 222 | 219 |
| 223 DART_EXPORT Dart_Handle Dart_GetStackTraceFromError(Dart_Handle handle, | 220 DART_EXPORT Dart_Handle Dart_GetStackTraceFromError(Dart_Handle handle, |
| 224 Dart_StackTrace* trace) { | 221 Dart_StackTrace* trace) { |
| 225 Isolate* isolate = Isolate::Current(); | 222 DARTSCOPE(Thread::Current()); |
| 226 DARTSCOPE(isolate); | |
| 227 CHECK_NOT_NULL(trace); | 223 CHECK_NOT_NULL(trace); |
| 228 const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(handle)); | 224 const Object& obj = Object::Handle(Z, Api::UnwrapHandle(handle)); |
| 229 if (obj.IsUnhandledException()) { | 225 if (obj.IsUnhandledException()) { |
| 230 const UnhandledException& error = UnhandledException::Cast(obj); | 226 const UnhandledException& error = UnhandledException::Cast(obj); |
| 231 Stacktrace& dart_stacktrace = Stacktrace::Handle(isolate); | 227 Stacktrace& dart_stacktrace = Stacktrace::Handle(Z); |
| 232 dart_stacktrace ^= error.stacktrace(); | 228 dart_stacktrace ^= error.stacktrace(); |
| 233 if (dart_stacktrace.IsNull()) { | 229 if (dart_stacktrace.IsNull()) { |
| 234 *trace = NULL; | 230 *trace = NULL; |
| 235 } else { | 231 } else { |
| 236 *trace = reinterpret_cast<Dart_StackTrace>( | 232 *trace = reinterpret_cast<Dart_StackTrace>( |
| 237 isolate->debugger()->StackTraceFrom(dart_stacktrace)); | 233 I->debugger()->StackTraceFrom(dart_stacktrace)); |
| 238 } | 234 } |
| 239 return Api::Success(); | 235 return Api::Success(); |
| 240 } else { | 236 } else { |
| 241 return Api::NewError("Can only get stacktraces from error handles or " | 237 return Api::NewError("Can only get stacktraces from error handles or " |
| 242 "instances of Error."); | 238 "instances of Error."); |
| 243 } | 239 } |
| 244 } | 240 } |
| 245 | 241 |
| 246 | 242 |
| 247 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( | 243 DART_EXPORT Dart_Handle Dart_ActivationFrameInfo( |
| 248 Dart_ActivationFrame activation_frame, | 244 Dart_ActivationFrame activation_frame, |
| 249 Dart_Handle* function_name, | 245 Dart_Handle* function_name, |
| 250 Dart_Handle* script_url, | 246 Dart_Handle* script_url, |
| 251 intptr_t* line_number, | 247 intptr_t* line_number, |
| 252 intptr_t* column_number) { | 248 intptr_t* column_number) { |
| 253 Isolate* isolate = Isolate::Current(); | 249 DARTSCOPE(Thread::Current()); |
| 254 DARTSCOPE(isolate); | |
| 255 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 250 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 256 if (function_name != NULL) { | 251 if (function_name != NULL) { |
| 257 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); | 252 *function_name = Api::NewHandle(I, frame->QualifiedFunctionName()); |
| 258 } | 253 } |
| 259 if (script_url != NULL) { | 254 if (script_url != NULL) { |
| 260 *script_url = Api::NewHandle(isolate, frame->SourceUrl()); | 255 *script_url = Api::NewHandle(I, frame->SourceUrl()); |
| 261 } | 256 } |
| 262 if (line_number != NULL) { | 257 if (line_number != NULL) { |
| 263 *line_number = frame->LineNumber(); | 258 *line_number = frame->LineNumber(); |
| 264 } | 259 } |
| 265 if (column_number != NULL) { | 260 if (column_number != NULL) { |
| 266 *column_number = frame->ColumnNumber(); | 261 *column_number = frame->ColumnNumber(); |
| 267 } | 262 } |
| 268 return Api::Success(); | 263 return Api::Success(); |
| 269 } | 264 } |
| 270 | 265 |
| 271 | 266 |
| 272 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( | 267 DART_EXPORT Dart_Handle Dart_ActivationFrameGetLocation( |
| 273 Dart_ActivationFrame activation_frame, | 268 Dart_ActivationFrame activation_frame, |
| 274 Dart_Handle* function_name, | 269 Dart_Handle* function_name, |
| 275 Dart_Handle* function, | 270 Dart_Handle* function, |
| 276 Dart_CodeLocation* location) { | 271 Dart_CodeLocation* location) { |
| 277 // TODO(hausner): Implement a way to recognize when there | 272 // TODO(hausner): Implement a way to recognize when there |
| 278 // is no source code for the code in the frame. | 273 // is no source code for the code in the frame. |
| 279 Isolate* isolate = Isolate::Current(); | 274 DARTSCOPE(Thread::Current()); |
| 280 DARTSCOPE(isolate); | |
| 281 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 275 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 282 if (function_name != NULL) { | 276 if (function_name != NULL) { |
| 283 *function_name = Api::NewHandle(isolate, frame->QualifiedFunctionName()); | 277 *function_name = Api::NewHandle(I, frame->QualifiedFunctionName()); |
| 284 } | 278 } |
| 285 if (function != NULL) { | 279 if (function != NULL) { |
| 286 *function = Api::NewHandle(isolate, frame->function().raw()); | 280 *function = Api::NewHandle(I, frame->function().raw()); |
| 287 } | 281 } |
| 288 | 282 |
| 289 if (location != NULL) { | 283 if (location != NULL) { |
| 290 location->script_url = Api::NewHandle(isolate, frame->SourceUrl()); | 284 location->script_url = Api::NewHandle(I, frame->SourceUrl()); |
| 291 const Library& lib = Library::Handle(frame->Library()); | 285 const Library& lib = Library::Handle(Z, frame->Library()); |
| 292 location->library_id = lib.index(); | 286 location->library_id = lib.index(); |
| 293 location->token_pos = frame->TokenPos(); | 287 location->token_pos = frame->TokenPos(); |
| 294 } | 288 } |
| 295 return Api::Success(); | 289 return Api::Success(); |
| 296 } | 290 } |
| 297 | 291 |
| 298 DART_EXPORT Dart_Handle Dart_ActivationFrameGetFramePointer( | 292 DART_EXPORT Dart_Handle Dart_ActivationFrameGetFramePointer( |
| 299 Dart_ActivationFrame activation_frame, | 293 Dart_ActivationFrame activation_frame, |
| 300 uintptr_t* frame_pointer) { | 294 uintptr_t* frame_pointer) { |
| 301 Isolate* isolate = Isolate::Current(); | 295 DARTSCOPE(Thread::Current()); |
| 302 DARTSCOPE(isolate); | |
| 303 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 296 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 304 | 297 |
| 305 if (frame_pointer != NULL) { | 298 if (frame_pointer != NULL) { |
| 306 *frame_pointer = static_cast<uintptr_t>(frame->fp()); | 299 *frame_pointer = static_cast<uintptr_t>(frame->fp()); |
| 307 } | 300 } |
| 308 return Api::Success(); | 301 return Api::Success(); |
| 309 } | 302 } |
| 310 | 303 |
| 311 | 304 |
| 312 DART_EXPORT Dart_Handle Dart_GetFunctionOrigin(Dart_Handle function_in) { | 305 DART_EXPORT Dart_Handle Dart_GetFunctionOrigin(Dart_Handle function_in) { |
| 313 Isolate* isolate = Isolate::Current(); | 306 DARTSCOPE(Thread::Current()); |
| 314 DARTSCOPE(isolate); | |
| 315 UNWRAP_AND_CHECK_PARAM(Function, function, function_in); | 307 UNWRAP_AND_CHECK_PARAM(Function, function, function_in); |
| 316 | 308 |
| 317 const Class& cls = Class::Handle(function.origin()); | 309 const Class& cls = Class::Handle(Z, function.origin()); |
| 318 if (!cls.IsTopLevel()) { | 310 if (!cls.IsTopLevel()) { |
| 319 return Dart_NewInteger(cls.id()); | 311 return Dart_NewInteger(cls.id()); |
| 320 } | 312 } |
| 321 return Api::Null(); | 313 return Api::Null(); |
| 322 } | 314 } |
| 323 | 315 |
| 324 | 316 |
| 325 DART_EXPORT Dart_Handle Dart_GetLocalVariables( | 317 DART_EXPORT Dart_Handle Dart_GetLocalVariables( |
| 326 Dart_ActivationFrame activation_frame) { | 318 Dart_ActivationFrame activation_frame) { |
| 327 Isolate* isolate = Isolate::Current(); | 319 DARTSCOPE(Thread::Current()); |
| 328 DARTSCOPE(isolate); | |
| 329 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 320 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 330 return Api::NewHandle(isolate, frame->GetLocalVariables()); | 321 return Api::NewHandle(I, frame->GetLocalVariables()); |
| 331 } | 322 } |
| 332 | 323 |
| 333 | 324 |
| 334 DART_EXPORT Dart_Handle Dart_SetBreakpoint( | 325 DART_EXPORT Dart_Handle Dart_SetBreakpoint( |
| 335 Dart_Handle script_url_in, | 326 Dart_Handle script_url_in, |
| 336 intptr_t line_number) { | 327 intptr_t line_number) { |
| 337 Isolate* isolate = Isolate::Current(); | 328 DARTSCOPE(Thread::Current()); |
| 338 DARTSCOPE(isolate); | |
| 339 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 329 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 340 | 330 |
| 341 Debugger* debugger = isolate->debugger(); | 331 Debugger* debugger = I->debugger(); |
| 342 Breakpoint* bpt = | 332 Breakpoint* bpt = |
| 343 debugger->SetBreakpointAtLine(script_url, line_number); | 333 debugger->SetBreakpointAtLine(script_url, line_number); |
| 344 if (bpt == NULL) { | 334 if (bpt == NULL) { |
| 345 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", | 335 return Api::NewError("%s: could not set breakpoint at line %" Pd " in '%s'", |
| 346 CURRENT_FUNC, line_number, script_url.ToCString()); | 336 CURRENT_FUNC, line_number, script_url.ToCString()); |
| 347 } | 337 } |
| 348 return Dart_NewInteger(bpt->id()); | 338 return Dart_NewInteger(bpt->id()); |
| 349 } | 339 } |
| 350 | 340 |
| 351 | 341 |
| 352 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { | 342 DART_EXPORT Dart_Handle Dart_GetBreakpointURL(intptr_t bp_id) { |
| 353 Isolate* isolate = Isolate::Current(); | 343 DARTSCOPE(Thread::Current()); |
| 354 DARTSCOPE(isolate); | 344 Debugger* debugger = I->debugger(); |
| 355 Debugger* debugger = isolate->debugger(); | |
| 356 | 345 |
| 357 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 346 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); |
| 358 if (bpt == NULL) { | 347 if (bpt == NULL) { |
| 359 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 348 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
| 360 CURRENT_FUNC, bp_id); | 349 CURRENT_FUNC, bp_id); |
| 361 } | 350 } |
| 362 return Api::NewHandle(isolate, bpt->bpt_location()->url()); | 351 return Api::NewHandle(I, bpt->bpt_location()->url()); |
| 363 } | 352 } |
| 364 | 353 |
| 365 | 354 |
| 366 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { | 355 DART_EXPORT Dart_Handle Dart_GetBreakpointLine(intptr_t bp_id) { |
| 367 Isolate* isolate = Isolate::Current(); | 356 DARTSCOPE(Thread::Current()); |
| 368 DARTSCOPE(isolate); | 357 Debugger* debugger = I->debugger(); |
| 369 Debugger* debugger = isolate->debugger(); | |
| 370 | 358 |
| 371 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); | 359 Breakpoint* bpt = debugger->GetBreakpointById(bp_id); |
| 372 if (bpt == NULL) { | 360 if (bpt == NULL) { |
| 373 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", | 361 return Api::NewError("%s: breakpoint with id %" Pd " does not exist", |
| 374 CURRENT_FUNC, bp_id); | 362 CURRENT_FUNC, bp_id); |
| 375 } | 363 } |
| 376 return Dart_NewInteger(bpt->bpt_location()->LineNumber()); | 364 return Dart_NewInteger(bpt->bpt_location()->LineNumber()); |
| 377 } | 365 } |
| 378 | 366 |
| 379 | 367 |
| 380 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( | 368 DART_EXPORT Dart_Handle Dart_SetBreakpointAtEntry( |
| 381 Dart_Handle library_in, | 369 Dart_Handle library_in, |
| 382 Dart_Handle class_name_in, | 370 Dart_Handle class_name_in, |
| 383 Dart_Handle function_name_in) { | 371 Dart_Handle function_name_in) { |
| 384 Isolate* isolate = Isolate::Current(); | 372 DARTSCOPE(Thread::Current()); |
| 385 DARTSCOPE(isolate); | |
| 386 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); | 373 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); |
| 387 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); | 374 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); |
| 388 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); | 375 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); |
| 389 | 376 |
| 390 // Ensure that the library is loaded. | 377 // Ensure that the library is loaded. |
| 391 if (!library.Loaded()) { | 378 if (!library.Loaded()) { |
| 392 return Api::NewError( | 379 return Api::NewError( |
| 393 "%s expects library argument 'library_in' to be loaded.", | 380 "%s expects library argument 'library_in' to be loaded.", |
| 394 CURRENT_FUNC); | 381 CURRENT_FUNC); |
| 395 } | 382 } |
| 396 | 383 |
| 397 // Resolve the breakpoint target function. | 384 // Resolve the breakpoint target function. |
| 398 Debugger* debugger = isolate->debugger(); | 385 Debugger* debugger = I->debugger(); |
| 399 const Function& bp_target = Function::Handle( | 386 const Function& bp_target = Function::Handle( |
| 400 debugger->ResolveFunction(library, class_name, function_name)); | 387 debugger->ResolveFunction(library, class_name, function_name)); |
| 401 if (bp_target.IsNull()) { | 388 if (bp_target.IsNull()) { |
| 402 const bool toplevel = class_name.Length() == 0; | 389 const bool toplevel = class_name.Length() == 0; |
| 403 return Api::NewError("%s: could not find function '%s%s%s'", | 390 return Api::NewError("%s: could not find function '%s%s%s'", |
| 404 CURRENT_FUNC, | 391 CURRENT_FUNC, |
| 405 toplevel ? "" : class_name.ToCString(), | 392 toplevel ? "" : class_name.ToCString(), |
| 406 toplevel ? "" : ".", | 393 toplevel ? "" : ".", |
| 407 function_name.ToCString()); | 394 function_name.ToCString()); |
| 408 } | 395 } |
| 409 | 396 |
| 410 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target, false); | 397 Breakpoint* bpt = debugger->SetBreakpointAtEntry(bp_target, false); |
| 411 if (bpt == NULL) { | 398 if (bpt == NULL) { |
| 412 const char* target_name = Debugger::QualifiedFunctionName(bp_target); | 399 const char* target_name = Debugger::QualifiedFunctionName(bp_target); |
| 413 return Api::NewError("%s: no breakpoint location found in '%s'", | 400 return Api::NewError("%s: no breakpoint location found in '%s'", |
| 414 CURRENT_FUNC, target_name); | 401 CURRENT_FUNC, target_name); |
| 415 } | 402 } |
| 416 return Dart_NewInteger(bpt->id()); | 403 return Dart_NewInteger(bpt->id()); |
| 417 } | 404 } |
| 418 | 405 |
| 419 | 406 |
| 420 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry( | 407 DART_EXPORT Dart_Handle Dart_OneTimeBreakAtEntry( |
| 421 Dart_Handle library_in, | 408 Dart_Handle library_in, |
| 422 Dart_Handle class_name_in, | 409 Dart_Handle class_name_in, |
| 423 Dart_Handle function_name_in) { | 410 Dart_Handle function_name_in) { |
| 424 Isolate* isolate = Isolate::Current(); | 411 DARTSCOPE(Thread::Current()); |
| 425 DARTSCOPE(isolate); | |
| 426 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); | 412 UNWRAP_AND_CHECK_PARAM(Library, library, library_in); |
| 427 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); | 413 UNWRAP_AND_CHECK_PARAM(String, class_name, class_name_in); |
| 428 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); | 414 UNWRAP_AND_CHECK_PARAM(String, function_name, function_name_in); |
| 429 | 415 |
| 430 // Ensure that the library is loaded. | 416 // Ensure that the library is loaded. |
| 431 if (!library.Loaded()) { | 417 if (!library.Loaded()) { |
| 432 return Api::NewError( | 418 return Api::NewError( |
| 433 "%s expects library argument 'library_in' to be loaded.", | 419 "%s expects library argument 'library_in' to be loaded.", |
| 434 CURRENT_FUNC); | 420 CURRENT_FUNC); |
| 435 } | 421 } |
| 436 | 422 |
| 437 // Resolve the breakpoint target function. | 423 // Resolve the breakpoint target function. |
| 438 Debugger* debugger = isolate->debugger(); | 424 Debugger* debugger = I->debugger(); |
| 439 const Function& bp_target = Function::Handle( | 425 const Function& bp_target = Function::Handle( |
| 440 debugger->ResolveFunction(library, class_name, function_name)); | 426 debugger->ResolveFunction(library, class_name, function_name)); |
| 441 if (bp_target.IsNull()) { | 427 if (bp_target.IsNull()) { |
| 442 const bool toplevel = class_name.Length() == 0; | 428 const bool toplevel = class_name.Length() == 0; |
| 443 return Api::NewError("%s: could not find function '%s%s%s'", | 429 return Api::NewError("%s: could not find function '%s%s%s'", |
| 444 CURRENT_FUNC, | 430 CURRENT_FUNC, |
| 445 toplevel ? "" : class_name.ToCString(), | 431 toplevel ? "" : class_name.ToCString(), |
| 446 toplevel ? "" : ".", | 432 toplevel ? "" : ".", |
| 447 function_name.ToCString()); | 433 function_name.ToCString()); |
| 448 } | 434 } |
| 449 | 435 |
| 450 const Error& error = | 436 const Error& error = Error::Handle(Z, |
| 451 Error::Handle(isolate, debugger->OneTimeBreakAtEntry(bp_target)); | 437 debugger->OneTimeBreakAtEntry(bp_target)); |
| 452 if (!error.IsNull()) { | 438 if (!error.IsNull()) { |
| 453 return Api::NewHandle(isolate, error.raw()); | 439 return Api::NewHandle(I, error.raw()); |
| 454 } | 440 } |
| 455 return Api::Success(); | 441 return Api::Success(); |
| 456 } | 442 } |
| 457 | 443 |
| 458 | 444 |
| 459 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { | 445 DART_EXPORT Dart_Handle Dart_RemoveBreakpoint(intptr_t bp_id) { |
| 460 Isolate* isolate = Isolate::Current(); | 446 DARTSCOPE(Thread::Current()); |
| 461 DARTSCOPE(isolate); | 447 I->debugger()->RemoveBreakpoint(bp_id); |
| 462 isolate->debugger()->RemoveBreakpoint(bp_id); | |
| 463 return Api::Success(); | 448 return Api::Success(); |
| 464 } | 449 } |
| 465 | 450 |
| 466 | 451 |
| 467 DART_EXPORT Dart_Handle Dart_SetStepOver() { | 452 DART_EXPORT Dart_Handle Dart_SetStepOver() { |
| 468 Isolate* isolate = Isolate::Current(); | 453 DARTSCOPE(Thread::Current()); |
| 469 DARTSCOPE(isolate); | 454 I->debugger()->SetStepOver(); |
| 470 isolate->debugger()->SetStepOver(); | |
| 471 return Api::Success(); | 455 return Api::Success(); |
| 472 } | 456 } |
| 473 | 457 |
| 474 | 458 |
| 475 DART_EXPORT Dart_Handle Dart_SetStepInto() { | 459 DART_EXPORT Dart_Handle Dart_SetStepInto() { |
| 476 Isolate* isolate = Isolate::Current(); | 460 DARTSCOPE(Thread::Current()); |
| 477 DARTSCOPE(isolate); | 461 I->debugger()->SetSingleStep(); |
| 478 isolate->debugger()->SetSingleStep(); | |
| 479 return Api::Success(); | 462 return Api::Success(); |
| 480 } | 463 } |
| 481 | 464 |
| 482 | 465 |
| 483 DART_EXPORT Dart_Handle Dart_SetStepOut() { | 466 DART_EXPORT Dart_Handle Dart_SetStepOut() { |
| 484 Isolate* isolate = Isolate::Current(); | 467 DARTSCOPE(Thread::Current()); |
| 485 DARTSCOPE(isolate); | 468 I->debugger()->SetStepOut(); |
| 486 isolate->debugger()->SetStepOut(); | |
| 487 return Api::Success(); | 469 return Api::Success(); |
| 488 } | 470 } |
| 489 | 471 |
| 490 | 472 |
| 491 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { | 473 DART_EXPORT Dart_Handle Dart_GetInstanceFields(Dart_Handle object_in) { |
| 492 Isolate* isolate = Isolate::Current(); | 474 DARTSCOPE(Thread::Current()); |
| 493 DARTSCOPE(isolate); | |
| 494 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 475 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 495 return Api::NewHandle(isolate, isolate->debugger()->GetInstanceFields(obj)); | 476 return Api::NewHandle(I, I->debugger()->GetInstanceFields(obj)); |
| 496 } | 477 } |
| 497 | 478 |
| 498 | 479 |
| 499 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle target) { | 480 DART_EXPORT Dart_Handle Dart_GetStaticFields(Dart_Handle target) { |
| 500 Isolate* isolate = Isolate::Current(); | 481 DARTSCOPE(Thread::Current()); |
| 501 DARTSCOPE(isolate); | 482 const Type& type_obj = Api::UnwrapTypeHandle(I, target); |
| 502 const Type& type_obj = Api::UnwrapTypeHandle(isolate, target); | |
| 503 if (type_obj.IsNull()) { | 483 if (type_obj.IsNull()) { |
| 504 return Api::NewError("%s expects argument 'target' to be a type", | 484 return Api::NewError("%s expects argument 'target' to be a type", |
| 505 CURRENT_FUNC); | 485 CURRENT_FUNC); |
| 506 } | 486 } |
| 507 const Class& cls = Class::Handle(isolate, type_obj.type_class()); | 487 const Class& cls = Class::Handle(Z, type_obj.type_class()); |
| 508 return Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); | 488 return Api::NewHandle(I, I->debugger()->GetStaticFields(cls)); |
| 509 } | 489 } |
| 510 | 490 |
| 511 | 491 |
| 512 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { | 492 DART_EXPORT Dart_Handle Dart_GetLibraryFields(intptr_t library_id) { |
| 513 Isolate* isolate = Isolate::Current(); | 493 DARTSCOPE(Thread::Current()); |
| 514 DARTSCOPE(isolate); | |
| 515 const Library& lib = | 494 const Library& lib = |
| 516 Library::Handle(isolate, Library::GetLibrary(library_id)); | 495 Library::Handle(Z, Library::GetLibrary(library_id)); |
| 517 if (lib.IsNull()) { | 496 if (lib.IsNull()) { |
| 518 return Api::NewError("%s: %" Pd " is not a valid library id", | 497 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 519 CURRENT_FUNC, library_id); | 498 CURRENT_FUNC, library_id); |
| 520 } | 499 } |
| 521 return Api::NewHandle(isolate, isolate->debugger()->GetLibraryFields(lib)); | 500 return Api::NewHandle(I, I->debugger()->GetLibraryFields(lib)); |
| 522 } | 501 } |
| 523 | 502 |
| 524 | 503 |
| 525 DART_EXPORT Dart_Handle Dart_GetGlobalVariables(intptr_t library_id) { | 504 DART_EXPORT Dart_Handle Dart_GetGlobalVariables(intptr_t library_id) { |
| 526 Isolate* isolate = Isolate::Current(); | 505 DARTSCOPE(Thread::Current()); |
| 527 ASSERT(isolate != NULL); | 506 |
| 528 DARTSCOPE(isolate); | 507 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
| 529 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | |
| 530 if (lib.IsNull()) { | 508 if (lib.IsNull()) { |
| 531 return Api::NewError("%s: %" Pd " is not a valid library id", | 509 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 532 CURRENT_FUNC, library_id); | 510 CURRENT_FUNC, library_id); |
| 533 } | 511 } |
| 534 return Api::NewHandle(isolate, isolate->debugger()->GetGlobalFields(lib)); | 512 return Api::NewHandle(I, I->debugger()->GetGlobalFields(lib)); |
| 535 } | 513 } |
| 536 | 514 |
| 537 | 515 |
| 538 DART_EXPORT Dart_Handle Dart_ActivationFrameEvaluate( | 516 DART_EXPORT Dart_Handle Dart_ActivationFrameEvaluate( |
| 539 Dart_ActivationFrame activation_frame, | 517 Dart_ActivationFrame activation_frame, |
| 540 Dart_Handle expr_in) { | 518 Dart_Handle expr_in) { |
| 541 Isolate* isolate = Isolate::Current(); | 519 DARTSCOPE(Thread::Current()); |
| 542 DARTSCOPE(isolate); | |
| 543 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); | 520 CHECK_AND_CAST(ActivationFrame, frame, activation_frame); |
| 544 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in); | 521 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in); |
| 545 return Api::NewHandle(isolate, frame->Evaluate(expr)); | 522 return Api::NewHandle(I, frame->Evaluate(expr)); |
| 546 } | 523 } |
| 547 | 524 |
| 548 | 525 |
| 549 DART_EXPORT Dart_Handle Dart_EvaluateExpr(Dart_Handle target_in, | 526 DART_EXPORT Dart_Handle Dart_EvaluateExpr(Dart_Handle target_in, |
| 550 Dart_Handle expr_in) { | 527 Dart_Handle expr_in) { |
| 551 Isolate* isolate = Isolate::Current(); | 528 DARTSCOPE(Thread::Current()); |
| 552 DARTSCOPE(isolate); | |
| 553 | 529 |
| 554 const Object& target = Object::Handle(isolate, Api::UnwrapHandle(target_in)); | 530 const Object& target = Object::Handle(Z, Api::UnwrapHandle(target_in)); |
| 555 if (target.IsError()) return target_in; | 531 if (target.IsError()) return target_in; |
| 556 if (target.IsNull()) { | 532 if (target.IsNull()) { |
| 557 return Api::NewError("%s expects argument 'target' to be non-null", | 533 return Api::NewError("%s expects argument 'target' to be non-null", |
| 558 CURRENT_FUNC); | 534 CURRENT_FUNC); |
| 559 } | 535 } |
| 560 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in); | 536 UNWRAP_AND_CHECK_PARAM(String, expr, expr_in); |
| 561 // Type extends Instance, must check first. | 537 // Type extends Instance, must check first. |
| 562 if (target.IsType()) { | 538 if (target.IsType()) { |
| 563 const Class& cls = Class::Handle(isolate, Type::Cast(target).type_class()); | 539 const Class& cls = Class::Handle(Z, Type::Cast(target).type_class()); |
| 564 return Api::NewHandle(isolate, cls.Evaluate(expr, | 540 return Api::NewHandle(I, cls.Evaluate(expr, |
| 565 Array::empty_array(), | 541 Array::empty_array(), |
| 566 Array::empty_array())); | 542 Array::empty_array())); |
| 567 } else if (target.IsInstance()) { | 543 } else if (target.IsInstance()) { |
| 568 const Instance& inst = Instance::Cast(target); | 544 const Instance& inst = Instance::Cast(target); |
| 569 return Api::NewHandle(isolate, inst.Evaluate(expr, | 545 return Api::NewHandle(I, inst.Evaluate(expr, |
| 570 Array::empty_array(), | 546 Array::empty_array(), |
| 571 Array::empty_array())); | 547 Array::empty_array())); |
| 572 } else if (target.IsLibrary()) { | 548 } else if (target.IsLibrary()) { |
| 573 const Library& lib = Library::Cast(target); | 549 const Library& lib = Library::Cast(target); |
| 574 return Api::NewHandle(isolate, lib.Evaluate(expr, | 550 return Api::NewHandle(I, lib.Evaluate(expr, |
| 575 Array::empty_array(), | 551 Array::empty_array(), |
| 576 Array::empty_array())); | 552 Array::empty_array())); |
| 577 } else if (target.IsClass()) { | 553 } else if (target.IsClass()) { |
| 578 const Class& cls = Class::Cast(target); | 554 const Class& cls = Class::Cast(target); |
| 579 return Api::NewHandle(isolate, cls.Evaluate(expr, | 555 return Api::NewHandle(I, cls.Evaluate(expr, |
| 580 Array::empty_array(), | 556 Array::empty_array(), |
| 581 Array::empty_array())); | 557 Array::empty_array())); |
| 582 } | 558 } |
| 583 return Api::NewError("%s: unsupported target type", CURRENT_FUNC); | 559 return Api::NewError("%s: unsupported target type", CURRENT_FUNC); |
| 584 } | 560 } |
| 585 | 561 |
| 586 | 562 |
| 587 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { | 563 DART_EXPORT Dart_Handle Dart_GetObjClass(Dart_Handle object_in) { |
| 588 Isolate* isolate = Isolate::Current(); | 564 DARTSCOPE(Thread::Current()); |
| 589 DARTSCOPE(isolate); | |
| 590 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 565 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 591 return Api::NewHandle(isolate, obj.GetType()); | 566 return Api::NewHandle(I, obj.GetType()); |
| 592 } | 567 } |
| 593 | 568 |
| 594 | 569 |
| 595 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, | 570 DART_EXPORT Dart_Handle Dart_GetObjClassId(Dart_Handle object_in, |
| 596 intptr_t* class_id) { | 571 intptr_t* class_id) { |
| 597 Isolate* isolate = Isolate::Current(); | 572 DARTSCOPE(Thread::Current()); |
| 598 DARTSCOPE(isolate); | |
| 599 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); | 573 UNWRAP_AND_CHECK_PARAM(Instance, obj, object_in); |
| 600 CHECK_NOT_NULL(class_id); | 574 CHECK_NOT_NULL(class_id); |
| 601 *class_id = obj.GetClassId(); | 575 *class_id = obj.GetClassId(); |
| 602 return Api::Success(); | 576 return Api::Success(); |
| 603 } | 577 } |
| 604 | 578 |
| 605 | 579 |
| 606 DART_EXPORT Dart_Handle Dart_GetClassFromId(intptr_t class_id) { | 580 DART_EXPORT Dart_Handle Dart_GetClassFromId(intptr_t class_id) { |
| 607 Isolate* isolate = Isolate::Current(); | 581 DARTSCOPE(Thread::Current()); |
| 608 DARTSCOPE(isolate); | 582 if (!I->class_table()->IsValidIndex(class_id)) { |
| 609 if (!isolate->class_table()->IsValidIndex(class_id)) { | |
| 610 return Api::NewError("%s: %" Pd " is not a valid class id", | 583 return Api::NewError("%s: %" Pd " is not a valid class id", |
| 611 CURRENT_FUNC, class_id); | 584 CURRENT_FUNC, class_id); |
| 612 } | 585 } |
| 613 return Api::NewHandle(isolate, isolate->class_table()->At(class_id)); | 586 return Api::NewHandle(I, I->class_table()->At(class_id)); |
| 614 } | 587 } |
| 615 | 588 |
| 616 | 589 |
| 617 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) { | 590 DART_EXPORT Dart_Handle Dart_GetSupertype(Dart_Handle type_in) { |
| 618 Isolate* isolate = Isolate::Current(); | 591 DARTSCOPE(Thread::Current()); |
| 619 DARTSCOPE(isolate); | |
| 620 | 592 |
| 621 UNWRAP_AND_CHECK_PARAM(Type, type, type_in); | 593 UNWRAP_AND_CHECK_PARAM(Type, type, type_in); |
| 622 if (!type.IsFinalized()) { | 594 if (!type.IsFinalized()) { |
| 623 return Api::NewError("%s: type in 'type_in' is not a finalized type", | 595 return Api::NewError("%s: type in 'type_in' is not a finalized type", |
| 624 CURRENT_FUNC); | 596 CURRENT_FUNC); |
| 625 } | 597 } |
| 626 if (!type.IsInstantiated()) { | 598 if (!type.IsInstantiated()) { |
| 627 return Api::NewError("%s: type in 'type_in' is not an instantiated type", | 599 return Api::NewError("%s: type in 'type_in' is not an instantiated type", |
| 628 CURRENT_FUNC); | 600 CURRENT_FUNC); |
| 629 } | 601 } |
| 630 const Class& cls = Class::Handle(type.type_class()); | 602 const Class& cls = Class::Handle(type.type_class()); |
| 631 if (cls.NumTypeParameters() == 0) { | 603 if (cls.NumTypeParameters() == 0) { |
| 632 // The super type has no type parameters or it is already instantiated | 604 // The super type has no type parameters or it is already instantiated |
| 633 // just return it. | 605 // just return it. |
| 634 const AbstractType& type = AbstractType::Handle(cls.super_type()); | 606 const AbstractType& type = AbstractType::Handle(cls.super_type()); |
| 635 if (type.IsNull()) { | 607 if (type.IsNull()) { |
| 636 return Dart_Null(); | 608 return Dart_Null(); |
| 637 } | 609 } |
| 638 return Api::NewHandle(isolate, type.Canonicalize()); | 610 return Api::NewHandle(I, type.Canonicalize()); |
| 639 } | 611 } |
| 640 // Set up the type arguments array for the super class type. | 612 // Set up the type arguments array for the super class type. |
| 641 const Class& super_cls = Class::Handle(cls.SuperClass()); | 613 const Class& super_cls = Class::Handle(cls.SuperClass()); |
| 642 intptr_t num_expected_type_arguments = super_cls.NumTypeArguments(); | 614 intptr_t num_expected_type_arguments = super_cls.NumTypeArguments(); |
| 643 TypeArguments& super_type_args_array = TypeArguments::Handle(); | 615 TypeArguments& super_type_args_array = TypeArguments::Handle(); |
| 644 const TypeArguments& type_args_array = | 616 const TypeArguments& type_args_array = |
| 645 TypeArguments::Handle(type.arguments()); | 617 TypeArguments::Handle(type.arguments()); |
| 646 if (!type_args_array.IsNull() && (num_expected_type_arguments > 0)) { | 618 if (!type_args_array.IsNull() && (num_expected_type_arguments > 0)) { |
| 647 super_type_args_array = TypeArguments::New(num_expected_type_arguments); | 619 super_type_args_array = TypeArguments::New(num_expected_type_arguments); |
| 648 AbstractType& type_arg = AbstractType::Handle(); | 620 AbstractType& type_arg = AbstractType::Handle(); |
| 649 for (intptr_t i = 0; i < num_expected_type_arguments; i++) { | 621 for (intptr_t i = 0; i < num_expected_type_arguments; i++) { |
| 650 type_arg ^= type_args_array.TypeAt(i); | 622 type_arg ^= type_args_array.TypeAt(i); |
| 651 super_type_args_array.SetTypeAt(i, type_arg); | 623 super_type_args_array.SetTypeAt(i, type_arg); |
| 652 } | 624 } |
| 653 } | 625 } |
| 654 | 626 |
| 655 // Construct the super type object, canonicalize it and return. | 627 // Construct the super type object, canonicalize it and return. |
| 656 Type& instantiated_type = Type::Handle( | 628 Type& instantiated_type = Type::Handle( |
| 657 Type::New(super_cls, super_type_args_array, Scanner::kNoSourcePos)); | 629 Type::New(super_cls, super_type_args_array, Scanner::kNoSourcePos)); |
| 658 ASSERT(!instantiated_type.IsNull()); | 630 ASSERT(!instantiated_type.IsNull()); |
| 659 instantiated_type.SetIsFinalized(); | 631 instantiated_type.SetIsFinalized(); |
| 660 return Api::NewHandle(isolate, instantiated_type.Canonicalize()); | 632 return Api::NewHandle(I, instantiated_type.Canonicalize()); |
| 661 } | 633 } |
| 662 | 634 |
| 663 | 635 |
| 664 DART_EXPORT Dart_Handle Dart_GetClosureInfo( | 636 DART_EXPORT Dart_Handle Dart_GetClosureInfo( |
| 665 Dart_Handle closure, | 637 Dart_Handle closure, |
| 666 Dart_Handle* name, | 638 Dart_Handle* name, |
| 667 Dart_Handle* signature, | 639 Dart_Handle* signature, |
| 668 Dart_CodeLocation* location) { | 640 Dart_CodeLocation* location) { |
| 669 Isolate* isolate = Isolate::Current(); | 641 DARTSCOPE(Thread::Current()); |
| 670 DARTSCOPE(isolate); | |
| 671 UNWRAP_AND_CHECK_PARAM(Instance, instance, closure); | 642 UNWRAP_AND_CHECK_PARAM(Instance, instance, closure); |
| 672 CHECK_NOT_NULL(location); | 643 CHECK_NOT_NULL(location); |
| 673 | 644 |
| 674 if (!instance.IsClosure()) { | 645 if (!instance.IsClosure()) { |
| 675 return Api::NewError("%s: parameter 0 is not a closure", CURRENT_FUNC); | 646 return Api::NewError("%s: parameter 0 is not a closure", CURRENT_FUNC); |
| 676 } | 647 } |
| 677 const Function& func = Function::Handle(Closure::function(instance)); | 648 const Function& func = Function::Handle(Closure::function(instance)); |
| 678 ASSERT(!func.IsNull()); | 649 ASSERT(!func.IsNull()); |
| 679 if (name != NULL) { | 650 if (name != NULL) { |
| 680 *name = Api::NewHandle(isolate, func.QualifiedUserVisibleName()); | 651 *name = Api::NewHandle(I, func.QualifiedUserVisibleName()); |
| 681 } | 652 } |
| 682 if (signature != NULL) { | 653 if (signature != NULL) { |
| 683 *signature = Api::NewHandle(isolate, func.UserVisibleSignature()); | 654 *signature = Api::NewHandle(I, func.UserVisibleSignature()); |
| 684 } | 655 } |
| 685 | 656 |
| 686 if (location != NULL) { | 657 if (location != NULL) { |
| 687 if (func.token_pos() >= 0) { | 658 if (func.token_pos() >= 0) { |
| 688 const Class& cls = Class::Handle(func.origin()); | 659 const Class& cls = Class::Handle(Z, func.origin()); |
| 689 ASSERT(!cls.IsNull()); | 660 ASSERT(!cls.IsNull()); |
| 690 const Library& lib = Library::Handle(isolate, cls.library()); | 661 const Library& lib = Library::Handle(Z, cls.library()); |
| 691 ASSERT(!lib.IsNull()); | 662 ASSERT(!lib.IsNull()); |
| 692 // Note func.script() is not the same as cls.script() for eval functions. | 663 // Note func.script() is not the same as cls.script() for eval functions. |
| 693 const Script& script = Script::Handle(func.script()); | 664 const Script& script = Script::Handle(Z, func.script()); |
| 694 ASSERT(!script.IsNull()); | 665 ASSERT(!script.IsNull()); |
| 695 location->script_url = Api::NewHandle(isolate, script.url()); | 666 location->script_url = Api::NewHandle(I, script.url()); |
| 696 location->library_id = lib.index(); | 667 location->library_id = lib.index(); |
| 697 location->token_pos = func.token_pos(); | 668 location->token_pos = func.token_pos(); |
| 698 } else { | 669 } else { |
| 699 location->script_url = Api::NewHandle(isolate, String::null()); | 670 location->script_url = Api::NewHandle(I, String::null()); |
| 700 location->library_id = -1; | 671 location->library_id = -1; |
| 701 location->token_pos = -1; | 672 location->token_pos = -1; |
| 702 } | 673 } |
| 703 } | 674 } |
| 704 return Api::True(); | 675 return Api::True(); |
| 705 } | 676 } |
| 706 | 677 |
| 707 | 678 |
| 708 DART_EXPORT Dart_Handle Dart_GetClassInfo( | 679 DART_EXPORT Dart_Handle Dart_GetClassInfo( |
| 709 intptr_t cls_id, | 680 intptr_t cls_id, |
| 710 Dart_Handle* class_name, | 681 Dart_Handle* class_name, |
| 711 intptr_t* library_id, | 682 intptr_t* library_id, |
| 712 intptr_t* super_class_id, | 683 intptr_t* super_class_id, |
| 713 Dart_Handle* static_fields) { | 684 Dart_Handle* static_fields) { |
| 714 Isolate* isolate = Isolate::Current(); | 685 DARTSCOPE(Thread::Current()); |
| 715 DARTSCOPE(isolate); | 686 if (!I->class_table()->IsValidIndex(cls_id)) { |
| 716 if (!isolate->class_table()->IsValidIndex(cls_id)) { | |
| 717 return Api::NewError("%s: %" Pd " is not a valid class id", | 687 return Api::NewError("%s: %" Pd " is not a valid class id", |
| 718 CURRENT_FUNC, cls_id); | 688 CURRENT_FUNC, cls_id); |
| 719 } | 689 } |
| 720 Class& cls = Class::Handle(isolate, isolate->class_table()->At(cls_id)); | 690 Class& cls = Class::Handle(Z, I->class_table()->At(cls_id)); |
| 721 if (class_name != NULL) { | 691 if (class_name != NULL) { |
| 722 *class_name = Api::NewHandle(isolate, cls.Name()); | 692 *class_name = Api::NewHandle(I, cls.Name()); |
| 723 } | 693 } |
| 724 if (library_id != NULL) { | 694 if (library_id != NULL) { |
| 725 const Library& lib = Library::Handle(isolate, cls.library()); | 695 const Library& lib = Library::Handle(Z, cls.library()); |
| 726 *library_id = lib.index(); | 696 *library_id = lib.index(); |
| 727 } | 697 } |
| 728 if (super_class_id != NULL) { | 698 if (super_class_id != NULL) { |
| 729 *super_class_id = 0; | 699 *super_class_id = 0; |
| 730 Class& super_cls = Class::Handle(isolate, cls.SuperClass()); | 700 Class& super_cls = Class::Handle(Z, cls.SuperClass()); |
| 731 if (!super_cls.IsNull()) { | 701 if (!super_cls.IsNull()) { |
| 732 *super_class_id = super_cls.id(); | 702 *super_class_id = super_cls.id(); |
| 733 } | 703 } |
| 734 } | 704 } |
| 735 if (static_fields != NULL) { | 705 if (static_fields != NULL) { |
| 736 *static_fields = | 706 *static_fields = |
| 737 Api::NewHandle(isolate, isolate->debugger()->GetStaticFields(cls)); | 707 Api::NewHandle(I, I->debugger()->GetStaticFields(cls)); |
| 738 } | 708 } |
| 739 return Api::Success(); | 709 return Api::Success(); |
| 740 } | 710 } |
| 741 | 711 |
| 742 | 712 |
| 743 DART_EXPORT Dart_Handle Dart_ScriptGetSource( | 713 DART_EXPORT Dart_Handle Dart_ScriptGetSource( |
| 744 intptr_t library_id, | 714 intptr_t library_id, |
| 745 Dart_Handle script_url_in) { | 715 Dart_Handle script_url_in) { |
| 746 Isolate* isolate = Isolate::Current(); | 716 DARTSCOPE(Thread::Current()); |
| 747 DARTSCOPE(isolate); | |
| 748 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 717 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 749 if (lib.IsNull()) { | 718 if (lib.IsNull()) { |
| 750 return Api::NewError("%s: %" Pd " is not a valid library id", | 719 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 751 CURRENT_FUNC, library_id); | 720 CURRENT_FUNC, library_id); |
| 752 } | 721 } |
| 753 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 722 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 754 const Script& script = Script::Handle(lib.LookupScript(script_url)); | 723 const Script& script = Script::Handle(lib.LookupScript(script_url)); |
| 755 if (script.IsNull()) { | 724 if (script.IsNull()) { |
| 756 return Api::NewError("%s: script '%s' not found in library '%s'", | 725 return Api::NewError("%s: script '%s' not found in library '%s'", |
| 757 CURRENT_FUNC, script_url.ToCString(), | 726 CURRENT_FUNC, script_url.ToCString(), |
| 758 String::Handle(lib.url()).ToCString()); | 727 String::Handle(lib.url()).ToCString()); |
| 759 } | 728 } |
| 760 return Api::NewHandle(isolate, script.Source()); | 729 return Api::NewHandle(I, script.Source()); |
| 761 } | 730 } |
| 762 | 731 |
| 763 | 732 |
| 764 DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo( | 733 DART_EXPORT Dart_Handle Dart_ScriptGetTokenInfo( |
| 765 intptr_t library_id, | 734 intptr_t library_id, |
| 766 Dart_Handle script_url_in) { | 735 Dart_Handle script_url_in) { |
| 767 Isolate* isolate = Isolate::Current(); | 736 DARTSCOPE(Thread::Current()); |
| 768 DARTSCOPE(isolate); | |
| 769 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 737 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 770 if (lib.IsNull()) { | 738 if (lib.IsNull()) { |
| 771 return Api::NewError("%s: %" Pd " is not a valid library id", | 739 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 772 CURRENT_FUNC, library_id); | 740 CURRENT_FUNC, library_id); |
| 773 } | 741 } |
| 774 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 742 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 775 const Script& script = Script::Handle(lib.LookupScript(script_url)); | 743 const Script& script = Script::Handle(lib.LookupScript(script_url)); |
| 776 if (script.IsNull()) { | 744 if (script.IsNull()) { |
| 777 return Api::NewError("%s: script '%s' not found in library '%s'", | 745 return Api::NewError("%s: script '%s' not found in library '%s'", |
| 778 CURRENT_FUNC, script_url.ToCString(), | 746 CURRENT_FUNC, script_url.ToCString(), |
| 779 String::Handle(lib.url()).ToCString()); | 747 String::Handle(lib.url()).ToCString()); |
| 780 } | 748 } |
| 781 | 749 |
| 782 const GrowableObjectArray& info = | 750 const GrowableObjectArray& info = |
| 783 GrowableObjectArray::Handle(script.GenerateLineNumberArray()); | 751 GrowableObjectArray::Handle(script.GenerateLineNumberArray()); |
| 784 return Api::NewHandle(isolate, Array::MakeArray(info)); | 752 return Api::NewHandle(I, Array::MakeArray(info)); |
| 785 } | 753 } |
| 786 | 754 |
| 787 | 755 |
| 788 DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in, | 756 DART_EXPORT Dart_Handle Dart_GenerateScriptSource(Dart_Handle library_url_in, |
| 789 Dart_Handle script_url_in) { | 757 Dart_Handle script_url_in) { |
| 790 Isolate* isolate = Isolate::Current(); | 758 DARTSCOPE(Thread::Current()); |
| 791 DARTSCOPE(isolate); | |
| 792 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 759 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
| 793 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); | 760 UNWRAP_AND_CHECK_PARAM(String, script_url, script_url_in); |
| 794 | 761 |
| 795 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); | 762 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); |
| 796 if (library.IsNull()) { | 763 if (library.IsNull()) { |
| 797 return Api::NewError("%s: library '%s' not found", | 764 return Api::NewError("%s: library '%s' not found", |
| 798 CURRENT_FUNC, library_url.ToCString()); | 765 CURRENT_FUNC, library_url.ToCString()); |
| 799 } | 766 } |
| 800 | 767 |
| 801 const Script& script = Script::Handle(library.LookupScript(script_url)); | 768 const Script& script = Script::Handle(library.LookupScript(script_url)); |
| 802 if (script.IsNull()) { | 769 if (script.IsNull()) { |
| 803 return Api::NewError("%s: script '%s' not found in library '%s'", | 770 return Api::NewError("%s: script '%s' not found in library '%s'", |
| 804 CURRENT_FUNC, script_url.ToCString(), | 771 CURRENT_FUNC, script_url.ToCString(), |
| 805 library_url.ToCString()); | 772 library_url.ToCString()); |
| 806 } | 773 } |
| 807 | 774 |
| 808 return Api::NewHandle(isolate, script.GenerateSource()); | 775 return Api::NewHandle(I, script.GenerateSource()); |
| 809 } | 776 } |
| 810 | 777 |
| 811 | 778 |
| 812 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) { | 779 DART_EXPORT Dart_Handle Dart_GetScriptURLs(Dart_Handle library_url_in) { |
| 813 Isolate* isolate = Isolate::Current(); | 780 DARTSCOPE(Thread::Current()); |
| 814 DARTSCOPE(isolate); | |
| 815 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); | 781 UNWRAP_AND_CHECK_PARAM(String, library_url, library_url_in); |
| 816 | 782 |
| 817 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); | 783 const Library& library = Library::Handle(Library::LookupLibrary(library_url)); |
| 818 if (library.IsNull()) { | 784 if (library.IsNull()) { |
| 819 return Api::NewError("%s: library '%s' not found", | 785 return Api::NewError("%s: library '%s' not found", |
| 820 CURRENT_FUNC, library_url.ToCString()); | 786 CURRENT_FUNC, library_url.ToCString()); |
| 821 } | 787 } |
| 822 const Array& loaded_scripts = Array::Handle(library.LoadedScripts()); | 788 const Array& loaded_scripts = Array::Handle(library.LoadedScripts()); |
| 823 ASSERT(!loaded_scripts.IsNull()); | 789 ASSERT(!loaded_scripts.IsNull()); |
| 824 intptr_t num_scripts = loaded_scripts.Length(); | 790 intptr_t num_scripts = loaded_scripts.Length(); |
| 825 const Array& script_list = Array::Handle(Array::New(num_scripts)); | 791 const Array& script_list = Array::Handle(Array::New(num_scripts)); |
| 826 Script& script = Script::Handle(); | 792 Script& script = Script::Handle(); |
| 827 String& url = String::Handle(); | 793 String& url = String::Handle(); |
| 828 for (int i = 0; i < num_scripts; i++) { | 794 for (int i = 0; i < num_scripts; i++) { |
| 829 script ^= loaded_scripts.At(i); | 795 script ^= loaded_scripts.At(i); |
| 830 url = script.url(); | 796 url = script.url(); |
| 831 script_list.SetAt(i, url); | 797 script_list.SetAt(i, url); |
| 832 } | 798 } |
| 833 return Api::NewHandle(isolate, script_list.raw()); | 799 return Api::NewHandle(I, script_list.raw()); |
| 834 } | 800 } |
| 835 | 801 |
| 836 | 802 |
| 837 DART_EXPORT Dart_Handle Dart_GetLibraryIds() { | 803 DART_EXPORT Dart_Handle Dart_GetLibraryIds() { |
| 838 Isolate* isolate = Isolate::Current(); | 804 DARTSCOPE(Thread::Current()); |
| 839 ASSERT(isolate != NULL); | |
| 840 DARTSCOPE(isolate); | |
| 841 | 805 |
| 842 const GrowableObjectArray& libs = | 806 const GrowableObjectArray& libs = |
| 843 GrowableObjectArray::Handle(isolate->object_store()->libraries()); | 807 GrowableObjectArray::Handle(Z, I->object_store()->libraries()); |
| 844 int num_libs = libs.Length(); | 808 int num_libs = libs.Length(); |
| 845 | 809 |
| 846 // Create new list and populate with the url of loaded libraries. | 810 // Create new list and populate with the url of loaded libraries. |
| 847 Library &lib = Library::Handle(); | 811 Library &lib = Library::Handle(); |
| 848 const Array& library_id_list = Array::Handle(Array::New(num_libs)); | 812 const Array& library_id_list = Array::Handle(Z, Array::New(num_libs)); |
| 849 for (int i = 0; i < num_libs; i++) { | 813 for (int i = 0; i < num_libs; i++) { |
| 850 lib ^= libs.At(i); | 814 lib ^= libs.At(i); |
| 851 ASSERT(!lib.IsNull()); | 815 ASSERT(!lib.IsNull()); |
| 852 ASSERT(Smi::IsValid(lib.index())); | 816 ASSERT(Smi::IsValid(lib.index())); |
| 853 library_id_list.SetAt(i, Smi::Handle(Smi::New(lib.index()))); | 817 library_id_list.SetAt(i, Smi::Handle(Smi::New(lib.index()))); |
| 854 } | 818 } |
| 855 return Api::NewHandle(isolate, library_id_list.raw()); | 819 return Api::NewHandle(I, library_id_list.raw()); |
| 856 } | 820 } |
| 857 | 821 |
| 858 | 822 |
| 859 DART_EXPORT Dart_Handle Dart_GetLibraryFromId(intptr_t library_id) { | 823 DART_EXPORT Dart_Handle Dart_GetLibraryFromId(intptr_t library_id) { |
| 860 Isolate* isolate = Isolate::Current(); | 824 DARTSCOPE(Thread::Current()); |
| 861 ASSERT(isolate != NULL); | 825 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
| 862 DARTSCOPE(isolate); | |
| 863 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | |
| 864 if (lib.IsNull()) { | 826 if (lib.IsNull()) { |
| 865 return Api::NewError("%s: %" Pd " is not a valid library id", | 827 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 866 CURRENT_FUNC, library_id); | 828 CURRENT_FUNC, library_id); |
| 867 } | 829 } |
| 868 return Api::NewHandle(isolate, lib.raw()); | 830 return Api::NewHandle(I, lib.raw()); |
| 869 } | 831 } |
| 870 | 832 |
| 871 | 833 |
| 872 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, | 834 DART_EXPORT Dart_Handle Dart_LibraryId(Dart_Handle library, |
| 873 intptr_t* library_id) { | 835 intptr_t* library_id) { |
| 874 Isolate* isolate = Isolate::Current(); | 836 DARTSCOPE(Thread::Current()); |
| 875 DARTSCOPE(isolate); | 837 const Library& lib = Api::UnwrapLibraryHandle(I, library); |
| 876 const Library& lib = Api::UnwrapLibraryHandle(isolate, library); | |
| 877 if (lib.IsNull()) { | 838 if (lib.IsNull()) { |
| 878 RETURN_TYPE_ERROR(isolate, library, Library); | 839 RETURN_TYPE_ERROR(I, library, Library); |
| 879 } | 840 } |
| 880 if (library_id == NULL) { | 841 if (library_id == NULL) { |
| 881 RETURN_NULL_ERROR(library_id); | 842 RETURN_NULL_ERROR(library_id); |
| 882 } | 843 } |
| 883 *library_id = lib.index(); | 844 *library_id = lib.index(); |
| 884 return Api::Success(); | 845 return Api::Success(); |
| 885 } | 846 } |
| 886 | 847 |
| 887 | 848 |
| 888 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { | 849 DART_EXPORT Dart_Handle Dart_GetLibraryImports(intptr_t library_id) { |
| 889 Isolate* isolate = Isolate::Current(); | 850 DARTSCOPE(Thread::Current()); |
| 890 ASSERT(isolate != NULL); | |
| 891 DARTSCOPE(isolate); | |
| 892 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 851 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 893 if (lib.IsNull()) { | 852 if (lib.IsNull()) { |
| 894 return Api::NewError("%s: %" Pd " is not a valid library id", | 853 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 895 CURRENT_FUNC, library_id); | 854 CURRENT_FUNC, library_id); |
| 896 } | 855 } |
| 897 const GrowableObjectArray& import_list = | 856 const GrowableObjectArray& import_list = |
| 898 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); | 857 GrowableObjectArray::Handle(GrowableObjectArray::New(8)); |
| 899 | 858 |
| 900 String& prefix_name = String::Handle(isolate); | 859 String& prefix_name = String::Handle(Z); |
| 901 Library& imported = Library::Handle(isolate); | 860 Library& imported = Library::Handle(Z); |
| 902 intptr_t num_imports = lib.num_imports(); | 861 intptr_t num_imports = lib.num_imports(); |
| 903 for (int i = 0; i < num_imports; i++) { | 862 for (int i = 0; i < num_imports; i++) { |
| 904 import_list.Add(prefix_name); // Null prefix name means no prefix. | 863 import_list.Add(prefix_name); // Null prefix name means no prefix. |
| 905 imported = lib.ImportLibraryAt(i); | 864 imported = lib.ImportLibraryAt(i); |
| 906 ASSERT(!imported.IsNull()); | 865 ASSERT(!imported.IsNull()); |
| 907 ASSERT(Smi::IsValid(imported.index())); | 866 ASSERT(Smi::IsValid(imported.index())); |
| 908 import_list.Add(Smi::Handle(Smi::New(imported.index()))); | 867 import_list.Add(Smi::Handle(Z, Smi::New(imported.index()))); |
| 909 } | 868 } |
| 910 LibraryPrefixIterator it(lib); | 869 LibraryPrefixIterator it(lib); |
| 911 LibraryPrefix& prefix = LibraryPrefix::Handle(isolate); | 870 LibraryPrefix& prefix = LibraryPrefix::Handle(Z); |
| 912 while (it.HasNext()) { | 871 while (it.HasNext()) { |
| 913 prefix = it.GetNext(); | 872 prefix = it.GetNext(); |
| 914 prefix_name = prefix.name(); | 873 prefix_name = prefix.name(); |
| 915 ASSERT(!prefix_name.IsNull()); | 874 ASSERT(!prefix_name.IsNull()); |
| 916 prefix_name = String::Concat(prefix_name, Symbols::Dot()); | 875 prefix_name = String::Concat(prefix_name, Symbols::Dot()); |
| 917 for (int32_t i = 0; i < prefix.num_imports(); i++) { | 876 for (int32_t i = 0; i < prefix.num_imports(); i++) { |
| 918 imported = prefix.GetLibrary(i); | 877 imported = prefix.GetLibrary(i); |
| 919 import_list.Add(prefix_name); | 878 import_list.Add(prefix_name); |
| 920 import_list.Add(Smi::Handle(Smi::New(imported.index()))); | 879 import_list.Add(Smi::Handle(Smi::New(imported.index()))); |
| 921 } | 880 } |
| 922 } | 881 } |
| 923 return Api::NewHandle(isolate, Array::MakeArray(import_list)); | 882 return Api::NewHandle(I, Array::MakeArray(import_list)); |
| 924 } | 883 } |
| 925 | 884 |
| 926 | 885 |
| 927 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id) { | 886 DART_EXPORT Dart_Handle Dart_GetLibraryURL(intptr_t library_id) { |
| 928 Isolate* isolate = Isolate::Current(); | 887 DARTSCOPE(Thread::Current()); |
| 929 ASSERT(isolate != NULL); | 888 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
| 930 DARTSCOPE(isolate); | |
| 931 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | |
| 932 if (lib.IsNull()) { | 889 if (lib.IsNull()) { |
| 933 return Api::NewError("%s: %" Pd " is not a valid library id", | 890 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 934 CURRENT_FUNC, library_id); | 891 CURRENT_FUNC, library_id); |
| 935 } | 892 } |
| 936 return Api::NewHandle(isolate, lib.url()); | 893 return Api::NewHandle(I, lib.url()); |
| 937 } | 894 } |
| 938 | 895 |
| 939 | 896 |
| 940 DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id, | 897 DART_EXPORT Dart_Handle Dart_GetLibraryDebuggable(intptr_t library_id, |
| 941 bool* is_debuggable) { | 898 bool* is_debuggable) { |
| 942 Isolate* isolate = Isolate::Current(); | 899 DARTSCOPE(Thread::Current()); |
| 943 ASSERT(isolate != NULL); | |
| 944 DARTSCOPE(isolate); | |
| 945 CHECK_NOT_NULL(is_debuggable); | 900 CHECK_NOT_NULL(is_debuggable); |
| 946 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | 901 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); |
| 947 if (lib.IsNull()) { | 902 if (lib.IsNull()) { |
| 948 return Api::NewError("%s: %" Pd " is not a valid library id", | 903 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 949 CURRENT_FUNC, library_id); | 904 CURRENT_FUNC, library_id); |
| 950 } | 905 } |
| 951 *is_debuggable = lib.IsDebuggable(); | 906 *is_debuggable = lib.IsDebuggable(); |
| 952 return Api::Success(); | 907 return Api::Success(); |
| 953 } | 908 } |
| 954 | 909 |
| 955 | 910 |
| 956 DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id, | 911 DART_EXPORT Dart_Handle Dart_SetLibraryDebuggable(intptr_t library_id, |
| 957 bool is_debuggable) { | 912 bool is_debuggable) { |
| 958 Isolate* isolate = Isolate::Current(); | 913 DARTSCOPE(Thread::Current()); |
| 959 ASSERT(isolate != NULL); | 914 const Library& lib = Library::Handle(Z, Library::GetLibrary(library_id)); |
| 960 DARTSCOPE(isolate); | |
| 961 const Library& lib = Library::Handle(Library::GetLibrary(library_id)); | |
| 962 if (lib.IsNull()) { | 915 if (lib.IsNull()) { |
| 963 return Api::NewError("%s: %" Pd " is not a valid library id", | 916 return Api::NewError("%s: %" Pd " is not a valid library id", |
| 964 CURRENT_FUNC, library_id); | 917 CURRENT_FUNC, library_id); |
| 965 } | 918 } |
| 966 lib.set_debuggable(is_debuggable); | 919 lib.set_debuggable(is_debuggable); |
| 967 return Api::Success(); | 920 return Api::Success(); |
| 968 } | 921 } |
| 969 | 922 |
| 970 | 923 |
| 971 DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) { | 924 DART_EXPORT Dart_Isolate Dart_GetIsolate(Dart_IsolateId isolate_id) { |
| 972 Isolate* isolate = PortMap::GetIsolate(isolate_id); | 925 Isolate* isolate = PortMap::GetIsolate(isolate_id); |
| 973 return Api::CastIsolate(isolate); | 926 return Api::CastIsolate(isolate); |
| 974 } | 927 } |
| 975 | 928 |
| 976 | 929 |
| 977 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { | 930 DART_EXPORT Dart_IsolateId Dart_GetIsolateId(Dart_Isolate dart_isolate) { |
| 978 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); | 931 Isolate* isolate = reinterpret_cast<Isolate*>(dart_isolate); |
| 979 return isolate->debugger()->GetIsolateId(); | 932 return isolate->debugger()->GetIsolateId(); |
| 980 } | 933 } |
| 981 | 934 |
| 982 } // namespace dart | 935 } // namespace dart |
| OLD | NEW |