aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiana Husikyan <liana@ethdev.com>2015-03-10 02:22:24 +0800
committerLiana Husikyan <liana@ethdev.com>2015-03-10 19:02:48 +0800
commit74a01826ee9587ef9413e2ec808fcd53564f0b9d (patch)
treead0d4cb8d7996b0906d1d3230ab19f697a46ddaa
parent9c82cbeddf1b03cc99660a867de8720d1d174b9c (diff)
downloaddexon-solidity-74a01826ee9587ef9413e2ec808fcd53564f0b9d.tar
dexon-solidity-74a01826ee9587ef9413e2ec808fcd53564f0b9d.tar.gz
dexon-solidity-74a01826ee9587ef9413e2ec808fcd53564f0b9d.tar.bz2
dexon-solidity-74a01826ee9587ef9413e2ec808fcd53564f0b9d.tar.lz
dexon-solidity-74a01826ee9587ef9413e2ec808fcd53564f0b9d.tar.xz
dexon-solidity-74a01826ee9587ef9413e2ec808fcd53564f0b9d.tar.zst
dexon-solidity-74a01826ee9587ef9413e2ec808fcd53564f0b9d.zip
added information about jump type for jump instructions
Conflicts: libevmcore/Assembly.cpp libsolidity/Compiler.cpp
-rw-r--r--Compiler.cpp11
-rw-r--r--CompilerContext.cpp7
-rw-r--r--CompilerContext.h2
-rw-r--r--ExpressionCompiler.cpp5
4 files changed, 19 insertions, 6 deletions
diff --git a/Compiler.cpp b/Compiler.cpp
index 7ff846bd..46888683 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -177,7 +177,9 @@ 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;
- m_context.appendConditionalJumpTo(callDataUnpackerEntryPoints.at(it.first));
+ auto assemblyItem = callDataUnpackerEntryPoints.at(it.first);
+ //assemblyItem.setJumpType(eth::AssemblyItem::JumpType::IntoFunction);
+ m_context.appendConditionalJumpTo(assemblyItem);
}
if (FunctionDefinition const* fallback = _contract.getFallbackFunction())
{
@@ -197,7 +199,9 @@ void Compiler::appendFunctionSelector(ContractDefinition const& _contract)
m_context << callDataUnpackerEntryPoints.at(it.first);
eth::AssemblyItem returnTag = m_context.pushNewTag();
appendCalldataUnpacker(functionType->getParameterTypes());
- m_context.appendJumpTo(m_context.getFunctionEntryLabel(functionType->getDeclaration()));
+ auto assemblyItem = m_context.getFunctionEntryLabel(functionType->getDeclaration());
+ //assemblyItem.setJumpType(eth::AssemblyItem::JumpType::IntoFunction);
+ m_context.appendJumpTo(assemblyItem);
m_context << returnTag;
appendReturnValuePacker(functionType->getReturnParameterTypes());
}
@@ -378,8 +382,9 @@ bool Compiler::visit(FunctionDefinition const& _function)
m_context.removeVariable(*localVariable);
m_context.adjustStackOffset(-(int)c_returnValuesSize);
+
if (!_function.isConstructor())
- m_context << eth::Instruction::JUMP;
+ m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction);
return false;
}
diff --git a/CompilerContext.cpp b/CompilerContext.cpp
index 1dea62e9..f2bb1de2 100644
--- a/CompilerContext.cpp
+++ b/CompilerContext.cpp
@@ -177,6 +177,13 @@ u256 CompilerContext::getStorageLocationOfVariable(const Declaration& _declarati
return it->second;
}
+CompilerContext& CompilerContext::appendJump(eth::AssemblyItem::JumpType _jumpType)
+{
+ eth::AssemblyItem item(eth::Instruction::JUMP);
+ item.setJumpType(_jumpType);
+ return *this << item;
+}
+
void CompilerContext::resetVisitedNodes(ASTNode const* _node)
{
stack<ASTNode const*> newStack;
diff --git a/CompilerContext.h b/CompilerContext.h
index 4d63d8ba..f468d29c 100644
--- a/CompilerContext.h
+++ b/CompilerContext.h
@@ -91,7 +91,7 @@ public:
/// Appends a JUMP to a new tag and @returns the tag
eth::AssemblyItem appendJumpToNew() { return m_asm.appendJump().tag(); }
/// Appends a JUMP to a tag already on the stack
- CompilerContext& appendJump() { return *this << eth::Instruction::JUMP; }
+ CompilerContext& appendJump(eth::AssemblyItem::JumpType _jumpType = eth::AssemblyItem::JumpType::Ordinary);
/// Appends a JUMP to a specific tag
CompilerContext& appendJumpTo(eth::AssemblyItem const& _tag) { m_asm.appendJump(_tag); return *this; }
/// Appends pushing of a new tag and @returns the new tag.
diff --git a/ExpressionCompiler.cpp b/ExpressionCompiler.cpp
index d2457e67..12926112 100644
--- a/ExpressionCompiler.cpp
+++ b/ExpressionCompiler.cpp
@@ -108,7 +108,8 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
retSizeOnStack = returnType->getSizeOnStack();
}
solAssert(retSizeOnStack <= 15, "Stack too deep.");
- m_context << eth::dupInstruction(retSizeOnStack + 1) << eth::Instruction::JUMP;
+ m_context << eth::dupInstruction(retSizeOnStack + 1);
+ m_context.appendJump(eth::AssemblyItem::JumpType::OutOfFunction);
}
void ExpressionCompiler::appendTypeConversion(Type const& _typeOnStack, Type const& _targetType, bool _cleanupNeeded)
@@ -405,7 +406,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
}
_functionCall.getExpression().accept(*this);
- m_context.appendJump();
+ m_context.appendJump(eth::AssemblyItem::JumpType::IntoFunction);
m_context << returnLabel;
unsigned returnParametersSize = CompilerUtils::getSizeOnStack(function.getReturnParameterTypes());