s/repr/lake_repr/

This commit is contained in:
Sami Samhuri 2011-04-23 19:59:30 -07:00
parent 62bebe7bc6
commit 2eddae72ee
8 changed files with 15 additions and 17 deletions

View file

@ -33,14 +33,14 @@ char *dlist_repr(LakeDottedList *dlist)
char *s2;
if (dlist->head) {
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_free(s2);
if (i != LIST_N(dlist->head) - 1) g_string_append(s, " ");
}
}
g_string_append(s, " . ");
s2 = repr(dlist->tail);
s2 = lake_repr(dlist->tail);
g_string_append(s, s2);
g_free(s2);
g_string_append(s, ")");

View file

@ -19,7 +19,7 @@ typedef LakeVal *(*special_form_handler)(LakeCtx *ctx, Env *env, LakeList *expr)
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 */
@ -376,7 +376,7 @@ LakeVal *apply(LakeCtx *ctx, LakeVal *fnVal, LakeList *args)
result = eval_exprs1(ctx, env, fn->body);
}
else {
ERR("not a function: %s", repr(fnVal));
ERR("not a function: %s", lake_repr(fnVal));
}
return result;
}

View file

@ -42,19 +42,19 @@ char *fn_repr(LakeFn *fn)
free(s2);
}
else if (fn->varargs) {
s2 = repr(VAL(fn->varargs));
s2 = lake_repr(VAL(fn->varargs));
g_string_append(s, s2);
free(s2);
}
else {
s2 = repr(VAL(fn->params));
s2 = lake_repr(VAL(fn->params));
g_string_append(s, s2);
free(s2);
}
g_string_append(s, " ");
int 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_free(s2);
if (i != LIST_N(fn->body) - 1) g_string_append(s, " ");

View file

@ -17,6 +17,4 @@
LakeFn *fn_make(LakeList *params, LakeSym *varargs, LakeList *body, Env *closure);
char *fn_repr(LakeFn *fn);
/* TODO: function operations */
#endif

View file

@ -91,7 +91,7 @@ static LakeVal *prompt_read(LakeCtx *ctx, Env *env, char *prompt)
return result;
}
char *repr(LakeVal *expr)
char *lake_repr(LakeVal *expr)
{
if (expr == NULL) return g_strdup("(null)");

View file

@ -162,7 +162,7 @@ typedef struct lake_comment LakeComment;
gboolean lake_is(LakeVal *a, LakeVal *b);
gboolean lake_equal(LakeVal *a, LakeVal *b);
char *repr(LakeVal *val);
char *lake_repr(LakeVal *val);
#include <stdio.h>

View file

@ -187,7 +187,7 @@ char *list_repr(LakeList *list)
int i;
char *s2;
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_free(s2);
if (i != LIST_N(list) - 1) g_string_append(s, " ");

View file

@ -105,11 +105,11 @@ static LakeVal *_not(LakeCtx *ctx, LakeList *args)
return VAL(not);
}
#define ENSURE_INT(x, i) do { \
if (!IS(TYPE_INT, x)) { \
ERR("argument %zu is not an integer: %s", i, repr(x)); \
return NULL; \
} \
#define ENSURE_INT(x, i) do { \
if (!IS(TYPE_INT, x)) { \
ERR("argument %zu is not an integer: %s", i, lake_repr(x)); \
return NULL; \
} \
} while (0)
static LakeVal *_add(LakeCtx *ctx, LakeList *args)