aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2016-10-26 20:55:14 +0800
committerGitHub <noreply@github.com>2016-10-26 20:55:14 +0800
commitf9946ec029cf14d973d78b31c265c8735ab9eb05 (patch)
tree81113a8c376d8d9eeb65deff84bc67693244a2b5
parent34e2209bcc782ceb0400b73cda23bf1173ea34e9 (diff)
parent6cb9c369774f9a1fc39bbaefcb3e50a5b4b68bef (diff)
downloaddexon-solidity-f9946ec029cf14d973d78b31c265c8735ab9eb05.tar.gz
dexon-solidity-f9946ec029cf14d973d78b31c265c8735ab9eb05.tar.zst
dexon-solidity-f9946ec029cf14d973d78b31c265c8735ab9eb05.zip
Merge pull request #1285 from ethereum/lll-simplify-not
LLL: use NOT for ~
-rw-r--r--liblll/CodeFragment.cpp40
1 files changed, 26 insertions, 14 deletions
diff --git a/liblll/CodeFragment.cpp b/liblll/CodeFragment.cpp
index 9dcac845..eadb0140 100644
--- a/liblll/CodeFragment.cpp
+++ b/liblll/CodeFragment.cpp
@@ -330,9 +330,32 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
if (nonStandard)
return;
- std::map<std::string, Instruction> const c_arith = { { "+", Instruction::ADD }, { "-", Instruction::SUB }, { "*", Instruction::MUL }, { "/", Instruction::DIV }, { "%", Instruction::MOD }, { "&", Instruction::AND }, { "|", Instruction::OR }, { "^", Instruction::XOR } };
- std::map<std::string, pair<Instruction, bool>> const c_binary = { { "<", { Instruction::LT, false } }, { "<=", { Instruction::GT, true } }, { ">", { Instruction::GT, false } }, { ">=", { Instruction::LT, true } }, { "S<", { Instruction::SLT, false } }, { "S<=", { Instruction::SGT, true } }, { "S>", { Instruction::SGT, false } }, { "S>=", { Instruction::SLT, true } }, { "=", { Instruction::EQ, false } }, { "!=", { Instruction::EQ, true } } };
- std::map<std::string, Instruction> const c_unary = { { "!", Instruction::ISZERO } };
+ std::map<std::string, Instruction> const c_arith = {
+ { "+", Instruction::ADD },
+ { "-", Instruction::SUB },
+ { "*", Instruction::MUL },
+ { "/", Instruction::DIV },
+ { "%", Instruction::MOD },
+ { "&", Instruction::AND },
+ { "|", Instruction::OR },
+ { "^", Instruction::XOR }
+ };
+ std::map<std::string, pair<Instruction, bool>> const c_binary = {
+ { "<", { Instruction::LT, false } },
+ { "<=", { Instruction::GT, true } },
+ { ">", { Instruction::GT, false } },
+ { ">=", { Instruction::LT, true } },
+ { "S<", { Instruction::SLT, false } },
+ { "S<=", { Instruction::SGT, true } },
+ { "S>", { Instruction::SGT, false } },
+ { "S>=", { Instruction::SLT, true } },
+ { "=", { Instruction::EQ, false } },
+ { "!=", { Instruction::EQ, true } }
+ };
+ std::map<std::string, Instruction> const c_unary = {
+ { "!", Instruction::ISZERO },
+ { "~", Instruction::NOT }
+ };
vector<CodeFragment> code;
CompilerState ns = _s;
@@ -541,17 +564,6 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
// At end now.
m_asm.append(end);
}
- else if (us == "~")
- {
- requireSize(1);
- requireDeposit(0, 1);
-
- m_asm.append(code[0].m_asm, 1);
- m_asm.append((u256)1);
- m_asm.append((u256)0);
- m_asm.append(Instruction::SUB);
- m_asm.append(Instruction::SUB);
- }
else if (us == "SEQ")
{
unsigned ii = 0;