2008-06-30 21:54:22 -04:00
|
|
|
#ifndef _FLISP_H_
|
|
|
|
#define _FLISP_H_
|
|
|
|
|
|
|
|
typedef uptrint_t value_t;
|
|
|
|
typedef int_t fixnum_t;
|
|
|
|
#ifdef BITS64
|
|
|
|
#define T_FIXNUM T_INT64
|
|
|
|
#else
|
|
|
|
#define T_FIXNUM T_INT32
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
value_t car;
|
|
|
|
value_t cdr;
|
|
|
|
} cons_t;
|
|
|
|
|
|
|
|
typedef struct _symbol_t {
|
|
|
|
value_t syntax; // syntax environment entry
|
2008-10-30 22:50:00 -04:00
|
|
|
value_t binding; // global value binding
|
2008-12-10 23:04:17 -05:00
|
|
|
struct _fltype_t *type;
|
2008-11-23 02:12:37 -05:00
|
|
|
uint32_t hash;
|
2008-12-10 23:04:17 -05:00
|
|
|
void *dlcache; // dlsym address
|
2008-06-30 21:54:22 -04:00
|
|
|
// below fields are private
|
|
|
|
struct _symbol_t *left;
|
|
|
|
struct _symbol_t *right;
|
|
|
|
union {
|
|
|
|
char name[1];
|
|
|
|
void *_pad; // ensure field aligned to pointer size
|
|
|
|
};
|
|
|
|
} symbol_t;
|
|
|
|
|
|
|
|
#define TAG_NUM 0x0
|
2009-01-02 18:00:21 -05:00
|
|
|
#define TAG_CPRIM 0x1
|
2008-08-04 21:43:12 -04:00
|
|
|
#define TAG_BUILTIN 0x2
|
|
|
|
#define TAG_VECTOR 0x3
|
|
|
|
#define TAG_NUM1 0x4
|
|
|
|
#define TAG_CVALUE 0x5
|
|
|
|
#define TAG_SYM 0x6
|
|
|
|
#define TAG_CONS 0x7
|
|
|
|
#define UNBOUND ((value_t)0x1) // an invalid value
|
2008-10-30 22:50:00 -04:00
|
|
|
#define TAG_FWD UNBOUND
|
2008-06-30 21:54:22 -04:00
|
|
|
#define TAG_CONST ((value_t)-2) // in sym->syntax for constants
|
2008-08-04 21:43:12 -04:00
|
|
|
#define tag(x) ((x)&0x7)
|
|
|
|
#define ptr(x) ((void*)((x)&(~(value_t)0x7)))
|
2008-06-30 21:54:22 -04:00
|
|
|
#define tagptr(p,t) (((value_t)(p)) | (t))
|
2009-03-11 15:16:40 -04:00
|
|
|
#define fixnum(x) ((value_t)(((fixnum_t)(x))<<2))
|
2008-06-30 21:54:22 -04:00
|
|
|
#define numval(x) (((fixnum_t)(x))>>2)
|
2008-08-04 21:43:12 -04:00
|
|
|
#ifdef BITS64
|
|
|
|
#define fits_fixnum(x) (((x)>>61) == 0 || (~((x)>>61)) == 0)
|
|
|
|
#else
|
2008-06-30 21:54:22 -04:00
|
|
|
#define fits_fixnum(x) (((x)>>29) == 0 || (~((x)>>29)) == 0)
|
2008-08-04 21:43:12 -04:00
|
|
|
#endif
|
2008-06-30 21:54:22 -04:00
|
|
|
#define fits_bits(x,b) (((x)>>(b-1)) == 0 || (~((x)>>(b-1))) == 0)
|
2008-08-04 21:43:12 -04:00
|
|
|
#define uintval(x) (((unsigned int)(x))>>3)
|
|
|
|
#define builtin(n) tagptr((((int)n)<<3), TAG_BUILTIN)
|
2008-06-30 21:54:22 -04:00
|
|
|
#define iscons(x) (tag(x) == TAG_CONS)
|
|
|
|
#define issymbol(x) (tag(x) == TAG_SYM)
|
2008-08-04 21:43:12 -04:00
|
|
|
#define isfixnum(x) (((x)&3) == TAG_NUM)
|
|
|
|
#define bothfixnums(x,y) ((((x)|(y))&3) == TAG_NUM)
|
2008-06-30 21:54:22 -04:00
|
|
|
#define isbuiltin(x) ((tag(x) == TAG_BUILTIN) && uintval(x) < N_BUILTINS)
|
2008-08-04 21:43:12 -04:00
|
|
|
#define isbuiltinish(x) (tag(x) == TAG_BUILTIN)
|
|
|
|
#define isvector(x) (tag(x) == TAG_VECTOR)
|
|
|
|
#define iscvalue(x) (tag(x) == TAG_CVALUE)
|
2009-01-02 18:00:21 -05:00
|
|
|
#define iscprim(x) (tag(x) == TAG_CPRIM)
|
2008-09-06 18:19:51 -04:00
|
|
|
#define selfevaluating(x) (tag(x)<6)
|
2008-08-02 12:18:39 -04:00
|
|
|
// comparable with ==
|
2008-09-06 18:19:51 -04:00
|
|
|
#define eq_comparable(a,b) (!(((a)|(b))&1))
|
|
|
|
#define eq_comparablep(a) (!((a)&1))
|
2008-08-04 21:43:12 -04:00
|
|
|
// doesn't lead to other values
|
|
|
|
#define leafp(a) (((a)&3) != 3)
|
|
|
|
|
2008-10-30 22:50:00 -04:00
|
|
|
#define isforwarded(v) (((value_t*)ptr(v))[0] == TAG_FWD)
|
|
|
|
#define forwardloc(v) (((value_t*)ptr(v))[1])
|
|
|
|
#define forward(v,to) do { (((value_t*)ptr(v))[0] = TAG_FWD); \
|
|
|
|
(((value_t*)ptr(v))[1] = to); } while (0)
|
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
#define vector_size(v) (((size_t*)ptr(v))[0]>>2)
|
|
|
|
#define vector_setsize(v,n) (((size_t*)ptr(v))[0] = ((n)<<2))
|
|
|
|
#define vector_elt(v,i) (((value_t*)ptr(v))[1+(i)])
|
|
|
|
#define vector_grow_amt(x) ((x)<8 ? 4 : 6*((x)>>3))
|
|
|
|
// functions ending in _ are unsafe, faster versions
|
|
|
|
#define car_(v) (((cons_t*)ptr(v))->car)
|
|
|
|
#define cdr_(v) (((cons_t*)ptr(v))->cdr)
|
|
|
|
#define car(v) (tocons((v),"car")->car)
|
|
|
|
#define cdr(v) (tocons((v),"cdr")->cdr)
|
2008-10-30 22:50:00 -04:00
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
#define set(s, v) (((symbol_t*)ptr(s))->binding = (v))
|
|
|
|
#define setc(s, v) do { ((symbol_t*)ptr(s))->syntax = TAG_CONST; \
|
|
|
|
((symbol_t*)ptr(s))->binding = (v); } while (0)
|
|
|
|
#define isconstant(s) (((symbol_t*)ptr(s))->syntax == TAG_CONST)
|
|
|
|
#define symbol_value(s) (((symbol_t*)ptr(s))->binding)
|
|
|
|
#define ismanaged(v) ((((unsigned char*)ptr(v)) >= fromspace) && \
|
|
|
|
(((unsigned char*)ptr(v)) < fromspace+heapsize))
|
2008-09-06 18:19:51 -04:00
|
|
|
#define isgensym(x) (issymbol(x) && ismanaged(x))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
2009-04-01 00:31:49 -04:00
|
|
|
extern value_t *Stack;
|
2008-11-23 02:12:37 -05:00
|
|
|
extern uint32_t SP;
|
2008-06-30 21:54:22 -04:00
|
|
|
#define PUSH(v) (Stack[SP++] = (v))
|
|
|
|
#define POP() (Stack[--SP])
|
|
|
|
#define POPN(n) (SP-=(n))
|
|
|
|
|
2009-03-26 23:06:55 -04:00
|
|
|
// maximum number of explicit arguments. the 128th arg is a list of rest args.
|
|
|
|
// the largest value nargs can have is MAX_ARGS+1
|
|
|
|
#define MAX_ARGS 127
|
|
|
|
|
|
|
|
// utility for iterating over all arguments in a builtin
|
|
|
|
// i=index, i0=start index, arg = var for each arg, args = arg array
|
|
|
|
// assumes "nargs" is the argument count
|
|
|
|
// modifies args[MAX_ARGS] when nargs==MAX_ARGS+1
|
|
|
|
#define FOR_ARGS(i, i0, arg, args) \
|
|
|
|
for(i=i0; (((size_t)i<nargs || \
|
|
|
|
(i>MAX_ARGS && iscons(args[MAX_ARGS]))) && \
|
|
|
|
((i>=MAX_ARGS?(arg=car_(args[MAX_ARGS]), \
|
|
|
|
args[MAX_ARGS]=cdr_(args[MAX_ARGS])) : \
|
|
|
|
(arg = args[i])) || 1)); i++)
|
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
enum {
|
|
|
|
// special forms
|
2008-07-14 21:20:52 -04:00
|
|
|
F_QUOTE=0, F_COND, F_IF, F_AND, F_OR, F_WHILE, F_LAMBDA,
|
2009-03-24 22:28:21 -04:00
|
|
|
F_TRYCATCH, F_SPECIAL_APPLY, F_SETQ, F_PROG1, F_BEGIN,
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
// functions
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
F_EQ, F_EQV, F_EQUAL, F_ATOM, F_NOT, F_NULL, F_BOOLEANP, F_SYMBOLP,
|
|
|
|
F_NUMBERP, F_BOUNDP, F_CONSP, F_BUILTINP, F_VECTORP, F_FIXNUMP,
|
|
|
|
|
|
|
|
F_CONS, F_LIST, F_CAR, F_CDR, F_SETCAR, F_SETCDR,
|
2009-03-24 22:28:21 -04:00
|
|
|
F_EVAL, F_EVALSTAR, F_APPLY,
|
|
|
|
F_ADD, F_SUB, F_MUL, F_DIV, F_LT, F_BNOT, F_COMPARE,
|
|
|
|
|
2009-03-16 23:29:17 -04:00
|
|
|
F_VECTOR, F_AREF, F_ASET, F_LENGTH, F_FOR,
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
F_TRUE, F_FALSE, F_NIL,
|
|
|
|
N_BUILTINS,
|
2008-06-30 21:54:22 -04:00
|
|
|
};
|
2009-03-11 22:47:34 -04:00
|
|
|
#define isspecial(v) (uintval(v) <= (unsigned int)F_BEGIN)
|
2008-06-30 21:54:22 -04:00
|
|
|
|
switching to scheme #t, #f, and () values
porting code to sort out which NILs are false and which are
empty lists
switching to scheme-style special forms. however you feel about
scheme names vs. CL names, using both is silly.
mostly switching to scheme predicate names, with compatibility
aliases for now. adding set-constant! to make this efficient.
adding null?, eqv?, assq, assv, assoc, memq, memv, member
adding 2-argument form of if
allowing else as final cond condition
looking for init file in same directory as executable, so flisp
can be started from anywhere
renaming T to FL_T, since exporting a 1-character symbol is
not very nice
adding opaque type boilerplate example file
adding correctness checking for the pattern-lambda benchmark
bugfix in int2str
2009-01-28 20:04:23 -05:00
|
|
|
extern value_t NIL, FL_T, FL_F;
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
/* read, eval, print main entry points */
|
2009-02-23 21:21:16 -05:00
|
|
|
value_t read_sexpr(value_t f);
|
2008-08-17 14:16:31 -04:00
|
|
|
void print(ios_t *f, value_t v, int princ);
|
2008-06-30 21:54:22 -04:00
|
|
|
value_t toplevel_eval(value_t expr);
|
|
|
|
value_t apply(value_t f, value_t l);
|
2009-03-13 18:26:44 -04:00
|
|
|
value_t apply1(value_t f, value_t a0);
|
2008-06-30 21:54:22 -04:00
|
|
|
value_t load_file(char *fname);
|
|
|
|
|
|
|
|
/* object model manipulation */
|
|
|
|
value_t fl_cons(value_t a, value_t b);
|
|
|
|
value_t list2(value_t a, value_t b);
|
|
|
|
value_t listn(size_t n, ...);
|
|
|
|
value_t symbol(char *str);
|
|
|
|
value_t fl_gensym();
|
|
|
|
char *symbol_name(value_t v);
|
|
|
|
value_t alloc_vector(size_t n, int init);
|
|
|
|
size_t llength(value_t v);
|
2008-08-30 18:18:20 -04:00
|
|
|
value_t compare(value_t a, value_t b); // -1, 0, or 1
|
|
|
|
value_t equal(value_t a, value_t b); // T or nil
|
2008-11-28 16:44:59 -05:00
|
|
|
int equal_lispvalue(value_t a, value_t b);
|
|
|
|
uptrint_t hash_lispvalue(value_t a);
|
2009-03-23 15:49:08 -04:00
|
|
|
int isnumtok_base(char *tok, value_t *pval, int base);
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
/* safe casts */
|
|
|
|
cons_t *tocons(value_t v, char *fname);
|
|
|
|
symbol_t *tosymbol(value_t v, char *fname);
|
|
|
|
fixnum_t tofixnum(value_t v, char *fname);
|
|
|
|
char *tostring(value_t v, char *fname);
|
|
|
|
|
|
|
|
/* error handling */
|
2009-03-24 22:28:21 -04:00
|
|
|
void lerrorf(value_t e, char *format, ...) __attribute__ ((__noreturn__));
|
|
|
|
void lerror(value_t e, const char *msg) __attribute__ ((__noreturn__));
|
2008-06-30 21:54:22 -04:00
|
|
|
void raise(value_t e) __attribute__ ((__noreturn__));
|
|
|
|
void type_error(char *fname, char *expected, value_t got) __attribute__ ((__noreturn__));
|
|
|
|
void bounds_error(char *fname, value_t arr, value_t ind) __attribute__ ((__noreturn__));
|
2009-03-21 22:05:26 -04:00
|
|
|
extern value_t ArgError, IOError, KeyError, MemoryError, EnumerationError;
|
2009-01-16 09:12:35 -05:00
|
|
|
static inline void argcount(char *fname, uint32_t nargs, uint32_t c)
|
2008-06-30 21:54:22 -04:00
|
|
|
{
|
2008-12-28 03:01:18 -05:00
|
|
|
if (__unlikely(nargs != c))
|
2009-03-24 22:28:21 -04:00
|
|
|
lerrorf(ArgError,"%s: too %s arguments", fname, nargs<c ? "few":"many");
|
2008-06-30 21:54:22 -04:00
|
|
|
}
|
|
|
|
|
2008-09-06 18:19:51 -04:00
|
|
|
typedef struct {
|
2008-10-30 22:50:00 -04:00
|
|
|
void (*print)(value_t self, ios_t *f, int princ);
|
2008-11-28 16:44:59 -05:00
|
|
|
void (*relocate)(value_t oldv, value_t newv);
|
2008-09-06 18:19:51 -04:00
|
|
|
void (*finalize)(value_t self);
|
|
|
|
void (*print_traverse)(value_t self);
|
|
|
|
} cvtable_t;
|
|
|
|
|
2008-12-20 01:16:00 -05:00
|
|
|
/* functions needed to implement the value interface (cvtable_t) */
|
|
|
|
value_t relocate_lispvalue(value_t v);
|
|
|
|
void print_traverse(value_t v);
|
|
|
|
void fl_print_chr(char c, ios_t *f);
|
|
|
|
void fl_print_str(char *s, ios_t *f);
|
|
|
|
void fl_print_child(ios_t *f, value_t v, int princ);
|
|
|
|
|
2009-03-04 22:48:17 -05:00
|
|
|
typedef int (*cvinitfunc_t)(struct _fltype_t*, value_t, void*);
|
2008-12-10 23:04:17 -05:00
|
|
|
|
|
|
|
typedef struct _fltype_t {
|
|
|
|
value_t type;
|
|
|
|
numerictype_t numtype;
|
|
|
|
size_t size;
|
|
|
|
size_t elsz;
|
|
|
|
cvtable_t *vtable;
|
|
|
|
struct _fltype_t *eltype; // for arrays
|
|
|
|
struct _fltype_t *artype; // (array this)
|
|
|
|
int marked;
|
|
|
|
cvinitfunc_t init;
|
|
|
|
} fltype_t;
|
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
typedef struct {
|
2008-12-10 23:04:17 -05:00
|
|
|
fltype_t *type;
|
|
|
|
void *data;
|
|
|
|
size_t len; // length of *data in bytes
|
2008-06-30 21:54:22 -04:00
|
|
|
union {
|
2008-12-10 23:04:17 -05:00
|
|
|
value_t parent; // optional
|
|
|
|
char _space[1]; // variable size
|
2008-06-30 21:54:22 -04:00
|
|
|
};
|
|
|
|
} cvalue_t;
|
|
|
|
|
2008-12-10 23:04:17 -05:00
|
|
|
#define CVALUE_NWORDS 4
|
2008-09-06 18:19:51 -04:00
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
typedef struct {
|
2008-12-10 23:04:17 -05:00
|
|
|
fltype_t *type;
|
|
|
|
char _space[1];
|
2008-06-30 21:54:22 -04:00
|
|
|
} cprim_t;
|
|
|
|
|
2008-12-10 23:04:17 -05:00
|
|
|
#define CPRIM_NWORDS 2
|
2008-12-27 01:02:53 -05:00
|
|
|
#define MAX_INL_SIZE 96
|
2008-09-06 18:19:51 -04:00
|
|
|
|
2008-12-10 23:04:17 -05:00
|
|
|
#define CV_OWNED_BIT 0x1
|
|
|
|
#define CV_PARENT_BIT 0x2
|
2008-12-20 01:16:00 -05:00
|
|
|
#define owned(cv) ((uptrint_t)(cv)->type & CV_OWNED_BIT)
|
|
|
|
#define hasparent(cv) ((uptrint_t)(cv)->type & CV_PARENT_BIT)
|
2008-12-10 23:04:17 -05:00
|
|
|
#define isinlined(cv) ((cv)->data == &(cv)->_space[0])
|
|
|
|
#define cv_class(cv) ((fltype_t*)(((uptrint_t)(cv)->type)&~3))
|
|
|
|
#define cv_len(cv) ((cv)->len)
|
|
|
|
#define cv_type(cv) (cv_class(cv)->type)
|
|
|
|
#define cv_data(cv) ((cv)->data)
|
2008-12-23 23:43:36 -05:00
|
|
|
#define cv_isstr(cv) (cv_class(cv)->eltype == bytetype)
|
2008-12-10 23:04:17 -05:00
|
|
|
|
|
|
|
#define cvalue_data(v) cv_data((cvalue_t*)ptr(v))
|
2009-03-01 23:26:16 -05:00
|
|
|
#define value2c(type, v) ((type)cv_data((cvalue_t*)ptr(v)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
#define valid_numtype(v) ((v) < N_NUMTYPES)
|
2009-01-02 18:00:21 -05:00
|
|
|
#define cp_class(cp) ((cp)->type)
|
|
|
|
#define cp_type(cp) (cp_class(cp)->type)
|
|
|
|
#define cp_numtype(cp) (cp_class(cp)->numtype)
|
|
|
|
#define cp_data(cp) (&(cp)->_space[0])
|
|
|
|
|
|
|
|
// WARNING: multiple evaluation!
|
|
|
|
#define cptr(v) \
|
|
|
|
(iscprim(v) ? cp_data((cprim_t*)ptr(v)) : cv_data((cvalue_t*)ptr(v)))
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
/* C type names corresponding to cvalues type names */
|
|
|
|
typedef unsigned long ulong;
|
|
|
|
typedef unsigned int uint;
|
|
|
|
typedef unsigned char uchar;
|
|
|
|
typedef char char_t;
|
|
|
|
typedef long long_t;
|
|
|
|
typedef unsigned long ulong_t;
|
|
|
|
typedef double double_t;
|
|
|
|
typedef float float_t;
|
|
|
|
|
2008-12-10 23:04:17 -05:00
|
|
|
typedef value_t (*builtin_t)(value_t*, uint32_t);
|
2008-06-30 21:54:22 -04:00
|
|
|
|
|
|
|
extern value_t int8sym, uint8sym, int16sym, uint16sym, int32sym, uint32sym;
|
2008-12-10 23:04:17 -05:00
|
|
|
extern value_t int64sym, uint64sym;
|
2008-12-23 23:43:36 -05:00
|
|
|
extern value_t longsym, ulongsym, bytesym, wcharsym;
|
2008-06-30 21:54:22 -04:00
|
|
|
extern value_t structsym, arraysym, enumsym, cfunctionsym, voidsym, pointersym;
|
|
|
|
extern value_t stringtypesym, wcstringtypesym, emptystringsym;
|
2008-12-10 23:04:17 -05:00
|
|
|
extern value_t unionsym, floatsym, doublesym, builtinsym;
|
2008-12-23 23:43:36 -05:00
|
|
|
extern fltype_t *bytetype, *wchartype;
|
2008-12-10 23:04:17 -05:00
|
|
|
extern fltype_t *stringtype, *wcstringtype;
|
2008-12-20 01:16:00 -05:00
|
|
|
extern fltype_t *builtintype;
|
2008-06-30 21:54:22 -04:00
|
|
|
|
2008-12-10 23:04:17 -05:00
|
|
|
value_t cvalue(fltype_t *type, size_t sz);
|
2008-12-22 01:36:50 -05:00
|
|
|
void add_finalizer(cvalue_t *cv);
|
2008-12-27 01:02:53 -05:00
|
|
|
void cv_autorelease(cvalue_t *cv);
|
2008-06-30 21:54:22 -04:00
|
|
|
size_t ctype_sizeof(value_t type, int *palign);
|
|
|
|
value_t cvalue_copy(value_t v);
|
2008-12-10 23:04:17 -05:00
|
|
|
value_t cvalue_from_data(fltype_t *type, void *data, size_t sz);
|
|
|
|
value_t cvalue_from_ref(fltype_t *type, void *ptr, size_t sz, value_t parent);
|
2008-12-21 00:55:00 -05:00
|
|
|
value_t cbuiltin(char *name, builtin_t f);
|
2008-06-30 21:54:22 -04:00
|
|
|
size_t cvalue_arraylen(value_t v);
|
|
|
|
value_t size_wrap(size_t sz);
|
|
|
|
size_t toulong(value_t n, char *fname);
|
|
|
|
value_t cvalue_string(size_t sz);
|
2009-03-24 22:28:21 -04:00
|
|
|
value_t cvalue_static_cstring(const char *str);
|
2008-09-10 22:37:38 -04:00
|
|
|
value_t string_from_cstr(char *str);
|
2009-03-04 22:48:17 -05:00
|
|
|
value_t string_from_cstrn(char *str, size_t n);
|
2008-06-30 21:54:22 -04:00
|
|
|
int isstring(value_t v);
|
|
|
|
int isnumber(value_t v);
|
2009-03-04 22:48:17 -05:00
|
|
|
int isiostream(value_t v);
|
2008-06-30 21:54:22 -04:00
|
|
|
value_t cvalue_compare(value_t a, value_t b);
|
|
|
|
|
2009-03-04 22:48:17 -05:00
|
|
|
void to_sized_ptr(value_t v, char *fname, char **pdata, size_t *psz);
|
|
|
|
|
2008-12-10 23:04:17 -05:00
|
|
|
fltype_t *get_type(value_t t);
|
|
|
|
fltype_t *get_array_type(value_t eltype);
|
|
|
|
fltype_t *define_opaque_type(value_t sym, size_t sz, cvtable_t *vtab,
|
|
|
|
cvinitfunc_t init);
|
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
value_t mk_double(double_t n);
|
2008-08-16 17:15:36 -04:00
|
|
|
value_t mk_float(float_t n);
|
2008-06-30 21:54:22 -04:00
|
|
|
value_t mk_uint32(uint32_t n);
|
|
|
|
value_t mk_uint64(uint64_t n);
|
2008-12-23 23:43:36 -05:00
|
|
|
value_t mk_wchar(int32_t n);
|
2008-06-30 21:54:22 -04:00
|
|
|
value_t return_from_uint64(uint64_t Uaccum);
|
|
|
|
value_t return_from_int64(int64_t Saccum);
|
|
|
|
|
2008-11-23 02:12:37 -05:00
|
|
|
typedef struct {
|
|
|
|
char *name;
|
2008-12-10 23:04:17 -05:00
|
|
|
builtin_t fptr;
|
2008-11-23 02:12:37 -05:00
|
|
|
} builtinspec_t;
|
|
|
|
|
|
|
|
void assign_global_builtins(builtinspec_t *b);
|
|
|
|
|
2008-12-20 01:16:00 -05:00
|
|
|
/* builtins */
|
|
|
|
value_t fl_hash(value_t *args, u_int32_t nargs);
|
2008-12-23 23:43:36 -05:00
|
|
|
value_t cvalue_byte(value_t *args, uint32_t nargs);
|
2008-12-20 01:16:00 -05:00
|
|
|
value_t cvalue_wchar(value_t *args, uint32_t nargs);
|
|
|
|
|
2008-06-30 21:54:22 -04:00
|
|
|
#endif
|