removed get prefix

style fixes
This commit is contained in:
LianaHus 2015-09-01 11:19:02 +02:00
parent 1b5e6fc9e7
commit 02d4198242
15 changed files with 72 additions and 60 deletions

View File

@ -817,10 +817,16 @@ void BinaryOperation::checkTypeRequirements(TypePointers const*)
m_right->checkTypeRequirements(nullptr); m_right->checkTypeRequirements(nullptr);
m_commonType = m_left->type()->binaryOperatorResult(m_operator, m_right->type()); m_commonType = m_left->type()->binaryOperatorResult(m_operator, m_right->type());
if (!m_commonType) if (!m_commonType)
BOOST_THROW_EXCEPTION(createTypeError("Operator " + string(Token::toString(m_operator)) + BOOST_THROW_EXCEPTION(
createTypeError(
"Operator " +
string(Token::toString(m_operator)) +
" not compatible with types " + " not compatible with types " +
m_left->type()->toString() + " and " + m_left->type()->toString() +
m_right->type()->toString())); " and " +
m_right->type()->toString()
)
);
m_type = Token::isCompareOp(m_operator) ? make_shared<BoolType>() : m_commonType; m_type = Token::isCompareOp(m_operator) ? make_shared<BoolType>() : m_commonType;
} }

View File

@ -209,7 +209,7 @@ bool ASTJsonConverter::visit(Assignment const& _node)
{ {
addJsonNode("Assignment", addJsonNode("Assignment",
{ make_pair("operator", Token::toString(_node.assignmentOperator())), { make_pair("operator", Token::toString(_node.assignmentOperator())),
make_pair("type", getType(_node)) }, make_pair("type", type(_node)) },
true); true);
return true; return true;
} }
@ -219,7 +219,7 @@ bool ASTJsonConverter::visit(UnaryOperation const& _node)
addJsonNode("UnaryOperation", addJsonNode("UnaryOperation",
{ make_pair("prefix", boost::lexical_cast<std::string>(_node.isPrefixOperation())), { make_pair("prefix", boost::lexical_cast<std::string>(_node.isPrefixOperation())),
make_pair("operator", Token::toString(_node.getOperator())), make_pair("operator", Token::toString(_node.getOperator())),
make_pair("type", getType(_node)) }, make_pair("type", type(_node)) },
true); true);
return true; return true;
} }
@ -228,7 +228,7 @@ bool ASTJsonConverter::visit(BinaryOperation const& _node)
{ {
addJsonNode("BinaryOperation", addJsonNode("BinaryOperation",
{ make_pair("operator", Token::toString(_node.getOperator())), { make_pair("operator", Token::toString(_node.getOperator())),
make_pair("type", getType(_node))}, make_pair("type", type(_node))},
true); true);
return true; return true;
} }
@ -237,14 +237,14 @@ bool ASTJsonConverter::visit(FunctionCall const& _node)
{ {
addJsonNode("FunctionCall", addJsonNode("FunctionCall",
{ make_pair("type_conversion", boost::lexical_cast<std::string>(_node.isTypeConversion())), { make_pair("type_conversion", boost::lexical_cast<std::string>(_node.isTypeConversion())),
make_pair("type", getType(_node)) }, make_pair("type", type(_node)) },
true); true);
return true; return true;
} }
bool ASTJsonConverter::visit(NewExpression const& _node) bool ASTJsonConverter::visit(NewExpression const& _node)
{ {
addJsonNode("NewExpression", { make_pair("type", getType(_node)) }, true); addJsonNode("NewExpression", { make_pair("type", type(_node)) }, true);
return true; return true;
} }
@ -252,28 +252,28 @@ bool ASTJsonConverter::visit(MemberAccess const& _node)
{ {
addJsonNode("MemberAccess", addJsonNode("MemberAccess",
{ make_pair("member_name", _node.memberName()), { make_pair("member_name", _node.memberName()),
make_pair("type", getType(_node)) }, make_pair("type", type(_node)) },
true); true);
return true; return true;
} }
bool ASTJsonConverter::visit(IndexAccess const& _node) bool ASTJsonConverter::visit(IndexAccess const& _node)
{ {
addJsonNode("IndexAccess", { make_pair("type", getType(_node)) }, true); addJsonNode("IndexAccess", { make_pair("type", type(_node)) }, true);
return true; return true;
} }
bool ASTJsonConverter::visit(Identifier const& _node) bool ASTJsonConverter::visit(Identifier const& _node)
{ {
addJsonNode("Identifier", addJsonNode("Identifier",
{ make_pair("value", _node.name()), make_pair("type", getType(_node)) }); { make_pair("value", _node.name()), make_pair("type", type(_node)) });
return true; return true;
} }
bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node) bool ASTJsonConverter::visit(ElementaryTypeNameExpression const& _node)
{ {
addJsonNode("ElementaryTypenameExpression", addJsonNode("ElementaryTypenameExpression",
{ make_pair("value", Token::toString(_node.typeToken())), make_pair("type", getType(_node)) }); { make_pair("value", Token::toString(_node.typeToken())), make_pair("type", type(_node)) });
return true; return true;
} }
@ -283,7 +283,7 @@ bool ASTJsonConverter::visit(Literal const& _node)
addJsonNode("Literal", addJsonNode("Literal",
{ make_pair("string", (tokenString) ? tokenString : "null"), { make_pair("string", (tokenString) ? tokenString : "null"),
make_pair("value", _node.value()), make_pair("value", _node.value()),
make_pair("type", getType(_node)) }); make_pair("type", type(_node)) });
return true; return true;
} }
@ -428,7 +428,7 @@ void ASTJsonConverter::process()
processed = true; processed = true;
} }
string ASTJsonConverter::getType(Expression const& _expression) string ASTJsonConverter::type(Expression const& _expression)
{ {
return (_expression.type()) ? _expression.type()->toString() : "Unknown"; return (_expression.type()) ? _expression.type()->toString() : "Unknown";
} }

View File

@ -112,7 +112,7 @@ private:
void addJsonNode(std::string const& _nodeName, void addJsonNode(std::string const& _nodeName,
std::initializer_list<std::pair<std::string const, std::string const>> _list, std::initializer_list<std::pair<std::string const, std::string const>> _list,
bool _hasChildren); bool _hasChildren);
std::string getType(Expression const& _expression); std::string type(Expression const& _expression);
inline void goUp() inline void goUp()
{ {
solAssert(!m_jsonNodePtrs.empty(), "Uneven json nodes stack. Internal error."); solAssert(!m_jsonNodePtrs.empty(), "Uneven json nodes stack. Internal error.");

View File

@ -507,11 +507,11 @@ void ASTPrinter::endVisit(Literal const&)
void ASTPrinter::printSourcePart(ASTNode const& _node) void ASTPrinter::printSourcePart(ASTNode const& _node)
{ {
if (m_gasCosts.count(&_node)) if (m_gasCosts.count(&_node))
*m_ostream << getIndentation() << " Gas costs: " << m_gasCosts.at(&_node) << endl; *m_ostream << indentation() << " Gas costs: " << m_gasCosts.at(&_node) << endl;
if (!m_source.empty()) if (!m_source.empty())
{ {
SourceLocation const& location(_node.location()); SourceLocation const& location(_node.location());
*m_ostream << getIndentation() << " Source: " *m_ostream << indentation() << " Source: "
<< escaped(m_source.substr(location.start, location.end - location.start), false) << endl; << escaped(m_source.substr(location.start, location.end - location.start), false) << endl;
} }
} }
@ -519,19 +519,19 @@ void ASTPrinter::printSourcePart(ASTNode const& _node)
void ASTPrinter::printType(Expression const& _expression) void ASTPrinter::printType(Expression const& _expression)
{ {
if (_expression.type()) if (_expression.type())
*m_ostream << getIndentation() << " Type: " << _expression.type()->toString() << "\n"; *m_ostream << indentation() << " Type: " << _expression.type()->toString() << "\n";
else else
*m_ostream << getIndentation() << " Type unknown.\n"; *m_ostream << indentation() << " Type unknown.\n";
} }
string ASTPrinter::getIndentation() const string ASTPrinter::indentation() const
{ {
return string(m_indentation * 2, ' '); return string(m_indentation * 2, ' ');
} }
void ASTPrinter::writeLine(string const& _line) void ASTPrinter::writeLine(string const& _line)
{ {
*m_ostream << getIndentation() << _line << endl; *m_ostream << indentation() << _line << endl;
} }
} }

View File

@ -126,7 +126,7 @@ public:
private: private:
void printSourcePart(ASTNode const& _node); void printSourcePart(ASTNode const& _node);
void printType(Expression const& _expression); void printType(Expression const& _expression);
std::string getIndentation() const; std::string indentation() const;
void writeLine(std::string const& _line); void writeLine(std::string const& _line);
bool goDeeper() { m_indentation++; return true; } bool goDeeper() { m_indentation++; return true; }

View File

@ -59,9 +59,9 @@ public:
return m_context.streamAssembly(_stream, _sourceCodes, _inJsonFormat); return m_context.streamAssembly(_stream, _sourceCodes, _inJsonFormat);
} }
/// @returns Assembly items of the normal compiler context /// @returns Assembly items of the normal compiler context
eth::AssemblyItems const& assemblyItems() const { return m_context.assembly().getItems(); } eth::AssemblyItems const& assemblyItems() const { return m_context.assembly().items(); }
/// @returns Assembly items of the runtime compiler context /// @returns Assembly items of the runtime compiler context
eth::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().getSub(m_runtimeSub).getItems(); } eth::AssemblyItems const& runtimeAssemblyItems() const { return m_context.assembly().sub(m_runtimeSub).items(); }
/// @returns the entry label of the given function. Might return an AssemblyItem of type /// @returns the entry label of the given function. Might return an AssemblyItem of type
/// UndefinedItem if it does not exist yet. /// UndefinedItem if it does not exist yet.

View File

@ -339,9 +339,11 @@ void CompilerStack::resolveImports()
{ {
string const& id = import->identifier(); string const& id = import->identifier();
if (!m_sources.count(id)) if (!m_sources.count(id))
BOOST_THROW_EXCEPTION(ParserError() BOOST_THROW_EXCEPTION(
ParserError()
<< errinfo_sourceLocation(import->location()) << errinfo_sourceLocation(import->location())
<< errinfo_comment("Source not found.")); << errinfo_comment("Source not found.")
);
toposort(&m_sources[id]); toposort(&m_sources[id]);
} }
sourceOrder.push_back(_source); sourceOrder.push_back(_source);

View File

@ -450,8 +450,8 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
arg->accept(*this); arg->accept(*this);
argumentTypes.push_back(arg->type()); argumentTypes.push_back(arg->type());
} }
ContractDefinition const& contract = dynamic_cast<ContractType const&>( ContractDefinition const& contract =
*function.returnParameterTypes().front()).contractDefinition(); dynamic_cast<ContractType const&>(*function.returnParameterTypes().front()).contractDefinition();
// copy the contract's code into memory // copy the contract's code into memory
bytes const& bytecode = m_context.compiledContract(contract); bytes const& bytecode = m_context.compiledContract(contract);
utils().fetchFreeMemoryPointer(); utils().fetchFreeMemoryPointer();
@ -1087,8 +1087,10 @@ void ExpressionCompiler::appendExternalFunctionCall(
vector<ASTPointer<Expression const>> const& _arguments vector<ASTPointer<Expression const>> const& _arguments
) )
{ {
solAssert(_functionType.takesArbitraryParameters() || solAssert(
_arguments.size() == _functionType.parameterTypes().size(), ""); _functionType.takesArbitraryParameters() ||
_arguments.size() == _functionType.parameterTypes().size(), ""
);
// Assumed stack content here: // Assumed stack content here:
// <stack top> // <stack top>

View File

@ -52,7 +52,7 @@ GasEstimator::ASTGasConsumptionSelfAccumulated GasEstimator::structuralEstimatio
GasMeter meter(block.startState->copy()); GasMeter meter(block.startState->copy());
auto const end = _items.begin() + block.end; auto const end = _items.begin() + block.end;
for (auto iter = _items.begin() + block.begin; iter != end; ++iter) for (auto iter = _items.begin() + block.begin; iter != end; ++iter)
particularCosts[iter->getLocation()] += meter.estimateMax(*iter); particularCosts[iter->location()] += meter.estimateMax(*iter);
} }
set<ASTNode const*> finestNodes = finestNodesAtLocation(_ast); set<ASTNode const*> finestNodes = finestNodesAtLocation(_ast);

View File

@ -393,7 +393,7 @@ string::const_iterator InterfaceHandler::appendDocTag(
} }
} }
static inline string::const_iterator getFirstSpaceOrNl( static inline string::const_iterator firstSpaceOrNl(
string::const_iterator _pos, string::const_iterator _pos,
string::const_iterator _end string::const_iterator _end
) )
@ -416,7 +416,7 @@ void InterfaceHandler::parseDocString(string const& _string, CommentOwner _owner
if (tagPos != end && tagPos < nlPos) if (tagPos != end && tagPos < nlPos)
{ {
// we found a tag // we found a tag
auto tagNameEndPos = getFirstSpaceOrNl(tagPos, end); auto tagNameEndPos = firstSpaceOrNl(tagPos, end);
if (tagNameEndPos == end) if (tagNameEndPos == end)
BOOST_THROW_EXCEPTION( BOOST_THROW_EXCEPTION(
DocstringParsingError() << DocstringParsingError() <<

View File

@ -697,7 +697,9 @@ bool ContractType::isImplicitlyConvertibleTo(Type const& _convertTo) const
bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const bool ContractType::isExplicitlyConvertibleTo(Type const& _convertTo) const
{ {
return isImplicitlyConvertibleTo(_convertTo) || _convertTo.category() == Category::Integer || return
isImplicitlyConvertibleTo(_convertTo) ||
_convertTo.category() == Category::Integer ||
_convertTo.category() == Category::Contract; _convertTo.category() == Category::Contract;
} }

View File

@ -80,10 +80,10 @@ void checkAssemblyLocations(AssemblyItems const& _items, vector<SourceLocation>
for (size_t i = 0; i < min(_items.size(), _locations.size()); ++i) for (size_t i = 0; i < min(_items.size(), _locations.size()); ++i)
{ {
BOOST_CHECK_MESSAGE( BOOST_CHECK_MESSAGE(
_items[i].getLocation() == _locations[i], _items[i].location() == _locations[i],
"Location mismatch for assembly item " + to_string(i) + ". Found: " + "Location mismatch for assembly item " + to_string(i) + ". Found: " +
to_string(_items[i].getLocation().start) + "-" + to_string(_items[i].location().start) + "-" +
to_string(_items[i].getLocation().end) + ", expected: " + to_string(_items[i].location().end) + ", expected: " +
to_string(_locations[i].start) + "-" + to_string(_locations[i].start) + "-" +
to_string(_locations[i].end)); to_string(_locations[i].end));
} }

View File

@ -48,7 +48,7 @@ class FirstExpressionExtractor: private ASTVisitor
{ {
public: public:
FirstExpressionExtractor(ASTNode& _node): m_expression(nullptr) { _node.accept(*this); } FirstExpressionExtractor(ASTNode& _node): m_expression(nullptr) { _node.accept(*this); }
Expression* getExpression() const { return m_expression; } Expression* expression() const { return m_expression; }
private: private:
virtual bool visit(Assignment& _expression) override { return checkExpression(_expression); } virtual bool visit(Assignment& _expression) override { return checkExpression(_expression); }
virtual bool visit(UnaryOperation& _expression) override { return checkExpression(_expression); } virtual bool visit(UnaryOperation& _expression) override { return checkExpression(_expression); }
@ -123,7 +123,7 @@ bytes compileFirstExpression(const string& _sourceCode, vector<vector<string>> _
if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get()))
{ {
FirstExpressionExtractor extractor(*contract); FirstExpressionExtractor extractor(*contract);
BOOST_REQUIRE(extractor.getExpression() != nullptr); BOOST_REQUIRE(extractor.expression() != nullptr);
CompilerContext context; CompilerContext context;
context.resetVisitedNodes(contract); context.resetVisitedNodes(contract);
@ -134,7 +134,7 @@ bytes compileFirstExpression(const string& _sourceCode, vector<vector<string>> _
context.addVariable(dynamic_cast<VariableDeclaration const&>(resolveDeclaration(variable, resolver)), context.addVariable(dynamic_cast<VariableDeclaration const&>(resolveDeclaration(variable, resolver)),
parametersSize--); parametersSize--);
ExpressionCompiler(context).compile(*extractor.getExpression()); ExpressionCompiler(context).compile(*extractor.expression());
for (vector<string> const& function: _functions) for (vector<string> const& function: _functions)
context << context.functionEntryLabel(dynamic_cast<FunctionDefinition const&>(resolveDeclaration(function, resolver))); context << context.functionEntryLabel(dynamic_cast<FunctionDefinition const&>(resolveDeclaration(function, resolver)));

View File

@ -48,7 +48,7 @@ public:
return m_reCompiler.contractDefinition(_contractName); return m_reCompiler.contractDefinition(_contractName);
} }
string getSourcePart(ASTNode const& _node) const string sourcePart(ASTNode const& _node) const
{ {
SourceLocation location = _node.location(); SourceLocation location = _node.location();
BOOST_REQUIRE(!location.isEmpty()); BOOST_REQUIRE(!location.isEmpty());
@ -67,7 +67,7 @@ BOOST_FIXTURE_TEST_SUITE(SolidityInterface, SolidityInterfaceChecker)
BOOST_AUTO_TEST_CASE(empty_contract) BOOST_AUTO_TEST_CASE(empty_contract)
{ {
ContractDefinition const& contract = checkInterface("contract test {}"); ContractDefinition const& contract = checkInterface("contract test {}");
BOOST_CHECK_EQUAL(getSourcePart(contract), "contract test{}"); BOOST_CHECK_EQUAL(sourcePart(contract), "contract test{}");
} }
BOOST_AUTO_TEST_CASE(single_function) BOOST_AUTO_TEST_CASE(single_function)
@ -77,7 +77,7 @@ BOOST_AUTO_TEST_CASE(single_function)
" function f(uint a) returns(uint d) { return a * 7; }\n" " function f(uint a) returns(uint d) { return a * 7; }\n"
"}\n"); "}\n");
BOOST_REQUIRE_EQUAL(1, contract.definedFunctions().size()); BOOST_REQUIRE_EQUAL(1, contract.definedFunctions().size());
BOOST_CHECK_EQUAL(getSourcePart(*contract.definedFunctions().front()), BOOST_CHECK_EQUAL(sourcePart(*contract.definedFunctions().front()),
"function f(uint256 a)returns(uint256 d);"); "function f(uint256 a)returns(uint256 d);");
} }
@ -86,7 +86,7 @@ BOOST_AUTO_TEST_CASE(single_constant_function)
ContractDefinition const& contract = checkInterface( ContractDefinition const& contract = checkInterface(
"contract test { function f(uint a) constant returns(bytes1 x) { 1==2; } }"); "contract test { function f(uint a) constant returns(bytes1 x) { 1==2; } }");
BOOST_REQUIRE_EQUAL(1, contract.definedFunctions().size()); BOOST_REQUIRE_EQUAL(1, contract.definedFunctions().size());
BOOST_CHECK_EQUAL(getSourcePart(*contract.definedFunctions().front()), BOOST_CHECK_EQUAL(sourcePart(*contract.definedFunctions().front()),
"function f(uint256 a)constant returns(bytes1 x);"); "function f(uint256 a)constant returns(bytes1 x);");
} }
@ -100,15 +100,15 @@ BOOST_AUTO_TEST_CASE(multiple_functions)
set<string> expectation({"function f(uint256 a)returns(uint256 d);", set<string> expectation({"function f(uint256 a)returns(uint256 d);",
"function g(uint256 b)returns(uint256 e);"}); "function g(uint256 b)returns(uint256 e);"});
BOOST_REQUIRE_EQUAL(2, contract.definedFunctions().size()); BOOST_REQUIRE_EQUAL(2, contract.definedFunctions().size());
BOOST_CHECK(expectation == set<string>({getSourcePart(*contract.definedFunctions().at(0)), BOOST_CHECK(expectation == set<string>({sourcePart(*contract.definedFunctions().at(0)),
getSourcePart(*contract.definedFunctions().at(1))})); sourcePart(*contract.definedFunctions().at(1))}));
} }
BOOST_AUTO_TEST_CASE(exclude_fallback_function) BOOST_AUTO_TEST_CASE(exclude_fallback_function)
{ {
char const* sourceCode = "contract test { function() {} }"; char const* sourceCode = "contract test { function() {} }";
ContractDefinition const& contract = checkInterface(sourceCode); ContractDefinition const& contract = checkInterface(sourceCode);
BOOST_CHECK_EQUAL(getSourcePart(contract), "contract test{}"); BOOST_CHECK_EQUAL(sourcePart(contract), "contract test{}");
} }
BOOST_AUTO_TEST_CASE(events) BOOST_AUTO_TEST_CASE(events)
@ -138,8 +138,8 @@ BOOST_AUTO_TEST_CASE(inheritance)
set<string> expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i);", set<string> expectedFunctions({"function baseFunction(uint256 p)returns(uint256 i);",
"function derivedFunction(bytes32 p)returns(bytes32 i);"}); "function derivedFunction(bytes32 p)returns(bytes32 i);"});
BOOST_REQUIRE_EQUAL(2, contract.definedFunctions().size()); BOOST_REQUIRE_EQUAL(2, contract.definedFunctions().size());
BOOST_CHECK(expectedFunctions == set<string>({getSourcePart(*contract.definedFunctions().at(0)), BOOST_CHECK(expectedFunctions == set<string>({sourcePart(*contract.definedFunctions().at(0)),
getSourcePart(*contract.definedFunctions().at(1))})); sourcePart(*contract.definedFunctions().at(1))}));
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()

View File

@ -101,7 +101,7 @@ public:
return state; return state;
} }
AssemblyItems getCSE(AssemblyItems const& _input, eth::KnownState const& _state = eth::KnownState()) AssemblyItems CSE(AssemblyItems const& _input, eth::KnownState const& _state = eth::KnownState())
{ {
AssemblyItems input = addDummyLocations(_input); AssemblyItems input = addDummyLocations(_input);
@ -111,7 +111,7 @@ public:
for (AssemblyItem const& item: output) for (AssemblyItem const& item: output)
{ {
BOOST_CHECK(item == Instruction::POP || !item.getLocation().isEmpty()); BOOST_CHECK(item == Instruction::POP || !item.location().isEmpty());
} }
return output; return output;
} }
@ -122,11 +122,11 @@ public:
KnownState const& _state = eth::KnownState() KnownState const& _state = eth::KnownState()
) )
{ {
AssemblyItems output = getCSE(_input, _state); AssemblyItems output = CSE(_input, _state);
BOOST_CHECK_EQUAL_COLLECTIONS(_expectation.begin(), _expectation.end(), output.begin(), output.end()); BOOST_CHECK_EQUAL_COLLECTIONS(_expectation.begin(), _expectation.end(), output.begin(), output.end());
} }
AssemblyItems getCFG(AssemblyItems const& _input) AssemblyItems CFG(AssemblyItems const& _input)
{ {
AssemblyItems output = _input; AssemblyItems output = _input;
// Running it four times should be enough for these tests. // Running it four times should be enough for these tests.
@ -144,7 +144,7 @@ public:
void checkCFG(AssemblyItems const& _input, AssemblyItems const& _expectation) void checkCFG(AssemblyItems const& _input, AssemblyItems const& _expectation)
{ {
AssemblyItems output = getCFG(_input); AssemblyItems output = CFG(_input);
BOOST_CHECK_EQUAL_COLLECTIONS(_expectation.begin(), _expectation.end(), output.begin(), output.end()); BOOST_CHECK_EQUAL_COLLECTIONS(_expectation.begin(), _expectation.end(), output.begin(), output.end());
} }
@ -890,7 +890,7 @@ BOOST_AUTO_TEST_CASE(cse_sha3_twice_same_content_noninterfering_store_in_between
Instruction::SHA3 // sha3(m[12..(12+32)]) Instruction::SHA3 // sha3(m[12..(12+32)])
}; };
// if this changes too often, only count the number of SHA3 and MSTORE instructions // if this changes too often, only count the number of SHA3 and MSTORE instructions
AssemblyItems output = getCSE(input); AssemblyItems output = CSE(input);
BOOST_CHECK_EQUAL(4, count(output.begin(), output.end(), AssemblyItem(Instruction::MSTORE))); BOOST_CHECK_EQUAL(4, count(output.begin(), output.end(), AssemblyItem(Instruction::MSTORE)));
BOOST_CHECK_EQUAL(1, count(output.begin(), output.end(), AssemblyItem(Instruction::SHA3))); BOOST_CHECK_EQUAL(1, count(output.begin(), output.end(), AssemblyItem(Instruction::SHA3)));
} }
@ -914,7 +914,7 @@ BOOST_AUTO_TEST_CASE(cse_equality_on_initially_known_stack)
AssemblyItems input{ AssemblyItems input{
Instruction::EQ Instruction::EQ
}; };
AssemblyItems output = getCSE(input, state); AssemblyItems output = CSE(input, state);
// check that it directly pushes 1 (true) // check that it directly pushes 1 (true)
BOOST_CHECK(find(output.begin(), output.end(), AssemblyItem(u256(1))) != output.end()); BOOST_CHECK(find(output.begin(), output.end(), AssemblyItem(u256(1))) != output.end());
} }
@ -938,7 +938,7 @@ BOOST_AUTO_TEST_CASE(cse_access_previous_sequence)
u256(0), u256(0),
Instruction::SLOAD, Instruction::SLOAD,
}; };
BOOST_CHECK_THROW(getCSE(input, state), StackTooDeepException); BOOST_CHECK_THROW(CSE(input, state), StackTooDeepException);
// @todo for now, this throws an exception, but it should recover to the following // @todo for now, this throws an exception, but it should recover to the following
// (or an even better version) at some point: // (or an even better version) at some point:
// 0, SLOAD, 1, ADD, SSTORE, 0 SLOAD // 0, SLOAD, 1, ADD, SSTORE, 0 SLOAD