From 7c509137cfea7373628f74d8c4fd94e78eb26cbb Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 27 Jul 2018 23:16:53 +0100 Subject: Replace dev::eth namespace with dev::lll in LLL --- liblll/CodeFragment.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'liblll/CodeFragment.cpp') diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 5c68194b..3e82889a 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -32,9 +32,10 @@ #include #include "CompilerState.h" #include "Parser.h" + using namespace std; using namespace dev; -using namespace dev::eth; +using namespace dev::lll; void CodeFragment::finalise(CompilerState const& _cs) { @@ -552,7 +553,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) int targetDeposit = hasDefault ? code[code.size() - 1].m_asm.deposit() : 0; // The conditions - AssemblyItems jumpTags; + eth::AssemblyItems jumpTags; for (unsigned i = 0; i < code.size() - 1; i += 2) { requireDeposit(i, 1); @@ -619,7 +620,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) requireMaxSize(3); requireDeposit(1, 1); - auto subPush = m_asm.appendSubroutine(make_shared(code[0].assembly(ns))); + auto subPush = m_asm.appendSubroutine(make_shared(code[0].assembly(ns))); m_asm.append(Instruction::DUP1); if (code.size() == 3) { -- cgit v1.2.3 From 6c3b48ddfcfb0849e1083cea8d4fae4446511be1 Mon Sep 17 00:00:00 2001 From: "Augusto F. Hack" Date: Sat, 21 Jul 2018 19:08:47 -0300 Subject: Added guards for unknown pragmas Removed push/pop if there was no change to the warnings *in the same file* for a given compiler. This assumes the imported boost headers use a warning stack themselves. The pragmas don't seem to be required anymore, but were not removed to mantain compatibility with older versions of the boost library. Compiled with - clang version 6.0.1 (tags/RELEASE_601/final) - gcc (GCC) 8.1.1 20180531 against: - libboost 1.67.0-5 --- liblll/CodeFragment.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'liblll/CodeFragment.cpp') diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 3e82889a..0aef05a9 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -22,12 +22,18 @@ #include "CodeFragment.h" #include -#pragma warning(push) + +#if defined(__GNUC__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-parameter" +#endif // defined(__GNUC__) + #include -#pragma warning(pop) + +#if defined(__GNUC__) #pragma GCC diagnostic pop +#endif // defined(__GNUC__) + #include #include #include "CompilerState.h" -- cgit v1.2.3 From ab0de38f16a9eff13ee5a32a3408b890d87941f6 Mon Sep 17 00:00:00 2001 From: Christian Parpart Date: Wed, 7 Nov 2018 12:04:46 +0100 Subject: Eliminate `byte`-typedef and use `uint8_t` in all their places instead. This change is made to (easily) be forward compatible with future C++ standards, in order to allow compiling the code with newer standards at some point in the future. * Removed the `using byte = uint8_t;` line from Common.h * Mechanically change all uses of `byte` to `uint8_t`. Tested with GCC 7.3 in C++11/14/17 modes :-) --- liblll/CodeFragment.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'liblll/CodeFragment.cpp') diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 0aef05a9..85480119 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -348,7 +348,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) else if (i.which() == sp::utree_type::string_type) { auto sr = i.get, sp::utree_type::string_type>>(); - data.insert(data.end(), (byte const *)sr.begin(), (byte const*)sr.end()); + data.insert(data.end(), (uint8_t const *)sr.begin(), (uint8_t const*)sr.end()); } else if (i.which() == sp::utree_type::any_type) { -- cgit v1.2.3 From c320a650f940fe96108c4c4687313ef26a33e248 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 19 Sep 2018 13:13:42 +0100 Subject: LLL: terminate sequences with a STOP --- liblll/CodeFragment.cpp | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'liblll/CodeFragment.cpp') diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 85480119..60dd0917 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -45,6 +45,10 @@ using namespace dev::lll; void CodeFragment::finalise(CompilerState const& _cs) { + // NOTE: add this as a safeguard in case the user didn't issue an + // explicit stop at the end of the sequence + m_asm.append(Instruction::STOP); + if (_cs.usedAlloc && _cs.vars.size() && !m_finalised) { m_finalised = true; -- cgit v1.2.3 From e82917d4e6428fdfc86f10ce63846aea65852540 Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Wed, 26 Sep 2018 15:39:53 +0100 Subject: Add LLL error when assembly instruction causes stack underflow --- liblll/CodeFragment.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'liblll/CodeFragment.cpp') diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp index 60dd0917..f37cb8b9 100644 --- a/liblll/CodeFragment.cpp +++ b/liblll/CodeFragment.cpp @@ -236,7 +236,12 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) int c = 0; for (auto const& i: _t) if (c++) - m_asm.append(CodeFragment(i, _s, m_readFile, true).m_asm); + { + auto fragment = CodeFragment(i, _s, m_readFile, true).m_asm; + if ((m_asm.deposit() + fragment.deposit()) < 0) + error("The assembly instruction resulted in stack underflow"); + m_asm.append(fragment); + } } else if (us == "INCLUDE") { -- cgit v1.2.3