Skip to content

Commit 1a515a4

Browse files
committed
Fix compilation errors on Github Actions by resolving vm macro and system() warnings
1 parent 584c6f9 commit 1a515a4

2 files changed

Lines changed: 27 additions & 19 deletions

File tree

src/prm/commands/cmd_core.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,8 @@ void prm_search(const char* query) {
311311
char cmd[1024];
312312
snprintf(cmd, sizeof(cmd), "curl -s \"%s/api/registry/search?q=%s\"", REGISTRY_URL, query);
313313

314-
system(cmd);
314+
int ret = system(cmd);
315+
(void)ret;
315316
printf("\n");
316317
}
317318

@@ -322,7 +323,8 @@ void prm_info(const char* packageName) {
322323
char cmd[1024];
323324
snprintf(cmd, sizeof(cmd), "curl -s \"%s/api/registry/package/%s\"", REGISTRY_URL, packageName);
324325

325-
system(cmd);
326+
int ret = system(cmd);
327+
(void)ret;
326328
printf("\n");
327329
}
328330

src/runtime/vm.c

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ static bool resolveContextualMethod(VM* pvm, ObjString* name, Value* result) {
659659

660660
CASE_OP(OP_SET_UPVALUE) {
661661
uint8_t slot = READ_BYTE();
662-
*frame->closure->upvalues[slot]->location = peek(vm, 0);
662+
*frame->closure->upvalues[slot]->location = stackTop[-1];
663663
DISPATCH();
664664
}
665665

@@ -712,16 +712,18 @@ static bool resolveContextualMethod(VM* pvm, ObjString* name, Value* result) {
712712

713713
CASE_OP(OP_GET_SUPER) {
714714
ObjString* name = READ_STRING();
715-
ObjClass* superclass = AS_CLASS(pop(vm));
716-
if (!bindMethod(superclass, name, vm)) {
715+
ObjClass* superclass = AS_CLASS((*(--stackTop)));
716+
STORE_FRAME();
717+
if (!bindMethod(superclass, name, pvm)) {
717718
return INTERPRET_RUNTIME_ERROR;
718719
}
720+
LOAD_FRAME();
719721
DISPATCH();
720722
}
721723

722724
CASE_OP(OP_EQUAL) {
723-
Value b = pop(vm);
724-
Value a = pop(vm);
725+
Value b = (*(--stackTop));
726+
Value a = (*(--stackTop));
725727
if (IS_NUMBER(a) && IS_NUMBER(b)) {
726728
// IEEE 754 semantics: NaN != NaN
727729
PUSH(BOOL_VAL(AS_NUMBER(a) == AS_NUMBER(b)));
@@ -736,23 +738,25 @@ static bool resolveContextualMethod(VM* pvm, ObjString* name, Value* result) {
736738
}
737739

738740
CASE_OP(OP_GREATER) {
739-
if (!IS_NUMBER(peek(vm, 0)) || !IS_NUMBER(peek(vm, 1))) {
740-
runtimeError(vm, "Operands must be numbers.");
741+
if (!IS_NUMBER(stackTop[-1]) || !IS_NUMBER(stackTop[-2])) {
742+
STORE_FRAME();
743+
runtimeError(pvm, "Operands must be numbers.");
741744
return INTERPRET_RUNTIME_ERROR;
742745
}
743-
double b = AS_NUMBER(pop(vm));
744-
double a = AS_NUMBER(pop(vm));
746+
double b = AS_NUMBER((*(--stackTop)));
747+
double a = AS_NUMBER((*(--stackTop)));
745748
PUSH(BOOL_VAL(a > b));
746749
DISPATCH();
747750
}
748751

749752
CASE_OP(OP_LESS) {
750-
if (!IS_NUMBER(peek(vm, 0)) || !IS_NUMBER(peek(vm, 1))) {
751-
runtimeError(vm, "Operands must be numbers.");
753+
if (!IS_NUMBER(stackTop[-1]) || !IS_NUMBER(stackTop[-2])) {
754+
STORE_FRAME();
755+
runtimeError(pvm, "Operands must be numbers.");
752756
return INTERPRET_RUNTIME_ERROR;
753757
}
754-
double b = AS_NUMBER(pop(vm));
755-
double a = AS_NUMBER(pop(vm));
758+
double b = AS_NUMBER((*(--stackTop)));
759+
double a = AS_NUMBER((*(--stackTop)));
756760
PUSH(BOOL_VAL(a < b));
757761
DISPATCH();
758762
}
@@ -1073,7 +1077,8 @@ static bool resolveContextualMethod(VM* pvm, ObjString* name, Value* result) {
10731077
CASE_OP(OP_TRY)
10741078
CASE_OP(OP_CATCH)
10751079
CASE_OP(OP_END_TRY) {
1076-
runtimeError(vm, "Exception handling not yet implemented.");
1080+
STORE_FRAME();
1081+
runtimeError(pvm, "Exception handling not yet implemented.");
10771082
return INTERPRET_RUNTIME_ERROR;
10781083
}
10791084

@@ -1216,7 +1221,8 @@ static bool resolveContextualMethod(VM* pvm, ObjString* name, Value* result) {
12161221
DISPATCH();
12171222
}
12181223
if (a->dimCount != 2 || b->dimCount != 2 || a->dims[1] != b->dims[0]) {
1219-
runtimeError(vm, "Incompatible tensor dimensions for '@'.");
1224+
STORE_FRAME();
1225+
runtimeError(pvm, "Incompatible tensor dimensions for '@'.");
12201226
return INTERPRET_RUNTIME_ERROR;
12211227
}
12221228
int outDims[] = {a->dims[0], b->dims[1]};
@@ -1297,7 +1303,7 @@ static bool resolveContextualMethod(VM* pvm, ObjString* name, Value* result) {
12971303
ObjString* name = READ_STRING();
12981304
ObjLayer* layer = newLayer(name);
12991305
PUSH(OBJ_VAL(layer));
1300-
Value contextVal = peek(vm, 1);
1306+
Value contextVal = stackTop[-2];
13011307
if (IS_CONTEXT(contextVal)) {
13021308
tableSet(&AS_CONTEXT(contextVal)->layers, name, OBJ_VAL(layer));
13031309
}
@@ -1340,7 +1346,7 @@ static bool resolveContextualMethod(VM* pvm, ObjString* name, Value* result) {
13401346
}
13411347
}
13421348
#endif
1343-
#undef vm
1349+
13441350

13451351
#undef READ_BYTE
13461352
#undef READ_SHORT

0 commit comments

Comments
 (0)