Chromium Code Reviews| 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 "vm/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/compiler.h" | 7 #include "vm/compiler.h" |
| 8 #include "vm/dart_entry.h" | 8 #include "vm/dart_entry.h" |
| 9 #include "vm/exceptions.h" | 9 #include "vm/exceptions.h" |
| 10 #include "vm/native_entry.h" | 10 #include "vm/native_entry.h" |
| 11 #include "vm/object.h" | 11 #include "vm/object.h" |
| 12 #include "vm/symbols.h" | 12 #include "vm/symbols.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 DEFINE_NATIVE_ENTRY(Function_apply, 2) { | 16 DEFINE_NATIVE_ENTRY(Function_apply, 2) { |
| 17 const int kTypeArgsLen = 0; // TODO(regis): Add support for generic function. | |
| 17 const Array& fun_arguments = Array::CheckedHandle(arguments->NativeArgAt(0)); | 18 const Array& fun_arguments = Array::CheckedHandle(arguments->NativeArgAt(0)); |
| 18 const Array& fun_arg_names = Array::CheckedHandle(arguments->NativeArgAt(1)); | 19 const Array& fun_arg_names = Array::CheckedHandle(arguments->NativeArgAt(1)); |
| 19 const Array& fun_args_desc = Array::Handle( | 20 const Array& fun_args_desc = Array::Handle(ArgumentsDescriptor::New( |
| 20 ArgumentsDescriptor::New(fun_arguments.Length(), fun_arg_names)); | 21 kTypeArgsLen, fun_arguments.Length(), fun_arg_names)); |
| 21 const Object& result = | 22 const Object& result = |
| 22 Object::Handle(DartEntry::InvokeClosure(fun_arguments, fun_args_desc)); | 23 Object::Handle(DartEntry::InvokeClosure(fun_arguments, fun_args_desc)); |
| 23 if (result.IsError()) { | 24 if (result.IsError()) { |
| 24 Exceptions::PropagateError(Error::Cast(result)); | 25 Exceptions::PropagateError(Error::Cast(result)); |
| 25 } | 26 } |
| 26 return result.raw(); | 27 return result.raw(); |
| 27 } | 28 } |
| 28 | 29 |
| 29 | 30 |
| 30 DEFINE_NATIVE_ENTRY(Closure_equals, 2) { | 31 DEFINE_NATIVE_ENTRY(Closure_equals, 2) { |
| 31 const Closure& receiver = | 32 const Closure& receiver = |
| 32 Closure::CheckedHandle(zone, arguments->NativeArgAt(0)); | 33 Closure::CheckedHandle(zone, arguments->NativeArgAt(0)); |
|
zra
2017/05/03 15:03:24
The stuff in this file is inconsistent about passi
regis
2017/05/09 18:31:22
It looks like 'zone' is indeed passed in and is a
| |
| 33 GET_NATIVE_ARGUMENT(Instance, other, arguments->NativeArgAt(1)); | 34 GET_NATIVE_ARGUMENT(Instance, other, arguments->NativeArgAt(1)); |
| 34 ASSERT(!other.IsNull()); | 35 ASSERT(!other.IsNull()); |
| 35 if (receiver.raw() == other.raw()) return Bool::True().raw(); | 36 if (receiver.raw() == other.raw()) return Bool::True().raw(); |
| 36 if (other.IsClosure()) { | 37 if (other.IsClosure()) { |
| 37 const Function& func_a = Function::Handle(receiver.function()); | 38 const Function& func_a = Function::Handle(receiver.function()); |
| 38 const Function& func_b = Function::Handle(Closure::Cast(other).function()); | 39 const Function& func_b = Function::Handle(Closure::Cast(other).function()); |
| 39 if (func_a.raw() == func_b.raw()) { | 40 if (func_a.raw() == func_b.raw()) { |
| 40 ASSERT(!func_a.IsImplicitStaticClosureFunction()); | 41 ASSERT(!func_a.IsImplicitStaticClosureFunction()); |
| 41 if (func_a.IsImplicitInstanceClosureFunction()) { | 42 if (func_a.IsImplicitInstanceClosureFunction()) { |
| 42 const Context& context_a = Context::Handle(receiver.context()); | 43 const Context& context_a = Context::Handle(receiver.context()); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 89 for (int i = 0; i < context.num_variables(); i++) { | 90 for (int i = 0; i < context.num_variables(); i++) { |
| 90 instance = context.At(i); | 91 instance = context.At(i); |
| 91 cloned_context.SetAt(i, instance); | 92 cloned_context.SetAt(i, instance); |
| 92 } | 93 } |
| 93 return Closure::New(instantiator_type_arguments, function_type_arguments, | 94 return Closure::New(instantiator_type_arguments, function_type_arguments, |
| 94 function, cloned_context); | 95 function, cloned_context); |
| 95 } | 96 } |
| 96 | 97 |
| 97 | 98 |
| 98 } // namespace dart | 99 } // namespace dart |
| OLD | NEW |