|
|
|
@ -21,7 +21,7 @@ CScript ParseScript(std::string s)
@@ -21,7 +21,7 @@ CScript ParseScript(std::string s)
|
|
|
|
|
|
|
|
|
|
static map<string, opcodetype> mapOpNames; |
|
|
|
|
|
|
|
|
|
if (mapOpNames.size() == 0) |
|
|
|
|
if (mapOpNames.empty()) |
|
|
|
|
{ |
|
|
|
|
for (int op = 0; op <= OP_NOP10; op++) |
|
|
|
|
{ |
|
|
|
@ -43,36 +43,36 @@ CScript ParseScript(std::string s)
@@ -43,36 +43,36 @@ CScript ParseScript(std::string s)
|
|
|
|
|
vector<string> words; |
|
|
|
|
split(words, s, is_any_of(" \t\n"), token_compress_on); |
|
|
|
|
|
|
|
|
|
BOOST_FOREACH(string w, words) |
|
|
|
|
for (std::vector<std::string>::const_iterator w = words.begin(); w != words.end(); ++w) |
|
|
|
|
{ |
|
|
|
|
if (w.size() == 0) |
|
|
|
|
if (w->empty()) |
|
|
|
|
{ |
|
|
|
|
// Empty string, ignore. (boost::split given '' will return one word)
|
|
|
|
|
} |
|
|
|
|
else if (all(w, is_digit()) || |
|
|
|
|
(starts_with(w, "-") && all(string(w.begin()+1, w.end()), is_digit()))) |
|
|
|
|
else if (all(*w, is_digit()) || |
|
|
|
|
(starts_with(*w, "-") && all(string(w->begin()+1, w->end()), is_digit()))) |
|
|
|
|
{ |
|
|
|
|
// Number
|
|
|
|
|
int64_t n = atoi64(w); |
|
|
|
|
int64_t n = atoi64(*w); |
|
|
|
|
result << n; |
|
|
|
|
} |
|
|
|
|
else if (starts_with(w, "0x") && IsHex(string(w.begin()+2, w.end()))) |
|
|
|
|
else if (starts_with(*w, "0x") && (w->begin()+2 != w->end()) && IsHex(string(w->begin()+2, w->end()))) |
|
|
|
|
{ |
|
|
|
|
// Raw hex data, inserted NOT pushed onto stack:
|
|
|
|
|
std::vector<unsigned char> raw = ParseHex(string(w.begin()+2, w.end())); |
|
|
|
|
std::vector<unsigned char> raw = ParseHex(string(w->begin()+2, w->end())); |
|
|
|
|
result.insert(result.end(), raw.begin(), raw.end()); |
|
|
|
|
} |
|
|
|
|
else if (w.size() >= 2 && starts_with(w, "'") && ends_with(w, "'")) |
|
|
|
|
else if (w->size() >= 2 && starts_with(*w, "'") && ends_with(*w, "'")) |
|
|
|
|
{ |
|
|
|
|
// Single-quoted string, pushed as data. NOTE: this is poor-man's
|
|
|
|
|
// parsing, spaces/tabs/newlines in single-quoted strings won't work.
|
|
|
|
|
std::vector<unsigned char> value(w.begin()+1, w.end()-1); |
|
|
|
|
std::vector<unsigned char> value(w->begin()+1, w->end()-1); |
|
|
|
|
result << value; |
|
|
|
|
} |
|
|
|
|
else if (mapOpNames.count(w)) |
|
|
|
|
else if (mapOpNames.count(*w)) |
|
|
|
|
{ |
|
|
|
|
// opcode, e.g. OP_ADD or ADD:
|
|
|
|
|
result << mapOpNames[w]; |
|
|
|
|
result << mapOpNames[*w]; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|