forked from ground/cground
drop instruction for saving memory and time
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user