diff options
author | chriseth <chris@ethereum.org> | 2017-03-22 20:21:58 +0800 |
---|---|---|
committer | chriseth <chris@ethereum.org> | 2017-04-25 22:49:03 +0800 |
commit | 580921b3294bc582c68db04f1ebf83b9bec206f5 (patch) | |
tree | 2ca11e27a3ce567377eea1d265628c2bdd31dc4a /libsolidity/inlineasm/AsmAnalysis.h | |
parent | f13c8af3f9f3b0aec88809fbb609e183c9bba4be (diff) | |
download | dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar.gz dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.tar.zst dexon-solidity-580921b3294bc582c68db04f1ebf83b9bec206f5.zip |
Perform stack height checks in assembly analysis phase.
Diffstat (limited to 'libsolidity/inlineasm/AsmAnalysis.h')
-rw-r--r-- | libsolidity/inlineasm/AsmAnalysis.h | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.h b/libsolidity/inlineasm/AsmAnalysis.h index c6d23227..cfc9b25a 100644 --- a/libsolidity/inlineasm/AsmAnalysis.h +++ b/libsolidity/inlineasm/AsmAnalysis.h @@ -53,7 +53,7 @@ struct Scope; /** * Performs the full analysis stage, calls the ScopeFiller internally, then resolves * references and performs other checks. - * @todo Does not yet check for stack height issues. + * If all these checks pass, code generation should not throw errors. */ class AsmAnalyzer: public boost::static_visitor<bool> { @@ -63,7 +63,7 @@ public: bool analyze(assembly::Block const& _block); - bool operator()(assembly::Instruction const&) { return true; } + bool operator()(assembly::Instruction const&); bool operator()(assembly::Literal const& _literal); bool operator()(assembly::Identifier const&); bool operator()(assembly::FunctionalInstruction const& _functionalInstruction); @@ -76,9 +76,16 @@ public: bool operator()(assembly::Block const& _block); private: - bool checkAssignment(assembly::Identifier const& _assignment); + /// Verifies that a variable to be assigned to exists and has the same size + /// as the value, @a _valueSize, unless that is equal to -1. + bool checkAssignment(assembly::Identifier const& _assignment, size_t _valueSize = size_t(-1)); + bool expectDeposit(int _deposit, int _oldHeight, SourceLocation const& _location); Scope& scope(assembly::Block const* _block); + /// Number of excess stack slots generated by function arguments to take into account for + /// next block. + int m_virtualVariablesInNextBlock = 0; + int m_stackHeight = 0; ExternalIdentifierAccess::Resolver const& m_resolver; Scope* m_currentScope = nullptr; Scopes& m_scopes; |