From cfb7f91f0153250b009a68b076ef4d1e6f12c4eb Mon Sep 17 00:00:00 2001 From: Teddy Date: Tue, 13 Aug 2013 19:42:19 +0800 Subject: add the middle class: `Container` to help resolve circular issues --- model.cpp | 3 +++ model.h | 7 +++++++ types.cpp | 4 ++-- types.h | 2 +- 4 files changed, 13 insertions(+), 3 deletions(-) diff --git a/model.cpp b/model.cpp index 938deca..cb3d5c6 100644 --- a/model.cpp +++ b/model.cpp @@ -132,3 +132,6 @@ string EvalObj::ext_repr() { RetAddr::RetAddr(Pair *_addr, Pair *_state) : FrameObj(CLS_RET_ADDR), addr(_addr), state(_state) {} + +Container::Container(int otype) : EvalObj(otype | CLS_CONTAINER) { +} diff --git a/model.h b/model.h index 7fb9fc8..1ace1c9 100644 --- a/model.h +++ b/model.h @@ -15,6 +15,7 @@ const int CLS_PAR_BRA = 1 << 2; const int CLS_SIM_OBJ = 1 << 0; const int CLS_PAIR_OBJ = 1 << 1; +const int CLS_CONTAINER = 1 << 20; #define TO_PAIR(ptr) \ (static_cast(ptr)) @@ -101,6 +102,12 @@ class EvalObj : public FrameObj { virtual ReprCons *get_repr_cons() = 0; }; +class Container: public EvalObj { + public: + size_t gc_refs; + Container(int otype); +}; + /** @class RetAddr * Tracking the caller's Pair pointer */ diff --git a/types.cpp b/types.cpp index 449da5e..7988c59 100644 --- a/types.cpp +++ b/types.cpp @@ -15,8 +15,8 @@ const int PREC = 16; extern EmptyList *empty_list; extern UnspecObj *unspec_obj; -Pair::Pair(EvalObj *_car, EvalObj *_cdr) : EvalObj(CLS_PAIR_OBJ), - car(_car), cdr(_cdr), next(NULL) { +Pair::Pair(EvalObj *_car, EvalObj *_cdr) : +Container(CLS_PAIR_OBJ), car(_car), cdr(_cdr), next(NULL) { gc.attach(car); gc.attach(cdr); diff --git a/types.h b/types.h index a364e55..93dac66 100644 --- a/types.h +++ b/types.h @@ -44,7 +44,7 @@ class PairReprCons; * more, a syntax tree * (car . cdr) in Scheme */ -class Pair : public EvalObj {/*{{{*/ +class Pair : public Container {/*{{{*/ public: EvalObj *car; /**< car (as in Scheme) */ EvalObj *cdr; /**< cdr (as in Scheme) */ -- cgit v1.2.3-70-g09d2