| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "include/dart_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 1820 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1831 } | 1831 } |
| 1832 if (obj.IsGrowableObjectArray()) { | 1832 if (obj.IsGrowableObjectArray()) { |
| 1833 GET_LIST_LENGTH(isolate, GrowableObjectArray, obj, len); | 1833 GET_LIST_LENGTH(isolate, GrowableObjectArray, obj, len); |
| 1834 } | 1834 } |
| 1835 // Now check and handle a dart object that implements the List interface. | 1835 // Now check and handle a dart object that implements the List interface. |
| 1836 const Instance& instance = | 1836 const Instance& instance = |
| 1837 Instance::Handle(isolate, GetListInstance(isolate, obj)); | 1837 Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| 1838 if (instance.IsNull()) { | 1838 if (instance.IsNull()) { |
| 1839 return Api::NewError("Object does not implement the List interface"); | 1839 return Api::NewError("Object does not implement the List interface"); |
| 1840 } | 1840 } |
| 1841 String& name = String::Handle(isolate, String::New("length")); | 1841 String& name = String::Handle(isolate, Symbols::Length()); |
| 1842 name = Field::GetterName(name); | 1842 name = Field::GetterName(name); |
| 1843 const Function& function = | 1843 const Function& function = |
| 1844 Function::Handle(isolate, Resolver::ResolveDynamic(instance, name, 1, 0)); | 1844 Function::Handle(isolate, Resolver::ResolveDynamic(instance, name, 1, 0)); |
| 1845 if (function.IsNull()) { | 1845 if (function.IsNull()) { |
| 1846 return Api::NewError("List object does not have a 'length' field."); | 1846 return Api::NewError("List object does not have a 'length' field."); |
| 1847 } | 1847 } |
| 1848 | 1848 |
| 1849 GrowableArray<const Object*> args(0); | 1849 GrowableArray<const Object*> args(0); |
| 1850 const Array& kNoArgumentNames = Array::Handle(isolate); | 1850 const Array& kNoArgumentNames = Array::Handle(isolate); |
| 1851 const Object& retval = Object::Handle( | 1851 const Object& retval = Object::Handle( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1897 GET_LIST_ELEMENT(isolate, Array, obj, index); | 1897 GET_LIST_ELEMENT(isolate, Array, obj, index); |
| 1898 } else if (obj.IsGrowableObjectArray()) { | 1898 } else if (obj.IsGrowableObjectArray()) { |
| 1899 GET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index); | 1899 GET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index); |
| 1900 } else if (obj.IsError()) { | 1900 } else if (obj.IsError()) { |
| 1901 return list; | 1901 return list; |
| 1902 } else { | 1902 } else { |
| 1903 // Check and handle a dart object that implements the List interface. | 1903 // Check and handle a dart object that implements the List interface. |
| 1904 const Instance& instance = | 1904 const Instance& instance = |
| 1905 Instance::Handle(isolate, GetListInstance(isolate, obj)); | 1905 Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| 1906 if (!instance.IsNull()) { | 1906 if (!instance.IsNull()) { |
| 1907 String& name = String::Handle(isolate, String::New("[]")); | 1907 String& name = String::Handle(isolate, Symbols::IndexToken()); |
| 1908 const Function& function = | 1908 const Function& function = |
| 1909 Function::Handle(isolate, | 1909 Function::Handle(isolate, |
| 1910 Resolver::ResolveDynamic(instance, name, 2, 0)); | 1910 Resolver::ResolveDynamic(instance, name, 2, 0)); |
| 1911 if (!function.IsNull()) { | 1911 if (!function.IsNull()) { |
| 1912 GrowableArray<const Object*> args(1); | 1912 GrowableArray<const Object*> args(1); |
| 1913 Integer& indexobj = Integer::Handle(isolate); | 1913 Integer& indexobj = Integer::Handle(isolate); |
| 1914 indexobj = Integer::New(index); | 1914 indexobj = Integer::New(index); |
| 1915 args.Add(&indexobj); | 1915 args.Add(&indexobj); |
| 1916 const Array& kNoArgumentNames = Array::Handle(isolate); | 1916 const Array& kNoArgumentNames = Array::Handle(isolate); |
| 1917 return Api::NewHandle(isolate, DartEntry::InvokeDynamic( | 1917 return Api::NewHandle(isolate, DartEntry::InvokeDynamic( |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 SET_LIST_ELEMENT(isolate, Array, obj, index, value); | 1949 SET_LIST_ELEMENT(isolate, Array, obj, index, value); |
| 1950 } else if (obj.IsGrowableObjectArray()) { | 1950 } else if (obj.IsGrowableObjectArray()) { |
| 1951 SET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index, value); | 1951 SET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index, value); |
| 1952 } else if (obj.IsError()) { | 1952 } else if (obj.IsError()) { |
| 1953 return list; | 1953 return list; |
| 1954 } else { | 1954 } else { |
| 1955 // Check and handle a dart object that implements the List interface. | 1955 // Check and handle a dart object that implements the List interface. |
| 1956 const Instance& instance = | 1956 const Instance& instance = |
| 1957 Instance::Handle(isolate, GetListInstance(isolate, obj)); | 1957 Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| 1958 if (!instance.IsNull()) { | 1958 if (!instance.IsNull()) { |
| 1959 String& name = String::Handle(isolate, String::New("[]=")); | 1959 String& name = String::Handle(isolate, Symbols::AssignIndexToken()); |
| 1960 const Function& function = | 1960 const Function& function = |
| 1961 Function::Handle(isolate, | 1961 Function::Handle(isolate, |
| 1962 Resolver::ResolveDynamic(instance, name, 3, 0)); | 1962 Resolver::ResolveDynamic(instance, name, 3, 0)); |
| 1963 if (!function.IsNull()) { | 1963 if (!function.IsNull()) { |
| 1964 const Integer& index_obj = | 1964 const Integer& index_obj = |
| 1965 Integer::Handle(isolate, Integer::New(index)); | 1965 Integer::Handle(isolate, Integer::New(index)); |
| 1966 const Object& value_obj = | 1966 const Object& value_obj = |
| 1967 Object::Handle(isolate, Api::UnwrapHandle(value)); | 1967 Object::Handle(isolate, Api::UnwrapHandle(value)); |
| 1968 if (!value_obj.IsNull() && !value_obj.IsInstance()) { | 1968 if (!value_obj.IsNull() && !value_obj.IsInstance()) { |
| 1969 RETURN_TYPE_ERROR(isolate, value, Instance); | 1969 RETURN_TYPE_ERROR(isolate, value, Instance); |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2031 native_array, | 2031 native_array, |
| 2032 offset, | 2032 offset, |
| 2033 length); | 2033 length); |
| 2034 } else if (obj.IsError()) { | 2034 } else if (obj.IsError()) { |
| 2035 return list; | 2035 return list; |
| 2036 } else { | 2036 } else { |
| 2037 // Check and handle a dart object that implements the List interface. | 2037 // Check and handle a dart object that implements the List interface. |
| 2038 const Instance& instance = | 2038 const Instance& instance = |
| 2039 Instance::Handle(isolate, GetListInstance(isolate, obj)); | 2039 Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| 2040 if (!instance.IsNull()) { | 2040 if (!instance.IsNull()) { |
| 2041 String& name = String::Handle(isolate, String::New("[]")); | 2041 String& name = String::Handle(isolate, Symbols::IndexToken()); |
| 2042 const Function& function = | 2042 const Function& function = |
| 2043 Function::Handle(isolate, | 2043 Function::Handle(isolate, |
| 2044 Resolver::ResolveDynamic(instance, name, 2, 0)); | 2044 Resolver::ResolveDynamic(instance, name, 2, 0)); |
| 2045 if (!function.IsNull()) { | 2045 if (!function.IsNull()) { |
| 2046 Object& result = Object::Handle(isolate); | 2046 Object& result = Object::Handle(isolate); |
| 2047 Integer& intobj = Integer::Handle(isolate); | 2047 Integer& intobj = Integer::Handle(isolate); |
| 2048 for (int i = 0; i < length; i++) { | 2048 for (int i = 0; i < length; i++) { |
| 2049 intobj = Integer::New(offset + i); | 2049 intobj = Integer::New(offset + i); |
| 2050 GrowableArray<const Object*> args(1); | 2050 GrowableArray<const Object*> args(1); |
| 2051 args.Add(&intobj); | 2051 args.Add(&intobj); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2119 native_array, | 2119 native_array, |
| 2120 offset, | 2120 offset, |
| 2121 length); | 2121 length); |
| 2122 } else if (obj.IsError()) { | 2122 } else if (obj.IsError()) { |
| 2123 return list; | 2123 return list; |
| 2124 } else { | 2124 } else { |
| 2125 // Check and handle a dart object that implements the List interface. | 2125 // Check and handle a dart object that implements the List interface. |
| 2126 const Instance& instance = | 2126 const Instance& instance = |
| 2127 Instance::Handle(isolate, GetListInstance(isolate, obj)); | 2127 Instance::Handle(isolate, GetListInstance(isolate, obj)); |
| 2128 if (!instance.IsNull()) { | 2128 if (!instance.IsNull()) { |
| 2129 String& name = String::Handle(isolate, String::New("[]=")); | 2129 String& name = String::Handle(isolate, Symbols::AssignIndexToken()); |
| 2130 const Function& function = | 2130 const Function& function = |
| 2131 Function::Handle(isolate, | 2131 Function::Handle(isolate, |
| 2132 Resolver::ResolveDynamic(instance, name, 3, 0)); | 2132 Resolver::ResolveDynamic(instance, name, 3, 0)); |
| 2133 if (!function.IsNull()) { | 2133 if (!function.IsNull()) { |
| 2134 Integer& indexobj = Integer::Handle(isolate); | 2134 Integer& indexobj = Integer::Handle(isolate); |
| 2135 Integer& valueobj = Integer::Handle(isolate); | 2135 Integer& valueobj = Integer::Handle(isolate); |
| 2136 for (int i = 0; i < length; i++) { | 2136 for (int i = 0; i < length; i++) { |
| 2137 indexobj = Integer::New(offset + i); | 2137 indexobj = Integer::New(offset + i); |
| 2138 valueobj = Integer::New(native_array[i]); | 2138 valueobj = Integer::New(native_array[i]); |
| 2139 GrowableArray<const Object*> args(2); | 2139 GrowableArray<const Object*> args(2); |
| (...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4453 } | 4453 } |
| 4454 { | 4454 { |
| 4455 NoGCScope no_gc; | 4455 NoGCScope no_gc; |
| 4456 RawObject* raw_obj = obj.raw(); | 4456 RawObject* raw_obj = obj.raw(); |
| 4457 isolate->heap()->SetPeer(raw_obj, peer); | 4457 isolate->heap()->SetPeer(raw_obj, peer); |
| 4458 } | 4458 } |
| 4459 return Api::Success(isolate); | 4459 return Api::Success(isolate); |
| 4460 } | 4460 } |
| 4461 | 4461 |
| 4462 } // namespace dart | 4462 } // namespace dart |
| OLD | NEW |