aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorAlex Beregszaszi <alex@rtfs.hu>2017-05-06 01:56:29 +0800
committerAlex Beregszaszi <alex@rtfs.hu>2017-05-23 01:45:34 +0800
commitcb4966046d9871b63084ddcf0ff6fac8a4c322aa (patch)
tree3fde5c5114865b10c30c71b8a2327a476868d041 /libsolidity
parent15b4d4def23bcf0feb93c67dccc137baa59d5102 (diff)
downloaddexon-solidity-cb4966046d9871b63084ddcf0ff6fac8a4c322aa.tar
dexon-solidity-cb4966046d9871b63084ddcf0ff6fac8a4c322aa.tar.gz
dexon-solidity-cb4966046d9871b63084ddcf0ff6fac8a4c322aa.tar.bz2
dexon-solidity-cb4966046d9871b63084ddcf0ff6fac8a4c322aa.tar.lz
dexon-solidity-cb4966046d9871b63084ddcf0ff6fac8a4c322aa.tar.xz
dexon-solidity-cb4966046d9871b63084ddcf0ff6fac8a4c322aa.tar.zst
dexon-solidity-cb4966046d9871b63084ddcf0ff6fac8a4c322aa.zip
Enable a single right hand item on let
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/inlineasm/AsmAnalysis.cpp21
-rw-r--r--libsolidity/inlineasm/AsmCodeGen.cpp3
-rw-r--r--libsolidity/inlineasm/AsmData.h2
-rw-r--r--libsolidity/inlineasm/AsmParser.cpp11
-rw-r--r--libsolidity/inlineasm/AsmPrinter.cpp7
5 files changed, 7 insertions, 37 deletions
diff --git a/libsolidity/inlineasm/AsmAnalysis.cpp b/libsolidity/inlineasm/AsmAnalysis.cpp
index 8d3d1fd2..5062fcf4 100644
--- a/libsolidity/inlineasm/AsmAnalysis.cpp
+++ b/libsolidity/inlineasm/AsmAnalysis.cpp
@@ -181,32 +181,15 @@ bool AsmAnalyzer::operator()(FunctionalAssignment const& _assignment)
bool AsmAnalyzer::operator()(assembly::VariableDeclaration const& _varDecl)
{
- // The number of variable names and values must match. One exception
- // is a single value, where a tuple assignment is assumed from a function.
- if (_varDecl.variables.size() != _varDecl.values.size())
- {
- if (_varDecl.values.size() != 1)
- {
- m_errors.push_back(make_shared<Error>(
- Error::Type::DeclarationError,
- "Variable declaration name and value count mismatch.",
- _varDecl.location
- ));
- return false;
- }
- }
-
int const expectedItems = _varDecl.variables.size();
int const stackHeight = m_stackHeight;
- for (auto const& value: _varDecl.values)
- if (!boost::apply_visitor(*this, value))
- return false;
+ bool success = boost::apply_visitor(*this, *_varDecl.value);
solAssert(m_stackHeight - stackHeight == expectedItems, "Invalid value size.");
for (auto const& variable: _varDecl.variables)
boost::get<Scope::Variable>(m_currentScope->identifiers.at(variable.name)).active = true;
m_info.stackHeightInfo[&_varDecl] = m_stackHeight;
- return true;
+ return success;
}
bool AsmAnalyzer::operator()(assembly::FunctionDefinition const& _funDef)
diff --git a/libsolidity/inlineasm/AsmCodeGen.cpp b/libsolidity/inlineasm/AsmCodeGen.cpp
index 1063d552..02d5ced0 100644
--- a/libsolidity/inlineasm/AsmCodeGen.cpp
+++ b/libsolidity/inlineasm/AsmCodeGen.cpp
@@ -252,8 +252,7 @@ public:
{
int height = m_assembly.stackHeight();
int expectedItems = _varDecl.variables.size();
- for (auto const& value: _varDecl.values)
- boost::apply_visitor(*this, value);
+ boost::apply_visitor(*this, *_varDecl.value);
expectDeposit(expectedItems, height);
for (auto const& variable: _varDecl.variables)
{
diff --git a/libsolidity/inlineasm/AsmData.h b/libsolidity/inlineasm/AsmData.h
index bf21ba00..65dfbadf 100644
--- a/libsolidity/inlineasm/AsmData.h
+++ b/libsolidity/inlineasm/AsmData.h
@@ -65,7 +65,7 @@ struct FunctionalAssignment { SourceLocation location; Identifier variableName;
struct FunctionalInstruction { SourceLocation location; 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::vector<Statement> values; };
+struct VariableDeclaration { SourceLocation location; TypedNameList variables; std::shared_ptr<Statement> value; };
/// Block that creates a scope (frees declared stack variables)
struct Block { SourceLocation location; std::vector<Statement> statements; };
/// Function definition ("function f(a, b) -> (d, e) { ... }")
diff --git a/libsolidity/inlineasm/AsmParser.cpp b/libsolidity/inlineasm/AsmParser.cpp
index 53954a49..73f70e3f 100644
--- a/libsolidity/inlineasm/AsmParser.cpp
+++ b/libsolidity/inlineasm/AsmParser.cpp
@@ -268,15 +268,8 @@ assembly::VariableDeclaration Parser::parseVariableDeclaration()
}
expectToken(Token::Colon);
expectToken(Token::Assign);
- while (true)
- {
- varDecl.values.emplace_back(new Statement(parseExpression()));
- if (m_scanner->currentToken() == Token::Comma)
- expectToken(Token::Comma);
- else
- break;
- }
- varDecl.location.end = locationOf(varDecl.values.back()).end;
+ varDecl.value.reset(new Statement(parseExpression()));
+ varDecl.location.end = locationOf(*varDecl.value).end;
return varDecl;
}
diff --git a/libsolidity/inlineasm/AsmPrinter.cpp b/libsolidity/inlineasm/AsmPrinter.cpp
index 845aefb9..219a57ad 100644
--- a/libsolidity/inlineasm/AsmPrinter.cpp
+++ b/libsolidity/inlineasm/AsmPrinter.cpp
@@ -129,12 +129,7 @@ string AsmPrinter::operator()(assembly::VariableDeclaration const& _variableDecl
", "
);
out += " := ";
- out += boost::algorithm::join(
- _variableDeclaration.values | boost::adaptors::transformed(
- [this](Statement statement) { return boost::apply_visitor(*this, statement); }
- ),
- ", "
- );
+ out += boost::apply_visitor(*this, *_variableDeclaration.value);
return out;
}