drop instruction for saving memory and time

This commit is contained in:
2025-12-22 14:05:40 +11:00
parent 579720015a
commit 90361e6bee
5 changed files with 27 additions and 1 deletions

View File

@@ -1468,6 +1468,24 @@ GroundValue interpretGroundInstruction(GroundInstruction inst, GroundScope* scop
currentInstruction = currentCurrentInstruction;
break;
}
case DROP: {
if (in->args.length < 1) {
runtimeError(TOO_FEW_ARGS, "Expecting 1 arg", in, currentInstruction);
}
if (in->args.length > 1) {
runtimeError(TOO_MANY_ARGS, "Expecting 1 arg", in, currentInstruction);
}
if (in->args.args[0].type != DIRREF) {
runtimeError(ARG_TYPE_MISMATCH, "Expecting a DirectRef for arg 1", in, currentInstruction);
}
GroundVariable* var = findVariable(*scope->variables, in->args.args[0].value.refName);
if (!var) {
runtimeError(UNKNOWN_VARIABLE, NULL, in, currentInstruction);
}
deleteVariable(scope->variables, var);
break;
}
default: {
runtimeError(FIXME, "Currently unimplemented instruction", in, currentInstruction);
}