mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
return instructionInfo style
This commit is contained in:
parent
9816510065
commit
d43d4347bf
@ -121,7 +121,7 @@ ostream& Assembly::streamAsm(ostream& _out, string const& _prefix, StringMap con
|
||||
switch (i.type())
|
||||
{
|
||||
case Operation:
|
||||
_out << " " << getInstructionInfo(i.instruction()).name << "\t" << i.getJumpTypeAsString();
|
||||
_out << " " << instructionInfo(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(getInstructionInfo(i.instruction()).name, i.location().start, i.location().end, i.getJumpTypeAsString()));
|
||||
createJsonValue(instructionInfo(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 getInstructionInfo(instruction()).ret - getInstructionInfo(instruction()).args;
|
||||
return instructionInfo(instruction()).ret - instructionInfo(instruction()).args;
|
||||
case Push:
|
||||
case PushString:
|
||||
case PushTag:
|
||||
@ -93,7 +93,7 @@ ostream& dev::eth::operator<<(ostream& _out, AssemblyItem const& _item)
|
||||
switch (_item.type())
|
||||
{
|
||||
case Operation:
|
||||
_out << " " << getInstructionInfo(_item.instruction()).name;
|
||||
_out << " " << instructionInfo(_item.instruction()).name;
|
||||
if (_item.instruction() == solidity::Instruction::JUMP || _item.instruction() == solidity::Instruction::JUMPI)
|
||||
_out << "\t" << _item.getJumpTypeAsString();
|
||||
break;
|
||||
|
@ -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 || getInstructionInfo(expr.item->instruction()).ret == 1)
|
||||
if (expr.item->type() != Operation || instructionInfo(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(
|
||||
getInstructionInfo(expr.item->instruction()).ret == 0,
|
||||
instructionInfo(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 << getInstructionInfo(Instruction(unsigned(m_data))).name;
|
||||
s << instructionInfo(Instruction(unsigned(m_data))).name;
|
||||
break;
|
||||
case Push:
|
||||
s << "PUSH " << hex << m_data;
|
||||
|
@ -209,7 +209,7 @@ u256 GasMeter::runGas(Instruction _instruction, EVMSchedule const& _es)
|
||||
if (_instruction == Instruction::JUMPDEST)
|
||||
return 1;
|
||||
|
||||
int tier = getInstructionInfo(_instruction).gasPriceTier;
|
||||
int tier = instructionInfo(_instruction).gasPriceTier;
|
||||
assertThrow(tier != InvalidTier, OptimizerException, "Invalid gas tier.");
|
||||
return _es.tierStepGas[tier];
|
||||
}
|
||||
|
@ -307,7 +307,7 @@ void dev::solidity::eachInstruction(
|
||||
Instruction instr = Instruction(*it);
|
||||
size_t additional = 0;
|
||||
if (isValidInstruction(instr))
|
||||
additional = getInstructionInfo(instr).additional;
|
||||
additional = instructionInfo(instr).additional;
|
||||
u256 data;
|
||||
for (size_t i = 0; i < additional; ++i)
|
||||
{
|
||||
@ -327,7 +327,7 @@ string dev::solidity::disassemble(bytes const& _mem)
|
||||
ret << "0x" << hex << int(_instr) << " ";
|
||||
else
|
||||
{
|
||||
InstructionInfo info = getInstructionInfo(_instr);
|
||||
InstructionInfo info = instructionInfo(_instr);
|
||||
ret << info.name << " ";
|
||||
if (info.additional)
|
||||
ret << "0x" << hex << _data << " ";
|
||||
@ -336,7 +336,7 @@ string dev::solidity::disassemble(bytes const& _mem)
|
||||
return ret.str();
|
||||
}
|
||||
|
||||
InstructionInfo dev::solidity::getInstructionInfo(Instruction _inst)
|
||||
InstructionInfo dev::solidity::instructionInfo(Instruction _inst)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -250,7 +250,7 @@ struct InstructionInfo
|
||||
};
|
||||
|
||||
/// Information on all the instructions.
|
||||
InstructionInfo getInstructionInfo(Instruction _inst);
|
||||
InstructionInfo instructionInfo(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 = getInstructionInfo(instruction);
|
||||
InstructionInfo info = instructionInfo(instruction);
|
||||
if (SemanticInformation::isDupInstruction(_item))
|
||||
setStackElement(
|
||||
m_stackHeight + 1,
|
||||
|
@ -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 = getInstructionInfo(_item.instruction());
|
||||
InstructionInfo info = instructionInfo(_item.instruction());
|
||||
if (_item.instruction() == Instruction::SSTORE)
|
||||
return false;
|
||||
if (_item.instruction() == Instruction::MSTORE)
|
||||
|
@ -375,7 +375,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
||||
else if (c_instructions.count(us))
|
||||
{
|
||||
auto it = c_instructions.find(us);
|
||||
int ea = getInstructionInfo(it->second).args;
|
||||
int ea = instructionInfo(it->second).args;
|
||||
if (ea >= 0)
|
||||
requireSize(ea);
|
||||
else
|
||||
|
@ -154,7 +154,7 @@ assembly::Statement Parser::parseElementaryOperation(bool _onlySinglePusher)
|
||||
dev::solidity::Instruction const& instr = s_instructions[literal];
|
||||
if (_onlySinglePusher)
|
||||
{
|
||||
InstructionInfo info = dev::solidity::getInstructionInfo(instr);
|
||||
InstructionInfo info = dev::solidity::instructionInfo(instr);
|
||||
if (info.ret != 1)
|
||||
fatalParserError("Instruction " + info.name + " not allowed in this context.");
|
||||
}
|
||||
@ -200,7 +200,7 @@ FunctionalInstruction Parser::parseFunctionalInstruction(assembly::Statement con
|
||||
if (_instruction.type() != typeid(Instruction))
|
||||
fatalParserError("Assembly instruction required in front of \"(\")");
|
||||
solidity::Instruction instr = boost::get<solidity::assembly::Instruction>(_instruction).instruction;
|
||||
InstructionInfo instrInfo = getInstructionInfo(instr);
|
||||
InstructionInfo instrInfo = instructionInfo(instr);
|
||||
if (solidity::Instruction::DUP1 <= instr && instr <= solidity::Instruction::DUP16)
|
||||
fatalParserError("DUPi instructions not allowed for functional notation");
|
||||
if (solidity::Instruction::SWAP1 <= instr && instr <= solidity::Instruction::SWAP16)
|
||||
|
Loading…
Reference in New Issue
Block a user