Chromium Code Reviews| Index: runtime/vm/raw_object.h |
| =================================================================== |
| --- runtime/vm/raw_object.h (revision 41399) |
| +++ runtime/vm/raw_object.h (working copy) |
| @@ -1211,13 +1211,21 @@ |
| int32_t num_variables_; |
| RawObject** from() { |
| - return reinterpret_cast<RawObject**>(&ptr()->data()[0]); |
| + VariableDesc* begin = const_cast<VariableDesc*>(ptr()->VariableDescAddr(0)); |
| + return reinterpret_cast<RawObject**>(begin); |
| } |
| // Variable length data follows here. |
| - RawObject** data() { OPEN_ARRAY_START(RawObject*, RawObject*); } |
| + RawObject* const* data() const { OPEN_ARRAY_START(RawObject*, RawObject*); } |
| + const VariableDesc* VariableDescAddr(intptr_t index) const { |
| + ASSERT((index >= 0) && (index < num_variables_ + 1)); |
| + // data() points to the first component of the first descriptor. |
| + return &(reinterpret_cast<const VariableDesc*>(data())[index]); |
| + } |
| RawObject** to(intptr_t num_vars) { |
| - const intptr_t data_length = num_vars * (sizeof(VariableDesc)/kWordSize); |
| - return reinterpret_cast<RawObject**>(&ptr()->data()[data_length - 1]); |
| + VariableDesc* end = |
| + const_cast<VariableDesc*>(ptr()->VariableDescAddr(num_vars)); |
| + // 'end' points at the first word beyond the last descriptor, so step back. |
| + return reinterpret_cast<RawObject**>(end) - 1; |
|
Ivan Posva
2014/11/07 00:18:12
Pointer arithmetic?
|
| } |
| }; |