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

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

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

Powered by Google App Engine
This is Rietveld 408576698