Browse Source

Fixes and whatnot.

cl-refactor
Gav Wood 11 years ago
parent
commit
f8edff3f54
  1. 26
      alethzero/MainWin.cpp
  2. 2
      libethereum/Client.cpp
  3. 2
      liblll/CompilerState.cpp
  4. 6
      libpyserpent/pyserpent.cpp
  5. 2
      libserpent/rewriter.cpp
  6. 12
      stdserv.js

26
alethzero/MainWin.cpp

@ -1299,8 +1299,9 @@ void Main::on_data_textChanged()
QString s = ui->data->toPlainText(); QString s = ui->data->toPlainText();
while (s.size()) while (s.size())
{ {
QRegExp r("(@|\\$)?\"([^\"]*)\"(.*)"); QRegExp r("(@|\\$)?\"([^\"]*)\"(\\s.*)?");
QRegExp h("(@|\\$)?(0x)?(([a-fA-F0-9])+)(.*)"); QRegExp d("(@|\\$)?([0-9]+)(\\s*(ether)|(finney)|(szabo))?(\\s.*)?");
QRegExp h("(@|\\$)?(0x)?(([a-fA-F0-9])+)(\\s.*)?");
if (r.exactMatch(s)) if (r.exactMatch(s))
{ {
for (auto i: r.cap(2)) for (auto i: r.cap(2))
@ -1312,6 +1313,23 @@ void Main::on_data_textChanged()
m_data.push_back(0); m_data.push_back(0);
s = r.cap(3); s = r.cap(3);
} }
else if (d.exactMatch(s))
{
u256 v(d.cap(2).toStdString());
if (d.cap(6) == "szabo")
v *= eth::szabo;
else if (d.cap(5) == "finney")
v *= eth::finney;
else if (d.cap(4) == "ether")
v *= eth::ether;
bytes bs = eth::toCompactBigEndian(v);
if (d.cap(1) != "$")
for (auto i = bs.size(); i < 32; ++i)
m_data.push_back(0);
for (auto b: bs)
m_data.push_back(b);
s = d.cap(7);
}
else if (h.exactMatch(s)) else if (h.exactMatch(s))
{ {
bytes bs = fromHex((((h.cap(3).size() & 1) ? "0" : "") + h.cap(3)).toStdString()); bytes bs = fromHex((((h.cap(3).size() & 1) ? "0" : "") + h.cap(3)).toStdString());
@ -1679,9 +1697,9 @@ QString Main::prettyU256(eth::u256 _n) const
QString raw; QString raw;
ostringstream s; ostringstream s;
if (!(_n >> 64)) if (!(_n >> 64))
s << "<span style=\"color: #448\">0x</span><span style=\"color: #008\">" << (uint64_t)_n << "</span>"; s << "<span style=\"color: #008\">" << (uint64_t)_n << "</span> <span style=\"color: #448\">(0x" << hex << (uint64_t)_n << ")</span>";
else if (!~(_n >> 64)) else if (!~(_n >> 64))
s << "<span style=\"color: #448\">0x</span><span style=\"color: #008\">" << (int64_t)_n << "</span>"; s << "<span style=\"color: #008\">" << (int64_t)_n << "</span> <span style=\"color: #448\">(0x" << hex << (int64_t)_n << ")</span>";
else if (_n >> 200 == 0) else if (_n >> 200 == 0)
{ {
Address a = right160(_n); Address a = right160(_n);

2
libethereum/Client.cpp

@ -25,6 +25,8 @@
#include <thread> #include <thread>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <libethential/Common.h> #include <libethential/Common.h>
#include <libethential/CommonIO.h>
#include <libethential/Log.h>
#include "Defaults.h" #include "Defaults.h"
#include "PeerServer.h" #include "PeerServer.h"
using namespace std; using namespace std;

2
liblll/CompilerState.cpp

@ -62,6 +62,8 @@ void CompilerState::populateStandard()
"(def 'create (value code) { [0]:(msize) (create value @0 (lll code @0)) })" "(def 'create (value code) { [0]:(msize) (create value @0 (lll code @0)) })"
"(def 'create (code) { [0]:(msize) (create 0 @0 (lll code @0)) })" "(def 'create (code) { [0]:(msize) (create 0 @0 (lll code @0)) })"
"(def 'sha3 (val) { [0]:val (sha3 0 32) })" "(def 'sha3 (val) { [0]:val (sha3 0 32) })"
"(def 'sha3pair (a b) { [0]:a [32]:b (sha3 0 64) })"
"(def 'sha3trip (a b c) { [0]:a [32]:b [64]:c (sha3 0 96) })"
"(def 'return (val) { [0]:val (return 0 32) })" "(def 'return (val) { [0]:val (return 0 32) })"
"(def 'returnlll (code) (return 0 (lll code 0)) )" "(def 'returnlll (code) (return 0 (lll code 0)) )"
"(def 'makeperm (name pos) { (def name (sload pos)) (def name (v) (sstore pos v)) } )" "(def 'makeperm (name pos) { (def name (sload pos)) (def name (v) (sstore pos v)) } )"

6
libpyserpent/pyserpent.cpp

@ -7,7 +7,7 @@
#include <libserpent/funcs.h> #include <libserpent/funcs.h>
#define PYMETHOD(name, FROM, method, TO) \ #define PYMETHOD(name, FROM, method, TO) \
static PyObject * name(PyObject *self, PyObject *args) { \ static PyObject * name(PyObject *, PyObject *args) { \
FROM(med) \ FROM(med) \
return TO(method(med)); \ return TO(method(med)); \
} }
@ -128,7 +128,7 @@ PYMETHOD(ps_parse_lll, FROMSTR, parseLLL, pyifyNode)
static PyMethodDef PyextMethods[] = { static PyMethodDef PyextMethods[] = {
{"compile", ps_compile, METH_VARARGS, {"compile", ps_compile, METH_VARARGS,
"Compile code."}, "Compile code."},
{"compile_to_lll", ps_parse, METH_VARARGS, {"compile_to_lll", ps_compile_to_lll, METH_VARARGS,
"Compile code to LLL."}, "Compile code to LLL."},
{"compile_lll", ps_compile_lll, METH_VARARGS, {"compile_lll", ps_compile_lll, METH_VARARGS,
"Compile LLL to EVM."}, "Compile LLL to EVM."},
@ -151,5 +151,5 @@ static PyMethodDef PyextMethods[] = {
PyMODINIT_FUNC initpyext(void) PyMODINIT_FUNC initpyext(void)
{ {
PyObject *m = Py_InitModule( "pyext", PyextMethods ); Py_InitModule( "pyext", PyextMethods );
} }

2
libserpent/rewriter.cpp

@ -411,7 +411,7 @@ Node apply_rules(Node node) {
node.args[0].val = "'" + node.args[0].val; node.args[0].val = "'" + node.args[0].val;
i = 1; i = 1;
} }
for (i = i; i < node.args.size(); i++) { for (; i < node.args.size(); i++) {
node.args[i] = apply_rules(node.args[i]); node.args[i] = apply_rules(node.args[i]);
} }
} }

12
stdserv.js

@ -92,10 +92,10 @@ var gavCoinCode = eth.lll("
(returnlll { (returnlll {
(when (&& (= $0 'kill) (= (caller) @@0x69)) (suicide (caller))) (when (&& (= $0 'kill) (= (caller) @@0x69)) (suicide (caller)))
(when (= $0 'balance) (return @@$32)) (when (= $0 'balance) (return @@$32))
(when (= $0 'approved) (return @@ @(sha3 (^ (if (= (calldatasize) 64) (caller) $64) $32))) ) (when (= $0 'approved) (return @@ (sha3pair (if (= (calldatasize) 64) (caller) $64) $32)) )
(when (= $0 'approve) { (when (= $0 'approve) {
[[@(sha3 (^ (caller) $32))]] $32 [[(sha3pair (caller) $32)]] $32
(stop) (stop)
}) })
@ -103,18 +103,18 @@ var gavCoinCode = eth.lll("
(set 'fromVar (if (= (calldatasize) 96) (set 'fromVar (if (= (calldatasize) 96)
(caller) (caller)
{ {
(when (! @@ @(sha3 (^ $96 $32)) ) (stop)) (when (! @@ (sha3pair (origin) (caller))) (return 0))
$96 (origin)
} }
)) ))
(def 'to $32) (def 'to $32)
(def 'value $64) (def 'value $64)
(def 'from (get 'fromVar)) (def 'from (get 'fromVar))
(set 'fromBal @@from) (set 'fromBal @@from)
(when (< @fromBal value) (stop)) (when (< @fromBal value) (return 0))
[[ from ]]: (- @fromBal value) [[ from ]]: (- @fromBal value)
[[ to ]]: (+ @@to value) [[ to ]]: (+ @@to value)
(stop) (return 1)
}) })
(set 'n @@0x42) (set 'n @@0x42)

Loading…
Cancel
Save