projects
/
fw
/
altos
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
altos/telegps-v2.0: Set CPU clock to 48MHz instread of 96MHz
[fw/altos]
/
src
/
lisp
/
ao_lisp_atom.c
diff --git
a/src/lisp/ao_lisp_atom.c
b/src/lisp/ao_lisp_atom.c
index d7cb19960c46b4482cf1fa0cd7e2cef1fa416edb..8c9e8ed11346ae5062c3f601ba38b6406f91233d 100644
(file)
--- a/
src/lisp/ao_lisp_atom.c
+++ b/
src/lisp/ao_lisp_atom.c
@@
-38,7
+38,7
@@
static void atom_mark(void *addr)
atom = ao_lisp_poly_atom(atom->next);
if (!atom)
break;
atom = ao_lisp_poly_atom(atom->next);
if (!atom)
break;
- if (ao_lisp_mark_memory(
atom, atom_size(atom)
))
+ if (ao_lisp_mark_memory(
&ao_lisp_atom_type, atom
))
break;
}
}
break;
}
}
@@
-46,11
+46,19
@@
static void atom_mark(void *addr)
static void atom_move(void *addr)
{
struct ao_lisp_atom *atom = addr;
static void atom_move(void *addr)
{
struct ao_lisp_atom *atom = addr;
+ int ret;
for (;;) {
for (;;) {
- if (ao_lisp_poly_move(&atom->next, 0))
+ struct ao_lisp_atom *next = ao_lisp_poly_atom(atom->next);
+
+ if (!next)
break;
break;
- atom = ao_lisp_poly_atom(atom->next);
+ ret = ao_lisp_move_memory(&ao_lisp_atom_type, (void **) &next);
+ if (next != ao_lisp_poly_atom(atom->next))
+ atom->next = ao_lisp_atom_poly(next);
+ if (ret)
+ break;
+ atom = next;
}
}
}
}
@@
-58,6
+66,7
@@
const struct ao_lisp_type ao_lisp_atom_type = {
.mark = atom_mark,
.size = atom_size,
.move = atom_move,
.mark = atom_mark,
.size = atom_size,
.move = atom_move,
+ .name = "atom"
};
struct ao_lisp_atom *ao_lisp_atoms;
};
struct ao_lisp_atom *ao_lisp_atoms;
@@
-77,12
+86,12
@@
ao_lisp_atom_intern(char *name)
return atom;
}
#endif
return atom;
}
#endif
+ ao_lisp_string_stash(0, name);
atom = ao_lisp_alloc(name_size(name));
atom = ao_lisp_alloc(name_size(name));
+ name = ao_lisp_string_fetch(0);
if (atom) {
atom->type = AO_LISP_ATOM;
atom->next = ao_lisp_atom_poly(ao_lisp_atoms);
if (atom) {
atom->type = AO_LISP_ATOM;
atom->next = ao_lisp_atom_poly(ao_lisp_atoms);
- if (!ao_lisp_atoms)
- ao_lisp_root_add(&ao_lisp_atom_type, &ao_lisp_atoms);
ao_lisp_atoms = atom;
strcpy(atom->name, name);
}
ao_lisp_atoms = atom;
strcpy(atom->name, name);
}
@@
-95,14
+104,11
@@
struct ao_lisp_frame *ao_lisp_frame_current;
static void
ao_lisp_atom_init(void)
{
static void
ao_lisp_atom_init(void)
{
- if (!ao_lisp_frame_global)
{
+ if (!ao_lisp_frame_global)
ao_lisp_frame_global = ao_lisp_frame_new(0);
ao_lisp_frame_global = ao_lisp_frame_new(0);
- ao_lisp_root_add(&ao_lisp_frame_type, &ao_lisp_frame_global);
- ao_lisp_root_add(&ao_lisp_frame_type, &ao_lisp_frame_current);
- }
}
}
-
static
ao_poly *
+ao_poly *
ao_lisp_atom_ref(struct ao_lisp_frame *frame, ao_poly atom)
{
ao_poly *ref;
ao_lisp_atom_ref(struct ao_lisp_frame *frame, ao_poly atom)
{
ao_poly *ref;
@@
-111,7
+117,7
@@
ao_lisp_atom_ref(struct ao_lisp_frame *frame, ao_poly atom)
ref = ao_lisp_frame_ref(frame, atom);
if (ref)
return ref;
ref = ao_lisp_frame_ref(frame, atom);
if (ref)
return ref;
- frame = ao_lisp_poly_frame(frame->
next
);
+ frame = ao_lisp_poly_frame(frame->
prev
);
}
if (ao_lisp_frame_global) {
ref = ao_lisp_frame_ref(ao_lisp_frame_global, atom);
}
if (ao_lisp_frame_global) {
ref = ao_lisp_frame_ref(ao_lisp_frame_global, atom);
@@
-134,7
+140,7
@@
ao_lisp_atom_get(ao_poly atom)
#endif
if (ref)
return *ref;
#endif
if (ref)
return *ref;
- return
AO_LISP_NIL
;
+ return
ao_lisp_error(AO_LISP_UNDEFINED, "undefined atom %s", ao_lisp_poly_atom(atom)->name)
;
}
ao_poly
}
ao_poly
@@
-147,7
+153,7
@@
ao_lisp_atom_set(ao_poly atom, ao_poly val)
if (ref)
*ref = val;
else
if (ref)
*ref = val;
else
- ao_lisp_frame_
global = ao_lisp_frame_add(
ao_lisp_frame_global, atom, val);
+ ao_lisp_frame_
add(&
ao_lisp_frame_global, atom, val);
return val;
}
return val;
}