mirror of
https://github.com/samsonjs/lake.git
synced 2026-03-25 08:55:49 +00:00
clean out cruft, make things more uniform
This commit is contained in:
parent
06e00c32e5
commit
ccdffc87aa
13 changed files with 5 additions and 48 deletions
|
|
@ -10,18 +10,13 @@
|
|||
#include <glib.h>
|
||||
#include "bool.h"
|
||||
#include "lake.h"
|
||||
#include "sym.h"
|
||||
#include "string.h"
|
||||
|
||||
LakeBool *bool_from_int(int n)
|
||||
{
|
||||
return n ? T : F;
|
||||
}
|
||||
|
||||
gboolean bool_val(LakeBool *b)
|
||||
{
|
||||
return b->val;
|
||||
}
|
||||
|
||||
char *bool_repr(LakeBool *b)
|
||||
{
|
||||
return g_strdup(BOOL_VAL(b) ? "#t" : "#f");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@
|
|||
#include "lake.h"
|
||||
|
||||
LakeBool *bool_from_int(int b);
|
||||
gboolean bool_val(LakeBool *b);
|
||||
LakeStr *bool_to_str(LakeBool *b);
|
||||
char *bool_repr(LakeBool *b);
|
||||
LakeVal* bool_and(LakeVal *a, LakeVal *b);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ char *comment_repr(LakeComment *comment)
|
|||
return g_strdup(STR_S(comment->text));
|
||||
}
|
||||
|
||||
gboolean comm_equal(LakeComment *a, LakeComment *b)
|
||||
gboolean comment_equal(LakeComment *a, LakeComment *b)
|
||||
{
|
||||
return str_equal(COMM_TEXT(a), COMM_TEXT(b));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,6 @@
|
|||
LakeComment *comment_make(LakeStr *text);
|
||||
LakeComment *comment_from_c(char *text);
|
||||
char *comment_repr(LakeComment *comment);
|
||||
gboolean comm_equal(LakeComment *a, LakeComment *b);
|
||||
gboolean comment_equal(LakeComment *a, LakeComment *b);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -16,11 +16,6 @@
|
|||
|
||||
static Env *_top = NULL;
|
||||
|
||||
void env_set_toplevel(Env *env)
|
||||
{
|
||||
_top = env;
|
||||
}
|
||||
|
||||
Env *env_toplevel(void)
|
||||
{
|
||||
if (!_top) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ typedef struct env Env;
|
|||
|
||||
#include "lake.h"
|
||||
|
||||
void env_set_toplevel(Env *env);
|
||||
Env *env_toplevel(void);
|
||||
|
||||
Env *env_make(Env *parent);
|
||||
|
|
|
|||
15
src/int.c
15
src/int.c
|
|
@ -26,13 +26,6 @@ LakeInt *int_make(void)
|
|||
return i;
|
||||
}
|
||||
|
||||
LakeInt *int_copy(LakeInt *i)
|
||||
{
|
||||
LakeInt *copy = int_alloc();
|
||||
copy->val = i->val;
|
||||
return copy;
|
||||
}
|
||||
|
||||
LakeInt *int_from_c(int n)
|
||||
{
|
||||
LakeInt *i = int_alloc();
|
||||
|
|
@ -40,14 +33,6 @@ LakeInt *int_from_c(int n)
|
|||
return i;
|
||||
}
|
||||
|
||||
LakeInt *int_cmp(LakeInt *a, LakeInt *b)
|
||||
{
|
||||
int aN = a->val, bN = b->val;
|
||||
LakeInt *result = int_alloc();
|
||||
result->val = aN < bN ? -1 : (aN == bN ? 0 : 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
LakeStr *int_to_str(LakeInt *i)
|
||||
{
|
||||
char *s = g_strdup_printf("%d", i->val);
|
||||
|
|
|
|||
|
|
@ -13,9 +13,7 @@
|
|||
#include "lake.h"
|
||||
|
||||
LakeInt *int_make(void);
|
||||
LakeInt *int_copy(LakeInt *i);
|
||||
LakeInt *int_from_c(int n);
|
||||
LakeInt *int_cmp(LakeInt *a, LakeInt *b);
|
||||
LakeStr *int_to_str(LakeInt *i);
|
||||
|
||||
#endif
|
||||
|
|
@ -184,7 +184,7 @@ gboolean lake_equal(LakeVal *a, LakeVal *b)
|
|||
return dlist_equal(DLIST(a), DLIST(b));
|
||||
|
||||
case TYPE_COMM:
|
||||
return comm_equal(COMM(a), COMM(b));
|
||||
return comment_equal(COMM(a), COMM(b));
|
||||
|
||||
default:
|
||||
ERR("unknown type %d (%s)", a->type, type_name(a));
|
||||
|
|
|
|||
|
|
@ -164,12 +164,6 @@ LakeVal *list_pop(LakeList *list)
|
|||
return tail;
|
||||
}
|
||||
|
||||
LakeInt *list_cmp(LakeList *a, LakeList *b)
|
||||
{
|
||||
/* TODO */
|
||||
return 0;
|
||||
}
|
||||
|
||||
gboolean list_equal(LakeList *a, LakeList *b)
|
||||
{
|
||||
if (a == b) return TRUE;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@ LakeInt *list_len(LakeList *list);
|
|||
LakeVal *list_pop(LakeList *list);
|
||||
LakeVal *list_shift(LakeList *list);
|
||||
LakeVal *list_unshift(LakeList *list, LakeVal *val);
|
||||
LakeInt *list_cmp(LakeList *a, LakeList *b);
|
||||
gboolean list_equal(LakeList *a, LakeList *b);
|
||||
LakeStr *list_to_str(LakeList *list);
|
||||
char *list_repr(LakeList *list);
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ void str_free(LakeStr *str)
|
|||
g_free(str);
|
||||
}
|
||||
|
||||
LakeVal *str_set(LakeStr *str, char *s)
|
||||
static LakeVal *str_set(LakeStr *str, char *s)
|
||||
{
|
||||
str->n = strlen(s);
|
||||
str->s = g_strdup(s);
|
||||
|
|
@ -62,11 +62,6 @@ char *str_val(LakeStr *str)
|
|||
return g_strdup(str->s);
|
||||
}
|
||||
|
||||
LakeInt *str_cmp(LakeStr *a, LakeStr *b)
|
||||
{
|
||||
return int_from_c(g_strcmp0(a->s, b->s));
|
||||
}
|
||||
|
||||
gboolean str_equal(LakeStr *a, LakeStr *b)
|
||||
{
|
||||
size_t n = STR_N(a);
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ LakeStr *str_copy(LakeStr *str);
|
|||
LakeStr *str_from_c(char *s);
|
||||
char *str_val(LakeStr *str);
|
||||
LakeInt *str_len(LakeStr *str);
|
||||
LakeVal *str_set(LakeStr *str, char *s);
|
||||
LakeInt *str_cmp(LakeStr *a, LakeStr *b);
|
||||
gboolean str_equal(LakeStr *a, LakeStr *b);
|
||||
LakeStr *str_to_str(LakeStr *str);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue