commit 615500209f78b80f9dd42fd5deffcc4990297bd0
parent 36dacb1442b45aaf601f38b7356c2902f9127e8d
Author: Andres Navarro <canavarro82@gmail.com>
Date: Sat, 12 Mar 2011 23:14:39 -0300
Extracted out the equivalence under mutation features from kground.c to a new file kgeqp.c (and .h).
Diffstat:
5 files changed, 75 insertions(+), 45 deletions(-)
diff --git a/src/Makefile b/src/Makefile
@@ -10,7 +10,7 @@ MYLIBS=
CORE_O= kobject.o ktoken.o kpair.o kstring.o ksymbol.o kread.o \
kwrite.o kstate.o kmem.o kerror.o kauxlib.o kenvironment.o \
kcontinuation.o koperative.o kapplicative.o keval.o krepl.o \
- kground.o kghelpers.o
+ kground.o kghelpers.o kgbooleans.o kgeqp.o
KRN_T= klisp
KRN_O= klisp.o
@@ -66,8 +66,11 @@ keval.o: keval.c keval.h kcontinuation.h kenvironment.h kstate.h kobject.h \
krepl.o: krepl.c krepl.h kcontinuation.h kstate.h kobject.h keval.h klisp.h \
kread.h kwrite.h kenvironment.h
kground.o: kground.c kground.h kstate.h kobject.h klisp.h kenvironment.h \
- kpair.h kapplicative.h koperative.h ksymbol.h kerror.h kghelpers.h
+ kpair.h kapplicative.h koperative.h ksymbol.h kerror.h kghelpers.h \
+ kgbooleans.h kgeqp.h
kghelpers.o: kghelpers.c kghelpers.h kstate.h kstate.h klisp.h kpair.h \
kapplicative.h koperative.h kerror.h kobject.h ksymbol.h
kgbooleans.o: kgbooleans.c kgbooleans.c kghelpers.h kstate.h klisp.h \
- kobject.h kerror.h kpair.h
-\ No newline at end of file
+ kobject.h kerror.h kpair.h kcontinuation.h
+kgeqp.o: kgeqp.c kgeqp.c kghelpers.h kstate.h klisp.h \
+ kobject.h kerror.h kpair.h kcontinuation.h
+\ No newline at end of file
diff --git a/src/kgbooleans.c b/src/kgbooleans.c
@@ -14,6 +14,7 @@
#include "klisp.h"
#include "kstate.h"
#include "kpair.h"
+#include "kcontinuation.h"
#include "kerror.h"
#include "kghelpers.h"
diff --git a/src/kgeqp.c b/src/kgeqp.c
@@ -0,0 +1,33 @@
+/*
+** kgeqp.c
+** Equivalence under mutation features for the ground environment
+** See Copyright Notice in klisp.h
+*/
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "kstate.h"
+#include "kobject.h"
+#include "kpair.h"
+#include "kcontinuation.h"
+#include "kerror.h"
+
+#include "kghelpers.h"
+#include "kgeqp.h"
+
+/* 4.2.1 eq? */
+/* TEMP: for now it takes only two argument */
+void eqp(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
+{
+ (void) denv;
+ (void) xparams;
+
+ bind_2p(K, "eq?", ptree, obj1, obj2);
+
+ bool res = eq2p(K, obj1, obj2);
+ kapply_cc(K, b2tv(res));
+}
diff --git a/src/kgeqp.h b/src/kgeqp.h
@@ -0,0 +1,33 @@
+/*
+** kgeqp.c
+** Equivalence under mutation features for the ground environment
+** See Copyright Notice in klisp.h
+*/
+
+#ifndef kgeqp_h
+#define kgeqp_h
+
+#include <assert.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+#include "kstate.h"
+#include "kobject.h"
+#include "klisp.h"
+#include "kghelpers.h"
+
+/* Helper (also used in equal?) */
+/* TEMP: for now this is the same as tv_equal,
+ later it will change with numbers and immutable objects */
+inline bool eq2p(klisp_State *K, TValue obj1, TValue obj2)
+{
+ return (tv_equal(obj1, obj2));
+}
+
+/* 4.2.1 eq? */
+/* TEMP: for now it takes only two argument */
+void eqp(klisp_State *K, TValue *xparams, TValue ptree, TValue denv);
+
+#endif
diff --git a/src/kground.c b/src/kground.c
@@ -24,6 +24,7 @@
#include "kghelpers.h"
#include "kgbooleans.h"
+#include "kgeqp.h"
/*
** This section will roughly follow the report and will reference the
@@ -32,47 +33,6 @@
/* TODO: split in different files for each module */
/*
-**
-** 4 Core types and primitive features
-**
-*/
-
-/*
-** 4.1 Booleans
-*/
-
-/* 4.1.1 boolean? */
-/* uses typep */
-
-/*
-** 4.2 Equivalence under mutation
-*/
-
-/* 4.2.1 eq? */
-
-/* Helper (also used in equal?) */
-inline bool eq2p(klisp_State *K, TValue obj1, TValue obj2);
-
-/* TEMP: for now it takes only two argument */
-void eqp(klisp_State *K, TValue *xparams, TValue ptree, TValue denv)
-{
- (void) denv;
- (void) xparams;
-
- bind_2p(K, "eq?", ptree, obj1, obj2);
-
- bool res = eq2p(K, obj1, obj2);
- kapply_cc(K, b2tv(res));
-}
-
-/* TEMP: for now this is the same as tv_equal,
- later it will change with numbers and immutable objects */
-inline bool eq2p(klisp_State *K, TValue obj1, TValue obj2)
-{
- return (tv_equal(obj1, obj2));
-}
-
-/*
** 4.3 Equivalence up to mutation
*/