Add bitwise or

This commit is contained in:
2026-03-25 21:04:44 +11:00
parent be7db9d837
commit 5c5b0bd26f
6 changed files with 48 additions and 2 deletions

View File

@@ -1451,6 +1451,29 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
}
break;
}
case OR: {
if (in->args.length < 2) {
runtimeError(TOO_FEW_ARGS, "Expecting at least 2 args", in, currentInstruction);
}
for (size_t i = 0; i < in->args.length - 1; i++) {
if (in->args.args[i].type != VALUE) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting a value for all args except last", in, currentInstruction);
}
if (in->args.args[i].value.value.type != INT) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting an int for all args except last", in, currentInstruction);
}
}
if (in->args.args[in->args.length-1].type != DIRREF) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting a direct reference for last argument", in, currentInstruction);
}
int64_t result = 0;
for (size_t i = 0; i < in->args.length - 1; i++) {
result |= in->args.args[i].value.value.data.intVal;
}
addVariable(scope->variables, in->args.args[in->args.length-1].value.refName, createIntGroundValue(result));
break;
}
/*
* STRING OPERATIONS