mirror of
https://github.com/janet-lang/janet
synced 2025-10-29 22:53:03 +00:00
Rename DstValue to Dst for easier access. Move vector.c into
util.c and make public API smaller. Pad strings and symbols with extra 0 byte for better interop with C.
This commit is contained in:
@@ -38,9 +38,9 @@ DstArray *dst_array_init(DstArray *array, int32_t capacity);
|
||||
void dst_array_deinit(DstArray *array);
|
||||
void dst_array_ensure(DstArray *array, int32_t capacity);
|
||||
void dst_array_setcount(DstArray *array, int32_t count);
|
||||
void dst_array_push(DstArray *array, DstValue x);
|
||||
DstValue dst_array_pop(DstArray *array);
|
||||
DstValue dst_array_peek(DstArray *array);
|
||||
void dst_array_push(DstArray *array, Dst x);
|
||||
Dst dst_array_pop(DstArray *array);
|
||||
Dst dst_array_peek(DstArray *array);
|
||||
|
||||
/* Buffer functions */
|
||||
DstBuffer *dst_buffer(int32_t capacity);
|
||||
@@ -59,11 +59,11 @@ void dst_buffer_push_u64(DstBuffer *buffer, uint64_t x);
|
||||
#define dst_tuple_raw(t) ((int32_t *)(t) - 2)
|
||||
#define dst_tuple_length(t) (dst_tuple_raw(t)[0])
|
||||
#define dst_tuple_hash(t) ((dst_tuple_raw(t)[1]))
|
||||
DstValue *dst_tuple_begin(int32_t length);
|
||||
const DstValue *dst_tuple_end(DstValue *tuple);
|
||||
const DstValue *dst_tuple_n(DstValue *values, int32_t n);
|
||||
int dst_tuple_equal(const DstValue *lhs, const DstValue *rhs);
|
||||
int dst_tuple_compare(const DstValue *lhs, const DstValue *rhs);
|
||||
Dst *dst_tuple_begin(int32_t length);
|
||||
const Dst *dst_tuple_end(Dst *tuple);
|
||||
const Dst *dst_tuple_n(Dst *values, int32_t n);
|
||||
int dst_tuple_equal(const Dst *lhs, const Dst *rhs);
|
||||
int dst_tuple_compare(const Dst *lhs, const Dst *rhs);
|
||||
|
||||
/* String/Symbol functions */
|
||||
#define dst_string_raw(s) ((int32_t *)(s) - 2)
|
||||
@@ -78,9 +78,10 @@ int dst_string_equal(const uint8_t *lhs, const uint8_t *rhs);
|
||||
int dst_string_equalconst(const uint8_t *lhs, const uint8_t *rhs, int32_t rlen, int32_t rhash);
|
||||
const uint8_t *dst_string_unique(const uint8_t *buf, int32_t len);
|
||||
const uint8_t *dst_cstring_unique(const char *s);
|
||||
const uint8_t *dst_description(DstValue x);
|
||||
const uint8_t *dst_short_description(DstValue x);
|
||||
const uint8_t *dst_to_string(DstValue x);
|
||||
const uint8_t *dst_description(Dst x);
|
||||
const uint8_t *dst_short_description(Dst x);
|
||||
const uint8_t *dst_to_string(Dst x);
|
||||
const char *dst_to_zerostring(Dst x);
|
||||
#define dst_cstringv(cstr) dst_wrap_string(dst_cstring(cstr))
|
||||
#define dst_stringv(str, len) dst_wrap_string(dst_string((str), (len)))
|
||||
const uint8_t *dst_formatc(const char *format, ...);
|
||||
@@ -101,9 +102,9 @@ const uint8_t *dst_symbol_gen(const uint8_t *buf, int32_t len);
|
||||
#define dst_struct_hash(t) (dst_struct_raw(t)[2])
|
||||
/* Do something with the 4th header slot - flags? */
|
||||
DstKV *dst_struct_begin(int32_t count);
|
||||
void dst_struct_put(DstKV *st, DstValue key, DstValue value);
|
||||
void dst_struct_put(DstKV *st, Dst key, Dst value);
|
||||
const DstKV *dst_struct_end(DstKV *st);
|
||||
DstValue dst_struct_get(const DstKV *st, DstValue key);
|
||||
Dst dst_struct_get(const DstKV *st, Dst key);
|
||||
const DstKV *dst_struct_next(const DstKV *st, const DstKV *kv);
|
||||
DstTable *dst_struct_to_table(const DstKV *st);
|
||||
int dst_struct_equal(const DstKV *lhs, const DstKV *rhs);
|
||||
@@ -113,12 +114,12 @@ int dst_struct_compare(const DstKV *lhs, const DstKV *rhs);
|
||||
DstTable *dst_table(int32_t capacity);
|
||||
DstTable *dst_table_init(DstTable *table, int32_t capacity);
|
||||
void dst_table_deinit(DstTable *table);
|
||||
DstValue dst_table_get(DstTable *t, DstValue key);
|
||||
DstValue dst_table_remove(DstTable *t, DstValue key);
|
||||
void dst_table_put(DstTable *t, DstValue key, DstValue value);
|
||||
Dst dst_table_get(DstTable *t, Dst key);
|
||||
Dst dst_table_remove(DstTable *t, Dst key);
|
||||
void dst_table_put(DstTable *t, Dst key, Dst value);
|
||||
const DstKV *dst_table_next(DstTable *t, const DstKV *kv);
|
||||
const DstKV *dst_table_to_struct(DstTable *t);
|
||||
void dst_table_merge(DstTable *t, DstValue other);
|
||||
void dst_table_merge(DstTable *t, Dst other);
|
||||
|
||||
/* Fiber */
|
||||
DstFiber *dst_fiber(int32_t capacity);
|
||||
@@ -126,10 +127,10 @@ DstFiber *dst_fiber(int32_t capacity);
|
||||
#define dst_fiber_frame(f) dst_stack_frame((f)->data + (f)->frame)
|
||||
DstFiber *dst_fiber_reset(DstFiber *fiber);
|
||||
void dst_fiber_setcapacity(DstFiber *fiber, int32_t n);
|
||||
void dst_fiber_push(DstFiber *fiber, DstValue x);
|
||||
void dst_fiber_push2(DstFiber *fiber, DstValue x, DstValue y);
|
||||
void dst_fiber_push3(DstFiber *fiber, DstValue x, DstValue y, DstValue z);
|
||||
void dst_fiber_pushn(DstFiber *fiber, const DstValue *arr, int32_t n);
|
||||
void dst_fiber_push(DstFiber *fiber, Dst x);
|
||||
void dst_fiber_push2(DstFiber *fiber, Dst x, Dst y);
|
||||
void dst_fiber_push3(DstFiber *fiber, Dst x, Dst y, Dst z);
|
||||
void dst_fiber_pushn(DstFiber *fiber, const Dst *arr, int32_t n);
|
||||
void dst_fiber_funcframe(DstFiber *fiber, DstFunction *func);
|
||||
void dst_fiber_funcframe_tail(DstFiber *fiber, DstFunction *func);
|
||||
void dst_fiber_cframe(DstFiber *fiber);
|
||||
@@ -138,13 +139,13 @@ void dst_fiber_popframe(DstFiber *fiber);
|
||||
/* Assembly */
|
||||
DstAssembleResult dst_asm(DstAssembleOptions opts);
|
||||
DstFunction *dst_asm_func(DstAssembleResult result);
|
||||
DstValue dst_disasm(DstFuncDef *def);
|
||||
DstValue dst_asm_decode_instruction(uint32_t instr);
|
||||
Dst dst_disasm(DstFuncDef *def);
|
||||
Dst dst_asm_decode_instruction(uint32_t instr);
|
||||
|
||||
/* Treat similar types through uniform interfaces for iteration */
|
||||
int dst_seq_view(DstValue seq, const DstValue **data, int32_t *len);
|
||||
int dst_chararray_view(DstValue str, const uint8_t **data, int32_t *len);
|
||||
int dst_hashtable_view(DstValue tab, const DstKV **data, int32_t *len, int32_t *cap);
|
||||
int dst_seq_view(Dst seq, const Dst **data, int32_t *len);
|
||||
int dst_chararray_view(Dst str, const uint8_t **data, int32_t *len);
|
||||
int dst_hashtable_view(Dst tab, const DstKV **data, int32_t *len, int32_t *cap);
|
||||
|
||||
/* Abstract */
|
||||
#define dst_abstract_header(u) ((DstAbstractHeader *)(u) - 1)
|
||||
@@ -152,33 +153,16 @@ int dst_hashtable_view(DstValue tab, const DstKV **data, int32_t *len, int32_t *
|
||||
#define dst_abstract_size(u) (dst_abstract_header(u)->size)
|
||||
|
||||
/* Value functions */
|
||||
int dst_equals(DstValue x, DstValue y);
|
||||
int32_t dst_hash(DstValue x);
|
||||
int dst_compare(DstValue x, DstValue y);
|
||||
DstValue dst_get(DstValue ds, DstValue key);
|
||||
void dst_put(DstValue ds, DstValue key, DstValue value);
|
||||
const DstKV *dst_next(DstValue ds, const DstKV *kv);
|
||||
int32_t dst_length(DstValue x);
|
||||
int32_t dst_capacity(DstValue x);
|
||||
DstValue dst_getindex(DstValue ds, int32_t index);
|
||||
void dst_setindex(DstValue ds, DstValue value, int32_t index);
|
||||
|
||||
/* Utils */
|
||||
extern const char dst_base64[65];
|
||||
int32_t dst_array_calchash(const DstValue *array, int32_t len);
|
||||
int32_t dst_kv_calchash(const DstKV *kvs, int32_t len);
|
||||
int32_t dst_string_calchash(const uint8_t *str, int32_t len);
|
||||
int32_t dst_tablen(int32_t n);
|
||||
DstValue dst_loadreg(DstReg *regs, size_t count);
|
||||
DstValue dst_scan_number(const uint8_t *src, int32_t len);
|
||||
int32_t dst_scan_integer(const uint8_t *str, int32_t len, int *err);
|
||||
double dst_scan_real(const uint8_t *str, int32_t len, int *err);
|
||||
int dst_cstrcmp(const uint8_t *str, const char *other);
|
||||
const void *dst_strbinsearch(
|
||||
const void *tab,
|
||||
size_t tabcount,
|
||||
size_t itemsize,
|
||||
const uint8_t *key);
|
||||
int dst_equals(Dst x, Dst y);
|
||||
int32_t dst_hash(Dst x);
|
||||
int dst_compare(Dst x, Dst y);
|
||||
Dst dst_get(Dst ds, Dst key);
|
||||
void dst_put(Dst ds, Dst key, Dst value);
|
||||
const DstKV *dst_next(Dst ds, const DstKV *kv);
|
||||
int32_t dst_length(Dst x);
|
||||
int32_t dst_capacity(Dst x);
|
||||
Dst dst_getindex(Dst ds, int32_t index);
|
||||
void dst_setindex(Dst ds, Dst value, int32_t index);
|
||||
|
||||
/* Parsing */
|
||||
DstParseResult dst_parse(const uint8_t *src, int32_t len);
|
||||
@@ -187,7 +171,13 @@ DstParseResult dst_parsec(const char *src);
|
||||
/* VM functions */
|
||||
int dst_init();
|
||||
void dst_deinit();
|
||||
int dst_run(DstValue callee, DstValue *returnreg);
|
||||
int dst_run(Dst callee, Dst *returnreg);
|
||||
|
||||
/* Misc */
|
||||
Dst dst_loadreg(DstReg *regs, size_t count);
|
||||
Dst dst_scan_number(const uint8_t *src, int32_t len);
|
||||
int32_t dst_scan_integer(const uint8_t *str, int32_t len, int *err);
|
||||
double dst_scan_real(const uint8_t *str, int32_t len, int *err);
|
||||
|
||||
/* Compile */
|
||||
DstCompileResult dst_compile(DstCompileOptions opts);
|
||||
@@ -195,16 +185,16 @@ DstFunction *dst_compile_func(DstCompileResult result);
|
||||
|
||||
/* STL */
|
||||
#define DST_LOAD_ROOT 1
|
||||
DstValue dst_loadstl(int flags);
|
||||
Dst dst_loadstl(int flags);
|
||||
|
||||
/* GC */
|
||||
void dst_mark(DstValue x);
|
||||
void dst_mark(Dst x);
|
||||
void dst_sweep();
|
||||
void dst_collect();
|
||||
void dst_clear_memory();
|
||||
void dst_gcroot(DstValue root);
|
||||
int dst_gcunroot(DstValue root);
|
||||
int dst_gcunrootall(DstValue root);
|
||||
void dst_gcroot(Dst root);
|
||||
int dst_gcunroot(Dst root);
|
||||
int dst_gcunrootall(Dst root);
|
||||
#define dst_maybe_collect() do {\
|
||||
if (dst_vm_next_collection >= dst_vm_gc_interval) dst_collect(); } while (0)
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ extern uint32_t dst_vm_cache_count;
|
||||
extern uint32_t dst_vm_cache_deleted;
|
||||
|
||||
/* GC roots */
|
||||
extern DstValue *dst_vm_roots;
|
||||
extern Dst *dst_vm_roots;
|
||||
extern uint32_t dst_vm_root_count;
|
||||
extern uint32_t dst_vm_root_capacity;
|
||||
|
||||
|
||||
@@ -25,41 +25,47 @@
|
||||
|
||||
#include "dsttypes.h"
|
||||
|
||||
int dst_add(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_subtract(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_multiply(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_divide(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_modulo(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
/* File type definition */
|
||||
extern DstAbstractType dst_stl_filetype;
|
||||
|
||||
int dst_acos(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_asin(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_atan(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_cos(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_cosh(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_sin(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_sinh(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_tan(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_tanh(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_exp(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_log(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_log10(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_sqrt(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_ceil(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_fabs(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_floor(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_pow(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_int(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_real(int32_t argn, Dst *argv, Dst *ret);
|
||||
|
||||
int dst_stl_table(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_stl_array(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_stl_struct(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_stl_tuple(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_add(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_subtract(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_multiply(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_divide(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_modulo(int32_t argn, Dst *argv, Dst *ret);
|
||||
|
||||
int dst_band(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_bor(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_bxor(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
int dst_acos(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_asin(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_atan(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_cos(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_cosh(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_sin(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_sinh(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_tan(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_tanh(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_exp(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_log(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_log10(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_sqrt(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_ceil(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_fabs(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_floor(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_pow(int32_t argn, Dst *argv, Dst *ret);
|
||||
|
||||
int dst_lshift(int argn, DstValue *argv, DstValue *ret);
|
||||
int dst_rshift(int argn, DstValue *argv, DstValue *ret);
|
||||
int dst_lshiftu(int argn, DstValue *argv, DstValue *ret);
|
||||
int dst_stl_table(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_stl_array(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_stl_struct(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_stl_tuple(int32_t argn, Dst *argv, Dst *ret);
|
||||
|
||||
int dst_band(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_bor(int32_t argn, Dst *argv, Dst *ret);
|
||||
int dst_bxor(int32_t argn, Dst *argv, Dst *ret);
|
||||
|
||||
int dst_lshift(int argn, Dst *argv, Dst *ret);
|
||||
int dst_rshift(int argn, Dst *argv, Dst *ret);
|
||||
int dst_lshiftu(int argn, Dst *argv, Dst *ret);
|
||||
|
||||
#endif /* DST_MATH_H_defined */
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#include "dstconfig.h"
|
||||
|
||||
#ifdef DST_NANBOX
|
||||
typedef union DstValue DstValue;
|
||||
typedef union Dst Dst;
|
||||
#else
|
||||
typedef struct DstValue DstValue;
|
||||
typedef struct Dst Dst;
|
||||
#endif
|
||||
|
||||
/* All of the dst types */
|
||||
@@ -47,7 +47,7 @@ typedef struct DstFuncEnv DstFuncEnv;
|
||||
typedef struct DstKV DstKV;
|
||||
typedef struct DstStackFrame DstStackFrame;
|
||||
typedef struct DstAbstractType DstAbstractType;
|
||||
typedef int (*DstCFunction)(int32_t argn, DstValue *argv, DstValue *ret);
|
||||
typedef int (*DstCFunction)(int32_t argn, Dst *argv, Dst *ret);
|
||||
|
||||
typedef enum DstAssembleStatus DstAssembleStatus;
|
||||
typedef struct DstAssembleResult DstAssembleResult;
|
||||
@@ -78,11 +78,11 @@ typedef enum DstType {
|
||||
DST_ABSTRACT
|
||||
} DstType;
|
||||
|
||||
/* We provide two possible implemenations of DstValues. The preferred
|
||||
/* We provide two possible implemenations of Dsts. The preferred
|
||||
* nanboxing approach, and the standard C version. Code in the rest of the
|
||||
* application must interact through exposed interface. */
|
||||
|
||||
/* Required interface for DstValue */
|
||||
/* Required interface for Dst */
|
||||
/* wrap and unwrap for all types */
|
||||
/* Get type quickly */
|
||||
/* Check against type quickly */
|
||||
@@ -102,7 +102,7 @@ typedef enum DstType {
|
||||
|
||||
#include <math.h>
|
||||
|
||||
union DstValue {
|
||||
union Dst {
|
||||
uint64_t u64;
|
||||
int64_t i64;
|
||||
void *pointer;
|
||||
@@ -177,13 +177,13 @@ union DstValue {
|
||||
? dst_nanbox_isreal(x) \
|
||||
: dst_nanbox_checkauxtype((x), (t)))
|
||||
|
||||
void *dst_nanbox_to_pointer(DstValue x);
|
||||
void *dst_nanbox_to_pointer(Dst x);
|
||||
void dst_nanbox_memempty(DstKV *mem, int32_t count);
|
||||
void *dst_nanbox_memalloc_empty(int32_t count);
|
||||
DstValue dst_nanbox_from_pointer(void *p, uint64_t tagmask);
|
||||
DstValue dst_nanbox_from_cpointer(const void *p, uint64_t tagmask);
|
||||
DstValue dst_nanbox_from_double(double d);
|
||||
DstValue dst_nanbox_from_bits(uint64_t bits);
|
||||
Dst dst_nanbox_from_pointer(void *p, uint64_t tagmask);
|
||||
Dst dst_nanbox_from_cpointer(const void *p, uint64_t tagmask);
|
||||
Dst dst_nanbox_from_double(double d);
|
||||
Dst dst_nanbox_from_bits(uint64_t bits);
|
||||
|
||||
#define dst_memempty(mem, len) dst_nanbox_memempty((mem), (len))
|
||||
#define dst_memalloc_empty(count) dst_nanbox_memalloc_empty(count)
|
||||
@@ -231,7 +231,7 @@ DstValue dst_nanbox_from_bits(uint64_t bits);
|
||||
|
||||
/* Unwrap the pointer types */
|
||||
#define dst_unwrap_struct(x) ((const DstKV *)dst_nanbox_to_pointer(x))
|
||||
#define dst_unwrap_tuple(x) ((const DstValue *)dst_nanbox_to_pointer(x))
|
||||
#define dst_unwrap_tuple(x) ((const Dst *)dst_nanbox_to_pointer(x))
|
||||
#define dst_unwrap_fiber(x) ((DstFiber *)dst_nanbox_to_pointer(x))
|
||||
#define dst_unwrap_array(x) ((DstArray *)dst_nanbox_to_pointer(x))
|
||||
#define dst_unwrap_table(x) ((DstTable *)dst_nanbox_to_pointer(x))
|
||||
@@ -247,7 +247,7 @@ DstValue dst_nanbox_from_bits(uint64_t bits);
|
||||
#else
|
||||
|
||||
/* A general dst value type */
|
||||
struct DstValue {
|
||||
struct Dst {
|
||||
union {
|
||||
uint64_t u64;
|
||||
double real;
|
||||
@@ -267,7 +267,7 @@ struct DstValue {
|
||||
((x).type != DST_NIL && (x).type != DST_FALSE)
|
||||
|
||||
#define dst_unwrap_struct(x) ((const DstKV *)(x).as.pointer)
|
||||
#define dst_unwrap_tuple(x) ((const DstValue *)(x).as.pointer)
|
||||
#define dst_unwrap_tuple(x) ((const Dst *)(x).as.pointer)
|
||||
#define dst_unwrap_fiber(x) ((DstFiber *)(x).as.pointer)
|
||||
#define dst_unwrap_array(x) ((DstArray *)(x).as.pointer)
|
||||
#define dst_unwrap_table(x) ((DstTable *)(x).as.pointer)
|
||||
@@ -282,23 +282,23 @@ struct DstValue {
|
||||
#define dst_unwrap_integer(x) ((x).as.integer)
|
||||
#define dst_unwrap_real(x) ((x).as.real)
|
||||
|
||||
DstValue dst_wrap_nil();
|
||||
DstValue dst_wrap_real(double x);
|
||||
DstValue dst_wrap_integer(int32_t x);
|
||||
DstValue dst_wrap_true();
|
||||
DstValue dst_wrap_false();
|
||||
DstValue dst_wrap_boolean(int x);
|
||||
DstValue dst_wrap_string(const uint8_t *x);
|
||||
DstValue dst_wrap_symbol(const uint8_t *x);
|
||||
DstValue dst_wrap_array(DstArray *x);
|
||||
DstValue dst_wrap_tuple(const DstValue *x);
|
||||
DstValue dst_wrap_struct(const DstKV *x);
|
||||
DstValue dst_wrap_fiber(DstFiber *x);
|
||||
DstValue dst_wrap_buffer(DstBuffer *x);
|
||||
DstValue dst_wrap_function(DstFunction *x);
|
||||
DstValue dst_wrap_cfunction(DstCFunction x);
|
||||
DstValue dst_wrap_table(DstTable *x);
|
||||
DstValue dst_wrap_abstract(void *x);
|
||||
Dst dst_wrap_nil();
|
||||
Dst dst_wrap_real(double x);
|
||||
Dst dst_wrap_integer(int32_t x);
|
||||
Dst dst_wrap_true();
|
||||
Dst dst_wrap_false();
|
||||
Dst dst_wrap_boolean(int x);
|
||||
Dst dst_wrap_string(const uint8_t *x);
|
||||
Dst dst_wrap_symbol(const uint8_t *x);
|
||||
Dst dst_wrap_array(DstArray *x);
|
||||
Dst dst_wrap_tuple(const Dst *x);
|
||||
Dst dst_wrap_struct(const DstKV *x);
|
||||
Dst dst_wrap_fiber(DstFiber *x);
|
||||
Dst dst_wrap_buffer(DstBuffer *x);
|
||||
Dst dst_wrap_function(DstFunction *x);
|
||||
Dst dst_wrap_cfunction(DstCFunction x);
|
||||
Dst dst_wrap_table(DstTable *x);
|
||||
Dst dst_wrap_abstract(void *x);
|
||||
|
||||
/* End of tagged union implementation */
|
||||
#endif
|
||||
@@ -312,7 +312,7 @@ struct DstReg {
|
||||
/* A lightweight green thread in dst. Does not correspond to
|
||||
* operating system threads. */
|
||||
struct DstFiber {
|
||||
DstValue *data;
|
||||
Dst *data;
|
||||
DstFiber *parent;
|
||||
int32_t frame; /* Index of the stack frame */
|
||||
int32_t stackstart; /* Beginning of next args */
|
||||
@@ -333,12 +333,12 @@ struct DstStackFrame {
|
||||
int32_t prevframe;
|
||||
};
|
||||
|
||||
/* Number of DstValues a frame takes up in the stack */
|
||||
#define DST_FRAME_SIZE ((sizeof(DstStackFrame) + sizeof(DstValue) - 1)/ sizeof(DstValue))
|
||||
/* Number of Dsts a frame takes up in the stack */
|
||||
#define DST_FRAME_SIZE ((sizeof(DstStackFrame) + sizeof(Dst) - 1)/ sizeof(Dst))
|
||||
|
||||
/* A dynamic array type. */
|
||||
struct DstArray {
|
||||
DstValue *data;
|
||||
Dst *data;
|
||||
int32_t count;
|
||||
int32_t capacity;
|
||||
};
|
||||
@@ -360,8 +360,8 @@ struct DstTable {
|
||||
|
||||
/* A key value pair in a struct or table */
|
||||
struct DstKV {
|
||||
DstValue key;
|
||||
DstValue value;
|
||||
Dst key;
|
||||
Dst value;
|
||||
};
|
||||
|
||||
/* Some function defintion flags */
|
||||
@@ -371,7 +371,7 @@ struct DstKV {
|
||||
/* A function definition. Contains information needed to instantiate closures. */
|
||||
struct DstFuncDef {
|
||||
int32_t *environments; /* Which environments to capture from parent. */
|
||||
DstValue *constants;
|
||||
Dst *constants;
|
||||
DstFuncDef **defs;
|
||||
uint32_t *bytecode;
|
||||
|
||||
@@ -393,7 +393,7 @@ struct DstFuncDef {
|
||||
struct DstFuncEnv {
|
||||
union {
|
||||
DstFiber *fiber;
|
||||
DstValue *values;
|
||||
Dst *values;
|
||||
} as;
|
||||
int32_t length; /* Size of environment */
|
||||
int32_t offset; /* Stack offset when values still on stack. If offset is <= 0, then
|
||||
@@ -428,7 +428,7 @@ enum DstAssembleStatus {
|
||||
};
|
||||
|
||||
struct DstAssembleOptions {
|
||||
DstValue source;
|
||||
Dst source;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
@@ -454,9 +454,9 @@ struct DstCompileResult {
|
||||
|
||||
struct DstCompileOptions {
|
||||
uint32_t flags;
|
||||
const DstValue *sourcemap;
|
||||
DstValue source;
|
||||
DstValue env;
|
||||
const Dst *sourcemap;
|
||||
Dst source;
|
||||
Dst env;
|
||||
};
|
||||
|
||||
/* Parse structs */
|
||||
@@ -468,9 +468,9 @@ enum DstParseStatus {
|
||||
};
|
||||
|
||||
struct DstParseResult {
|
||||
DstValue value;
|
||||
Dst value;
|
||||
const uint8_t *error;
|
||||
const DstValue *map;
|
||||
const Dst *map;
|
||||
int32_t bytes_read;
|
||||
DstParseStatus status;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user