From d038c0751dba11ce8c6d9c3ec2375190ab145b6d Mon Sep 17 00:00:00 2001 From: Christian Date: Thu, 30 Oct 2014 01:20:32 +0100 Subject: Contract compiler and also add ExpressionStatement to AST. ExpressionStatement functions as glue between Statements and Expressions. This way it is possible to detect when the border between statements and expressions is crossed while walking the AST. Note that ExpressionStatement is not the only border, almost every statement can contains expressions. --- Assembly.cpp | 2 +- Assembly.h | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/Assembly.cpp b/Assembly.cpp index 5b10138d..7ad84682 100644 --- a/Assembly.cpp +++ b/Assembly.cpp @@ -54,6 +54,7 @@ unsigned Assembly::bytesRequired() const switch (i.m_type) { case Operation: + case Tag: // 1 byte for the JUMPDEST ret++; break; case PushString: @@ -69,7 +70,6 @@ unsigned Assembly::bytesRequired() const case PushData: case PushSub: ret += 1 + br; - case Tag:; default:; } if (dev::bytesRequired(ret) <= br) diff --git a/Assembly.h b/Assembly.h index 8ab3062d..38baee0c 100644 --- a/Assembly.h +++ b/Assembly.h @@ -105,7 +105,11 @@ public: void injectStart(AssemblyItem const& _i); std::string out() const { std::stringstream ret; streamRLP(ret); return ret.str(); } + int deposit() const { return m_deposit; } + void adjustDeposit(int _adjustment) { m_deposit += _adjustment; assert(m_deposit >= 0); } + void setDeposit(int _deposit) { m_deposit = _deposit; assert(m_deposit >= 0); } + bytes assemble() const; Assembly& optimise(bool _enable); std::ostream& streamRLP(std::ostream& _out, std::string const& _prefix = "") const; -- cgit