From 88d32f8aa5cec9a04f4dcd3c73e0908b2701d43a Mon Sep 17 00:00:00 2001 From: Gav Wood Date: Sun, 25 May 2014 13:45:08 +0200 Subject: [PATCH] Numeric mem literals. --- libethereum/Instruction.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/libethereum/Instruction.cpp b/libethereum/Instruction.cpp index 826d4072f..2d3f4e64b 100644 --- a/libethereum/Instruction.cpp +++ b/libethereum/Instruction.cpp @@ -568,6 +568,7 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) error(); unsigned ii = 0; CodeFragment pos; + bytes data; for (auto const& i: _t) { if (ii == 1) @@ -579,19 +580,25 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s) else if (ii == 2 && !i.tag() && i.which() == sp::utree_type::string_type) { auto sr = i.get, sp::utree_type::string_type>>(); - appendPush(sr.end() - sr.begin()); - appendInstruction(Instruction::DUP); - appendPushDataLocation(bytes((byte const*)sr.begin(), (byte const*)sr.end())); - appendFragment(pos, 1); - appendInstruction(Instruction::CODECOPY); + data = bytes((byte const*)sr.begin(), (byte const*)sr.end()); } 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)) + error(); + data.resize(data.size() + 32); + *(h256*)(&data.back() - 31) = (u256)bi; } else if (ii) error(); ++ii; } + appendPush(data.size()); + appendInstruction(Instruction::DUP); + appendPushDataLocation(data); + appendFragment(pos, 1); + appendInstruction(Instruction::CODECOPY); } else nonStandard = false;