mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Compiler fixes. Updates for coins.
This commit is contained in:
parent
a7f4690200
commit
b5cc0ae6cd
@ -74,12 +74,14 @@ unsigned Assembly::bytesRequired() const
|
||||
|
||||
void Assembly::append(Assembly const& _a)
|
||||
{
|
||||
auto newDeposit = m_deposit + _a.deposit();
|
||||
for (AssemblyItem i: _a.m_items)
|
||||
{
|
||||
if (i.type() == Tag || i.type() == PushTag)
|
||||
i.m_data += m_usedTags;
|
||||
append(i);
|
||||
}
|
||||
m_deposit = newDeposit;
|
||||
m_usedTags += _a.m_usedTags;
|
||||
for (auto const& i: _a.m_data)
|
||||
m_data.insert(i);
|
||||
|
@ -151,6 +151,9 @@ void CodeFragment::constructOperation(sp::utree const& _t, CompilerState& _s)
|
||||
case 5:
|
||||
us = "SEQ";
|
||||
break;
|
||||
case 6:
|
||||
us = "CALLDATALOAD";
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
|
@ -45,18 +45,20 @@ void CompilerState::populateStandard()
|
||||
{
|
||||
static const string s = "{"
|
||||
"(def 'gav 0x51ba59315b3a95761d0863b05ccc7a7f54703d99)"
|
||||
"(def 'namereg 0x2d0aceee7e5ab874e22ccf8d1a649f59106d74e8)"
|
||||
"(def 'config 0xccdeac59d35627b7de09332e819d5159e7bb7250)"
|
||||
"(def 'config 0x661005d2720d855f1d9976f88bb10c1a3398c77f)"
|
||||
"(def 'namereg 0x50441127ea5b9dfd835a9aba4e1dc9c1257b58ca)"
|
||||
"(def 'gavcoin 0x5620133321fcac7f15a5c570016f6cb6dc263f9d)"
|
||||
"(def 'sendgavcoin (to value) { [0]:to [32]:value (call (- (gas) 21) gavcoin 0 0 64 0 0) })"
|
||||
"(def 'regname (name) { [0]:name (call (- (gas) 21) namereg 0 0 32 0 0) })"
|
||||
"(def 'send (to value) (call (- (gas) 21) to value 0 0 0 0))"
|
||||
"(def 'allgas (- (gas) 21))"
|
||||
"(def 'sendgavcoin (to value) { [0]'send [32]:to [64]:value (call allgas gavcoin 0 0 96 0 0) })"
|
||||
"(def 'regname (name) { [0]'register [32]name (call allgas namereg 0 0 64 0 0) })"
|
||||
"(def 'regcoins (name) { [0]'register [32]name (call allgas namereg 0 0 64 0 0) })"
|
||||
"(def 'send (to value) (call allgas to value 0 0 0 0))"
|
||||
"(def 'send (gaslimit to value) (call gaslimit to value 0 0 0 0))"
|
||||
"(def 'msg (gaslimit to value data datasize outsize) { (set x outsize) (set y (alloc @32)) (call gaslimit to value data datasize @0 @32) @0 })"
|
||||
"(def 'msg (gaslimit to value data datasize) { (call gaslimit to value data datasize 0 32) @0 })"
|
||||
"(def 'msg (gaslimit to value data) { [0]:data (msg gaslimit to value 0 32) })"
|
||||
"(def 'msg (to value data) { [0]:data (msg (- gas 21) to value 0 32) })"
|
||||
"(def 'msg (to data) { [0]:data (msg (- gas 21) to 0 0 32) })"
|
||||
"(def 'msg (to value data) { [0]:data (msg allgas to value 0 32) })"
|
||||
"(def 'msg (to data) { [0]:data (msg allgas to 0 0 32) })"
|
||||
"(def 'create (value code) { [0]:(msize) (create value @0 (lll code @0)) })"
|
||||
"(def 'create (code) { [0]:(msize) (create 0 @0 (lll code @0)) })"
|
||||
"(def 'sha3 (val) { [0]:val (sha3 0 32) })"
|
||||
|
@ -41,7 +41,7 @@ struct CompilerState
|
||||
CodeFragment const& getDef(std::string const& _s);
|
||||
void populateStandard();
|
||||
|
||||
unsigned stackSize = 64;
|
||||
unsigned stackSize = 128;
|
||||
std::map<std::string, std::pair<unsigned, unsigned>> vars; ///< maps name to stack offset & size.
|
||||
std::map<std::string, CodeFragment> defs;
|
||||
std::map<std::string, CodeFragment> args;
|
||||
|
11
Parser.cpp
11
Parser.cpp
@ -56,6 +56,7 @@ void eth::debugOutAST(ostream& _out, sp::utree const& _this)
|
||||
case 3: _out << "[ "; debugOutAST(_out, _this.front()); _out << " ] "; debugOutAST(_out, _this.back()); break;
|
||||
case 4: _out << "[[ "; debugOutAST(_out, _this.front()); _out << " ]] "; debugOutAST(_out, _this.back()); break;
|
||||
case 5: _out << "{ "; for (auto const& i: _this) { debugOutAST(_out, i); _out << " "; } _out << "}"; break;
|
||||
case 6: _out << "$ "; debugOutAST(_out, _this.front()); break;
|
||||
default:;
|
||||
}
|
||||
|
||||
@ -80,8 +81,8 @@ void eth::parseTreeLLL(string const& _s, sp::utree& o_out)
|
||||
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree()> element;
|
||||
qi::rule<it, string()> str = '"' > qi::lexeme[+(~qi::char_(std::string("\"") + '\0'))] > '"';
|
||||
qi::rule<it, string()> strsh = '\'' > qi::lexeme[+(~qi::char_(std::string(" ;@()[]{}:") + '\0'))];
|
||||
qi::rule<it, symbol_type()> symbol = qi::lexeme[+(~qi::char_(std::string(" @[]{}:();\"\x01-\x1f\x7f") + '\0'))];
|
||||
qi::rule<it, string()> strsh = '\'' > qi::lexeme[+(~qi::char_(std::string(" ;$@()[]{}:\n\t") + '\0'))];
|
||||
qi::rule<it, symbol_type()> symbol = qi::lexeme[+(~qi::char_(std::string(" $@[]{}:();\"\x01-\x1f\x7f") + '\0'))];
|
||||
qi::rule<it, string()> intstr = qi::lexeme[ qi::no_case["0x"][qi::_val = "0x"] >> *qi::char_("0-9a-fA-F")[qi::_val += qi::_1]] | qi::lexeme[+qi::char_("0-9")[qi::_val += qi::_1]];
|
||||
qi::rule<it, bigint()> integer = intstr;
|
||||
qi::rule<it, bigint()> multiplier = qi::lit("wei")[qi::_val = 1] | qi::lit("szabo")[qi::_val = szabo] | qi::lit("finney")[qi::_val = finney] | qi::lit("ether")[qi::_val = ether];
|
||||
@ -92,10 +93,11 @@ void eth::parseTreeLLL(string const& _s, sp::utree& o_out)
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> sload = qi::lit("@@") > element;
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> mstore = '[' > element > ']' > -qi::lit(":") > element;
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> sstore = qi::lit("[[") > element > qi::lit("]]") > -qi::lit(":") > element;
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> calldataload = qi::lit("$") > element;
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree::list_type()> list = '(' > *element > ')';
|
||||
|
||||
auto x = [](int a) { return [=](sp::utree& n, typename qi::rule<it, qi::ascii::space_type, sp::utree()>::context_type& c) { (boost::fusion::at_c<0>(c.attributes) = n).tag(a); }; };
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree()> extra = sload[x(2)] | mload[x(1)] | sstore[x(4)] | mstore[x(3)] | seq[x(5)];
|
||||
qi::rule<it, qi::ascii::space_type, sp::utree()> extra = sload[x(2)] | mload[x(1)] | sstore[x(4)] | mstore[x(3)] | seq[x(5)] | calldataload[x(6)];
|
||||
element = atom | list | extra;
|
||||
|
||||
string s;
|
||||
@ -120,7 +122,8 @@ void eth::parseTreeLLL(string const& _s, sp::utree& o_out)
|
||||
}
|
||||
auto ret = s.cbegin();
|
||||
qi::phrase_parse(ret, s.cend(), element, space, qi::skip_flag::dont_postskip, o_out);
|
||||
if (ret != s.cend())
|
||||
for (auto i = ret; i != s.cend(); ++i)
|
||||
if (!isspace(*i))
|
||||
throw std::exception();
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user