From 9b1d0e016822509e5d3ea7bdc6341b4533b42080 Mon Sep 17 00:00:00 2001 From: Teddy Date: Thu, 15 Aug 2013 20:06:54 +0800 Subject: move ParseBracket to model files --- TODO.rst | 18 +++++++++++------- model.cpp | 14 ++++++++++++-- model.h | 15 +++++++++++++-- types.cpp | 8 -------- types.h | 9 --------- 5 files changed, 36 insertions(+), 28 deletions(-) diff --git a/TODO.rst b/TODO.rst index b403d33..1befc72 100644 --- a/TODO.rst +++ b/TODO.rst @@ -1,7 +1,11 @@ -- OPT:Special Opt Repr -- OPT:Special Arg Checking -- Garbage Collection -- Testing -- Rounding support -- ext_repr optimization -- Add macro support +- Documents and comment + + - model + - eval + - builtin + - gc + - types + - consts + - parser + - exc + - main diff --git a/model.cpp b/model.cpp index ba664a8..a56e530 100644 --- a/model.cpp +++ b/model.cpp @@ -24,7 +24,7 @@ bool FrameObj::is_parse_bracket() { } EvalObj::EvalObj(int _otype) : - FrameObj(CLS_EVAL_OBJ), otype(_otype) { +FrameObj(CLS_EVAL_OBJ), otype(_otype) { gc_obj = gc.join(this); } @@ -139,5 +139,15 @@ string EvalObj::ext_repr() { return res; } +ParseBracket::ParseBracket(unsigned char _btype) : +FrameObj(CLS_SIM_OBJ | CLS_PAR_BRA), btype(_btype) {} + +UnspecObj::UnspecObj() : EvalObj(CLS_SIM_OBJ) {} + +ReprCons *UnspecObj::get_repr_cons() { + return new ReprStr("#"); +} + + Container::Container(int otype, bool override) : - EvalObj(otype | (override ? 0 : CLS_CONTAINER)) {} +EvalObj(otype | (override ? 0 : CLS_CONTAINER)) {} diff --git a/model.h b/model.h index fd88f7d..66c16f9 100644 --- a/model.h +++ b/model.h @@ -103,14 +103,25 @@ class EvalObj : public FrameObj { virtual ReprCons *get_repr_cons() = 0; }; +/** @class ParseBracket + * To indiate a left bracket when parsing, used in the parse_stack + */ +class ParseBracket : public FrameObj {/*{{{*/ + public: + unsigned char btype; /**< The type of the bracket */ + /** Construct a ParseBracket object */ + ParseBracket(unsigned char btype); +};/*}}}*/ + + typedef std::set EvalObjSet; -class Container: public EvalObj { +class Container: public EvalObj {/*{{{*/ public: bool keep; size_t gc_refs; Container(int otype = 0, bool override = false); virtual void gc_decrement() = 0; virtual void gc_trigger(EvalObj ** &tail, EvalObjSet &visited) = 0; -}; +};/*}}}*/ #endif diff --git a/types.cpp b/types.cpp index b583061..0cfe0be 100644 --- a/types.cpp +++ b/types.cpp @@ -41,14 +41,6 @@ ReprCons *Pair::get_repr_cons() { return new PairReprCons(this, this); } -ParseBracket::ParseBracket(unsigned char _btype) : - FrameObj(CLS_SIM_OBJ | CLS_PAR_BRA), btype(_btype) {} - - UnspecObj::UnspecObj() : EvalObj(CLS_SIM_OBJ) {} - - ReprCons *UnspecObj::get_repr_cons() { - return new ReprStr("#"); - } SymObj::SymObj(const string &str) : EvalObj(CLS_SIM_OBJ | CLS_SYM_OBJ), val(str) {} diff --git a/types.h b/types.h index e90e7bb..345e17b 100644 --- a/types.h +++ b/types.h @@ -100,15 +100,6 @@ class VectReprCons : public ReprCons {/*{{{*/ EvalObj *next(const string &prev); };/*}}}*/ -/** @class ParseBracket - * To indiate a left bracket when parsing, used in the parse_stack - */ -class ParseBracket : public FrameObj {/*{{{*/ - public: - unsigned char btype; /**< The type of the bracket */ - /** Construct a ParseBracket object */ - ParseBracket(unsigned char btype); -};/*}}}*/ /** @class UnspecObj * The "unspecified" value returned by some builtin procedures -- cgit v1.2.3-70-g09d2