adding fl_ prefix to some functions

This commit is contained in:
JeffBezanson 2010-04-29 18:01:26 +00:00
parent 45c11c944b
commit eec95c17b8
11 changed files with 47 additions and 48 deletions

View File

@ -144,7 +144,7 @@ static value_t fl_top_level_value(value_t *args, u_int32_t nargs)
argcount("top-level-value", nargs, 1); argcount("top-level-value", nargs, 1);
symbol_t *sym = tosymbol(args[0], "top-level-value"); symbol_t *sym = tosymbol(args[0], "top-level-value");
if (sym->binding == UNBOUND) if (sym->binding == UNBOUND)
fl_raise(list2(UnboundError, args[0])); fl_raise(fl_list2(UnboundError, args[0]));
return sym->binding; return sym->binding;
} }

View File

@ -369,7 +369,7 @@ static int cvalue_enum_init(fltype_t *ft, value_t arg, void *dest)
value_t cvalue_enum(value_t *args, u_int32_t nargs) value_t cvalue_enum(value_t *args, u_int32_t nargs)
{ {
argcount("enum", nargs, 2); argcount("enum", nargs, 2);
value_t type = list2(enumsym, args[0]); value_t type = fl_list2(enumsym, args[0]);
fltype_t *ft = get_type(type); fltype_t *ft = get_type(type);
value_t cv = cvalue(ft, sizeof(int32_t)); value_t cv = cvalue(ft, sizeof(int32_t));
cvalue_enum_init(ft, args[1], cp_data((cprim_t*)ptr(cv))); cvalue_enum_init(ft, args[1], cp_data((cprim_t*)ptr(cv)));
@ -973,10 +973,10 @@ static void cvalues_init()
assign_global_builtins(cvalues_builtin_info); assign_global_builtins(cvalues_builtin_info);
stringtypesym = symbol("*string-type*"); stringtypesym = symbol("*string-type*");
setc(stringtypesym, list2(arraysym, bytesym)); setc(stringtypesym, fl_list2(arraysym, bytesym));
wcstringtypesym = symbol("*wcstring-type*"); wcstringtypesym = symbol("*wcstring-type*");
setc(wcstringtypesym, list2(arraysym, wcharsym)); setc(wcstringtypesym, fl_list2(arraysym, wcharsym));
mk_primtype(int8); mk_primtype(int8);
mk_primtype(uint8); mk_primtype(uint8);

View File

@ -255,12 +255,12 @@ static value_t compare_(value_t a, value_t b, int eq)
return guess; return guess;
} }
value_t compare(value_t a, value_t b) value_t fl_compare(value_t a, value_t b)
{ {
return compare_(a, b, 0); return compare_(a, b, 0);
} }
value_t equal(value_t a, value_t b) value_t fl_equal(value_t a, value_t b)
{ {
if (eq_comparable(a, b)) if (eq_comparable(a, b))
return (a == b) ? FL_T : FL_F; return (a == b) ? FL_T : FL_F;

View File

@ -191,7 +191,7 @@ void lerrorf(value_t e, char *format, ...)
va_end(args); va_end(args);
e = POP(); e = POP();
fl_raise(list2(e, msg)); fl_raise(fl_list2(e, msg));
} }
void lerror(value_t e, const char *msg) void lerror(value_t e, const char *msg)
@ -199,17 +199,17 @@ void lerror(value_t e, const char *msg)
PUSH(e); PUSH(e);
value_t m = cvalue_static_cstring(msg); value_t m = cvalue_static_cstring(msg);
e = POP(); e = POP();
fl_raise(list2(e, m)); fl_raise(fl_list2(e, m));
} }
void type_error(char *fname, char *expected, value_t got) void type_error(char *fname, char *expected, value_t got)
{ {
fl_raise(listn(4, TypeError, symbol(fname), symbol(expected), got)); fl_raise(fl_listn(4, TypeError, symbol(fname), symbol(expected), got));
} }
void bounds_error(char *fname, value_t arr, value_t ind) void bounds_error(char *fname, value_t arr, value_t ind)
{ {
fl_raise(listn(4, BoundsError, symbol(fname), arr, ind)); fl_raise(fl_listn(4, BoundsError, symbol(fname), arr, ind));
} }
// safe cast operators -------------------------------------------------------- // safe cast operators --------------------------------------------------------
@ -626,7 +626,7 @@ static value_t _applyn(uint32_t n)
return v; return v;
} }
value_t apply(value_t f, value_t l) value_t fl_apply(value_t f, value_t l)
{ {
value_t v = l; value_t v = l;
uint32_t n = SP; uint32_t n = SP;
@ -644,7 +644,7 @@ value_t apply(value_t f, value_t l)
return v; return v;
} }
value_t applyn(uint32_t n, value_t f, ...) value_t fl_applyn(uint32_t n, value_t f, ...)
{ {
va_list ap; va_list ap;
va_start(ap, f); va_start(ap, f);
@ -663,7 +663,7 @@ value_t applyn(uint32_t n, value_t f, ...)
return v; return v;
} }
value_t listn(size_t n, ...) value_t fl_listn(size_t n, ...)
{ {
va_list ap; va_list ap;
va_start(ap, n); va_start(ap, n);
@ -690,7 +690,7 @@ value_t listn(size_t n, ...)
return tagptr(l, TAG_CONS); return tagptr(l, TAG_CONS);
} }
value_t list2(value_t a, value_t b) value_t fl_list2(value_t a, value_t b)
{ {
PUSH(a); PUSH(a);
PUSH(b); PUSH(b);
@ -1469,7 +1469,7 @@ static value_t apply_cl(uint32_t nargs)
v = (numval(Stack[SP-2]) < numval(Stack[SP-1])) ? FL_T : FL_F; v = (numval(Stack[SP-2]) < numval(Stack[SP-1])) ? FL_T : FL_F;
} }
else { else {
v = (numval(compare(Stack[SP-2], Stack[SP-1])) < 0) ? v = (numval(fl_compare(Stack[SP-2], Stack[SP-1])) < 0) ?
FL_T : FL_F; FL_T : FL_F;
} }
POPN(1); POPN(1);
@ -1575,7 +1575,7 @@ static value_t apply_cl(uint32_t nargs)
assert(issymbol(v)); assert(issymbol(v));
sym = (symbol_t*)ptr(v); sym = (symbol_t*)ptr(v);
if (sym->binding == UNBOUND) if (sym->binding == UNBOUND)
fl_raise(list2(UnboundError, v)); fl_raise(fl_list2(UnboundError, v));
PUSH(sym->binding); PUSH(sym->binding);
NEXT_OP; NEXT_OP;
@ -2229,8 +2229,8 @@ static void lisp_init(void)
setc(symbol("*install-dir*"), cvalue_static_cstring(EXEDIR)); setc(symbol("*install-dir*"), cvalue_static_cstring(EXEDIR));
} }
memory_exception_value = list2(MemoryError, memory_exception_value = fl_list2(MemoryError,
cvalue_static_cstring("out of memory")); cvalue_static_cstring("out of memory"));
assign_global_builtins(core_builtin_info); assign_global_builtins(core_builtin_info);
@ -2239,9 +2239,9 @@ static void lisp_init(void)
// repl ----------------------------------------------------------------------- // repl -----------------------------------------------------------------------
value_t toplevel_eval(value_t expr) value_t fl_toplevel_eval(value_t expr)
{ {
return applyn(1, symbol_value(evalsym), expr); return fl_applyn(1, symbol_value(evalsym), expr);
} }
static value_t argv_list(int argc, char *argv[]) static value_t argv_list(int argc, char *argv[])
@ -2281,7 +2281,7 @@ int main(int argc, char *argv[])
POPN(2); POPN(2);
PUSH(f); saveSP = SP; PUSH(f); saveSP = SP;
while (1) { while (1) {
e = read_sexpr(Stack[SP-1]); e = fl_read_sexpr(Stack[SP-1]);
if (ios_eof(value2c(ios_t*,Stack[SP-1]))) break; if (ios_eof(value2c(ios_t*,Stack[SP-1]))) break;
if (isfunction(e)) { if (isfunction(e)) {
// stage 0 format: series of thunks // stage 0 format: series of thunks
@ -2310,7 +2310,7 @@ int main(int argc, char *argv[])
} }
FL_CATCH { FL_CATCH {
ios_puts("fatal error during bootstrap:\n", ios_stderr); ios_puts("fatal error during bootstrap:\n", ios_stderr);
print(ios_stderr, lasterror); fl_print(ios_stderr, lasterror);
ios_putc('\n', ios_stderr); ios_putc('\n', ios_stderr);
return 1; return 1;
} }

View File

@ -118,26 +118,25 @@ extern value_t FL_NIL, FL_T, FL_F, FL_EOF;
#define FL_UNSPECIFIED FL_T #define FL_UNSPECIFIED FL_T
/* read, eval, print main entry points */ /* read, eval, print main entry points */
value_t read_sexpr(value_t f); value_t fl_read_sexpr(value_t f);
void print(ios_t *f, value_t v); void fl_print(ios_t *f, value_t v);
value_t toplevel_eval(value_t expr); value_t fl_toplevel_eval(value_t expr);
value_t apply(value_t f, value_t l); value_t fl_apply(value_t f, value_t l);
value_t applyn(uint32_t n, value_t f, ...); value_t fl_applyn(uint32_t n, value_t f, ...);
value_t load_file(char *fname);
extern value_t printprettysym, printreadablysym, printwidthsym; extern value_t printprettysym, printreadablysym, printwidthsym;
/* object model manipulation */ /* object model manipulation */
value_t fl_cons(value_t a, value_t b); value_t fl_cons(value_t a, value_t b);
value_t list2(value_t a, value_t b); value_t fl_list2(value_t a, value_t b);
value_t listn(size_t n, ...); value_t fl_listn(size_t n, ...);
value_t symbol(char *str); value_t symbol(char *str);
char *symbol_name(value_t v); char *symbol_name(value_t v);
int fl_is_keyword_name(char *str, size_t len); int fl_is_keyword_name(char *str, size_t len);
value_t alloc_vector(size_t n, int init); value_t alloc_vector(size_t n, int init);
size_t llength(value_t v); size_t llength(value_t v);
value_t compare(value_t a, value_t b); // -1, 0, or 1 value_t fl_compare(value_t a, value_t b); // -1, 0, or 1
value_t equal(value_t a, value_t b); // T or nil value_t fl_equal(value_t a, value_t b); // T or nil
int equal_lispvalue(value_t a, value_t b); int equal_lispvalue(value_t a, value_t b);
uptrint_t hash_lispvalue(value_t a); uptrint_t hash_lispvalue(value_t a);
int isnumtok_base(char *tok, value_t *pval, int base); int isnumtok_base(char *tok, value_t *pval, int base);

View File

@ -116,7 +116,7 @@ value_t fl_read(value_t *args, u_int32_t nargs)
} }
(void)toiostream(arg, "read"); (void)toiostream(arg, "read");
fl_gc_handle(&arg); fl_gc_handle(&arg);
value_t v = read_sexpr(arg); value_t v = fl_read_sexpr(arg);
fl_free_gc_handles(1); fl_free_gc_handles(1);
if (ios_eof(value2c(ios_t*,arg))) if (ios_eof(value2c(ios_t*,arg)))
return FL_EOF; return FL_EOF;
@ -216,7 +216,7 @@ value_t fl_write(value_t *args, u_int32_t nargs)
s = toiostream(args[1], "write"); s = toiostream(args[1], "write");
else else
s = toiostream(symbol_value(outstrsym), "write"); s = toiostream(symbol_value(outstrsym), "write");
print(s, args[0]); fl_print(s, args[0]);
return args[0]; return args[0];
} }

View File

@ -732,7 +732,7 @@ static void set_print_width()
SCR_WIDTH = numval(pw); SCR_WIDTH = numval(pw);
} }
void print(ios_t *f, value_t v) void fl_print(ios_t *f, value_t v)
{ {
print_pretty = (symbol_value(printprettysym) != FL_F); print_pretty = (symbol_value(printprettysym) != FL_F);
if (print_pretty) if (print_pretty)

View File

@ -611,8 +611,8 @@ static value_t do_read_sexpr(value_t label)
} }
v = symbol_value(sym); v = symbol_value(sym);
if (v == UNBOUND) if (v == UNBOUND)
fl_raise(list2(UnboundError, sym)); fl_raise(fl_list2(UnboundError, sym));
return apply(v, POP()); return fl_apply(v, POP());
case TOK_OPENB: case TOK_OPENB:
return read_vector(label, TOK_CLOSEB); return read_vector(label, TOK_CLOSEB);
case TOK_SHARPOPEN: case TOK_SHARPOPEN:
@ -627,10 +627,10 @@ static value_t do_read_sexpr(value_t label)
if (issymbol(sym)) { if (issymbol(sym)) {
v = symbol_value(sym); v = symbol_value(sym);
if (v == UNBOUND) if (v == UNBOUND)
fl_raise(list2(UnboundError, sym)); fl_raise(fl_list2(UnboundError, sym));
return v; return v;
} }
return toplevel_eval(sym); return fl_toplevel_eval(sym);
case TOK_LABEL: case TOK_LABEL:
// create backreference label // create backreference label
if (ptrhash_has(&readstate->backrefs, (void*)tokval)) if (ptrhash_has(&readstate->backrefs, (void*)tokval))
@ -656,7 +656,7 @@ static value_t do_read_sexpr(value_t label)
return FL_UNSPECIFIED; return FL_UNSPECIFIED;
} }
value_t read_sexpr(value_t f) value_t fl_read_sexpr(value_t f)
{ {
value_t v; value_t v;
readstate_t state; readstate_t state;

View File

@ -133,7 +133,7 @@ value_t fl_string(value_t *args, u_int32_t nargs)
set(printreadablysym, FL_F); set(printreadablysym, FL_F);
set(printprettysym, FL_F); set(printprettysym, FL_F);
FOR_ARGS(i,0,arg,args) { FOR_ARGS(i,0,arg,args) {
print(s, args[i]); fl_print(s, args[i]);
} }
set(printreadablysym, oldpr); set(printreadablysym, oldpr);
set(printprettysym, oldpp); set(printprettysym, oldpp);
@ -358,7 +358,7 @@ value_t fl_numbertostring(value_t *args, u_int32_t nargs)
else if (!iscprim(n)) type_error("number->string", "integer", n); else if (!iscprim(n)) type_error("number->string", "integer", n);
else num = conv_to_uint64(cp_data((cprim_t*)ptr(n)), else num = conv_to_uint64(cp_data((cprim_t*)ptr(n)),
cp_numtype((cprim_t*)ptr(n))); cp_numtype((cprim_t*)ptr(n)));
if (numval(compare(args[0],fixnum(0))) < 0) { if (numval(fl_compare(args[0],fixnum(0))) < 0) {
num = -num; num = -num;
neg = 1; neg = 1;
} }

View File

@ -127,7 +127,7 @@ value_t fl_table_put(value_t *args, uint32_t nargs)
static void key_error(char *fname, value_t key) static void key_error(char *fname, value_t key)
{ {
lerrorf(list2(KeyError, key), "%s: key not found", fname); lerrorf(fl_list2(KeyError, key), "%s: key not found", fname);
} }
// (get table key [default]) // (get table key [default])
@ -175,10 +175,10 @@ value_t fl_table_foldl(value_t *args, uint32_t nargs)
fl_gc_handle(&t); fl_gc_handle(&t);
for(i=0; i < n; i+=2) { for(i=0; i < n; i+=2) {
if (table[i+1] != HT_NOTFOUND) { if (table[i+1] != HT_NOTFOUND) {
zero = applyn(3, f, zero = fl_applyn(3, f,
(value_t)table[i], (value_t)table[i],
(value_t)table[i+1], (value_t)table[i+1],
zero); zero);
// reload pointer // reload pointer
h = (htable_t*)cv_data((cvalue_t*)ptr(t)); h = (htable_t*)cv_data((cvalue_t*)ptr(t));
if (h->size != n) if (h->size != n)

View File

@ -64,7 +64,7 @@ fltype_t *get_array_type(value_t eltype)
fltype_t *et = get_type(eltype); fltype_t *et = get_type(eltype);
if (et->artype != NULL) if (et->artype != NULL)
return et->artype; return et->artype;
return get_type(list2(arraysym, eltype)); return get_type(fl_list2(arraysym, eltype));
} }
fltype_t *define_opaque_type(value_t sym, size_t sz, cvtable_t *vtab, fltype_t *define_opaque_type(value_t sym, size_t sz, cvtable_t *vtab,