aboutsummaryrefslogtreecommitdiffstats
path: root/Compiler.cpp
diff options
context:
space:
mode:
authorLefteris Karapetsas <lefteris@refu.co>2015-02-23 23:31:36 +0800
committerLefteris Karapetsas <lefteris@refu.co>2015-02-25 00:16:22 +0800
commit38cb123a82dfa0d77c7eb629dfb9307463548a12 (patch)
tree3f3ecdcdcf40dc7b0affbf72f22adc55ae38ff1b /Compiler.cpp
parent820ed2dfe17d93a586ba1519333bbe79cc6b9a9c (diff)
downloaddexon-solidity-38cb123a82dfa0d77c7eb629dfb9307463548a12.tar
dexon-solidity-38cb123a82dfa0d77c7eb629dfb9307463548a12.tar.gz
dexon-solidity-38cb123a82dfa0d77c7eb629dfb9307463548a12.tar.bz2
dexon-solidity-38cb123a82dfa0d77c7eb629dfb9307463548a12.tar.lz
dexon-solidity-38cb123a82dfa0d77c7eb629dfb9307463548a12.tar.xz
dexon-solidity-38cb123a82dfa0d77c7eb629dfb9307463548a12.tar.zst
dexon-solidity-38cb123a82dfa0d77c7eb629dfb9307463548a12.zip
Adding location information to assembly items
- In order to facilitate this addition we also now have a ScopeGuard object used in the Compiler to set the currently visited node.
Diffstat (limited to 'Compiler.cpp')
-rw-r--r--Compiler.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/Compiler.cpp b/Compiler.cpp
index e691394c..7b79959c 100644
--- a/Compiler.cpp
+++ b/Compiler.cpp
@@ -273,6 +273,7 @@ void Compiler::initializeStateVariables(ContractDefinition const& _contract)
bool Compiler::visit(VariableDeclaration const& _variableDeclaration)
{
solAssert(_variableDeclaration.isStateVariable(), "Compiler visit to non-state variable declaration.");
+ CompilerContext::LocationSetter locationSetter(m_context, &_variableDeclaration);
m_context.startFunction(_variableDeclaration);
m_breakTags.clear();
@@ -286,6 +287,7 @@ bool Compiler::visit(VariableDeclaration const& _variableDeclaration)
bool Compiler::visit(FunctionDefinition const& _function)
{
+ CompilerContext::LocationSetter locationSetter(m_context, &_function);
//@todo to simplify this, the calling convention could by changed such that
// caller puts: [retarg0] ... [retargm] [return address] [arg0] ... [argn]
// although note that this reduces the size of the visible stack
@@ -355,7 +357,7 @@ bool Compiler::visit(FunctionDefinition const& _function)
bool Compiler::visit(IfStatement const& _ifStatement)
{
StackHeightChecker checker(m_context);
-
+ CompilerContext::LocationSetter locationSetter(m_context, &_ifStatement);
compileExpression(_ifStatement.getCondition());
eth::AssemblyItem trueTag = m_context.appendConditionalJump();
if (_ifStatement.getFalseStatement())
@@ -372,7 +374,7 @@ bool Compiler::visit(IfStatement const& _ifStatement)
bool Compiler::visit(WhileStatement const& _whileStatement)
{
StackHeightChecker checker(m_context);
-
+ CompilerContext::LocationSetter locationSetter(m_context, &_whileStatement);
eth::AssemblyItem loopStart = m_context.newTag();
eth::AssemblyItem loopEnd = m_context.newTag();
m_continueTags.push_back(loopStart);
@@ -398,7 +400,7 @@ bool Compiler::visit(WhileStatement const& _whileStatement)
bool Compiler::visit(ForStatement const& _forStatement)
{
StackHeightChecker checker(m_context);
-
+ CompilerContext::LocationSetter locationSetter(m_context, &_forStatement);
eth::AssemblyItem loopStart = m_context.newTag();
eth::AssemblyItem loopEnd = m_context.newTag();
m_continueTags.push_back(loopStart);
@@ -433,15 +435,17 @@ bool Compiler::visit(ForStatement const& _forStatement)
return false;
}
-bool Compiler::visit(Continue const&)
+bool Compiler::visit(Continue const& _continueStatement)
{
+ CompilerContext::LocationSetter locationSetter(m_context, &_continueStatement);
if (!m_continueTags.empty())
m_context.appendJumpTo(m_continueTags.back());
return false;
}
-bool Compiler::visit(Break const&)
+bool Compiler::visit(Break const& _breakStatement)
{
+ CompilerContext::LocationSetter locationSetter(m_context, &_breakStatement);
if (!m_breakTags.empty())
m_context.appendJumpTo(m_breakTags.back());
return false;
@@ -449,6 +453,7 @@ bool Compiler::visit(Break const&)
bool Compiler::visit(Return const& _return)
{
+ CompilerContext::LocationSetter locationSetter(m_context, &_return);
//@todo modifications are needed to make this work with functions returning multiple values
if (Expression const* expression = _return.getExpression())
{
@@ -467,6 +472,7 @@ bool Compiler::visit(Return const& _return)
bool Compiler::visit(VariableDeclarationStatement const& _variableDeclarationStatement)
{
StackHeightChecker checker(m_context);
+ CompilerContext::LocationSetter locationSetter(m_context, &_variableDefinition);
if (Expression const* expression = _variableDeclarationStatement.getExpression())
{
compileExpression(*expression, _variableDeclarationStatement.getDeclaration().getType());
@@ -479,6 +485,7 @@ bool Compiler::visit(VariableDeclarationStatement const& _variableDeclarationSta
bool Compiler::visit(ExpressionStatement const& _expressionStatement)
{
StackHeightChecker checker(m_context);
+ CompilerContext::LocationSetter locationSetter(m_context, &_expressionStatement);
Expression const& expression = _expressionStatement.getExpression();
compileExpression(expression);
CompilerUtils(m_context).popStackElement(*expression.getType());
@@ -486,9 +493,10 @@ bool Compiler::visit(ExpressionStatement const& _expressionStatement)
return false;
}
-bool Compiler::visit(PlaceholderStatement const&)
+bool Compiler::visit(PlaceholderStatement const& _placeholderStatement)
{
StackHeightChecker checker(m_context);
+ CompilerContext::LocationSetter locationSetter(m_context, &_placeholderStatement);
++m_modifierDepth;
appendModifierOrFunctionCode();
--m_modifierDepth;