| 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 RawObject* ArgAt(int index) const { | 90 RawObject* ArgAt(int index) const { |
| 91 ASSERT((index >= 0) && (index < ArgCount())); | 91 ASSERT((index >= 0) && (index < ArgCount())); |
| 92 return (*argv_)[-index]; | 92 return (*argv_)[-index]; |
| 93 } | 93 } |
| 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* NativeReceiver() const { | 100 RawObject* NativeArg0() const { |
| 101 ASSERT(ToInstanceFunction()); | 101 int function_bits = FunctionBits::decode(argc_tag_); |
| 102 return NativeArg0(); | 102 if (function_bits == (kClosureFunctionBit | kInstanceFunctionBit)) { |
| 103 // Retrieve the receiver from the context. |
| 104 const Context& context = Context::Handle(isolate_->top_context()); |
| 105 return context.At(0); |
| 106 } |
| 107 return ArgAt(NumHiddenArgs(function_bits)); |
| 103 } | 108 } |
| 104 | 109 |
| 105 RawObject* NativeArgAt(int index) const { | 110 RawObject* NativeArgAt(int index) const { |
| 106 ASSERT((index >= 0) && (index < NativeArgCount())); | 111 ASSERT((index >= 0) && (index < NativeArgCount())); |
| 107 if (index == 0) { | 112 if (index == 0) { |
| 108 return NativeArg0(); | 113 return NativeArg0(); |
| 109 } | 114 } |
| 110 int function_bits = FunctionBits::decode(argc_tag_); | 115 int function_bits = FunctionBits::decode(argc_tag_); |
| 111 const int actual_index = index + NumHiddenArgs(function_bits); | 116 const int actual_index = index + NumHiddenArgs(function_bits); |
| 112 return ArgAt(actual_index); | 117 return ArgAt(actual_index); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 // For static closure functions, the closure at index 0 is hidden. | 199 // For static closure functions, the closure at index 0 is hidden. |
| 195 // In the instance closure function case, the receiver is accessed from | 200 // In the instance closure function case, the receiver is accessed from |
| 196 // the context and the closure at index 0 is hidden, so the apparent | 201 // the context and the closure at index 0 is hidden, so the apparent |
| 197 // argument count remains unchanged. | 202 // argument count remains unchanged. |
| 198 if (function_bits == kClosureFunctionBit) { | 203 if (function_bits == kClosureFunctionBit) { |
| 199 return 1; | 204 return 1; |
| 200 } | 205 } |
| 201 return 0; | 206 return 0; |
| 202 } | 207 } |
| 203 | 208 |
| 204 RawObject* NativeArg0() const { | |
| 205 int function_bits = FunctionBits::decode(argc_tag_); | |
| 206 if (function_bits == (kClosureFunctionBit | kInstanceFunctionBit)) { | |
| 207 // Retrieve the receiver from the context. | |
| 208 const Context& context = Context::Handle(isolate_->top_context()); | |
| 209 return context.At(0); | |
| 210 } | |
| 211 return ArgAt(NumHiddenArgs(function_bits)); | |
| 212 } | |
| 213 | |
| 214 Isolate* isolate_; // Current isolate pointer. | 209 Isolate* isolate_; // Current isolate pointer. |
| 215 int argc_tag_; // Encodes argument count and invoked native call type. | 210 int argc_tag_; // Encodes argument count and invoked native call type. |
| 216 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. | 211 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. |
| 217 RawObject** retval_; // Pointer to the return value area. | 212 RawObject** retval_; // Pointer to the return value area. |
| 218 }; | 213 }; |
| 219 | 214 |
| 220 } // namespace dart | 215 } // namespace dart |
| 221 | 216 |
| 222 #endif // VM_NATIVE_ARGUMENTS_H_ | 217 #endif // VM_NATIVE_ARGUMENTS_H_ |
| OLD | NEW |