aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--docs/frequently-asked-questions.rst25
-rw-r--r--libyul/AsmPrinter.cpp30
-rw-r--r--libyul/AsmPrinter.h30
-rwxr-xr-xtest/cmdlineTests.sh9
-rw-r--r--test/cmdlineTests/standard.json.stdout2
5 files changed, 38 insertions, 58 deletions
diff --git a/docs/frequently-asked-questions.rst b/docs/frequently-asked-questions.rst
index a4ef3684..d263e0c6 100644
--- a/docs/frequently-asked-questions.rst
+++ b/docs/frequently-asked-questions.rst
@@ -16,31 +16,6 @@ Enums are not supported by the ABI, they are just supported by Solidity.
You have to do the mapping yourself for now, we might provide some help
later.
-Can state variables be initialized in-line?
-===========================================
-
-Yes, this is possible for all types (even for structs). However, for arrays it
-should be noted that you must declare them as static memory arrays.
-
-Examples::
-
- pragma solidity >=0.4.0 <0.6.0;
-
- contract C {
- struct S {
- uint a;
- uint b;
- }
-
- S public x = S(1, 2);
- string name = "Ada";
- string[4] adaArr = ["This", "is", "an", "array"];
- }
-
- contract D {
- C c = new C();
- }
-
How do structs work?
====================
diff --git a/libyul/AsmPrinter.cpp b/libyul/AsmPrinter.cpp
index eaaba9f3..a5b14953 100644
--- a/libyul/AsmPrinter.cpp
+++ b/libyul/AsmPrinter.cpp
@@ -40,14 +40,14 @@ using namespace dev::solidity;
//@TODO source locations
-string AsmPrinter::operator()(yul::Instruction const& _instruction)
+string AsmPrinter::operator()(yul::Instruction const& _instruction) const
{
solAssert(!m_yul, "");
solAssert(isValidInstruction(_instruction.instruction), "Invalid instruction");
return boost::to_lower_copy(instructionInfo(_instruction.instruction).name);
}
-string AsmPrinter::operator()(Literal const& _literal)
+string AsmPrinter::operator()(Literal const& _literal) const
{
switch (_literal.kind)
{
@@ -90,13 +90,13 @@ string AsmPrinter::operator()(Literal const& _literal)
return "\"" + out + "\"" + appendTypeName(_literal.type);
}
-string AsmPrinter::operator()(Identifier const& _identifier)
+string AsmPrinter::operator()(Identifier const& _identifier) const
{
solAssert(!_identifier.name.empty(), "Invalid identifier.");
return _identifier.name.str();
}
-string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstruction)
+string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstruction) const
{
solAssert(!m_yul, "");
solAssert(isValidInstruction(_functionalInstruction.instruction), "Invalid instruction");
@@ -109,26 +109,26 @@ string AsmPrinter::operator()(FunctionalInstruction const& _functionalInstructio
")";
}
-string AsmPrinter::operator()(ExpressionStatement const& _statement)
+string AsmPrinter::operator()(ExpressionStatement const& _statement) const
{
return boost::apply_visitor(*this, _statement.expression);
}
-string AsmPrinter::operator()(Label const& _label)
+string AsmPrinter::operator()(Label const& _label) const
{
solAssert(!m_yul, "");
solAssert(!_label.name.empty(), "Invalid label.");
return _label.name.str() + ":";
}
-string AsmPrinter::operator()(StackAssignment const& _assignment)
+string AsmPrinter::operator()(StackAssignment const& _assignment) const
{
solAssert(!m_yul, "");
solAssert(!_assignment.variableName.name.empty(), "Invalid variable name.");
return "=: " + (*this)(_assignment.variableName);
}
-string AsmPrinter::operator()(Assignment const& _assignment)
+string AsmPrinter::operator()(Assignment const& _assignment) const
{
solAssert(_assignment.variableNames.size() >= 1, "");
string variables = (*this)(_assignment.variableNames.front());
@@ -137,7 +137,7 @@ string AsmPrinter::operator()(Assignment const& _assignment)
return variables + " := " + boost::apply_visitor(*this, *_assignment.value);
}
-string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration)
+string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration) const
{
string out = "let ";
out += boost::algorithm::join(
@@ -154,7 +154,7 @@ string AsmPrinter::operator()(VariableDeclaration const& _variableDeclaration)
return out;
}
-string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition)
+string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition) const
{
solAssert(!_functionDefinition.name.empty(), "Invalid function name.");
string out = "function " + _functionDefinition.name.str() + "(";
@@ -179,7 +179,7 @@ string AsmPrinter::operator()(FunctionDefinition const& _functionDefinition)
return out + "\n" + (*this)(_functionDefinition.body);
}
-string AsmPrinter::operator()(FunctionCall const& _functionCall)
+string AsmPrinter::operator()(FunctionCall const& _functionCall) const
{
return
(*this)(_functionCall.functionName) + "(" +
@@ -189,13 +189,13 @@ string AsmPrinter::operator()(FunctionCall const& _functionCall)
")";
}
-string AsmPrinter::operator()(If const& _if)
+string AsmPrinter::operator()(If const& _if) const
{
solAssert(_if.condition, "Invalid if condition.");
return "if " + boost::apply_visitor(*this, *_if.condition) + "\n" + (*this)(_if.body);
}
-string AsmPrinter::operator()(Switch const& _switch)
+string AsmPrinter::operator()(Switch const& _switch) const
{
solAssert(_switch.expression, "Invalid expression pointer.");
string out = "switch " + boost::apply_visitor(*this, *_switch.expression);
@@ -210,7 +210,7 @@ string AsmPrinter::operator()(Switch const& _switch)
return out;
}
-string AsmPrinter::operator()(ForLoop const& _forLoop)
+string AsmPrinter::operator()(ForLoop const& _forLoop) const
{
solAssert(_forLoop.condition, "Invalid for loop condition.");
string out = "for ";
@@ -224,7 +224,7 @@ string AsmPrinter::operator()(ForLoop const& _forLoop)
return out;
}
-string AsmPrinter::operator()(Block const& _block)
+string AsmPrinter::operator()(Block const& _block) const
{
if (_block.statements.empty())
return "{\n}";
diff --git a/libyul/AsmPrinter.h b/libyul/AsmPrinter.h
index 61dfc18c..a1b9d6cd 100644
--- a/libyul/AsmPrinter.h
+++ b/libyul/AsmPrinter.h
@@ -36,21 +36,21 @@ class AsmPrinter: public boost::static_visitor<std::string>
public:
explicit AsmPrinter(bool _yul = false): m_yul(_yul) {}
- std::string operator()(Instruction const& _instruction);
- std::string operator()(Literal const& _literal);
- std::string operator()(Identifier const& _identifier);
- std::string operator()(FunctionalInstruction const& _functionalInstruction);
- std::string operator()(ExpressionStatement const& _expr);
- std::string operator()(Label const& _label);
- std::string operator()(StackAssignment const& _assignment);
- std::string operator()(Assignment const& _assignment);
- std::string operator()(VariableDeclaration const& _variableDeclaration);
- std::string operator()(FunctionDefinition const& _functionDefinition);
- std::string operator()(FunctionCall const& _functionCall);
- std::string operator()(If const& _if);
- std::string operator()(Switch const& _switch);
- std::string operator()(ForLoop const& _forLoop);
- std::string operator()(Block const& _block);
+ std::string operator()(Instruction const& _instruction) const;
+ std::string operator()(Literal const& _literal) const;
+ std::string operator()(Identifier const& _identifier) const;
+ std::string operator()(FunctionalInstruction const& _functionalInstruction) const;
+ std::string operator()(ExpressionStatement const& _expr) const;
+ std::string operator()(Label const& _label) const;
+ std::string operator()(StackAssignment const& _assignment) const;
+ std::string operator()(Assignment const& _assignment) const;
+ std::string operator()(VariableDeclaration const& _variableDeclaration) const;
+ std::string operator()(FunctionDefinition const& _functionDefinition) const;
+ std::string operator()(FunctionCall const& _functionCall) const;
+ std::string operator()(If const& _if) const;
+ std::string operator()(Switch const& _switch) const;
+ std::string operator()(ForLoop const& _forLoop) const;
+ std::string operator()(Block const& _block) const;
private:
std::string formatTypedName(TypedName _variable) const;
diff --git a/test/cmdlineTests.sh b/test/cmdlineTests.sh
index 95176814..bb71e012 100755
--- a/test/cmdlineTests.sh
+++ b/test/cmdlineTests.sh
@@ -130,8 +130,13 @@ test_solc_behaviour() {
exitCode=$?
set -e
- sed -i -e '/^Warning: This is a pre-release compiler version, please do not use it in production./d' "$stderr_path"
- sed -i -e 's/ Consider adding "pragma .*$//' "$stderr_path"
+ if [[ "$solc_args" == *"--standard-json"* ]]; then
+ sed -i -e 's/{[^{]*Warning: This is a pre-release compiler version[^}]*},\{0,1\}//' "$stdout_path"
+ sed -i -e 's/,"errors":\[\]//' "$stdout_path"
+ else
+ sed -i -e '/^Warning: This is a pre-release compiler version, please do not use it in production./d' "$stderr_path"
+ sed -i -e 's/ Consider adding "pragma .*$//' "$stderr_path"
+ fi
if [[ $exitCode -ne "$exit_code_expected" ]]; then
printError "Incorrect exit code. Expected $exit_code_expected but got $exitCode."
diff --git a/test/cmdlineTests/standard.json.stdout b/test/cmdlineTests/standard.json.stdout
index ba4099e5..490e1f80 100644
--- a/test/cmdlineTests/standard.json.stdout
+++ b/test/cmdlineTests/standard.json.stdout
@@ -1 +1 @@
-{"contracts":{"A":{"C":{"evm":{}}}},"errors":[{"component":"general","formattedMessage":"Warning: This is a pre-release compiler version, please do not use it in production.\n","message":"This is a pre-release compiler version, please do not use it in production.","severity":"warning","type":"Warning"}],"sources":{"A":{"id":0}}}
+{"contracts":{"A":{"C":{"evm":{}}}},"sources":{"A":{"id":0}}}