| 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 #ifndef VM_NATIVE_ARGUMENTS_H_ | 5 #ifndef VM_NATIVE_ARGUMENTS_H_ |
| 6 #define VM_NATIVE_ARGUMENTS_H_ | 6 #define VM_NATIVE_ARGUMENTS_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/handles_impl.h" | 10 #include "vm/handles_impl.h" |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 | 94 |
| 95 int NativeArgCount() const { | 95 int NativeArgCount() const { |
| 96 int function_bits = FunctionBits::decode(argc_tag_); | 96 int function_bits = FunctionBits::decode(argc_tag_); |
| 97 return ArgCount() - NumHiddenArgs(function_bits); | 97 return ArgCount() - NumHiddenArgs(function_bits); |
| 98 } | 98 } |
| 99 | 99 |
| 100 RawObject* NativeArg0() const { | 100 RawObject* NativeArg0() const { |
| 101 int function_bits = FunctionBits::decode(argc_tag_); | 101 int function_bits = FunctionBits::decode(argc_tag_); |
| 102 if (function_bits == (kClosureFunctionBit | kInstanceFunctionBit)) { | 102 if (function_bits == (kClosureFunctionBit | kInstanceFunctionBit)) { |
| 103 // Retrieve the receiver from the context. | 103 // Retrieve the receiver from the context. |
| 104 const Context& context = Context::Handle(isolate_->top_context()); | 104 const Object& closure = Object::Handle(ArgAt(0)); |
| 105 const Context& context = |
| 106 Context::Handle(Closure::context(Instance::Cast(closure))); |
| 105 return context.At(0); | 107 return context.At(0); |
| 106 } | 108 } |
| 107 return ArgAt(NumHiddenArgs(function_bits)); | 109 return ArgAt(NumHiddenArgs(function_bits)); |
| 108 } | 110 } |
| 109 | 111 |
| 110 RawObject* NativeArgAt(int index) const { | 112 RawObject* NativeArgAt(int index) const { |
| 111 ASSERT((index >= 0) && (index < NativeArgCount())); | 113 ASSERT((index >= 0) && (index < NativeArgCount())); |
| 112 if (index == 0) { | 114 if (index == 0) { |
| 113 return NativeArg0(); | 115 return NativeArg0(); |
| 114 } | 116 } |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 | 219 |
| 218 Isolate* isolate_; // Current isolate pointer. | 220 Isolate* isolate_; // Current isolate pointer. |
| 219 int argc_tag_; // Encodes argument count and invoked native call type. | 221 int argc_tag_; // Encodes argument count and invoked native call type. |
| 220 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. | 222 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. |
| 221 RawObject** retval_; // Pointer to the return value area. | 223 RawObject** retval_; // Pointer to the return value area. |
| 222 }; | 224 }; |
| 223 | 225 |
| 224 } // namespace dart | 226 } // namespace dart |
| 225 | 227 |
| 226 #endif // VM_NATIVE_ARGUMENTS_H_ | 228 #endif // VM_NATIVE_ARGUMENTS_H_ |
| OLD | NEW |