Fabcoin Core  0.16.2
P2P Digital Currency
Instruction.cpp
Go to the documentation of this file.
1 #include "Instruction.h"
2 
4 #include <llvm/ADT/APInt.h>
6 
7 namespace dev
8 {
9 namespace evmjit
10 {
11 
12 llvm::APInt readPushData(code_iterator& _curr, code_iterator _end)
13 {
14  auto pushInst = *_curr;
16  auto numBytes = pushInst - static_cast<size_t>(Instruction::PUSH1) + 1;
17  llvm::APInt value(256, 0);
18  ++_curr; // Point the data
19  for (decltype(numBytes) i = 0; i < numBytes; ++i)
20  {
21  byte b = (_curr != _end) ? *_curr++ : 0;
22  value <<= 8;
23  value |= b;
24  }
25  --_curr; // Point the last real byte read
26  return value;
27 }
28 
30 {
31  auto pushInst = *_curr;
33  auto numBytes = pushInst - static_cast<size_t>(Instruction::PUSH1) + 1;
34  --_end;
35  for (decltype(numBytes) i = 0; i < numBytes && _curr < _end; ++i, ++_curr) {}
36 }
37 
38 }
39 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
assert(len-trim+(2 *lenIndices)<=WIDTH)
Instruction
Virtual machine bytecode instruction.
Definition: Instruction.h:16
byte const * code_iterator
Definition: Common.h:11
void skipPushData(code_iterator &_curr, code_iterator _end)
Skips PUSH data in pointed fragment of bytecode.
Definition: Instruction.cpp:29
#define b(i, j)
uint8_t byte
Definition: Common.h:10
llvm::APInt readPushData(code_iterator &_curr, code_iterator _end)
Reads PUSH data from pointed fragment of bytecode and constructs number out of it Reading out of byte...
Definition: Instruction.cpp:12
place 1 byte item on stack
place 32 byte item on stack