diff options
author | Dimitry <winsvega@mail.ru> | 2016-04-02 20:56:43 +0800 |
---|---|---|
committer | Dimitry <winsvega@mail.ru> | 2016-04-02 20:56:43 +0800 |
commit | 858c41260d4cec26ba38ea3bd2ef71dcede63f7c (patch) | |
tree | 8dd03312a5f926f8dd95a4a7f0798c2b6624c1e3 /libevmasm | |
parent | ccbd3ff63feb696025c18211c3c93bab47f755b0 (diff) | |
download | dexon-solidity-858c41260d4cec26ba38ea3bd2ef71dcede63f7c.tar dexon-solidity-858c41260d4cec26ba38ea3bd2ef71dcede63f7c.tar.gz dexon-solidity-858c41260d4cec26ba38ea3bd2ef71dcede63f7c.tar.bz2 dexon-solidity-858c41260d4cec26ba38ea3bd2ef71dcede63f7c.tar.lz dexon-solidity-858c41260d4cec26ba38ea3bd2ef71dcede63f7c.tar.xz dexon-solidity-858c41260d4cec26ba38ea3bd2ef71dcede63f7c.tar.zst dexon-solidity-858c41260d4cec26ba38ea3bd2ef71dcede63f7c.zip |
rename namespace for instruction.h/cpp in libevmasm
Diffstat (limited to 'libevmasm')
-rw-r--r-- | libevmasm/Assembly.cpp | 4 | ||||
-rw-r--r-- | libevmasm/AssemblyItem.cpp | 6 | ||||
-rw-r--r-- | libevmasm/AssemblyItem.h | 1 | ||||
-rw-r--r-- | libevmasm/BlockDeduplicator.cpp | 2 | ||||
-rw-r--r-- | libevmasm/CommonSubexpressionEliminator.cpp | 4 | ||||
-rw-r--r-- | libevmasm/ExpressionClasses.cpp | 2 | ||||
-rw-r--r-- | libevmasm/GasMeter.cpp | 8 | ||||
-rw-r--r-- | libevmasm/Instruction.cpp | 18 | ||||
-rw-r--r-- | libevmasm/Instruction.h | 4 | ||||
-rw-r--r-- | libevmasm/KnownState.cpp | 2 | ||||
-rw-r--r-- | libevmasm/PathGasMeter.cpp | 6 | ||||
-rw-r--r-- | libevmasm/SemanticInformation.cpp | 4 | ||||
-rw-r--r-- | libevmasm/SemanticInformation.h | 4 |
13 files changed, 33 insertions, 32 deletions
diff --git a/libevmasm/Assembly.cpp b/libevmasm/Assembly.cpp index 7277865e..89159412 100644 --- a/libevmasm/Assembly.cpp +++ b/libevmasm/Assembly.cpp @@ -121,7 +121,7 @@ ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap con switch (i.type()) { case Operation: - _out << " " << instructionInfo(i.instruction()).name << "\t" << i.getJumpTypeAsString(); + _out << " " << getInstructionInfo(i.instruction()).name << "\t" << i.getJumpTypeAsString(); break; case Push: _out << " PUSH " << hex << i.data(); @@ -205,7 +205,7 @@ Json::Value Assembly::streamAsmJson(ostream& _out, StringMap const& _sourceCodes { case Operation: collection.append( - createJsonValue(instructionInfo(i.instruction()).name, i.location().start, i.location().end, i.getJumpTypeAsString())); + createJsonValue(getInstructionInfo(i.instruction()).name, i.location().start, i.location().end, i.getJumpTypeAsString())); break; case Push: collection.append( diff --git a/libevmasm/AssemblyItem.cpp b/libevmasm/AssemblyItem.cpp index d7051064..2bdc6391 100644 --- a/libevmasm/AssemblyItem.cpp +++ b/libevmasm/AssemblyItem.cpp @@ -57,7 +57,7 @@ int AssemblyItem::deposit() const switch (m_type) { case Operation: - return instructionInfo(instruction()).ret - instructionInfo(instruction()).args; + return getInstructionInfo(instruction()).ret - getInstructionInfo(instruction()).args; case Push: case PushString: case PushTag: @@ -93,8 +93,8 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item) switch (_item.type()) { case Operation: - _out << " " << instructionInfo(_item.instruction()).name; - if (_item.instruction() == eth::Instruction::JUMP || _item.instruction() == eth::Instruction::JUMPI) + _out << " " << getInstructionInfo(_item.instruction()).name; + if (_item.instruction() == solidity::Instruction::JUMP || _item.instruction() == solidity::Instruction::JUMPI) _out << "\t" << _item.getJumpTypeAsString(); break; case Push: diff --git a/libevmasm/AssemblyItem.h b/libevmasm/AssemblyItem.h index b9c752f8..9399fef4 100644 --- a/libevmasm/AssemblyItem.h +++ b/libevmasm/AssemblyItem.h @@ -28,6 +28,7 @@ #include <libevmasm/Instruction.h> #include <libevmasm/SourceLocation.h> #include "Exceptions.h" +using namespace dev::solidity; namespace dev { diff --git a/libevmasm/BlockDeduplicator.cpp b/libevmasm/BlockDeduplicator.cpp index d930ea22..d88474a7 100644 --- a/libevmasm/BlockDeduplicator.cpp +++ b/libevmasm/BlockDeduplicator.cpp @@ -106,7 +106,7 @@ BlockDeduplicator::BlockIterator& BlockDeduplicator::BlockIterator::operator++() { if (it == end) return *this; - if (SemanticInformation::altersControlFlow(*it) && *it != AssemblyItem(eth::Instruction::JUMPI)) + if (SemanticInformation::altersControlFlow(*it) && *it != AssemblyItem(solidity::Instruction::JUMPI)) it = end; else { diff --git a/libevmasm/CommonSubexpressionEliminator.cpp b/libevmasm/CommonSubexpressionEliminator.cpp index 0797dd29..80fc100c 100644 --- a/libevmasm/CommonSubexpressionEliminator.cpp +++ b/libevmasm/CommonSubexpressionEliminator.cpp @@ -399,7 +399,7 @@ void CSECodeGenerator::generateClassElement(Id _c, bool _allowSequenced) m_stack.erase(m_stackHeight - i); } appendItem(*expr.item); - if (expr.item->type() != Operation || instructionInfo(expr.item->instruction()).ret == 1) + if (expr.item->type() != Operation || getInstructionInfo(expr.item->instruction()).ret == 1) { m_stack[m_stackHeight] = _c; m_classPositions[_c].insert(m_stackHeight); @@ -407,7 +407,7 @@ void CSECodeGenerator::generateClassElement(Id _c, bool _allowSequenced) else { assertThrow( - instructionInfo(expr.item->instruction()).ret == 0, + getInstructionInfo(expr.item->instruction()).ret == 0, OptimizerException, "Invalid number of return values." ); diff --git a/libevmasm/ExpressionClasses.cpp b/libevmasm/ExpressionClasses.cpp index 9d13a57a..804ec947 100644 --- a/libevmasm/ExpressionClasses.cpp +++ b/libevmasm/ExpressionClasses.cpp @@ -435,7 +435,7 @@ string Pattern::toString() const switch (m_type) { case Operation: - s << instructionInfo(Instruction(unsigned(m_data))).name; + s << getInstructionInfo(Instruction(unsigned(m_data))).name; break; case Push: s << "PUSH " << hex << m_data; diff --git a/libevmasm/GasMeter.cpp b/libevmasm/GasMeter.cpp index 93583169..d57fc351 100644 --- a/libevmasm/GasMeter.cpp +++ b/libevmasm/GasMeter.cpp @@ -84,13 +84,13 @@ GasMeter::GasConsumption GasMeter::estimateMax(AssemblyItem const& _item) break; case Instruction::MLOAD: case Instruction::MSTORE: - gas += memoryGas(classes.find(eth::Instruction::ADD, { + gas += memoryGas(classes.find(solidity::Instruction::ADD, { m_state->relativeStackElement(0), classes.find(AssemblyItem(32)) })); break; case Instruction::MSTORE8: - gas += memoryGas(classes.find(eth::Instruction::ADD, { + gas += memoryGas(classes.find(solidity::Instruction::ADD, { m_state->relativeStackElement(0), classes.find(AssemblyItem(1)) })); @@ -198,7 +198,7 @@ GasMeter::GasConsumption GasMeter::memoryGas(int _stackPosOffset, int _stackPosS if (classes.knownZero(m_state->relativeStackElement(_stackPosSize))) return GasConsumption(0); else - return memoryGas(classes.find(eth::Instruction::ADD, { + return memoryGas(classes.find(solidity::Instruction::ADD, { m_state->relativeStackElement(_stackPosOffset), m_state->relativeStackElement(_stackPosSize) })); @@ -209,7 +209,7 @@ u256 GasMeter::runGas(Instruction _instruction, EVMSchedule const& _es) if (_instruction == Instruction::JUMPDEST) return 1; - int tier = instructionInfo(_instruction).gasPriceTier; + int tier = getInstructionInfo(_instruction).gasPriceTier; assertThrow(tier != InvalidTier, OptimizerException, "Invalid gas tier."); return _es.tierStepGas[tier]; } diff --git a/libevmasm/Instruction.cpp b/libevmasm/Instruction.cpp index 2703112d..e61b8e64 100644 --- a/libevmasm/Instruction.cpp +++ b/libevmasm/Instruction.cpp @@ -19,7 +19,7 @@ * @date 2014 */ -#include "Instruction.h" +#include "./Instruction.h" #include <functional> #include <libdevcore/Common.h> @@ -27,9 +27,9 @@ #include <libdevcore/Log.h> using namespace std; using namespace dev; -using namespace dev::eth; +using namespace dev::solidity; -const std::map<std::string, Instruction> dev::eth::c_instructions = +const std::map<std::string, Instruction> dev::solidity::c_instructions = { { "STOP", Instruction::STOP }, { "ADD", Instruction::ADD }, @@ -297,7 +297,7 @@ static const std::map<Instruction, InstructionInfo> c_instructionInfo = { Instruction::SUICIDE, { "SUICIDE", 0, 1, 0, true, ZeroTier } } }; -void dev::eth::eachInstruction( +void dev::solidity::eachInstruction( bytes const& _mem, function<void(Instruction,u256 const&)> const& _onInstruction ) @@ -307,7 +307,7 @@ void dev::eth::eachInstruction( Instruction instr = Instruction(*it); size_t additional = 0; if (isValidInstruction(instr)) - additional = instructionInfo(instr).additional; + additional = getInstructionInfo(instr).additional; u256 data; for (size_t i = 0; i < additional; ++i) { @@ -319,7 +319,7 @@ void dev::eth::eachInstruction( } } -string dev::eth::disassemble(bytes const& _mem) +string dev::solidity::disassemble(bytes const& _mem) { stringstream ret; eachInstruction(_mem, [&](Instruction _instr, u256 const& _data) { @@ -327,7 +327,7 @@ string dev::eth::disassemble(bytes const& _mem) ret << "0x" << hex << int(_instr) << " "; else { - InstructionInfo info = instructionInfo(_instr); + InstructionInfo info = getInstructionInfo(_instr); ret << info.name << " "; if (info.additional) ret << "0x" << hex << _data << " "; @@ -336,7 +336,7 @@ string dev::eth::disassemble(bytes const& _mem) return ret.str(); } -InstructionInfo dev::eth::instructionInfo(Instruction _inst) +InstructionInfo dev::solidity::getInstructionInfo(Instruction _inst) { try { @@ -348,7 +348,7 @@ InstructionInfo dev::eth::instructionInfo(Instruction _inst) } } -bool dev::eth::isValidInstruction(Instruction _inst) +bool dev::solidity::isValidInstruction(Instruction _inst) { return !!c_instructionInfo.count(_inst); } diff --git a/libevmasm/Instruction.h b/libevmasm/Instruction.h index 2d415c08..ff94569c 100644 --- a/libevmasm/Instruction.h +++ b/libevmasm/Instruction.h @@ -28,7 +28,7 @@ namespace dev { -namespace eth +namespace solidity { DEV_SIMPLE_EXCEPTION(InvalidDeposit); @@ -250,7 +250,7 @@ struct InstructionInfo }; /// Information on all the instructions. -InstructionInfo instructionInfo(Instruction _inst); +InstructionInfo getInstructionInfo(Instruction _inst); /// check whether instructions exists bool isValidInstruction(Instruction _inst); diff --git a/libevmasm/KnownState.cpp b/libevmasm/KnownState.cpp index dd269ff4..100598a7 100644 --- a/libevmasm/KnownState.cpp +++ b/libevmasm/KnownState.cpp @@ -101,7 +101,7 @@ KnownState::StoreOperation KnownState::feedItem(AssemblyItem const& _item, bool else { Instruction instruction = _item.instruction(); - InstructionInfo info = instructionInfo(instruction); + InstructionInfo info = getInstructionInfo(instruction); if (SemanticInformation::isDupInstruction(_item)) setStackElement( m_stackHeight + 1, diff --git a/libevmasm/PathGasMeter.cpp b/libevmasm/PathGasMeter.cpp index 8f7314f8..5988c280 100644 --- a/libevmasm/PathGasMeter.cpp +++ b/libevmasm/PathGasMeter.cpp @@ -76,7 +76,7 @@ GasMeter::GasConsumption PathGasMeter::handleQueueItem() bool branchStops = false; jumpTags.clear(); AssemblyItem const& item = m_items.at(index); - if (item.type() == Tag || item == AssemblyItem(eth::Instruction::JUMPDEST)) + if (item.type() == Tag || item == AssemblyItem(solidity::Instruction::JUMPDEST)) { // Do not allow any backwards jump. This is quite restrictive but should work for // the simplest things. @@ -84,14 +84,14 @@ GasMeter::GasConsumption PathGasMeter::handleQueueItem() return GasMeter::GasConsumption::infinite(); path->visitedJumpdests.insert(index); } - else if (item == AssemblyItem(eth::Instruction::JUMP)) + else if (item == AssemblyItem(solidity::Instruction::JUMP)) { branchStops = true; jumpTags = state->tagsInExpression(state->relativeStackElement(0)); if (jumpTags.empty()) // unknown jump destination return GasMeter::GasConsumption::infinite(); } - else if (item == AssemblyItem(eth::Instruction::JUMPI)) + else if (item == AssemblyItem(solidity::Instruction::JUMPI)) { ExpressionClasses::Id condition = state->relativeStackElement(-1); if (classes.knownNonZero(condition) || !classes.knownZero(condition)) diff --git a/libevmasm/SemanticInformation.cpp b/libevmasm/SemanticInformation.cpp index ea579b83..0c0a6e6b 100644 --- a/libevmasm/SemanticInformation.cpp +++ b/libevmasm/SemanticInformation.cpp @@ -53,7 +53,7 @@ bool SemanticInformation::breaksCSEAnalysisBlock(AssemblyItem const& _item) return true; // GAS and PC assume a specific order of opcodes if (_item.instruction() == Instruction::MSIZE) return true; // msize is modified already by memory access, avoid that for now - InstructionInfo info = instructionInfo(_item.instruction()); + InstructionInfo info = getInstructionInfo(_item.instruction()); if (_item.instruction() == Instruction::SSTORE) return false; if (_item.instruction() == Instruction::MSTORE) @@ -147,7 +147,7 @@ bool SemanticInformation::isDeterministic(AssemblyItem const& _item) } } -bool SemanticInformation::invalidatesMemory(Instruction _instruction) +bool SemanticInformation::invalidatesMemory(solidity::Instruction _instruction) { switch (_instruction) { diff --git a/libevmasm/SemanticInformation.h b/libevmasm/SemanticInformation.h index d18cac7c..0eda5ed5 100644 --- a/libevmasm/SemanticInformation.h +++ b/libevmasm/SemanticInformation.h @@ -50,9 +50,9 @@ struct SemanticInformation /// the information in the current block header, memory, storage or stack. static bool isDeterministic(AssemblyItem const& _item); /// @returns true if the given instruction modifies memory. - static bool invalidatesMemory(Instruction _instruction); + static bool invalidatesMemory(solidity::Instruction _instruction); /// @returns true if the given instruction modifies storage (even indirectly). - static bool invalidatesStorage(Instruction _instruction); + static bool invalidatesStorage(solidity::Instruction _instruction); }; } |