1
0
mirror of https://github.com/janet-lang/janet synced 2025-02-09 05:20:03 +00:00

Fix some gc mark issues and change dict to obj.

This commit is contained in:
Calvin Rose 2017-02-16 15:10:59 -05:00
parent 6677dff337
commit 69260fa3bd
5 changed files with 15 additions and 10 deletions

View File

@ -982,11 +982,6 @@ static SpecialFormHelper get_special(GstArray *form) {
if (gst_string_length(name) == 2 && if (gst_string_length(name) == 2 &&
name[1] == 'o') { name[1] == 'o') {
return compile_do; return compile_do;
} else if (gst_string_length(name) == 4 &&
name[1] == 'i' &&
name[2] == 'c' &&
name[3] == 't') {
return compile_object;
} }
} }
break; break;
@ -1014,6 +1009,15 @@ static SpecialFormHelper get_special(GstArray *form) {
return compile_not; return compile_not;
} }
} }
break;
case 'o':
{
if (gst_string_length(name) == 3 &&
name[1] == 'b' &&
name[2] == 'j') {
return compile_object;
}
}
case 'q': case 'q':
{ {
if (gst_string_length(name) == 5 && if (gst_string_length(name) == 5 &&

View File

@ -176,7 +176,7 @@ void gst_dasm(FILE * out, uint16_t *byteCode, uint32_t len) {
current += dasm_varg_op(out, current, "array", 1); current += dasm_varg_op(out, current, "array", 1);
break; break;
case GST_OP_DIC: case GST_OP_DIC:
current += dasm_varg_op(out, current, "dictionary", 1); current += dasm_varg_op(out, current, "object", 1);
break; break;
case GST_OP_TCL: case GST_OP_TCL:
current += dasm_varg_op(out, current, "tailCall", 1); current += dasm_varg_op(out, current, "tailCall", 1);

6
main.c
View File

@ -87,9 +87,9 @@ void debugRepl() {
} }
/* Print asm */ /* Print asm */
//printf("\n"); printf("\n");
//dasmFunc(stdout, func.data.func); gst_dasm_function(stdout, func.data.function);
//printf("\n"); printf("\n");
/* Execute function */ /* Execute function */
gst_load(&vm, func); gst_load(&vm, func);

View File

@ -89,7 +89,7 @@ static void parser_push(GstParser *p, ParseType type, uint8_t character) {
} }
if (character == '{') { if (character == '{') {
top->buf.form.endDelimiter = '}'; top->buf.form.endDelimiter = '}';
gst_array_push(p->vm, top->buf.form.array, gst_load_cstring(p->vm, "dict")); gst_array_push(p->vm, top->buf.form.array, gst_load_cstring(p->vm, "obj"));
} }
break; break;
} }

1
vm.c
View File

@ -223,6 +223,7 @@ static void gst_mark(Gst *vm, GstValue *x) {
for (i = 0; i < x->data.object->capacity; ++i) { for (i = 0; i < x->data.object->capacity; ++i) {
bucket = x->data.object->buckets[i]; bucket = x->data.object->buckets[i];
while (bucket) { while (bucket) {
gc_header(bucket)->color = vm->black;
gst_mark(vm, &bucket->key); gst_mark(vm, &bucket->key);
gst_mark(vm, &bucket->value); gst_mark(vm, &bucket->value);
bucket = bucket->next; bucket = bucket->next;