From 4138714e2790e623b8e9be2f732090f8b47b2fb6 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Tue, 25 Jun 2019 19:54:40 -0700 Subject: [PATCH] add reusable boolean constants This will save us having to reconstruct these repeatedly when we just want to ask the question "is the expression I have the literal true or false?" Github: related to #130 "interact with SMT solver" Github: related to #139 "avoid calling SMT solver for "true" and "false"" --- librumur/include/rumur/Boolean.h | 4 ++++ librumur/src/Boolean.cc | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/librumur/include/rumur/Boolean.h b/librumur/include/rumur/Boolean.h index 3f335e13..e71454ce 100644 --- a/librumur/include/rumur/Boolean.h +++ b/librumur/include/rumur/Boolean.h @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -9,4 +10,7 @@ namespace rumur { extern const Ptr Boolean; +extern const Ptr False; +extern const Ptr True; + } diff --git a/librumur/src/Boolean.cc b/librumur/src/Boolean.cc index ac20eb1a..b15aef66 100644 --- a/librumur/src/Boolean.cc +++ b/librumur/src/Boolean.cc @@ -2,7 +2,9 @@ #include "location.hh" #include #include +#include #include +#include #include #include #include @@ -15,4 +17,16 @@ const Ptr Boolean = Ptr::make( std::vector>( { {"false", location()}, {"true", location()} }), location()); +const Ptr False = Ptr::make("false", + Ptr::make("boolean", + Ptr::make(0, location()), + Boolean, location()), +location()); + +const Ptr True = Ptr::make("true", + Ptr::make("boolean", + Ptr::make(1, location()), + Boolean, location()), +location()); + }