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

Side by Side Diff: vm/dart_api_impl.cc

Issue 11519006: Add read only handles for the following predefined symbols (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 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 | Annotate | Revision Log
« vm/ast.h ('K') | « vm/ast.h ('k') | vm/dart_entry.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_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 1890 matching lines...) Expand 10 before | Expand all | Expand 10 after
1901 GET_LIST_ELEMENT(isolate, Array, obj, index); 1901 GET_LIST_ELEMENT(isolate, Array, obj, index);
1902 } else if (obj.IsGrowableObjectArray()) { 1902 } else if (obj.IsGrowableObjectArray()) {
1903 GET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index); 1903 GET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index);
1904 } else if (obj.IsError()) { 1904 } else if (obj.IsError()) {
1905 return list; 1905 return list;
1906 } else { 1906 } else {
1907 // Check and handle a dart object that implements the List interface. 1907 // Check and handle a dart object that implements the List interface.
1908 const Instance& instance = 1908 const Instance& instance =
1909 Instance::Handle(isolate, GetListInstance(isolate, obj)); 1909 Instance::Handle(isolate, GetListInstance(isolate, obj));
1910 if (!instance.IsNull()) { 1910 if (!instance.IsNull()) {
1911 String& name = String::Handle(isolate, Symbols::IndexToken()); 1911 const Function& function = Function::Handle(
1912 const Function& function = 1912 isolate,
1913 Function::Handle(isolate, 1913 Resolver::ResolveDynamic(instance,
1914 Resolver::ResolveDynamic(instance, name, 2, 0)); 1914 Symbols::IndexTokenHandle(),
1915 2,
1916 0));
1915 if (!function.IsNull()) { 1917 if (!function.IsNull()) {
1916 GrowableArray<const Object*> args(1); 1918 GrowableArray<const Object*> args(1);
1917 Integer& indexobj = Integer::Handle(isolate); 1919 Integer& indexobj = Integer::Handle(isolate);
1918 indexobj = Integer::New(index); 1920 indexobj = Integer::New(index);
1919 args.Add(&indexobj); 1921 args.Add(&indexobj);
1920 const Array& kNoArgumentNames = Array::Handle(isolate); 1922 const Array& kNoArgumentNames = Array::Handle(isolate);
1921 return Api::NewHandle(isolate, DartEntry::InvokeDynamic( 1923 return Api::NewHandle(isolate, DartEntry::InvokeDynamic(
1922 instance, function, args, kNoArgumentNames)); 1924 instance, function, args, kNoArgumentNames));
1923 } 1925 }
1924 } 1926 }
(...skipping 28 matching lines...) Expand all
1953 SET_LIST_ELEMENT(isolate, Array, obj, index, value); 1955 SET_LIST_ELEMENT(isolate, Array, obj, index, value);
1954 } else if (obj.IsGrowableObjectArray()) { 1956 } else if (obj.IsGrowableObjectArray()) {
1955 SET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index, value); 1957 SET_LIST_ELEMENT(isolate, GrowableObjectArray, obj, index, value);
1956 } else if (obj.IsError()) { 1958 } else if (obj.IsError()) {
1957 return list; 1959 return list;
1958 } else { 1960 } else {
1959 // Check and handle a dart object that implements the List interface. 1961 // Check and handle a dart object that implements the List interface.
1960 const Instance& instance = 1962 const Instance& instance =
1961 Instance::Handle(isolate, GetListInstance(isolate, obj)); 1963 Instance::Handle(isolate, GetListInstance(isolate, obj));
1962 if (!instance.IsNull()) { 1964 if (!instance.IsNull()) {
1963 String& name = String::Handle(isolate, Symbols::AssignIndexToken()); 1965 const Function& function = Function::Handle(
1964 const Function& function = 1966 isolate,
1965 Function::Handle(isolate, 1967 Resolver::ResolveDynamic(instance,
1966 Resolver::ResolveDynamic(instance, name, 3, 0)); 1968 Symbols::AssignIndexTokenHandle(),
1969 3,
1970 0));
1967 if (!function.IsNull()) { 1971 if (!function.IsNull()) {
1968 const Integer& index_obj = 1972 const Integer& index_obj =
1969 Integer::Handle(isolate, Integer::New(index)); 1973 Integer::Handle(isolate, Integer::New(index));
1970 const Object& value_obj = 1974 const Object& value_obj =
1971 Object::Handle(isolate, Api::UnwrapHandle(value)); 1975 Object::Handle(isolate, Api::UnwrapHandle(value));
1972 if (!value_obj.IsNull() && !value_obj.IsInstance()) { 1976 if (!value_obj.IsNull() && !value_obj.IsInstance()) {
1973 RETURN_TYPE_ERROR(isolate, value, Instance); 1977 RETURN_TYPE_ERROR(isolate, value, Instance);
1974 } 1978 }
1975 GrowableArray<const Object*> args(2); 1979 GrowableArray<const Object*> args(2);
1976 args.Add(&index_obj); 1980 args.Add(&index_obj);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
2036 native_array, 2040 native_array,
2037 offset, 2041 offset,
2038 length); 2042 length);
2039 } else if (obj.IsError()) { 2043 } else if (obj.IsError()) {
2040 return list; 2044 return list;
2041 } else { 2045 } else {
2042 // Check and handle a dart object that implements the List interface. 2046 // Check and handle a dart object that implements the List interface.
2043 const Instance& instance = 2047 const Instance& instance =
2044 Instance::Handle(isolate, GetListInstance(isolate, obj)); 2048 Instance::Handle(isolate, GetListInstance(isolate, obj));
2045 if (!instance.IsNull()) { 2049 if (!instance.IsNull()) {
2046 String& name = String::Handle(isolate, Symbols::IndexToken()); 2050 const Function& function = Function::Handle(
2047 const Function& function = 2051 isolate,
2048 Function::Handle(isolate, 2052 Resolver::ResolveDynamic(instance,
2049 Resolver::ResolveDynamic(instance, name, 2, 0)); 2053 Symbols::IndexTokenHandle(),
2054 2,
2055 0));
2050 if (!function.IsNull()) { 2056 if (!function.IsNull()) {
2051 Object& result = Object::Handle(isolate); 2057 Object& result = Object::Handle(isolate);
2052 Integer& intobj = Integer::Handle(isolate); 2058 Integer& intobj = Integer::Handle(isolate);
2053 for (int i = 0; i < length; i++) { 2059 for (int i = 0; i < length; i++) {
2054 intobj = Integer::New(offset + i); 2060 intobj = Integer::New(offset + i);
2055 GrowableArray<const Object*> args(1); 2061 GrowableArray<const Object*> args(1);
2056 args.Add(&intobj); 2062 args.Add(&intobj);
2057 const Array& kNoArgumentNames = Array::Handle(isolate); 2063 const Array& kNoArgumentNames = Array::Handle(isolate);
2058 result = DartEntry::InvokeDynamic( 2064 result = DartEntry::InvokeDynamic(
2059 instance, function, args, kNoArgumentNames); 2065 instance, function, args, kNoArgumentNames);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
2125 native_array, 2131 native_array,
2126 offset, 2132 offset,
2127 length); 2133 length);
2128 } else if (obj.IsError()) { 2134 } else if (obj.IsError()) {
2129 return list; 2135 return list;
2130 } else { 2136 } else {
2131 // Check and handle a dart object that implements the List interface. 2137 // Check and handle a dart object that implements the List interface.
2132 const Instance& instance = 2138 const Instance& instance =
2133 Instance::Handle(isolate, GetListInstance(isolate, obj)); 2139 Instance::Handle(isolate, GetListInstance(isolate, obj));
2134 if (!instance.IsNull()) { 2140 if (!instance.IsNull()) {
2135 String& name = String::Handle(isolate, Symbols::AssignIndexToken()); 2141 const Function& function = Function::Handle(
2136 const Function& function = 2142 isolate,
2137 Function::Handle(isolate, 2143 Resolver::ResolveDynamic(instance,
2138 Resolver::ResolveDynamic(instance, name, 3, 0)); 2144 Symbols::AssignIndexTokenHandle(),
2145 3,
2146 0));
2139 if (!function.IsNull()) { 2147 if (!function.IsNull()) {
2140 Integer& indexobj = Integer::Handle(isolate); 2148 Integer& indexobj = Integer::Handle(isolate);
2141 Integer& valueobj = Integer::Handle(isolate); 2149 Integer& valueobj = Integer::Handle(isolate);
2142 for (int i = 0; i < length; i++) { 2150 for (int i = 0; i < length; i++) {
2143 indexobj = Integer::New(offset + i); 2151 indexobj = Integer::New(offset + i);
2144 valueobj = Integer::New(native_array[i]); 2152 valueobj = Integer::New(native_array[i]);
2145 GrowableArray<const Object*> args(2); 2153 GrowableArray<const Object*> args(2);
2146 args.Add(&indexobj); 2154 args.Add(&indexobj);
2147 args.Add(&valueobj); 2155 args.Add(&valueobj);
2148 const Array& kNoArgumentNames = Array::Handle(isolate); 2156 const Array& kNoArgumentNames = Array::Handle(isolate);
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
4457 } 4465 }
4458 { 4466 {
4459 NoGCScope no_gc; 4467 NoGCScope no_gc;
4460 RawObject* raw_obj = obj.raw(); 4468 RawObject* raw_obj = obj.raw();
4461 isolate->heap()->SetPeer(raw_obj, peer); 4469 isolate->heap()->SetPeer(raw_obj, peer);
4462 } 4470 }
4463 return Api::Success(isolate); 4471 return Api::Success(isolate);
4464 } 4472 }
4465 4473
4466 } // namespace dart 4474 } // namespace dart
OLDNEW
« vm/ast.h ('K') | « vm/ast.h ('k') | vm/dart_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698