mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Split Instruction and FunctionalInstruction in Julia
This commit is contained in:
@@ -146,10 +146,11 @@ bool AsmAnalyzer::operator()(FunctionalInstruction const& _instr)
|
||||
if (!expectExpression(arg))
|
||||
success = false;
|
||||
// Parser already checks that the number of arguments is correct.
|
||||
solAssert(instructionInfo(_instr.instruction.instruction).args == int(_instr.arguments.size()), "");
|
||||
if (!(*this)(_instr.instruction))
|
||||
success = false;
|
||||
auto const& info = instructionInfo(_instr.instruction);
|
||||
solAssert(info.args == int(_instr.arguments.size()), "");
|
||||
m_stackHeight += info.ret - info.args;
|
||||
m_info.stackHeightInfo[&_instr] = m_stackHeight;
|
||||
warnOnInstructions(_instr.instruction, _instr.location);
|
||||
return success;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ struct StackAssignment { SourceLocation location; Identifier variableName; };
|
||||
/// the same amount of items as the number of variables.
|
||||
struct Assignment { SourceLocation location; std::vector<Identifier> variableNames; std::shared_ptr<Statement> value; };
|
||||
/// Functional instruction, e.g. "mul(mload(20:u256), add(2:u256, x))"
|
||||
struct FunctionalInstruction { SourceLocation location; Instruction instruction; std::vector<Statement> arguments; };
|
||||
struct FunctionalInstruction { SourceLocation location; solidity::Instruction instruction; std::vector<Statement> arguments; };
|
||||
struct FunctionCall { SourceLocation location; Identifier functionName; std::vector<Statement> arguments; };
|
||||
/// Block-scope variable declaration ("let x:u256 := mload(20:u256)"), non-hoisted
|
||||
struct VariableDeclaration { SourceLocation location; TypedNameList variables; std::shared_ptr<Statement> value; };
|
||||
|
||||
@@ -448,10 +448,11 @@ assembly::Statement Parser::parseCall(assembly::Statement&& _instruction)
|
||||
if (_instruction.type() == typeid(Instruction))
|
||||
{
|
||||
solAssert(!m_julia, "Instructions are invalid in JULIA");
|
||||
Instruction const& instruction = std::move(boost::get<Instruction>(_instruction));
|
||||
FunctionalInstruction ret;
|
||||
ret.instruction = std::move(boost::get<Instruction>(_instruction));
|
||||
ret.location = ret.instruction.location;
|
||||
solidity::Instruction instr = ret.instruction.instruction;
|
||||
ret.instruction = instruction.instruction;
|
||||
ret.location = std::move(instruction.location);
|
||||
solidity::Instruction instr = ret.instruction;
|
||||
InstructionInfo instrInfo = instructionInfo(instr);
|
||||
if (solidity::isDupInstruction(instr))
|
||||
fatalParserError("DUPi instructions not allowed for functional notation");
|
||||
|
||||
@@ -94,7 +94,7 @@ string AsmPrinter::operator()(assembly::FunctionalInstruction const& _functional
|
||||
{
|
||||
solAssert(!m_julia, "");
|
||||
return
|
||||
(*this)(_functionalInstruction.instruction) +
|
||||
boost::to_lower_copy(instructionInfo(_functionalInstruction.instruction).name) +
|
||||
"(" +
|
||||
boost::algorithm::join(
|
||||
_functionalInstruction.arguments | boost::adaptors::transformed(boost::apply_visitor(*this)),
|
||||
|
||||
Reference in New Issue
Block a user