1
0
mirror of https://github.com/janet-lang/janet synced 2024-11-24 17:27:18 +00:00

Fix an offset bug in closure creation.

This commit is contained in:
Calvin Rose 2018-03-22 17:38:37 -04:00
parent 8d302d9b1f
commit da15dac16b
4 changed files with 10 additions and 8 deletions

View File

@ -180,14 +180,19 @@ static int32_t string_description_impl(uint8_t *buf, const char *title, void *po
*c++ = ' ';
*c++ = '0';
*c++ = 'x';
for (i = sizeof(void *); i > 0; --i) {
#if defined(DST_64)
#define POINTSIZE 6
#else
#define POINTSIZE (sizeof(void *))
#endif
for (i = POINTSIZE; i > 0; --i) {
uint8_t byte = pbuf.bytes[i - 1];
if (!byte) continue;
*c++ = HEX(byte >> 4);
*c++ = HEX(byte & 0xF);
}
*c++ = '>';
return (int32_t) (c - buf);
#undef POINTSIZE
}
static void string_description_b(DstBuffer *buffer, const char *title, void *pointer) {

View File

@ -493,7 +493,7 @@ static void *op_lookup[255] = {
for (i = 0; i < elen; ++i) {
int32_t inherit = fd->environments[i];
if (inherit == -1) {
DstStackFrame *frame = (DstStackFrame *)stack - 1;
DstStackFrame *frame = dst_stack_frame(stack);
if (!frame->env) {
/* Lazy capture of current stack frame */
DstFuncEnv *env = dst_gcalloc(DST_MEMORY_FUNCENV, sizeof(DstFuncEnv));

View File

@ -50,10 +50,7 @@ extern "C" {
|| defined(sun) || defined(__sun) /* Solaris */ \
|| defined(unix) || defined(__unix) || defined(__unix__)
#define DST_UNIX 1
#endif
/* Check Windows */
#ifdef __EMSCRIPTEN__
#elif defined(__EMSCRIPTEN__)
#define DST_WEB 1
#elif defined(WIN32) || defined(_WIN32)
#define DST_WINDOWS 1

View File

@ -348,7 +348,7 @@ struct DstStackFrame {
};
/* Number of Dsts a frame takes up in the stack */
#define DST_FRAME_SIZE ((sizeof(DstStackFrame) + sizeof(Dst) - 1)/ sizeof(Dst))
#define DST_FRAME_SIZE ((sizeof(DstStackFrame) + sizeof(Dst) - 1) / sizeof(Dst))
/* A dynamic array type. */
struct DstArray {