mirror of
https://github.com/samsonjs/lake.git
synced 2026-04-27 14:57:43 +00:00
s/repr/lake_repr/
This commit is contained in:
parent
62bebe7bc6
commit
2eddae72ee
8 changed files with 15 additions and 17 deletions
|
|
@ -33,14 +33,14 @@ char *dlist_repr(LakeDottedList *dlist)
|
||||||
char *s2;
|
char *s2;
|
||||||
if (dlist->head) {
|
if (dlist->head) {
|
||||||
for (i = 0; i < LIST_N(dlist->head); ++i) {
|
for (i = 0; i < LIST_N(dlist->head); ++i) {
|
||||||
s2 = repr(LIST_VAL(dlist->head, i));
|
s2 = lake_repr(LIST_VAL(dlist->head, i));
|
||||||
g_string_append(s, s2);
|
g_string_append(s, s2);
|
||||||
g_free(s2);
|
g_free(s2);
|
||||||
if (i != LIST_N(dlist->head) - 1) g_string_append(s, " ");
|
if (i != LIST_N(dlist->head) - 1) g_string_append(s, " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
g_string_append(s, " . ");
|
g_string_append(s, " . ");
|
||||||
s2 = repr(dlist->tail);
|
s2 = lake_repr(dlist->tail);
|
||||||
g_string_append(s, s2);
|
g_string_append(s, s2);
|
||||||
g_free(s2);
|
g_free(s2);
|
||||||
g_string_append(s, ")");
|
g_string_append(s, ")");
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ typedef LakeVal *(*special_form_handler)(LakeCtx *ctx, Env *env, LakeList *expr)
|
||||||
|
|
||||||
static void invalid_special_form(LakeList *expr, char *detail)
|
static void invalid_special_form(LakeList *expr, char *detail)
|
||||||
{
|
{
|
||||||
ERR("malformed special form, %s: %s", detail, repr(VAL(expr)));
|
ERR("malformed special form, %s: %s", detail, lake_repr(VAL(expr)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* expr begins with the symbol "quote" so the quoted value is the 2nd value */
|
/* expr begins with the symbol "quote" so the quoted value is the 2nd value */
|
||||||
|
|
@ -376,7 +376,7 @@ LakeVal *apply(LakeCtx *ctx, LakeVal *fnVal, LakeList *args)
|
||||||
result = eval_exprs1(ctx, env, fn->body);
|
result = eval_exprs1(ctx, env, fn->body);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ERR("not a function: %s", repr(fnVal));
|
ERR("not a function: %s", lake_repr(fnVal));
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
6
src/fn.c
6
src/fn.c
|
|
@ -42,19 +42,19 @@ char *fn_repr(LakeFn *fn)
|
||||||
free(s2);
|
free(s2);
|
||||||
}
|
}
|
||||||
else if (fn->varargs) {
|
else if (fn->varargs) {
|
||||||
s2 = repr(VAL(fn->varargs));
|
s2 = lake_repr(VAL(fn->varargs));
|
||||||
g_string_append(s, s2);
|
g_string_append(s, s2);
|
||||||
free(s2);
|
free(s2);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
s2 = repr(VAL(fn->params));
|
s2 = lake_repr(VAL(fn->params));
|
||||||
g_string_append(s, s2);
|
g_string_append(s, s2);
|
||||||
free(s2);
|
free(s2);
|
||||||
}
|
}
|
||||||
g_string_append(s, " ");
|
g_string_append(s, " ");
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < LIST_N(fn->body); ++i) {
|
for (i = 0; i < LIST_N(fn->body); ++i) {
|
||||||
s2 = repr(LIST_VAL(fn->body, i));
|
s2 = lake_repr(LIST_VAL(fn->body, i));
|
||||||
g_string_append(s, s2);
|
g_string_append(s, s2);
|
||||||
g_free(s2);
|
g_free(s2);
|
||||||
if (i != LIST_N(fn->body) - 1) g_string_append(s, " ");
|
if (i != LIST_N(fn->body) - 1) g_string_append(s, " ");
|
||||||
|
|
|
||||||
2
src/fn.h
2
src/fn.h
|
|
@ -17,6 +17,4 @@
|
||||||
LakeFn *fn_make(LakeList *params, LakeSym *varargs, LakeList *body, Env *closure);
|
LakeFn *fn_make(LakeList *params, LakeSym *varargs, LakeList *body, Env *closure);
|
||||||
char *fn_repr(LakeFn *fn);
|
char *fn_repr(LakeFn *fn);
|
||||||
|
|
||||||
/* TODO: function operations */
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -91,7 +91,7 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *repr(LakeVal *expr)
|
char *lake_repr(LakeVal *expr)
|
||||||
{
|
{
|
||||||
if (expr == NULL) return g_strdup("(null)");
|
if (expr == NULL) return g_strdup("(null)");
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -162,7 +162,7 @@ typedef struct lake_comment LakeComment;
|
||||||
|
|
||||||
gboolean lake_is(LakeVal *a, LakeVal *b);
|
gboolean lake_is(LakeVal *a, LakeVal *b);
|
||||||
gboolean lake_equal(LakeVal *a, LakeVal *b);
|
gboolean lake_equal(LakeVal *a, LakeVal *b);
|
||||||
char *repr(LakeVal *val);
|
char *lake_repr(LakeVal *val);
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -187,7 +187,7 @@ char *list_repr(LakeList *list)
|
||||||
int i;
|
int i;
|
||||||
char *s2;
|
char *s2;
|
||||||
for (i = 0; i < LIST_N(list); ++i) {
|
for (i = 0; i < LIST_N(list); ++i) {
|
||||||
s2 = repr(LIST_VAL(list, i));
|
s2 = lake_repr(LIST_VAL(list, i));
|
||||||
g_string_append(s, s2);
|
g_string_append(s, s2);
|
||||||
g_free(s2);
|
g_free(s2);
|
||||||
if (i != LIST_N(list) - 1) g_string_append(s, " ");
|
if (i != LIST_N(list) - 1) g_string_append(s, " ");
|
||||||
|
|
|
||||||
|
|
@ -105,11 +105,11 @@ static LakeVal *_not(LakeCtx *ctx, LakeList *args)
|
||||||
return VAL(not);
|
return VAL(not);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ENSURE_INT(x, i) do { \
|
#define ENSURE_INT(x, i) do { \
|
||||||
if (!IS(TYPE_INT, x)) { \
|
if (!IS(TYPE_INT, x)) { \
|
||||||
ERR("argument %zu is not an integer: %s", i, repr(x)); \
|
ERR("argument %zu is not an integer: %s", i, lake_repr(x)); \
|
||||||
return NULL; \
|
return NULL; \
|
||||||
} \
|
} \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
static LakeVal *_add(LakeCtx *ctx, LakeList *args)
|
static LakeVal *_add(LakeCtx *ctx, LakeList *args)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue