| 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/stub_code.h" | 10 #include "vm/stub_code.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 return 1; | 86 return 1; |
| 87 } | 87 } |
| 88 return 0; | 88 return 0; |
| 89 } | 89 } |
| 90 | 90 |
| 91 int NativeArgCount() const { | 91 int NativeArgCount() const { |
| 92 return ArgCount() - NumHiddenArgs(); | 92 return ArgCount() - NumHiddenArgs(); |
| 93 } | 93 } |
| 94 | 94 |
| 95 RawObject* NativeArgAt(int index) const { | 95 RawObject* NativeArgAt(int index) const { |
| 96 const int num_hidden_args = NumHiddenArgs(); | 96 ASSERT((index >= 0) && (index < NativeArgCount())); |
| 97 const int actual_index = index + num_hidden_args; | |
| 98 ASSERT((actual_index >= num_hidden_args) && (index < ArgCount())); | |
| 99 if ((index == 0) && ToClosureFunction() && ToInstanceFunction()) { | 97 if ((index == 0) && ToClosureFunction() && ToInstanceFunction()) { |
| 100 // Retrieve the receiver from the context. | 98 // Retrieve the receiver from the context. |
| 101 const Context& context = Context::Handle(isolate_->top_context()); | 99 const Context& context = Context::Handle(isolate_->top_context()); |
| 102 return context.At(0); | 100 return context.At(0); |
| 103 } else { | 101 } else { |
| 102 const int actual_index = index + NumHiddenArgs(); |
| 104 return ArgAt(actual_index); | 103 return ArgAt(actual_index); |
| 105 } | 104 } |
| 106 } | 105 } |
| 107 | 106 |
| 108 void SetReturn(const Object& value) const; | 107 void SetReturn(const Object& value) const; |
| 109 | 108 |
| 110 static intptr_t isolate_offset() { | 109 static intptr_t isolate_offset() { |
| 111 return OFFSET_OF(NativeArguments, isolate_); | 110 return OFFSET_OF(NativeArguments, isolate_); |
| 112 } | 111 } |
| 113 static intptr_t argc_tag_offset() { | 112 static intptr_t argc_tag_offset() { |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 161 |
| 163 Isolate* isolate_; // Current isolate pointer. | 162 Isolate* isolate_; // Current isolate pointer. |
| 164 int argc_tag_; // Encodes argument count and invoked native call type. | 163 int argc_tag_; // Encodes argument count and invoked native call type. |
| 165 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. | 164 RawObject*(*argv_)[]; // Pointer to an array of arguments to runtime call. |
| 166 RawObject** retval_; // Pointer to the return value area. | 165 RawObject** retval_; // Pointer to the return value area. |
| 167 }; | 166 }; |
| 168 | 167 |
| 169 } // namespace dart | 168 } // namespace dart |
| 170 | 169 |
| 171 #endif // VM_NATIVE_ARGUMENTS_H_ | 170 #endif // VM_NATIVE_ARGUMENTS_H_ |
| OLD | NEW |