Browse Source

added brackets for printing in/out

cleaned up
cl-refactor
Liana Husikyan 10 years ago
parent
commit
035451db40
  1. 10
      libevmcore/Assembly.cpp
  2. 6
      libevmcore/Assembly.h
  3. 8
      libsolidity/Compiler.cpp
  4. 2
      libsolidity/CompilerContext.h

10
libevmcore/Assembly.cpp

@ -82,9 +82,9 @@ string AssemblyItem::getJumpTypeAsString() const
switch (m_jumpType)
{
case JumpType::IntoFunction:
return "in";
return "[in]";
case JumpType::OutOfFunction:
return "out";
return "[out]";
case JumpType::Ordinary:
default:
return "";
@ -210,7 +210,7 @@ string Assembly::getLocationFromSources(StringMap const& _sourceCodes, SourceLoc
return move(cut);
}
ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const
ostream& Assembly::stream(ostream& _out, string const& _prefix, StringMap const& _sourceCodes) const
{
_out << _prefix << ".code:" << endl;
for (AssemblyItem const& i: m_items)
@ -219,7 +219,7 @@ ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap con
switch (i.m_type)
{
case Operation:
_out << " " << instructionInfo((Instruction)(byte)i.m_data).name << "\t\t" << i.getJumpTypeAsString();
_out << " " << instructionInfo((Instruction)(byte)i.m_data).name << "\t" << i.getJumpTypeAsString();
break;
case Push:
_out << " PUSH " << i.m_data;
@ -266,7 +266,7 @@ ostream& Assembly::streamRLP(ostream& _out, string const& _prefix, StringMap con
for (size_t i = 0; i < m_subs.size(); ++i)
{
_out << _prefix << " " << hex << i << ": " << endl;
m_subs[i].streamRLP(_out, _prefix + " ", _sourceCodes);
m_subs[i].stream(_out, _prefix + " ", _sourceCodes);
}
}
return _out;

6
libevmcore/Assembly.h

@ -121,7 +121,7 @@ public:
void popTo(int _deposit) { while (m_deposit > _deposit) append(Instruction::POP); }
void injectStart(AssemblyItem const& _i);
std::string out() const { std::stringstream ret; streamRLP(ret); return ret.str(); }
std::string out() const { std::stringstream ret; stream(ret); return ret.str(); }
int deposit() const { return m_deposit; }
void adjustDeposit(int _adjustment) { m_deposit += _adjustment; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); }
void setDeposit(int _deposit) { m_deposit = _deposit; if (asserts(m_deposit >= 0)) BOOST_THROW_EXCEPTION(InvalidDeposit()); }
@ -131,7 +131,7 @@ public:
bytes assemble() const;
Assembly& optimise(bool _enable);
std::ostream& streamRLP(std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap()) const;
std::ostream& stream(std::ostream& _out, std::string const& _prefix = "", const StringMap &_sourceCodes = StringMap()) const;
protected:
std::string getLocationFromSources(StringMap const& _sourceCodes, SourceLocation const& _location) const;
@ -153,7 +153,7 @@ protected:
inline std::ostream& operator<<(std::ostream& _out, Assembly const& _a)
{
_a.streamRLP(_out);
_a.stream(_out);
return _out;
}

8
libsolidity/Compiler.cpp

@ -177,9 +177,7 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
{
callDataUnpackerEntryPoints.insert(std::make_pair(it.first, m_context.newTag()));
m_context << eth::dupInstruction(1) << u256(FixedHash<4>::Arith(it.first)) << eth::Instruction::EQ;
auto assemblyItem = callDataUnpackerEntryPoints.at(it.first);
//assemblyItem.setJumpType(eth::AssemblyItem::JumpType::IntoFunction);
m_context.appendConditionalJumpTo(assemblyItem);
m_context.appendConditionalJumpTo(callDataUnpackerEntryPoints.at(it.first));
}
if (FunctionDefinition const* fallback = _contract.getFallbackFunction())
{
@ -199,9 +197,7 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
m_context << callDataUnpackerEntryPoints.at(it.first);
eth::AssemblyItem returnTag = m_context.pushNewTag();
appendCalldataUnpacker(functionType->getParameterTypes());
auto assemblyItem = m_context.getFunctionEntryLabel(functionType->getDeclaration());
//assemblyItem.setJumpType(eth::AssemblyItem::JumpType::IntoFunction);
m_context.appendJumpTo(assemblyItem);
m_context.appendJumpTo(m_context.getFunctionEntryLabel(functionType->getDeclaration()));
m_context << returnTag;
appendReturnValuePacker(functionType->getReturnParameterTypes());
}

2
libsolidity/CompilerContext.h

@ -120,7 +120,7 @@ public:
eth::Assembly const& getAssembly() const { return m_asm; }
/// @arg _sourceCodes is the map of input files to source code strings
void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const { m_asm.streamRLP(_stream, "", _sourceCodes); }
void streamAssembly(std::ostream& _stream, StringMap const& _sourceCodes = StringMap()) const { m_asm.stream(_stream, "", _sourceCodes); }
bytes getAssembledBytecode(bool _optimize = false) { return m_asm.optimise(_optimize).assemble(); }

Loading…
Cancel
Save