diff options
author | chriseth <c@ethdev.com> | 2015-05-20 06:27:07 +0800 |
---|---|---|
committer | chriseth <c@ethdev.com> | 2015-05-20 06:28:15 +0800 |
commit | d015945a1db28ba55ce674a73091742b781d2d9d (patch) | |
tree | 1dfbc3afa30e700181e04b99c9685ff707043024 /KnownState.cpp | |
parent | 3ecd54a83513d8b59b5e27c671a036870cf1bc90 (diff) | |
download | dexon-solidity-d015945a1db28ba55ce674a73091742b781d2d9d.tar.gz dexon-solidity-d015945a1db28ba55ce674a73091742b781d2d9d.tar.zst dexon-solidity-d015945a1db28ba55ce674a73091742b781d2d9d.zip |
Gas estimation taking known state into account.
Diffstat (limited to 'KnownState.cpp')
-rw-r--r-- | KnownState.cpp | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/KnownState.cpp b/KnownState.cpp index 895778ed..d62dbf17 100644 --- a/KnownState.cpp +++ b/KnownState.cpp @@ -92,7 +92,11 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool else if (_item.type() != Operation) { assertThrow(_item.deposit() == 1, InvalidDeposit, ""); - setStackElement(++m_stackHeight, m_expressionClasses->find(_item, {}, _copyItem)); + if (_item.pushedValue()) + // only available after assembly stage, should not be used for optimisation + setStackElement(++m_stackHeight, m_expressionClasses->find(*_item.pushedValue())); + else + setStackElement(++m_stackHeight, m_expressionClasses->find(_item, {}, _copyItem)); } else { @@ -230,7 +234,12 @@ ExpressionClasses::Id KnownState::stackElement(int _stackHeight, SourceLocation return m_stackElements.at(_stackHeight); // Stack element not found (not assigned yet), create new unknown equivalence class. return m_stackElements[_stackHeight] = - m_expressionClasses->find(AssemblyItem(UndefinedItem, _stackHeight, _location)); + m_expressionClasses->find(AssemblyItem(UndefinedItem, _stackHeight, _location)); +} + +KnownState::Id KnownState::relativeStackElement(int _stackOffset, SourceLocation const& _location) +{ + return stackElement(m_stackHeight + _stackOffset, _location); } void KnownState::clearTagUnions() |