aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity/inlineasm
diff options
context:
space:
mode:
authorchriseth <c@ethdev.com>2017-02-28 17:46:09 +0800
committerchriseth <c@ethdev.com>2017-03-03 22:41:02 +0800
commit369005fc03f13a392abef4b0a8b23226c796d023 (patch)
tree16335cef458033f5aa18674f2660e05ed604c443 /libsolidity/inlineasm
parent13fd569f761154a4e4b4fe2c6431b056f04a9119 (diff)
downloaddexon-solidity-369005fc03f13a392abef4b0a8b23226c796d023.tar.gz
dexon-solidity-369005fc03f13a392abef4b0a8b23226c796d023.tar.zst
dexon-solidity-369005fc03f13a392abef4b0a8b23226c796d023.zip
Remove stack annotations again.
Diffstat (limited to 'libsolidity/inlineasm')
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp31
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.h2
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp20
-rw-r--r--libsolidity/inlineasm/AsmData.h4
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp36
-rw-r--r--libsolidity/inlineasm/AsmPrinter.cpp6
6 files changed, 4 insertions, 95 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index a21c50d1..4296d3a7 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -127,36 +127,7 @@ bool AsmAnalyzer::operator()(Label const& _item)
));
return false;
}
- bool success = true;
- if (!_item.stackInfo.empty())
- {
- Scope::Label& label = boost::get<Scope::Label>(m_currentScope->identifiers[_item.name]);
- if (_item.stackInfo.size() == 1)
- try
- {
- label.stackAdjustment = boost::lexical_cast<int>(_item.stackInfo[0]);
- label.resetStackHeight = false;
- return true;
- }
- catch (boost::bad_lexical_cast const&)
- {
- // Interpret as variable name
- }
- label.resetStackHeight = true;
- for (auto const& stackItem: _item.stackInfo)
- if (!stackItem.empty())
- if (!m_currentScope->registerVariable(stackItem))
- {
- //@TODO secondary location
- m_errors.push_back(make_shared<Error>(
- Error::Type::DeclarationError,
- "Variable name " + stackItem + " already taken in this scope.",
- _item.location
- ));
- success = false;
- }
- }
- return success;
+ return true;
}
bool AsmAnalyzer::operator()(FunctionalAssignment const& _assignment)
diff --git a/libsolidity/inlineasm/AsmAnalysis.h b/libsolidity/inlineasm/AsmAnalysis.h
index cd46cd73..9726210d 100644
--- a/libsolidity/inlineasm/AsmAnalysis.h
+++ b/libsolidity/inlineasm/AsmAnalysis.h
@@ -82,8 +82,6 @@ struct Scope
struct Label
{
size_t id = unassignedLabelId;
- int stackAdjustment = 0;
- bool resetStackHeight = false;
static const size_t errorLabelId = -1;
static const size_t unassignedLabelId = 0;
};
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index 69ce9507..78a9ee27 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -188,26 +188,6 @@ public:
solAssert(m_scope.identifiers.count(_label.name), "");
Scope::Label& label = boost::get<Scope::Label>(m_scope.identifiers[_label.name]);
assignLabelIdIfUnset(label);
- if (label.resetStackHeight)
- {
- size_t numVariables = boost::range::count_if(
- m_scope.identifiers | boost::adaptors::map_values,
- [](Scope::Identifier const& var) { return var.type() == typeid(Scope::Variable) && boost::get<Scope::Variable>(var).active; }
- );
- numVariables += boost::count_if(_label.stackInfo, [](string const& s) { return !s.empty(); });
- m_state.assembly.setDeposit(m_initialDeposit + numVariables);
- }
- else if (label.stackAdjustment != 0)
- m_state.assembly.adjustDeposit(label.stackAdjustment);
- int height = m_state.assembly.deposit();
- for (auto const& identifier: _label.stackInfo | boost::adaptors::reversed)
- if (!identifier.empty())
- {
- solAssert(m_scope.identifiers.count(identifier), "");
- Scope::Variable& var = boost::get<Scope::Variable>(m_scope.identifiers[identifier]);
- var.active = true;
- var.stackHeight = --height;
- }
m_state.assembly.append(eth::AssemblyItem(eth::Tag, label.id));
}
void operator()(assembly::Assignment const& _assignment)
diff --git a/libsolidity/inlineasm/AsmData.h b/libsolidity/inlineasm/AsmData.h
index 5969bf96..d61b5803 100644
--- a/libsolidity/inlineasm/AsmData.h
+++ b/libsolidity/inlineasm/AsmData.h
@@ -42,8 +42,8 @@ struct Literal { SourceLocation location; bool isNumber; std::string value; };
/// External / internal identifier or label reference
struct Identifier { SourceLocation location; std::string name; };
struct FunctionalInstruction;
-/// Jump label ("name:" or "name [x, y, z]:" or "name [-3]:")
-struct Label { SourceLocation location; std::string name; std::vector<std::string> stackInfo; };
+/// Jump label ("name:")
+struct Label { SourceLocation location; std::string name; };
/// Assignemnt (":= x", moves stack top into x, potentially multiple slots)
struct Assignment { SourceLocation location; Identifier variableName; };
struct FunctionalAssignment;
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp
index 9f24d9fb..0fc0a34f 100644
--- a/libsolidity/inlineasm/AsmParser.cpp
+++ b/libsolidity/inlineasm/AsmParser.cpp
@@ -121,42 +121,6 @@ assembly::Statement Parser::parseStatement()
return label;
}
}
- case Token::LBrack:
- {
- if (statement.type() != typeid(assembly::Identifier))
- fatalParserError("Label name must precede \"[\".");
- assembly::Identifier const& identifier = boost::get<assembly::Identifier>(statement);
- Label label = createWithLocation<Label>(identifier.location);
- label.name = identifier.name;
- m_scanner->next();
- if (m_scanner->currentToken() == Token::Number)
- {
- label.stackInfo.push_back(m_scanner->currentLiteral());
- m_scanner->next();
- }
- else if (m_scanner->currentToken() == Token::Sub)
- {
- m_scanner->next();
- label.stackInfo.push_back("-" + m_scanner->currentLiteral());
- expectToken(Token::Number);
- }
- else if (m_scanner->currentToken() != Token::RBrack)
- while (true)
- {
- label.stackInfo.push_back(expectAsmIdentifier());
- if (m_scanner->currentToken() == Token::RBrack)
- break;
- expectToken(Token::Comma);
- }
- // Push an empty string to signify that there were brackets, like in
- // "name[]:", which just resets the stack height to the height of the local variables.
- if (label.stackInfo.empty())
- label.stackInfo.push_back("");
- expectToken(Token::RBrack);
- label.location.end = endPosition();
- expectToken(Token::Colon);
- return label;
- }
default:
break;
}
diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp
index 5ec83281..a70b0b78 100644
--- a/libsolidity/inlineasm/AsmPrinter.cpp
+++ b/libsolidity/inlineasm/AsmPrinter.cpp
@@ -94,11 +94,7 @@ string AsmPrinter::operator()(assembly::FunctionalInstruction const& _functional
string AsmPrinter::operator()(assembly::Label const& _label)
{
- return _label.name + (
- !_label.stackInfo.empty() ?
- "[" + boost::algorithm::join(_label.stackInfo, ", ") + "]" :
- string()
- ) + ":";
+ return _label.name + ":";
}
string AsmPrinter::operator()(assembly::Assignment const& _assignment)