Browse Source

Improve stack binary interface

cl-refactor
Paweł Bylica 10 years ago
parent
commit
bd3cd40e96
  1. 40
      evmcc/Stack.cpp

40
evmcc/Stack.cpp

@ -120,42 +120,34 @@ EXPORT void* evmccrt_stack_create()
return stack; return stack;
} }
EXPORT void evmccrt_stack_push(void* _stack, void* _pWord) EXPORT void evmccrt_stack_push(StackImpl* _stack, i256* _word)
{ {
auto stack = static_cast<StackImpl*>(_stack); debugStack("push", *_word);
auto word = static_cast<i256*>(_pWord); _stack->push_back(*_word);
debugStack("push", *word);
stack->push_back(*word);
} }
EXPORT void evmccrt_stack_pop(void* _stack, void* _pWord) EXPORT void evmccrt_stack_pop(StackImpl* _stack, i256* _outWord)
{ {
auto stack = static_cast<StackImpl*>(_stack); assert(!_stack->empty());
assert(!stack->empty()); auto word = &_stack->back();
auto word = &stack->back();
debugStack("pop", *word); debugStack("pop", *word);
auto outWord = static_cast<i256*>(_pWord); _stack->pop_back();
stack->pop_back(); *_outWord = *word;
*outWord = *word;
} }
EXPORT void evmccrt_stack_get(void* _stack, uint32_t _index, void* _pWord) EXPORT void evmccrt_stack_get(StackImpl* _stack, uint32_t _index, i256* _outWord)
{ {
auto stack = static_cast<StackImpl*>(_stack); assert(_index < _stack->size());
assert(_index < stack->size()); auto word = _stack->rbegin() + _index;
auto word = stack->rbegin() + _index;
debugStack("get", *word, _index); debugStack("get", *word, _index);
auto outWord = static_cast<i256*>(_pWord); *_outWord = *word;
*outWord = *word;
} }
EXPORT void evmccrt_stack_set(void* _stack, uint32_t _index, void* _pWord) EXPORT void evmccrt_stack_set(StackImpl* _stack, uint32_t _index, i256* _word)
{ {
auto stack = static_cast<StackImpl*>(_stack); assert(_index < _stack->size());
auto word = static_cast<i256*>(_pWord); *(_stack->rbegin() + _index) = *_word;
assert(_index < stack->size()); debugStack("set", *_word, _index);
*(stack->rbegin() + _index) = *word;
debugStack("set", *word, _index);
} }
} // extern "C" } // extern "C"

Loading…
Cancel
Save