mirror of
https://github.com/janet-lang/janet
synced 2024-12-25 07:50:27 +00:00
Use 32 bit unsigned integers for stackframes.
This commit is contained in:
parent
1d7f42ba01
commit
14f8b12706
@ -145,6 +145,12 @@ int gst_stl_length(Gst *vm) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Get hash of a value */
|
||||||
|
int gst_stl_hash(Gst *vm) {
|
||||||
|
GstInteger h = gst_hash(gst_arg(vm, 0));
|
||||||
|
gst_c_return(vm, gst_wrap_integer(h));
|
||||||
|
}
|
||||||
|
|
||||||
/* Convert to integer */
|
/* Convert to integer */
|
||||||
int gst_stl_to_int(Gst *vm) {
|
int gst_stl_to_int(Gst *vm) {
|
||||||
GstValue x = gst_arg(vm, 0);
|
GstValue x = gst_arg(vm, 0);
|
||||||
@ -569,6 +575,7 @@ static const GstModuleItem const std_module[] = {
|
|||||||
{">=", gst_stl_greaterthaneq},
|
{">=", gst_stl_greaterthaneq},
|
||||||
{"not", gst_stl_not},
|
{"not", gst_stl_not},
|
||||||
{"length", gst_stl_length},
|
{"length", gst_stl_length},
|
||||||
|
{"hash", gst_stl_hash},
|
||||||
{"to-integer", gst_stl_to_int},
|
{"to-integer", gst_stl_to_int},
|
||||||
{"to-real", gst_stl_to_real},
|
{"to-real", gst_stl_to_real},
|
||||||
{"type", gst_stl_type},
|
{"type", gst_stl_type},
|
||||||
|
10
core/vm.c
10
core/vm.c
@ -417,9 +417,9 @@ int gst_run(Gst *vm, GstValue callee) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get an argument from the stack */
|
/* Get an argument from the stack */
|
||||||
GstValue gst_arg(Gst *vm, uint16_t index) {
|
GstValue gst_arg(Gst *vm, uint32_t index) {
|
||||||
GstValue *stack = gst_thread_stack(vm->thread);
|
GstValue *stack = gst_thread_stack(vm->thread);
|
||||||
uint16_t frameSize = gst_frame_size(stack);
|
uint32_t frameSize = gst_frame_size(stack);
|
||||||
if (frameSize <= index) {
|
if (frameSize <= index) {
|
||||||
GstValue ret;
|
GstValue ret;
|
||||||
ret.type = GST_NIL;
|
ret.type = GST_NIL;
|
||||||
@ -429,15 +429,15 @@ GstValue gst_arg(Gst *vm, uint16_t index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Put a value on the stack */
|
/* Put a value on the stack */
|
||||||
void gst_set_arg(Gst* vm, uint16_t index, GstValue x) {
|
void gst_set_arg(Gst* vm, uint32_t index, GstValue x) {
|
||||||
GstValue *stack = gst_thread_stack(vm->thread);
|
GstValue *stack = gst_thread_stack(vm->thread);
|
||||||
uint16_t frameSize = gst_frame_size(stack);
|
uint32_t frameSize = gst_frame_size(stack);
|
||||||
if (frameSize <= index) return;
|
if (frameSize <= index) return;
|
||||||
stack[index] = x;
|
stack[index] = x;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the size of the VMStack */
|
/* Get the size of the VMStack */
|
||||||
uint16_t gst_count_args(Gst *vm) {
|
uint32_t gst_count_args(Gst *vm) {
|
||||||
GstValue *stack = gst_thread_stack(vm->thread);
|
GstValue *stack = gst_thread_stack(vm->thread);
|
||||||
return gst_frame_size(stack);
|
return gst_frame_size(stack);
|
||||||
}
|
}
|
||||||
|
@ -79,16 +79,16 @@
|
|||||||
/* Stack frame manipulation */
|
/* Stack frame manipulation */
|
||||||
|
|
||||||
/* Size of stack frame in number of values */
|
/* Size of stack frame in number of values */
|
||||||
#define GST_FRAME_SIZE 4
|
#define GST_FRAME_SIZE 5
|
||||||
|
|
||||||
/* Macros for referencing a stack frame given a stack */
|
/* Macros for referencing a stack frame given a stack */
|
||||||
#define gst_frame_callee(s) (*(s - 1))
|
#define gst_frame_callee(s) (*(s - 1))
|
||||||
#define gst_frame_size(s) ((s - 2)->data.words[0])
|
#define gst_frame_size(s) ((s - 2)->data.dwords[0])
|
||||||
#define gst_frame_prevsize(s) ((s - 2)->data.words[1])
|
#define gst_frame_prevsize(s) ((s - 2)->data.dwords[1])
|
||||||
#define gst_frame_args(s) ((s - 2)->data.words[2])
|
#define gst_frame_args(s) ((s - 3)->data.dwords[0])
|
||||||
#define gst_frame_ret(s) ((s - 2)->data.words[3])
|
#define gst_frame_ret(s) ((s - 3)->data.dwords[1])
|
||||||
#define gst_frame_pc(s) ((s - 3)->data.u16p)
|
#define gst_frame_pc(s) ((s - 4)->data.u16p)
|
||||||
#define gst_frame_env(s) ((s - 4)->data.env)
|
#define gst_frame_env(s) ((s - 5)->data.env)
|
||||||
|
|
||||||
/* C function helpers */
|
/* C function helpers */
|
||||||
|
|
||||||
@ -492,9 +492,9 @@ void gst_init(Gst *vm);
|
|||||||
void gst_deinit(Gst *vm);
|
void gst_deinit(Gst *vm);
|
||||||
int gst_run(Gst *vm, GstValue func);
|
int gst_run(Gst *vm, GstValue func);
|
||||||
int gst_continue(Gst *vm);
|
int gst_continue(Gst *vm);
|
||||||
GstValue gst_arg(Gst *vm, uint16_t index);
|
GstValue gst_arg(Gst *vm, uint32_t index);
|
||||||
void gst_set_arg(Gst *vm, uint16_t index, GstValue x);
|
void gst_set_arg(Gst *vm, uint32_t index, GstValue x);
|
||||||
uint16_t gst_count_args(Gst *vm);
|
uint32_t gst_count_args(Gst *vm);
|
||||||
|
|
||||||
/****/
|
/****/
|
||||||
/* C Api */
|
/* C Api */
|
||||||
|
Loading…
Reference in New Issue
Block a user