From c48a5264be4221873fe02cac57f6a41a32010fea Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 28 Nov 2018 16:19:22 +0100 Subject: liblangutil: SourceLocation: adds (shared) pointer to underlying CharStream source, eliminating sourceName Also, adapted affecting code to those changes. --- test/libsolidity/Assembly.cpp | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) (limited to 'test/libsolidity/Assembly.cpp') diff --git a/test/libsolidity/Assembly.cpp b/test/libsolidity/Assembly.cpp index 620f9661..004917d4 100644 --- a/test/libsolidity/Assembly.cpp +++ b/test/libsolidity/Assembly.cpp @@ -52,13 +52,13 @@ namespace test namespace { -eth::AssemblyItems compileContract(string const& _sourceCode) +eth::AssemblyItems compileContract(std::shared_ptr _sourceCode) { ErrorList errors; ErrorReporter errorReporter(errors); Parser parser(errorReporter); ASTPointer sourceUnit; - BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(CharStream(_sourceCode, "")))); + BOOST_REQUIRE_NO_THROW(sourceUnit = parser.parse(make_shared(_sourceCode))); BOOST_CHECK(!!sourceUnit); map> scopes; @@ -104,7 +104,7 @@ void printAssemblyLocations(AssemblyItems const& _items) ", " << _loc.end << ", make_shared(\"" << - *_loc.sourceName << + _loc.source->name() << "\"))) +" << endl; }; @@ -151,29 +151,32 @@ BOOST_AUTO_TEST_SUITE(Assembly) BOOST_AUTO_TEST_CASE(location_test) { - char const* sourceCode = R"( + auto sourceCode = make_shared(R"( contract test { function f() public returns (uint256 a) { return 16; } } - )"; + )", ""); AssemblyItems items = compileContract(sourceCode); bool hasShifts = dev::test::Options::get().evmVersion().hasBitwiseShifting(); + + auto codegenCharStream = make_shared("", "--CODEGEN--"); + vector locations = - vector(hasShifts ? 21 : 22, SourceLocation(2, 82, make_shared(""))) + - vector(2, SourceLocation(20, 79, make_shared(""))) + - vector(1, SourceLocation(8, 17, make_shared("--CODEGEN--"))) + - vector(3, SourceLocation(5, 7, make_shared("--CODEGEN--"))) + - vector(1, SourceLocation(30, 31, make_shared("--CODEGEN--"))) + - vector(1, SourceLocation(27, 28, make_shared("--CODEGEN--"))) + - vector(1, SourceLocation(20, 32, make_shared("--CODEGEN--"))) + - vector(1, SourceLocation(5, 7, make_shared("--CODEGEN--"))) + - vector(24, SourceLocation(20, 79, make_shared(""))) + - vector(1, SourceLocation(49, 58, make_shared(""))) + - vector(1, SourceLocation(72, 74, make_shared(""))) + - vector(2, SourceLocation(65, 74, make_shared(""))) + - vector(2, SourceLocation(20, 79, make_shared(""))); + vector(hasShifts ? 21 : 22, SourceLocation(2, 82, sourceCode)) + + vector(2, SourceLocation(20, 79, sourceCode)) + + vector(1, SourceLocation(8, 17, codegenCharStream)) + + vector(3, SourceLocation(5, 7, codegenCharStream)) + + vector(1, SourceLocation(30, 31, codegenCharStream)) + + vector(1, SourceLocation(27, 28, codegenCharStream)) + + vector(1, SourceLocation(20, 32, codegenCharStream)) + + vector(1, SourceLocation(5, 7, codegenCharStream)) + + vector(24, SourceLocation(20, 79, sourceCode)) + + vector(1, SourceLocation(49, 58, sourceCode)) + + vector(1, SourceLocation(72, 74, sourceCode)) + + vector(2, SourceLocation(65, 74, sourceCode)) + + vector(2, SourceLocation(20, 79, sourceCode)); checkAssemblyLocations(items, locations); } -- cgit