mirror of
https://github.com/janet-lang/janet
synced 2025-02-20 10:30:02 +00:00
Fix assembler labels after keyword update.
This commit is contained in:
parent
6afaacf2af
commit
58d480539c
@ -48,7 +48,7 @@ struct JanetAssembler {
|
|||||||
int32_t bytecode_count; /* Used for calculating labels */
|
int32_t bytecode_count; /* Used for calculating labels */
|
||||||
|
|
||||||
Janet name;
|
Janet name;
|
||||||
JanetTable labels; /* symbol -> bytecode index */
|
JanetTable labels; /* keyword -> bytecode index */
|
||||||
JanetTable constants; /* symbol -> constant index */
|
JanetTable constants; /* symbol -> constant index */
|
||||||
JanetTable slots; /* symbol -> slot index */
|
JanetTable slots; /* symbol -> slot index */
|
||||||
JanetTable envs; /* symbol -> environment index */
|
JanetTable envs; /* symbol -> environment index */
|
||||||
@ -276,7 +276,14 @@ static int32_t doarg_1(
|
|||||||
}
|
}
|
||||||
case JANET_KEYWORD:
|
case JANET_KEYWORD:
|
||||||
{
|
{
|
||||||
if (argtype == JANET_OAT_TYPE || argtype == JANET_OAT_SIMPLETYPE) {
|
if (NULL != c && argtype == JANET_OAT_LABEL) {
|
||||||
|
Janet result = janet_table_get(c, x);
|
||||||
|
if (janet_checktype(result, JANET_NUMBER)) {
|
||||||
|
ret = janet_unwrap_integer(result) - a->bytecode_count;
|
||||||
|
} else {
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
} else if (argtype == JANET_OAT_TYPE || argtype == JANET_OAT_SIMPLETYPE) {
|
||||||
const TypeAlias *alias = janet_strbinsearch(
|
const TypeAlias *alias = janet_strbinsearch(
|
||||||
&type_aliases,
|
&type_aliases,
|
||||||
sizeof(type_aliases)/sizeof(TypeAlias),
|
sizeof(type_aliases)/sizeof(TypeAlias),
|
||||||
@ -297,11 +304,7 @@ static int32_t doarg_1(
|
|||||||
if (NULL != c) {
|
if (NULL != c) {
|
||||||
Janet result = janet_table_get(c, x);
|
Janet result = janet_table_get(c, x);
|
||||||
if (janet_checktype(result, JANET_NUMBER)) {
|
if (janet_checktype(result, JANET_NUMBER)) {
|
||||||
if (argtype == JANET_OAT_LABEL) {
|
|
||||||
ret = janet_unwrap_integer(result) - a->bytecode_count;
|
|
||||||
} else {
|
|
||||||
ret = (int32_t) janet_unwrap_number(result);
|
ret = (int32_t) janet_unwrap_number(result);
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
janet_asm_errorv(a, janet_formatc("unknown name %v", x));
|
janet_asm_errorv(a, janet_formatc("unknown name %v", x));
|
||||||
}
|
}
|
||||||
@ -641,7 +644,7 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
|
|||||||
int32_t blength = 0;
|
int32_t blength = 0;
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
Janet instr = arr[i];
|
Janet instr = arr[i];
|
||||||
if (janet_checktype(instr, JANET_SYMBOL)) {
|
if (janet_checktype(instr, JANET_KEYWORD)) {
|
||||||
janet_table_put(&a.labels, instr, janet_wrap_integer(blength));
|
janet_table_put(&a.labels, instr, janet_wrap_integer(blength));
|
||||||
} else if (janet_checktype(instr, JANET_TUPLE)) {
|
} else if (janet_checktype(instr, JANET_TUPLE)) {
|
||||||
blength++;
|
blength++;
|
||||||
@ -659,7 +662,7 @@ static JanetAssembleResult janet_asm1(JanetAssembler *parent, Janet source, int
|
|||||||
/* Do bytecode */
|
/* Do bytecode */
|
||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
Janet instr = arr[i];
|
Janet instr = arr[i];
|
||||||
if (janet_checktype(instr, JANET_SYMBOL)) {
|
if (janet_checktype(instr, JANET_KEYWORD)) {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
uint32_t op;
|
uint32_t op;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user