From 4dec7501619b144b01ff1ef51a895c9533dfd7f6 Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 25 May 2014 13:53:20 +0200 Subject: [PATCH] Big integer/binary mem literal support. --- libethereum/Instruction.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libethereum/Instruction.cpp b/libethereum/Instruction.cpp index 2d3f4e64b..762045db2 100644 --- a/libethereum/Instruction.cpp +++ b/libethereum/Instruction.cpp @@ -585,10 +585,24 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) else if (ii >= 2 && !i.tag() && i.which() == sp::utree_type::any_type) { bigint bi = *i.get(); - if (bi < 0 || bi > bigint(u256(0) - 1)) + if (bi < 0) error(); - data.resize(data.size() + 32); - *(h256*)(&data.back() - 31) = (u256)bi; + else if (bi > bigint(u256(0) - 1)) + { + if (ii == 2 && _t.size() == 3) + { + // One big int - allow it as hex. + data.resize(bytesRequired(bi)); + toBigEndian(bi, data); + } + else + error(); + } + else + { + data.resize(data.size() + 32); + *(h256*)(&data.back() - 31) = (u256)bi; + } } else if (ii) error();