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

Side by Side Diff: Source/bindings/dart/DartHandleProxy.cpp

Issue 21916002: Fix crashing bugs when dart code executed inside the debugger triggers breakpoints (Closed) Base URL: svn://svn.chromium.org/multivm/trunk/webkit
Patch Set: Ready to review Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/dart/DartDebugServer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 static v8::Local<v8::FunctionTemplate> libraryProxyTemplate(); 52 static v8::Local<v8::FunctionTemplate> libraryProxyTemplate();
53 static v8::Local<v8::FunctionTemplate> typeProxyTemplate(Dart_Handle type); 53 static v8::Local<v8::FunctionTemplate> typeProxyTemplate(Dart_Handle type);
54 static v8::Local<v8::FunctionTemplate> frameProxyTemplate(); 54 static v8::Local<v8::FunctionTemplate> frameProxyTemplate();
55 55
56 DartScriptValue* readPointerFromProxy(v8::Handle<v8::Value> proxy) 56 DartScriptValue* readPointerFromProxy(v8::Handle<v8::Value> proxy)
57 { 57 {
58 void* pointer = proxy.As<v8::Object>()->GetAlignedPointerFromInternalField(0 ); 58 void* pointer = proxy.As<v8::Object>()->GetAlignedPointerFromInternalField(0 );
59 return static_cast<DartScriptValue*>(pointer); 59 return static_cast<DartScriptValue*>(pointer);
60 } 60 }
61 61
62 /**
63 * Helper class to manage all scopes that must be entered to safely invoke Dart
64 * code.
65 */
66 class DartScopes {
67 private:
68 DartScriptValue* scriptValue;
69 DartIsolateScope scope;
70 DartApiScope apiScope;
71 Dart_ExceptionPauseInfo previousPauseInfo;
72
73 public:
74 Dart_Handle handle;
75
76 DartScopes(v8::Local<v8::Object> v8Handle) :
77 scriptValue(readPointerFromProxy(v8Handle)),
78 scope(scriptValue->isolate())
79 {
80 ASSERT(scriptValue->isIsolateAlive());
81 handle = Dart_HandleFromPersistent(scriptValue->value());
82 previousPauseInfo = Dart_GetExceptionPauseInfo();
83 // FIXME: it is not clear this is the right long term solution but for
84 // now we prevent pausing on exceptions when executing Dart code to
85 // avoid crashing when handling an exception triggers an exception.
86 Dart_SetExceptionPauseInfo(kNoPauseOnExceptions);
87 }
88
89 ~DartScopes()
90 {
91 Dart_SetExceptionPauseInfo(previousPauseInfo);
92 }
93 };
94
62 static void weakCallback(v8::Isolate* isolate, v8::Persistent<v8::Object>* proxy , DartScriptValue* value) 95 static void weakCallback(v8::Isolate* isolate, v8::Persistent<v8::Object>* proxy , DartScriptValue* value)
63 { 96 {
64 delete value; 97 delete value;
65 proxy->Dispose(isolate); 98 proxy->Dispose(isolate);
66 } 99 }
67 100
68 static Dart_Handle unwrapValue(v8::Handle<v8::Value> value) 101 static Dart_Handle unwrapValue(v8::Handle<v8::Value> value)
69 { 102 {
70 if (DartHandleProxy::isDartProxy(value)) 103 if (DartHandleProxy::isDartProxy(value))
71 return Dart_HandleFromPersistent(readPointerFromProxy(value)->value()); 104 return Dart_HandleFromPersistent(readPointerFromProxy(value)->value());
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 Dart_Handle exception = 0; 161 Dart_Handle exception = 0;
129 bool ret = DartUtilities::dartToBool(DartUtilities::invokeUtilsMethod("isNod e", 1, &type), exception); 162 bool ret = DartUtilities::dartToBool(DartUtilities::invokeUtilsMethod("isNod e", 1, &type), exception);
130 ASSERT(!exception); 163 ASSERT(!exception);
131 if (!ret) 164 if (!ret)
132 return false; 165 return false;
133 if (!DartNode::toNative(type, exception)) 166 if (!DartNode::toNative(type, exception))
134 return false; 167 return false;
135 return true; 168 return true;
136 } 169 }
137 170
171 bool isNoSuchMethodError(Dart_Handle type)
172 {
173 Dart_Handle exception = 0;
174 bool ret = DartUtilities::dartToBool(DartUtilities::invokeUtilsMethod("isNoS uchMethodError", 1, &type), exception);
175 ASSERT(!exception);
176 return ret;
177 }
178
138 Dart_Handle createLocalVariablesMap(Dart_Handle localVariablesList) 179 Dart_Handle createLocalVariablesMap(Dart_Handle localVariablesList)
139 { 180 {
140 return DartUtilities::invokeUtilsMethod("createLocalVariablesMap", 1, &local VariablesList); 181 return DartUtilities::invokeUtilsMethod("createLocalVariablesMap", 1, &local VariablesList);
141 } 182 }
142 183
143 Dart_Handle getMapKeyList(Dart_Handle localVariablesMap) 184 Dart_Handle getMapKeyList(Dart_Handle localVariablesMap)
144 { 185 {
145 return DartUtilities::invokeUtilsMethod("getMapKeyList", 1, &localVariablesM ap); 186 return DartUtilities::invokeUtilsMethod("getMapKeyList", 1, &localVariablesM ap);
146 } 187 }
147 188
148 bool mapContainsKey(Dart_Handle map, Dart_Handle key) 189 bool mapContainsKey(Dart_Handle map, Dart_Handle key)
149 { 190 {
150 Dart_Handle exception = 0; 191 Dart_Handle exception = 0;
151 return DartUtilities::dartToBool(Dart_Invoke(map, Dart_NewStringFromCString( "containsKey"), 1, &key), exception); 192 return DartUtilities::dartToBool(Dart_Invoke(map, Dart_NewStringFromCString( "containsKey"), 1, &key), exception);
152 } 193 }
153 194
154 void addFunctionNames(Dart_Handle handle, v8::Local<v8::Array>& properties, intp tr_t* count, bool isInstance, bool noMethods) 195 void addFunctionNames(Dart_Handle handle, v8::Local<v8::Array>& properties, intp tr_t* count, bool isInstance, bool noMethods)
155 { 196 {
156 intptr_t length = 0; 197 intptr_t length = 0;
157 Dart_Handle functionNames = Dart_GetFunctionNames(handle); 198 Dart_Handle functionNames = Dart_GetFunctionNames(handle);
158 ASSERT(!Dart_IsError(functionNames)); 199 ASSERT(!Dart_IsError(functionNames));
159 bool isLibrary = Dart_IsLibrary(handle); 200 bool isLibrary = Dart_IsLibrary(handle);
160 Dart_ListLength(functionNames, &length); 201 Dart_ListLength(functionNames, &length);
161 for (intptr_t i = 0; i < length; i++) { 202 for (intptr_t i = 0; i < length; i++) {
162 Dart_Handle functionName = Dart_ListGetAt(functionNames, i); 203 Dart_Handle functionName = Dart_ListGetAt(functionNames, i);
163 Dart_Handle function = Dart_LookupFunction(handle, functionName); 204 Dart_Handle function = Dart_LookupFunction(handle, functionName);
205
206 // FIXME: the DartVM doesn't correctly handle invoking properties with
207 // private names. For now, skip private function names.
208 intptr_t functionNameLength = 0;
209 uint8_t* functionNameData;
210 Dart_StringToUTF8(functionName, &functionNameData, &functionNameLength);
211 if (functionNameLength > 0 && functionNameData[0] == '_')
212 continue;
213
164 bool isStatic = false; 214 bool isStatic = false;
165 Dart_FunctionIsStatic(function, &isStatic); 215 Dart_FunctionIsStatic(function, &isStatic);
166 216
167 bool isConstructor = false; 217 bool isConstructor = false;
168 Dart_FunctionIsConstructor(function, &isConstructor); 218 Dart_FunctionIsConstructor(function, &isConstructor);
169 219
170 if (!isLibrary) { 220 if (!isLibrary) {
171 if (isInstance == (isStatic || isConstructor)) 221 if (isInstance == (isStatic || isConstructor))
172 continue; 222 continue;
173 223
174 bool isSetter = false; 224 bool isSetter = false;
175 Dart_FunctionIsSetter(function, &isSetter); 225 Dart_FunctionIsSetter(function, &isSetter);
176 bool isGetter = false; 226 bool isGetter = false;
177 Dart_FunctionIsGetter(function, &isGetter); 227 Dart_FunctionIsGetter(function, &isGetter);
178 228
179 if (noMethods && !isSetter && !isGetter) 229 if (noMethods && !isSetter && !isGetter)
180 continue; 230 continue;
231
232 // Skip setters as any setter we care to enumerate should have a mat ching getter.
233 // Setters without matching getters will still be callable but won't be enumerated.
234 if (isSetter)
235 continue;
181 } 236 }
182 237
183 // Strip off the leading typename from constructor name. 238 // Strip off the leading typename from constructor name.
184 if (isConstructor) 239 if (isConstructor)
185 functionName = stripClassName(functionName, Dart_ClassName(handle)); 240 functionName = stripClassName(functionName, Dart_ClassName(handle));
186 241
187 properties->Set(*count, V8Converter::stringToV8(functionName)); 242 properties->Set(*count, V8Converter::stringToV8(functionName));
188 *count = *count + 1; 243 *count = *count + 1;
189 } 244 }
190 } 245 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 Dart_Handle getLibraryPrefix(v8::Local<v8::Object> proxy) 303 Dart_Handle getLibraryPrefix(v8::Local<v8::Object> proxy)
249 { 304 {
250 v8::Local<v8::Value> prefix = proxy.As<v8::Object>()->GetHiddenValue(v8::Str ing::NewSymbol("prefix")); 305 v8::Local<v8::Value> prefix = proxy.As<v8::Object>()->GetHiddenValue(v8::Str ing::NewSymbol("prefix"));
251 if (*prefix && prefix->IsString()) 306 if (*prefix && prefix->IsString())
252 return V8Converter::stringToDart(prefix); 307 return V8Converter::stringToDart(prefix);
253 return Dart_Null(); 308 return Dart_Null();
254 } 309 }
255 310
256 static v8::Handle<v8::Value> functionNamedPropertyGetter(v8::Local<v8::String> n ame, const v8::AccessorInfo& info) 311 static v8::Handle<v8::Value> functionNamedPropertyGetter(v8::Local<v8::String> n ame, const v8::AccessorInfo& info)
257 { 312 {
258 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 313 DartScopes scopes(info.Holder());
259 ASSERT(scriptValue->isIsolateAlive()); 314 Dart_Handle handle = scopes.handle;
260 DartIsolateScope scope(scriptValue->isolate());
261 DartApiScope apiScope;
262 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
263 315
264 Dart_Handle ret; 316 Dart_Handle ret;
265 ASSERT(Dart_IsFunction(handle) || Dart_IsClosure(handle)); 317 ASSERT(Dart_IsFunction(handle) || Dart_IsClosure(handle));
266 318
267 ret = Dart_Invoke(handle, V8Converter::stringToDart(v8::String::Concat(v8::S tring::New("get:"), name)), 0, 0); 319 ret = Dart_Invoke(handle, V8Converter::stringToDart(v8::String::Concat(v8::S tring::New("get:"), name)), 0, 0);
268 if (Dart_IsError(ret) && name->Equals(v8::String::NewSymbol("__proto__"))) 320 if (Dart_IsError(ret) && name->Equals(v8::String::NewSymbol("__proto__")))
269 return v8::Undefined(); 321 return v8::Undefined();
270 322
271 return convertResult(ret); 323 return convertResult(ret);
272 } 324 }
273 325
274 static v8::Handle<v8::Value> functionNamedPropertySetter(v8::Local<v8::String> p roperty, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 326 static v8::Handle<v8::Value> functionNamedPropertySetter(v8::Local<v8::String> p roperty, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
275 { 327 {
276 return throwError(v8ReferenceError, "Dart functions do not have writeable pr operties", v8::Isolate::GetCurrent()); 328 return throwError(v8ReferenceError, "Dart functions do not have writeable pr operties", v8::Isolate::GetCurrent());
277 } 329 }
278 330
279 static v8::Handle<v8::Value> functionInvocationCallback(v8::Arguments const& arg s) 331 static v8::Handle<v8::Value> functionInvocationCallback(v8::Arguments const& arg s)
280 { 332 {
281 DartScriptValue* scriptValue = readPointerFromProxy(args.Holder()); 333 DartScopes scopes(args.Holder());
282 ASSERT(scriptValue->isIsolateAlive()); 334 Dart_Handle handle = scopes.handle;
283 DartIsolateScope scope(scriptValue->isolate());
284 DartApiScope apiScope;
285 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
286 335
287 ASSERT(Dart_IsFunction(handle) || Dart_IsClosure(handle)); 336 ASSERT(Dart_IsFunction(handle) || Dart_IsClosure(handle));
288 bool isConstructor = false; 337 bool isConstructor = false;
289 Dart_FunctionIsConstructor(handle, &isConstructor); 338 Dart_FunctionIsConstructor(handle, &isConstructor);
290 if (args.IsConstructCall() != isConstructor) { 339 if (args.IsConstructCall() != isConstructor) {
291 return throwError(v8ReferenceError, 340 return throwError(v8ReferenceError,
292 isConstructor ? "Constructor called without new" : "Regular function called as constructor", 341 isConstructor ? "Constructor called without new" : "Regular function called as constructor",
293 v8::Isolate::GetCurrent()); 342 v8::Isolate::GetCurrent());
294 } 343 }
295 344
296 Vector<Dart_Handle> dartFunctionArgs; 345 Vector<Dart_Handle> dartFunctionArgs;
297 for (uint32_t i = 0; i < args.Length(); ++i) 346 for (uint32_t i = 0; i < args.Length(); ++i)
298 dartFunctionArgs.append(unwrapValue(args[i])); 347 dartFunctionArgs.append(unwrapValue(args[i]));
299 348
300 if (Dart_IsClosure(handle)) 349 if (Dart_IsClosure(handle))
301 return convertResult(Dart_InvokeClosure(handle, dartFunctionArgs.size(), dartFunctionArgs.data())); 350 return convertResult(Dart_InvokeClosure(handle, dartFunctionArgs.size(), dartFunctionArgs.data()));
302 Dart_Handle type = Dart_FunctionOwner(handle); 351 Dart_Handle type = Dart_FunctionOwner(handle);
303 if (isConstructor) 352 if (isConstructor)
304 // FIXME: this seems like an overly complex way to have to invoke a cons tructor. 353 // FIXME: this seems like an overly complex way to have to invoke a cons tructor.
305 return convertResult( 354 return convertResult(
306 Dart_New(type, stripClassName(Dart_FunctionName(handle), Dart_ClassN ame(type)), 355 Dart_New(type, stripClassName(Dart_FunctionName(handle), Dart_ClassN ame(type)),
307 dartFunctionArgs.size(), dartFunctionArgs.data())); 356 dartFunctionArgs.size(), dartFunctionArgs.data()));
308 else 357 else
309 return convertResult( 358 return convertResult(
310 Dart_Invoke(type, Dart_FunctionName(handle), dartFunctionArgs.size() , dartFunctionArgs.data())); 359 Dart_Invoke(type, Dart_FunctionName(handle), dartFunctionArgs.size() , dartFunctionArgs.data()));
311 } 360 }
312 361
313 static v8::Handle<v8::Value> typeProxyConstructorInvocationCallback(v8::Argument s const& args) 362 static v8::Handle<v8::Value> typeProxyConstructorInvocationCallback(v8::Argument s const& args)
314 { 363 {
315 DartScriptValue* scriptValue = readPointerFromProxy(args.Holder()); 364 DartScopes scopes(args.Holder());
316 ASSERT(scriptValue->isIsolateAlive()); 365 Dart_Handle handle = scopes.handle;
317 DartIsolateScope scope(scriptValue->isolate());
318 DartApiScope apiScope;
319 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
320 366
321 ASSERT(Dart_IsType(handle)); 367 ASSERT(Dart_IsType(handle));
322 368
323 if (!args.IsConstructCall()) 369 if (!args.IsConstructCall())
324 return throwError(v8SyntaxError, "Constructors can only be invoked with 'new'", v8::Isolate::GetCurrent()); 370 return throwError(v8SyntaxError, "Constructors can only be invoked with 'new'", v8::Isolate::GetCurrent());
325 371
326 Vector<Dart_Handle> dartFunctionArgs; 372 Vector<Dart_Handle> dartFunctionArgs;
327 for (uint32_t i = 0; i < args.Length(); ++i) 373 for (uint32_t i = 0; i < args.Length(); ++i)
328 dartFunctionArgs.append(unwrapValue(args[i])); 374 dartFunctionArgs.append(unwrapValue(args[i]));
329 375
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
378 if (!Dart_IsNull(ret) && !Dart_IsError(ret)) { 424 if (!Dart_IsNull(ret) && !Dart_IsError(ret)) {
379 *handled = true; 425 *handled = true;
380 return convertResult(ret); 426 return convertResult(ret);
381 } 427 }
382 return v8::Undefined(); 428 return v8::Undefined();
383 } 429 }
384 430
385 static v8::Handle<v8::Value> libraryNamedPropertyGetterHelper(v8::Local<v8::Stri ng> name, 431 static v8::Handle<v8::Value> libraryNamedPropertyGetterHelper(v8::Local<v8::Stri ng> name,
386 const v8::AccessorInfo& info, bool* handled) 432 const v8::AccessorInfo& info, bool* handled)
387 { 433 {
388 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 434 DartScopes scopes(info.Holder());
389 ASSERT(scriptValue->isIsolateAlive()); 435 Dart_Handle handle = scopes.handle;
390 DartIsolateScope scope(scriptValue->isolate());
391 DartApiScope apiScope;
392 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
393 436
394 Dart_Handle ret; 437 Dart_Handle ret;
395 ASSERT(Dart_IsLibrary(handle)); 438 ASSERT(Dart_IsLibrary(handle));
396 intptr_t libraryId = getLibraryId(info.Holder()); 439 intptr_t libraryId = getLibraryId(info.Holder());
397 Dart_Handle dartName = V8Converter::stringToDart(name); 440 Dart_Handle dartName = V8Converter::stringToDart(name);
398 Dart_Handle prefix = getLibraryPrefix(info.Holder()); 441 Dart_Handle prefix = getLibraryPrefix(info.Holder());
399 bool hasLibraryPrefix = !Dart_IsNull(prefix) && Dart_IsString(prefix); 442 bool hasLibraryPrefix = !Dart_IsNull(prefix) && Dart_IsString(prefix);
400 443
401 if (hasLibraryPrefix) { 444 if (hasLibraryPrefix) {
402 Vector<std::pair<Dart_Handle, intptr_t> > libraries; 445 Vector<std::pair<Dart_Handle, intptr_t> > libraries;
(...skipping 23 matching lines...) Expand all
426 } 469 }
427 return v8::Undefined(); 470 return v8::Undefined();
428 } 471 }
429 472
430 static v8::Handle<v8::Value> libraryNamedPropertyGetter(v8::Local<v8::String> na me, const v8::AccessorInfo& info) 473 static v8::Handle<v8::Value> libraryNamedPropertyGetter(v8::Local<v8::String> na me, const v8::AccessorInfo& info)
431 { 474 {
432 bool handled = false; 475 bool handled = false;
433 v8::Handle<v8::Value> ret = libraryNamedPropertyGetterHelper(name, info, &ha ndled); 476 v8::Handle<v8::Value> ret = libraryNamedPropertyGetterHelper(name, info, &ha ndled);
434 if (handled) 477 if (handled)
435 return ret; 478 return ret;
436 return v8::ThrowException(v8::Exception::ReferenceError(v8::String::Concat(n ame, v8::String::New(" is not defined")))); 479 return v8::Undefined();
437 } 480 }
438 481
439 // FIXME: we need to handle prefixes when setting library properties as well 482 // FIXME: we need to handle prefixes when setting library properties as well
440 // for completness. Postponing implementing this for now as we hope Dart_Invoke 483 // for completness. Postponing implementing this for now as we hope Dart_Invoke
441 // can just be fixed to handle libraries correctly. 484 // can just be fixed to handle libraries correctly.
442 static v8::Handle<v8::Value> libraryNamedPropertySetter(v8::Local<v8::String> pr operty, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 485 static v8::Handle<v8::Value> libraryNamedPropertySetter(v8::Local<v8::String> pr operty, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
443 { 486 {
444 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 487 DartScopes scopes(info.Holder());
445 ASSERT(scriptValue->isIsolateAlive()); 488 Dart_Handle handle = scopes.handle;
446 DartIsolateScope scope(scriptValue->isolate());
447 DartApiScope apiScope;
448 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
449 489
450 Dart_Handle ret; 490 Dart_Handle ret;
451 ASSERT(Dart_IsLibrary(handle)); 491 ASSERT(Dart_IsLibrary(handle));
452 Dart_Handle dartValue = unwrapValue(value); 492 Dart_Handle dartValue = unwrapValue(value);
453 ret = Dart_SetField(handle, V8Converter::stringToDart(property), dartValue); 493 ret = Dart_SetField(handle, V8Converter::stringToDart(property), dartValue);
454 return convertResult(ret); 494 return convertResult(ret);
455 } 495 }
456 496
457 static v8::Handle<v8::Integer> libraryQueryProperty(v8::Local<v8::String> name, const v8::AccessorInfo& info) 497 static v8::Handle<v8::Integer> libraryQueryProperty(v8::Local<v8::String> name, const v8::AccessorInfo& info)
458 { 498 {
459 bool handled = false; 499 bool handled = false;
460 libraryNamedPropertyGetterHelper(name, info, &handled); 500 libraryNamedPropertyGetterHelper(name, info, &handled);
461 return handled ? v8::Integer::New(0, info.GetIsolate()) : v8::Handle<v8::Int eger>(); 501 return handled ? v8::Integer::New(0, info.GetIsolate()) : v8::Handle<v8::Int eger>();
462 } 502 }
463 503
464 void libraryEnumerateHelper(Dart_Handle library, intptr_t libraryId, v8::Local<v 8::Array> properties, intptr_t* count) 504 void libraryEnumerateHelper(Dart_Handle library, intptr_t libraryId, v8::Local<v 8::Array> properties, intptr_t* count)
465 { 505 {
466 addFunctionNames(library, properties, count, false, false); 506 addFunctionNames(library, properties, count, false, false);
467 addClassNames(library, properties, count); 507 addClassNames(library, properties, count);
468 addFieldNames(Dart_GetLibraryFields(libraryId), properties, count); 508 addFieldNames(Dart_GetLibraryFields(libraryId), properties, count);
469 } 509 }
470 510
471 static v8::Handle<v8::Array> libraryPropertyEnumerator(const v8::AccessorInfo& i nfo) 511 static v8::Handle<v8::Array> libraryPropertyEnumerator(const v8::AccessorInfo& i nfo)
472 { 512 {
473 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 513 DartScopes scopes(info.Holder());
474 ASSERT(scriptValue->isIsolateAlive()); 514 Dart_Handle handle = scopes.handle;
475 DartIsolateScope scope(scriptValue->isolate());
476 DartApiScope apiScope;
477 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
478 515
479 intptr_t libraryId = getLibraryId(info.Holder()); 516 intptr_t libraryId = getLibraryId(info.Holder());
480 ASSERT(Dart_IsLibrary(handle)); 517 ASSERT(Dart_IsLibrary(handle));
481 v8::Local<v8::Array> cachedProperties = info.Holder().As<v8::Object>()->GetH iddenValue(v8::String::NewSymbol("cache")).As<v8::Array>(); 518 v8::Local<v8::Array> cachedProperties = info.Holder().As<v8::Object>()->GetH iddenValue(v8::String::NewSymbol("cache")).As<v8::Array>();
482 if (*cachedProperties) 519 if (*cachedProperties)
483 return cachedProperties; 520 return cachedProperties;
484 521
485 Dart_Handle prefix = getLibraryPrefix(info.Holder()); 522 Dart_Handle prefix = getLibraryPrefix(info.Holder());
486 bool hasLibraryPrefix = Dart_IsString(prefix); 523 bool hasLibraryPrefix = Dart_IsString(prefix);
487 524
(...skipping 29 matching lines...) Expand all
517 554
518 bool isShowStatics(v8::Handle<v8::Value> value) 555 bool isShowStatics(v8::Handle<v8::Value> value)
519 { 556 {
520 v8::Local<v8::Value> showStatics = value.As<v8::Object>()->GetHiddenValue(v8 ::String::NewSymbol("showStatics")); 557 v8::Local<v8::Value> showStatics = value.As<v8::Object>()->GetHiddenValue(v8 ::String::NewSymbol("showStatics"));
521 ASSERT(*showStatics && showStatics->IsBoolean()); 558 ASSERT(*showStatics && showStatics->IsBoolean());
522 return showStatics->BooleanValue(); 559 return showStatics->BooleanValue();
523 } 560 }
524 561
525 static v8::Handle<v8::Value> typeNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info) 562 static v8::Handle<v8::Value> typeNamedPropertyGetter(v8::Local<v8::String> name, const v8::AccessorInfo& info)
526 { 563 {
527 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 564 DartScopes scopes(info.Holder());
528 ASSERT(scriptValue->isIsolateAlive()); 565 Dart_Handle handle = scopes.handle;
529 DartIsolateScope scope(scriptValue->isolate());
530 DartApiScope apiScope;
531 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
532 566
533 Dart_Handle ret; 567 Dart_Handle ret;
534 ASSERT(Dart_IsType(handle)); 568 ASSERT(Dart_IsType(handle));
535 569
536 if (name->Equals(v8::String::NewSymbol("__proto__"))) { 570 if (name->Equals(v8::String::NewSymbol("__proto__"))) {
537 // Due to Dart semantics, if we are showing statics, we need to 571 // Due to Dart semantics, if we are showing statics, we need to
538 // not link types up to their superclasses as statics in superclasses 572 // not link types up to their superclasses as statics in superclasses
539 // are not visible in subclasses. 573 // are not visible in subclasses.
540 if (isShowStatics(info.Holder())) 574 if (isShowStatics(info.Holder()))
541 return v8::Null(); 575 return v8::Null();
(...skipping 11 matching lines...) Expand all
553 ret = Dart_LookupFunction(handle, dartName); 587 ret = Dart_LookupFunction(handle, dartName);
554 if (!Dart_IsNull(ret) && !Dart_IsError(ret)) 588 if (!Dart_IsNull(ret) && !Dart_IsError(ret))
555 return convertResult(ret); 589 return convertResult(ret);
556 590
557 Dart_Handle typeName = Dart_ClassName(handle); 591 Dart_Handle typeName = Dart_ClassName(handle);
558 ASSERT(Dart_IsString(typeName)); 592 ASSERT(Dart_IsString(typeName));
559 Dart_Handle constructorName = buildConstructorName(typeName, V8Converter::st ringToDart(name)); 593 Dart_Handle constructorName = buildConstructorName(typeName, V8Converter::st ringToDart(name));
560 ret = Dart_LookupFunction(handle, constructorName); 594 ret = Dart_LookupFunction(handle, constructorName);
561 if (!Dart_IsNull(ret) && !Dart_IsError(ret)) 595 if (!Dart_IsNull(ret) && !Dart_IsError(ret))
562 return convertResult(ret); 596 return convertResult(ret);
563 597 return v8::Undefined();
564 return v8::ThrowException(v8::Exception::ReferenceError(v8::String::Concat(n ame, v8::String::New(" is not defined"))));
565 } 598 }
566 599
567 static v8::Handle<v8::Value> typeNamedPropertySetter(v8::Local<v8::String> prope rty, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 600 static v8::Handle<v8::Value> typeNamedPropertySetter(v8::Local<v8::String> prope rty, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
568 { 601 {
569 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 602 DartScopes scopes(info.Holder());
570 ASSERT(scriptValue->isIsolateAlive()); 603 Dart_Handle handle = scopes.handle;
571 DartIsolateScope scope(scriptValue->isolate());
572 DartApiScope apiScope;
573 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
574 604
575 Dart_Handle ret; 605 Dart_Handle ret;
576 ASSERT(Dart_IsType(handle)); 606 ASSERT(Dart_IsType(handle));
577 Dart_Handle dartValue = unwrapValue(value); 607 Dart_Handle dartValue = unwrapValue(value);
578 ret = Dart_Invoke(handle, V8Converter::stringToDart(v8::String::Concat(v8::S tring::New("set:"), property)), 1, &dartValue); 608 ret = Dart_Invoke(handle, V8Converter::stringToDart(v8::String::Concat(v8::S tring::New("set:"), property)), 1, &dartValue);
579 return convertResult(ret); 609 return convertResult(ret);
580 } 610 }
581 611
582 static v8::Handle<v8::Integer> typeQueryProperty(v8::Local<v8::String> name, con st v8::AccessorInfo& info) 612 static v8::Handle<v8::Integer> typeQueryProperty(v8::Local<v8::String> name, con st v8::AccessorInfo& info)
583 { 613 {
584 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 614 DartScopes scopes(info.Holder());
585 ASSERT(scriptValue->isIsolateAlive()); 615 Dart_Handle handle = scopes.handle;
586 DartIsolateScope scope(scriptValue->isolate());
587 DartApiScope apiScope;
588 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
589 616
590 Dart_Handle ret; 617 Dart_Handle ret;
591 ASSERT(Dart_IsType(handle)); 618 ASSERT(Dart_IsType(handle));
592 if (name->Equals(v8::String::NewSymbol("__proto__")) 619 if (name->Equals(v8::String::NewSymbol("__proto__"))
593 || typeHasMember(handle, V8Converter::stringToDart(name))) 620 || typeHasMember(handle, V8Converter::stringToDart(name)))
594 return v8::Integer::New(0, info.GetIsolate()); 621 return v8::Integer::New(0, info.GetIsolate());
595 return v8::Handle<v8::Integer>(); 622 return v8::Handle<v8::Integer>();
596 } 623 }
597 624
598 static v8::Handle<v8::Array> typePropertyEnumerator(const v8::AccessorInfo& info ) 625 static v8::Handle<v8::Array> typePropertyEnumerator(const v8::AccessorInfo& info )
599 { 626 {
600 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 627 DartScopes scopes(info.Holder());
601 ASSERT(scriptValue->isIsolateAlive()); 628 Dart_Handle handle = scopes.handle;
602 DartIsolateScope scope(scriptValue->isolate());
603 DartApiScope apiScope;
604 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
605 bool showStatics = isShowStatics(info.Holder()); 629 bool showStatics = isShowStatics(info.Holder());
606 630
607 ASSERT(Dart_IsType(handle)); 631 ASSERT(Dart_IsType(handle));
608 632
609 v8::Local<v8::Array> properties = v8::Array::New(); 633 v8::Local<v8::Array> properties = v8::Array::New();
610 intptr_t count = 0; 634 intptr_t count = 0;
611 addFunctionNames(handle, properties, &count, !showStatics, false); 635 addFunctionNames(handle, properties, &count, !showStatics, false);
612 if (showStatics) 636 if (showStatics)
613 addFieldNames(Dart_GetStaticFields(handle), properties, &count); 637 addFieldNames(Dart_GetStaticFields(handle), properties, &count);
614 638
615 return properties; 639 return properties;
616 } 640 }
617 641
618 static v8::Handle<v8::Value> frameNamedPropertyGetter(v8::Local<v8::String> name , const v8::AccessorInfo& info) 642 static v8::Handle<v8::Value> frameNamedPropertyGetter(v8::Local<v8::String> name , const v8::AccessorInfo& info)
619 { 643 {
620 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 644 DartScopes scopes(info.Holder());
621 ASSERT(scriptValue->isIsolateAlive()); 645 Dart_Handle handle = scopes.handle;
622 DartIsolateScope scope(scriptValue->isolate());
623 DartApiScope apiScope;
624 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
625 646
626 Dart_Handle dartName = dartName; 647 Dart_Handle dartName = dartName;
627 if (mapContainsKey(handle, V8Converter::stringToDart(name))) { 648 if (mapContainsKey(handle, V8Converter::stringToDart(name))) {
628 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
629 Dart_Handle indexedGetterOperator = Dart_NewStringFromCString("[]"); 649 Dart_Handle indexedGetterOperator = Dart_NewStringFromCString("[]");
630 Dart_Handle dartName = V8Converter::stringToDart(name); 650 Dart_Handle dartName = V8Converter::stringToDart(name);
631 return convertResult(Dart_Invoke(handle, indexedGetterOperator, 1, &dart Name)); 651 return convertResult(Dart_Invoke(handle, indexedGetterOperator, 1, &dart Name));
632 } 652 }
633 if (name->Equals(v8::String::NewSymbol("this"))) 653 return v8::Undefined();
634 return v8::Undefined();
635 return v8::ThrowException(v8::Exception::ReferenceError(v8::String::Concat(n ame, v8::String::New(" is not defined"))));
636 } 654 }
637 655
638 static v8::Handle<v8::Value> frameNamedPropertySetter(v8::Local<v8::String> prop erty, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 656 static v8::Handle<v8::Value> frameNamedPropertySetter(v8::Local<v8::String> prop erty, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
639 { 657 {
640 return throwError(v8ReferenceError, "Dart does not yet provide a debugger ap i for setting local fields", v8::Isolate::GetCurrent()); 658 return throwError(v8ReferenceError, "Dart does not yet provide a debugger ap i for setting local fields", v8::Isolate::GetCurrent());
641 } 659 }
642 660
643 static v8::Handle<v8::Integer> frameQueryProperty(v8::Local<v8::String> name, co nst v8::AccessorInfo& info) 661 static v8::Handle<v8::Integer> frameQueryProperty(v8::Local<v8::String> name, co nst v8::AccessorInfo& info)
644 { 662 {
645 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 663 DartScopes scopes(info.Holder());
646 ASSERT(scriptValue->isIsolateAlive());
647 DartIsolateScope scope(scriptValue->isolate());
648 DartApiScope apiScope;
649 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
650 664
651 return mapContainsKey(handle, V8Converter::stringToDart(name)) ? v8::Integer ::New(0, info.GetIsolate()) : v8::Handle<v8::Integer>(); 665 return mapContainsKey(scopes.handle, V8Converter::stringToDart(name)) ? v8:: Integer::New(0, info.GetIsolate()) : v8::Handle<v8::Integer>();
652 } 666 }
653 667
654 static v8::Handle<v8::Array> framePropertyEnumerator(const v8::AccessorInfo& inf o) 668 static v8::Handle<v8::Array> framePropertyEnumerator(const v8::AccessorInfo& inf o)
655 { 669 {
656 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 670 DartScopes scopes(info.Holder());
657 ASSERT(scriptValue->isIsolateAlive()); 671 Dart_Handle keyList = getMapKeyList(scopes.handle);
658 DartIsolateScope scope(scriptValue->isolate());
659 DartApiScope apiScope;
660 Dart_Handle keyList = getMapKeyList(Dart_HandleFromPersistent(scriptValue->v alue()));
661 ASSERT(!Dart_IsError(keyList)); 672 ASSERT(!Dart_IsError(keyList));
662 ASSERT(Dart_IsList(keyList)); 673 ASSERT(Dart_IsList(keyList));
663 674
664 intptr_t length = 0; 675 intptr_t length = 0;
665 Dart_ListLength(keyList, &length); 676 Dart_ListLength(keyList, &length);
666 v8::Local<v8::Array> properties = v8::Array::New(length); 677 v8::Local<v8::Array> properties = v8::Array::New(length);
667 for (intptr_t i = 0; i < length; i ++) 678 for (intptr_t i = 0; i < length; i ++)
668 properties->Set(i, V8Converter::stringToV8(Dart_ListGetAt(keyList, i))); 679 properties->Set(i, V8Converter::stringToV8(Dart_ListGetAt(keyList, i)));
669 return properties; 680 return properties;
670 } 681 }
671 682
672 static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String> name, con st v8::AccessorInfo& info) 683 static v8::Handle<v8::Value> namedPropertyGetter(v8::Local<v8::String> name, con st v8::AccessorInfo& info)
673 { 684 {
674 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 685 DartScopes scopes(info.Holder());
675 ASSERT(scriptValue->isIsolateAlive()); 686 Dart_Handle handle = scopes.handle;
676 DartIsolateScope scope(scriptValue->isolate());
677 DartApiScope apiScope;
678 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
679 687
680 ASSERT(Dart_IsInstance(handle)); 688 ASSERT(Dart_IsInstance(handle));
681 if (name->Equals(v8::String::NewSymbol("__proto__"))) 689 if (name->Equals(v8::String::NewSymbol("__proto__")))
682 return DartHandleProxy::createTypeProxy(Dart_InstanceGetType(handle), fa lse); 690 return DartHandleProxy::createTypeProxy(Dart_InstanceGetType(handle), fa lse);
683 691
684 v8::String::Utf8Value stringName(name); 692 v8::String::Utf8Value stringName(name);
685 const char* data = *stringName; 693 const char* data = *stringName;
686 if (data[0] == ':' || data[0] == '#') { 694 if (data[0] == ':' || data[0] == '#') {
687 // Look up a map key instead of a regular property as regular dart prope rty names 695 // Look up a map key instead of a regular property as regular dart prope rty names
688 // cannot start with these symbols. 696 // cannot start with these symbols.
689 return convertResult( 697 return convertResult(
690 lookupValueForEncodedMapKey(handle, V8Converter::stringToDart(name)) ); 698 lookupValueForEncodedMapKey(handle, V8Converter::stringToDart(name)) );
691 } 699 }
692 // Prefix for metadata used only by the Dart Editor debugger. 700 // Prefix for metadata used only by the Dart Editor debugger.
693 if (data[0] == '@') { 701 if (data[0] == '@') {
694 if (name->Equals(v8::String::New("@staticFields"))) 702 if (name->Equals(v8::String::New("@staticFields")))
695 return DartHandleProxy::createTypeProxy(Dart_InstanceGetType(handle) , true); 703 return DartHandleProxy::createTypeProxy(Dart_InstanceGetType(handle) , true);
696 } 704 }
697 705
698 return convertResult(Dart_Invoke(handle, V8Converter::stringToDart(v8::Strin g::Concat(v8::String::New("get:"), name)), 0, 0)); 706 Dart_Handle result = Dart_Invoke(handle, V8Converter::stringToDart(v8::Strin g::Concat(v8::String::New("get:"), name)), 0, 0);
707 if (Dart_IsError(result)) {
708 // To match JS conventions, we should just return undefined if a
709 // property does not exist rather than throwing.
710 if (Dart_ErrorHasException(result) && isNoSuchMethodError(Dart_ErrorGetE xception(result)))
711 return v8::Undefined();
712
713 return v8::ThrowException(v8::String::New(Dart_GetError(result)));
714 }
715 return DartHandleProxy::create(result);
699 } 716 }
700 717
701 static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 718 static v8::Handle<v8::Value> namedPropertySetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
702 { 719 {
703 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 720 DartScopes scopes(info.Holder());
704 ASSERT(scriptValue->isIsolateAlive()); 721 Dart_Handle handle = scopes.handle;
705 DartIsolateScope scope(scriptValue->isolate());
706 DartApiScope apiScope;
707 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
708 722
709 Dart_Handle dartValue = unwrapValue(value); 723 Dart_Handle dartValue = unwrapValue(value);
710 return convertResult(Dart_Invoke(handle, V8Converter::stringToDart(v8::Strin g::Concat(v8::String::New("set:"), property)), 1, &dartValue)); 724 return convertResult(Dart_Invoke(handle, V8Converter::stringToDart(v8::Strin g::Concat(v8::String::New("set:"), property)), 1, &dartValue));
711 } 725 }
712 726
713 static v8::Handle<v8::Integer> objectQueryProperty(v8::Local<v8::String> name, c onst v8::AccessorInfo& info) 727 static v8::Handle<v8::Integer> objectQueryProperty(v8::Local<v8::String> name, c onst v8::AccessorInfo& info)
714 { 728 {
715 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 729 DartScopes scopes(info.Holder());
716 ASSERT(scriptValue->isIsolateAlive()); 730 Dart_Handle handle = scopes.handle;
717 DartIsolateScope scope(scriptValue->isolate());
718 DartApiScope apiScope;
719 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
720 731
721 Dart_Handle ret; 732 Dart_Handle ret;
722 ASSERT(Dart_IsInstance(handle)); 733 ASSERT(Dart_IsInstance(handle));
723 v8::String::Utf8Value stringName(name); 734 v8::String::Utf8Value stringName(name);
724 const char* data = *stringName; 735 const char* data = *stringName;
725 736
726 // Looking up a map key instead of a regular property... as regular dart pro perty names 737 // Looking up a map key instead of a regular property... as regular dart pro perty names
727 // cannot start with these symbols. 738 // cannot start with these symbols.
728 if (data[0] == ':' || data[0] == '#') 739 if (data[0] == ':' || data[0] == '#')
729 return v8::Integer::New(v8::ReadOnly, info.GetIsolate()); 740 return v8::Integer::New(v8::ReadOnly, info.GetIsolate());
730 if (data[0] =='@') 741 if (data[0] == '@')
731 return v8::Integer::New(v8::DontEnum, info.GetIsolate()); 742 return v8::Integer::New(v8::DontEnum, info.GetIsolate());
732 743
733 ret = Dart_Invoke(handle, V8Converter::stringToDart(v8::String::Concat(v8::S tring::New("get:"), name)), 0, 0); 744 ret = Dart_Invoke(handle, V8Converter::stringToDart(v8::String::Concat(v8::S tring::New("get:"), name)), 0, 0);
734 if (Dart_IsError(ret)) { 745 if (Dart_IsError(ret)) {
735 if (name->Equals(v8::String::NewSymbol("__proto__"))) 746 if (name->Equals(v8::String::NewSymbol("__proto__")))
736 return v8::Integer::New(0, info.GetIsolate()); 747 return v8::Integer::New(0, info.GetIsolate());
737 return v8::Handle<v8::Integer>(); 748 return v8::Handle<v8::Integer>();
738 } 749 }
739 return v8::Integer::New(0, info.GetIsolate()); 750 return v8::Integer::New(0, info.GetIsolate());
740 } 751 }
741 752
742 static v8::Handle<v8::Array> objectPropertyEnumerator(const v8::AccessorInfo& in fo) 753 static v8::Handle<v8::Array> objectPropertyEnumerator(const v8::AccessorInfo& in fo)
743 { 754 {
744 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 755 DartScopes scopes(info.Holder());
745 ASSERT(scriptValue->isIsolateAlive()); 756 Dart_Handle handle = scopes.handle;
746 DartIsolateScope scope(scriptValue->isolate());
747 DartApiScope apiScope;
748 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
749 757
750 ASSERT(Dart_IsInstance(handle)); 758 ASSERT(Dart_IsInstance(handle));
751 759
752 Dart_Handle typeHandle = Dart_InstanceGetType(handle); 760 Dart_Handle typeHandle = Dart_InstanceGetType(handle);
753 761
754 v8::Local<v8::Array> properties = v8::Array::New(); 762 v8::Local<v8::Array> properties = v8::Array::New();
755 intptr_t count = 0; 763 intptr_t count = 0;
756 Dart_Handle mapKeys = getEncodedMapKeyList(handle); 764 Dart_Handle mapKeys = getEncodedMapKeyList(handle);
757 if (Dart_IsList(mapKeys)) { 765 if (Dart_IsList(mapKeys)) {
758 // If the object has map keys, add them all as properties at the start 766 // If the object has map keys, add them all as properties at the start
(...skipping 21 matching lines...) Expand all
780 typeHandle = Dart_GetSupertype(typeHandle); 788 typeHandle = Dart_GetSupertype(typeHandle);
781 } 789 }
782 790
783 properties->Set(count, v8::String::New("@staticFields")); 791 properties->Set(count, v8::String::New("@staticFields"));
784 count++; 792 count++;
785 return properties; 793 return properties;
786 } 794 }
787 795
788 static v8::Handle<v8::Value> indexedGetter(uint32_t index, const v8::AccessorInf o& info) 796 static v8::Handle<v8::Value> indexedGetter(uint32_t index, const v8::AccessorInf o& info)
789 { 797 {
790 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 798 DartScopes scopes(info.Holder());
791 ASSERT(scriptValue->isIsolateAlive()); 799 Dart_Handle handle = scopes.handle;
792 DartIsolateScope scope(scriptValue->isolate());
793 DartApiScope apiScope;
794 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
795 800
796 Dart_Handle ret = 0; 801 Dart_Handle ret = 0;
797 if (Dart_IsList(handle)) 802 if (Dart_IsList(handle))
798 ret = Dart_ListGetAt(handle, index); 803 ret = Dart_ListGetAt(handle, index);
799 else 804 else
800 ret = Dart_Null(); 805 ret = Dart_Null();
801 806
802 return convertResult(ret); 807 return convertResult(ret);
803 } 808 }
804 809
805 static v8::Handle<v8::Value> indexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 810 static v8::Handle<v8::Value> indexedSetter(uint32_t index, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
806 { 811 {
807 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 812 DartScopes scopes(info.Holder());
808 ASSERT(scriptValue->isIsolateAlive()); 813 Dart_Handle handle = scopes.handle;
809 DartIsolateScope scope(scriptValue->isolate());
810 DartApiScope apiScope;
811 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
812 814
813 Dart_Handle ret = 0; 815 Dart_Handle ret = 0;
814 if (Dart_IsList(handle)) 816 if (Dart_IsList(handle))
815 ret = Dart_ListSetAt(handle, index, unwrapValue(value)); 817 ret = Dart_ListSetAt(handle, index, unwrapValue(value));
816 else 818 else
817 ret = Dart_Null(); 819 ret = Dart_Null();
818 820
819 return convertResult(ret); 821 return convertResult(ret);
820 } 822 }
821 823
822 static v8::Handle<v8::Array> indexedEnumerator(const v8::AccessorInfo& info) 824 static v8::Handle<v8::Array> indexedEnumerator(const v8::AccessorInfo& info)
823 { 825 {
824 DartScriptValue* scriptValue = readPointerFromProxy(info.Holder()); 826 DartScopes scopes(info.Holder());
825 ASSERT(scriptValue->isIsolateAlive()); 827 Dart_Handle handle = scopes.handle;
826 DartIsolateScope scope(scriptValue->isolate());
827 DartApiScope apiScope;
828 Dart_Handle handle = Dart_HandleFromPersistent(scriptValue->value());
829 828
830 intptr_t length = 0; 829 intptr_t length = 0;
831 if (Dart_IsList(handle)) 830 if (Dart_IsList(handle))
832 Dart_ListLength(handle, &length); 831 Dart_ListLength(handle, &length);
833 832
834 v8::Local<v8::Array> indexes = v8::Array::New(length); 833 v8::Local<v8::Array> indexes = v8::Array::New(length);
835 for (int i = 0; i < length; i++) 834 for (int i = 0; i < length; i++)
836 indexes->Set(i, v8::Integer::New(i)); 835 indexes->Set(i, v8::Integer::New(i));
837 836
838 return indexes; 837 return indexes;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 { 1059 {
1061 v8::Local<v8::Object> proxy = frameProxyTemplate()->InstanceTemplate()->NewI nstance(); 1060 v8::Local<v8::Object> proxy = frameProxyTemplate()->InstanceTemplate()->NewI nstance();
1062 Dart_Handle localScopeVariableMap = createLocalVariablesMap(localVariables); 1061 Dart_Handle localScopeVariableMap = createLocalVariablesMap(localVariables);
1063 ASSERT(!Dart_IsError(localScopeVariableMap)); 1062 ASSERT(!Dart_IsError(localScopeVariableMap));
1064 setDartHandleInternalField(proxy, localScopeVariableMap); 1063 setDartHandleInternalField(proxy, localScopeVariableMap);
1065 proxy->SetHiddenValue(v8::String::NewSymbol("dartProxy"), v8::Boolean::New(t rue)); 1064 proxy->SetHiddenValue(v8::String::NewSymbol("dartProxy"), v8::Boolean::New(t rue));
1066 return proxy; 1065 return proxy;
1067 } 1066 }
1068 1067
1069 } 1068 }
OLDNEW
« no previous file with comments | « Source/bindings/dart/DartDebugServer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698