mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
rename namespace for instruction.h/cpp in libevmasm
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <libevmasm/Instruction.h>
|
||||
#include <libevmasm/SourceLocation.h>
|
||||
#include "Exceptions.h"
|
||||
using namespace dev::solidity;
|
||||
|
||||
namespace dev
|
||||
{
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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."
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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];
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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))
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user