| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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_api.h" | 5 #include "include/dart_api.h" |
| 6 | 6 |
| 7 #include "vm/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
| 8 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/dart.h" | 10 #include "vm/dart.h" |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 } | 1371 } |
| 1372 String& name = String::Handle(String::New("length")); | 1372 String& name = String::Handle(String::New("length")); |
| 1373 name = Field::GetterName(name); | 1373 name = Field::GetterName(name); |
| 1374 const Function& function = Function::Handle( | 1374 const Function& function = Function::Handle( |
| 1375 Resolver::ResolveDynamic(instance, name, 1, 0)); | 1375 Resolver::ResolveDynamic(instance, name, 1, 0)); |
| 1376 if (function.IsNull()) { | 1376 if (function.IsNull()) { |
| 1377 return Api::NewError("List object does not have a 'length' field."); | 1377 return Api::NewError("List object does not have a 'length' field."); |
| 1378 } | 1378 } |
| 1379 | 1379 |
| 1380 GrowableArray<const Object*> args(0); | 1380 GrowableArray<const Object*> args(0); |
| 1381 Dart_Handle result; | |
| 1382 const Array& kNoArgumentNames = Array::Handle(); | 1381 const Array& kNoArgumentNames = Array::Handle(); |
| 1383 const Object& retval = Object::Handle( | 1382 const Object& retval = Object::Handle( |
| 1384 DartEntry::InvokeDynamic(instance, function, args, kNoArgumentNames)); | 1383 DartEntry::InvokeDynamic(instance, function, args, kNoArgumentNames)); |
| 1385 if (retval.IsSmi() || retval.IsMint()) { | 1384 if (retval.IsSmi() || retval.IsMint()) { |
| 1386 Integer& integer = Integer::Handle(); | 1385 Integer& integer = Integer::Handle(); |
| 1387 integer ^= retval.raw(); | 1386 integer ^= retval.raw(); |
| 1388 *len = integer.AsInt64Value(); | 1387 *len = integer.AsInt64Value(); |
| 1389 return Api::Success(); | 1388 return Api::Success(); |
| 1390 } else if (retval.IsBigint()) { | 1389 } else if (retval.IsBigint()) { |
| 1391 Bigint& bigint = Bigint::Handle(); | 1390 Bigint& bigint = Bigint::Handle(); |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1592 // TODO(5526318): Make access to GrowableObjectArray more efficient. | 1591 // TODO(5526318): Make access to GrowableObjectArray more efficient. |
| 1593 // Now check and handle a dart object that implements the List interface. | 1592 // Now check and handle a dart object that implements the List interface. |
| 1594 const Instance& instance = Instance::Handle(GetListInstance(isolate, obj)); | 1593 const Instance& instance = Instance::Handle(GetListInstance(isolate, obj)); |
| 1595 if (!instance.IsNull()) { | 1594 if (!instance.IsNull()) { |
| 1596 String& name = String::Handle(String::New("[]=")); | 1595 String& name = String::Handle(String::New("[]=")); |
| 1597 const Function& function = Function::Handle( | 1596 const Function& function = Function::Handle( |
| 1598 Resolver::ResolveDynamic(instance, name, 3, 0)); | 1597 Resolver::ResolveDynamic(instance, name, 3, 0)); |
| 1599 if (!function.IsNull()) { | 1598 if (!function.IsNull()) { |
| 1600 Integer& indexobj = Integer::Handle(); | 1599 Integer& indexobj = Integer::Handle(); |
| 1601 Integer& valueobj = Integer::Handle(); | 1600 Integer& valueobj = Integer::Handle(); |
| 1602 Dart_Handle result; | |
| 1603 for (int i = 0; i < length; i++) { | 1601 for (int i = 0; i < length; i++) { |
| 1604 indexobj = Integer::New(offset + i); | 1602 indexobj = Integer::New(offset + i); |
| 1605 valueobj = Integer::New(native_array[i]); | 1603 valueobj = Integer::New(native_array[i]); |
| 1606 GrowableArray<const Object*> args(2); | 1604 GrowableArray<const Object*> args(2); |
| 1607 args.Add(&indexobj); | 1605 args.Add(&indexobj); |
| 1608 args.Add(&valueobj); | 1606 args.Add(&valueobj); |
| 1609 const Array& kNoArgumentNames = Array::Handle(); | 1607 const Array& kNoArgumentNames = Array::Handle(); |
| 1610 const Object& result = Object::Handle( | 1608 const Object& result = Object::Handle( |
| 1611 DartEntry::InvokeDynamic( | 1609 DartEntry::InvokeDynamic( |
| 1612 instance, function, args, kNoArgumentNames)); | 1610 instance, function, args, kNoArgumentNames)); |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1739 const char* format = "Unable to find entrypoint: static %s.%s()"; | 1737 const char* format = "Unable to find entrypoint: static %s.%s()"; |
| 1740 intptr_t length = OS::SNPrint(NULL, 0, format, | 1738 intptr_t length = OS::SNPrint(NULL, 0, format, |
| 1741 class_name.ToCString(), | 1739 class_name.ToCString(), |
| 1742 function_name.ToCString()); | 1740 function_name.ToCString()); |
| 1743 msg = reinterpret_cast<char*>(Api::Allocate(length + 1)); | 1741 msg = reinterpret_cast<char*>(Api::Allocate(length + 1)); |
| 1744 OS::SNPrint(msg, (length + 1), format, | 1742 OS::SNPrint(msg, (length + 1), format, |
| 1745 class_name.ToCString(), function_name.ToCString()); | 1743 class_name.ToCString(), function_name.ToCString()); |
| 1746 } | 1744 } |
| 1747 return Api::NewError(msg); | 1745 return Api::NewError(msg); |
| 1748 } | 1746 } |
| 1749 Dart_Handle retval; | |
| 1750 GrowableArray<const Object*> dart_arguments(number_of_arguments); | 1747 GrowableArray<const Object*> dart_arguments(number_of_arguments); |
| 1751 for (int i = 0; i < number_of_arguments; i++) { | 1748 for (int i = 0; i < number_of_arguments; i++) { |
| 1752 const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i])); | 1749 const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i])); |
| 1753 dart_arguments.Add(&arg); | 1750 dart_arguments.Add(&arg); |
| 1754 } | 1751 } |
| 1755 const Array& kNoArgumentNames = Array::Handle(); | 1752 const Array& kNoArgumentNames = Array::Handle(); |
| 1756 const Object& result = Object::Handle( | 1753 const Object& result = Object::Handle( |
| 1757 DartEntry::InvokeStatic(function, dart_arguments, kNoArgumentNames)); | 1754 DartEntry::InvokeStatic(function, dart_arguments, kNoArgumentNames)); |
| 1758 return Api::NewLocalHandle(result); | 1755 return Api::NewLocalHandle(result); |
| 1759 } | 1756 } |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1784 const Function& function = Function::Handle( | 1781 const Function& function = Function::Handle( |
| 1785 Resolver::ResolveDynamic(receiver, | 1782 Resolver::ResolveDynamic(receiver, |
| 1786 name, | 1783 name, |
| 1787 (number_of_arguments + 1), | 1784 (number_of_arguments + 1), |
| 1788 0)); // Named args not yet supported in API. | 1785 0)); // Named args not yet supported in API. |
| 1789 if (function.IsNull()) { | 1786 if (function.IsNull()) { |
| 1790 // TODO(5415268): Invoke noSuchMethod instead of failing. | 1787 // TODO(5415268): Invoke noSuchMethod instead of failing. |
| 1791 OS::PrintErr("Unable to find instance function: %s\n", name.ToCString()); | 1788 OS::PrintErr("Unable to find instance function: %s\n", name.ToCString()); |
| 1792 return Api::NewError("Unable to find instance function"); | 1789 return Api::NewError("Unable to find instance function"); |
| 1793 } | 1790 } |
| 1794 Dart_Handle retval; | |
| 1795 GrowableArray<const Object*> dart_arguments(number_of_arguments); | 1791 GrowableArray<const Object*> dart_arguments(number_of_arguments); |
| 1796 for (int i = 0; i < number_of_arguments; i++) { | 1792 for (int i = 0; i < number_of_arguments; i++) { |
| 1797 const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i])); | 1793 const Object& arg = Object::Handle(Api::UnwrapHandle(arguments[i])); |
| 1798 dart_arguments.Add(&arg); | 1794 dart_arguments.Add(&arg); |
| 1799 } | 1795 } |
| 1800 const Array& kNoArgumentNames = Array::Handle(); | 1796 const Array& kNoArgumentNames = Array::Handle(); |
| 1801 const Object& result = Object::Handle( | 1797 const Object& result = Object::Handle( |
| 1802 DartEntry::InvokeDynamic( | 1798 DartEntry::InvokeDynamic( |
| 1803 receiver, function, dart_arguments, kNoArgumentNames)); | 1799 receiver, function, dart_arguments, kNoArgumentNames)); |
| 1804 return Api::NewLocalHandle(result); | 1800 return Api::NewLocalHandle(result); |
| (...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2425 } | 2421 } |
| 2426 delete debug_region; | 2422 delete debug_region; |
| 2427 } else { | 2423 } else { |
| 2428 *buffer = NULL; | 2424 *buffer = NULL; |
| 2429 *buffer_size = 0; | 2425 *buffer_size = 0; |
| 2430 } | 2426 } |
| 2431 } | 2427 } |
| 2432 | 2428 |
| 2433 | 2429 |
| 2434 } // namespace dart | 2430 } // namespace dart |
| OLD | NEW |