diff options
author | Teddy <ted.sybil@gmail.com> | 2013-08-11 13:05:51 +0800 |
---|---|---|
committer | Teddy <ted.sybil@gmail.com> | 2013-08-11 13:05:51 +0800 |
commit | 81844497e621997c527ceedd722854966bd098e0 (patch) | |
tree | 4bc16a4100e1c330e558fdc975a113d272567b86 /model.cpp | |
parent | 448ac0bcc3a81e250a825c333dd01c77e754341a (diff) |
fixed `next` pointer and `ext_repr` issues
Diffstat (limited to 'model.cpp')
-rw-r--r-- | model.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
@@ -84,8 +84,13 @@ string EvalObj::ext_repr() { if (obj) { *(++top_ptr) = obj->get_repr_cons(); - if (hash.count((*top_ptr)->ori)) - *top_ptr = new ReprStr("#inf#"); + EvalObj *ptr = (*top_ptr)->ori; + if (ptr) + { + if (hash.count(ptr)) + *top_ptr = new ReprStr("#inf#"); + else hash.insert(ptr); + } } else { @@ -100,8 +105,13 @@ string EvalObj::ext_repr() { if (obj) { *(++top_ptr) = obj->get_repr_cons(); - if (hash.count((*top_ptr)->ori)) - *top_ptr = new ReprStr("#inf#"); + EvalObj *ptr = (*top_ptr)->ori; + if (ptr) + { + if (hash.count(ptr)) + *top_ptr = new ReprStr("#inf#"); + else hash.insert(ptr); + } } else *top_ptr = new ReprStr((*top_ptr)->repr); } @@ -401,13 +411,17 @@ EvalObj *PromObj::get_mem() { return mem; } void PromObj::feed_mem(EvalObj *res) { mem = res; } -bool is_list(Pair *ptr) { +bool make_exec(Pair *ptr) { if (ptr == empty_list) return true; EvalObj *nptr; for (;;) if ((nptr = ptr->cdr)->is_pair_obj()) - ptr = TO_PAIR(nptr); + { + ptr->next = TO_PAIR(nptr); + ptr = ptr->next; + } else break; + ptr->next = NULL; return ptr->cdr == empty_list; } |