Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r73577 - trunk/libs/spirit/example/qi/compiler_tutorial/conjure3
From: joel_at_[hidden]
Date: 2011-08-06 12:42:29


Author: djowel
Date: 2011-08-06 12:42:29 EDT (Sat, 06 Aug 2011)
New Revision: 73577
URL: http://svn.boost.org/trac/boost/changeset/73577

Log:
more tweaks
Text files modified:
   trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp | 20 ++++++++++----------
   trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp | 3 ++-
   2 files changed, 12 insertions(+), 11 deletions(-)

Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.cpp 2011-08-06 12:42:29 EDT (Sat, 06 Aug 2011)
@@ -67,7 +67,7 @@
         );
     }
 
- value not_(value a)
+ value operator!(value a)
     {
         BOOST_ASSERT(a.builder != 0);
         return value(
@@ -212,14 +212,14 @@
     value compiler::operator()(ast::unary const& x)
     {
         value operand = boost::apply_visitor(*this, x.operand_);
- if (!operand)
+ if (!operand.is_valid())
             return val();
 
         switch (x.operator_)
         {
             case token_ids::compl_: return operand ^ val(-1);
             case token_ids::minus: return -operand;
- case token_ids::not_: return not_(operand);
+ case token_ids::not_: return !operand;
             case token_ids::plus: return operand;
             case token_ids::plus_plus:
             {
@@ -386,7 +386,7 @@
         {
             token_ids::type op = rest_begin->operator_;
             value rhs = boost::apply_visitor(*this, rest_begin->operand_);
- if (!rhs)
+ if (!rhs.is_valid())
                 return val();
             ++rest_begin;
 
@@ -406,7 +406,7 @@
     value compiler::operator()(ast::expression const& x)
     {
         value lhs = boost::apply_visitor(*this, x.first);
- if (!lhs)
+ if (!lhs.is_valid())
             return val();
         std::list<ast::operation>::const_iterator rest_begin = x.rest.begin();
         return compile_expression(0, lhs, rest_begin, x.rest.end());
@@ -422,7 +422,7 @@
 
         lvalue lhs = named_values[x.lhs.name];
         value rhs = (*this)(x.rhs);
- if (!rhs)
+ if (!rhs.is_valid())
             return val();
 
         if (x.operator_ == token_ids::assign)
@@ -497,7 +497,7 @@
         if (x.rhs) // if there's an RHS initializer
         {
             init = (*this)(*x.rhs);
- if (!init) // don't add the variable if the RHS fails
+ if (!init.is_valid()) // don't add the variable if the RHS fails
                 return false;
         }
 
@@ -540,7 +540,7 @@
     bool compiler::operator()(ast::if_statement const& x)
     {
         value condition = (*this)(x.condition);
- if (!condition)
+ if (!condition.is_valid())
             return false;
 
         llvm::Function* function = builder.GetInsertBlock()->getParent();
@@ -612,7 +612,7 @@
         builder.CreateBr(cond_block);
         builder.SetInsertPoint(cond_block);
         value condition = (*this)(x.condition);
- if (!condition)
+ if (!condition.is_valid())
             return false;
         builder.CreateCondBr(condition, body_block, exit_block);
         function->getBasicBlockList().push_back(body_block);
@@ -656,7 +656,7 @@
         if (x.expr)
         {
             value return_val = (*this)(*x.expr);
- if (!return_val)
+ if (!return_val.is_valid())
                 return false;
             return_var.assign(return_val);
         }

Modified: trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp
==============================================================================
--- trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp (original)
+++ trunk/libs/spirit/example/qi/compiler_tutorial/conjure3/compiler.hpp 2011-08-06 12:42:29 EDT (Sat, 06 Aug 2011)
@@ -45,11 +45,12 @@
 
         value& operator=(value const& rhs);
         bool is_lvalue() const { return is_lvalue_; }
+ bool is_valid() const { return v != 0; }
 
         value& assign(value const& rhs);
 
         friend value operator-(value a);
- friend value not_(value a);
+ friend value operator!(value a);
         friend value operator+(value a, value b);
         friend value operator-(value a, value b);
         friend value operator^(value a, value b);


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk