aboutsummaryrefslogtreecommitdiff
path: root/model.cpp
diff options
context:
space:
mode:
authorTeddy <ted.sybil@gmail.com>2013-08-11 13:05:51 +0800
committerTeddy <ted.sybil@gmail.com>2013-08-11 13:05:51 +0800
commit81844497e621997c527ceedd722854966bd098e0 (patch)
tree4bc16a4100e1c330e558fdc975a113d272567b86 /model.cpp
parent448ac0bcc3a81e250a825c333dd01c77e754341a (diff)
fixed `next` pointer and `ext_repr` issues
Diffstat (limited to 'model.cpp')
-rw-r--r--model.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/model.cpp b/model.cpp
index 85d4e04..564aa74 100644
--- a/model.cpp
+++ b/model.cpp
@@ -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;
}