aboutsummaryrefslogtreecommitdiff
path: root/model.h
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-04 23:35:59 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-04 23:35:59 +0800
commit645549b8a42844fc5a8042a4808c8ebf5050d7da (patch)
tree6f96ef92e16f332a6eb3860450404903865a12fe /model.h
parentacb298c7f864f9862859320555b416c97632d2fa (diff)
added support for `cons`, `car`, `cdr`
Diffstat (limited to 'model.h')
-rw-r--r--model.h9
1 files changed, 7 insertions, 2 deletions
diff --git a/model.h b/model.h
index ebae3d6..a98a475 100644
--- a/model.h
+++ b/model.h
@@ -19,6 +19,9 @@ static const int CLS_CONS_OBJ = 1 << 1;
static const int CLS_SYM_OBJ = 1 << 2;
static const int CLS_OPT_OBJ = 1 << 3;
+#define TO_CONS(ptr) \
+ (static_cast<Cons*>(ptr))
+
/** @class FrameObj
* Objects that can be held in the evaluation stack
*/
@@ -76,6 +79,8 @@ class EvalObj : public FrameObj {
bool is_sym_obj();
/** Check if the object is an operator */
bool is_opt_obj();
+ /** Check if the object is a Cons */
+ bool is_cons_obj();
virtual void prepare(Cons *pc);
/** Any EvalObj has its external representation */
virtual string ext_repr() = 0;
@@ -94,11 +99,11 @@ class EvalObj : public FrameObj {
class Cons : public EvalObj {
public:
EvalObj *car; /**< car (as in Scheme) */
- Cons *cdr; /**< cdr (as in Scheme) */
+ EvalObj *cdr; /**< cdr (as in Scheme) */
bool skip; /**< Wether to skip the current branch */
Cons* next; /**< The next branch in effect */
- Cons(EvalObj *car, Cons *cdr); /**< Create a Cons (car . cdr) */
+ Cons(EvalObj *car, EvalObj *cdr); /**< Create a Cons (car . cdr) */
#ifdef DEBUG
void _debug_print();
string _debug_repr();