use of cz.cuni.mff.d3s.trupple.language.runtime.customvalues.EnumValue in project TrufflePascal by Aspect26.
the class ForNode method createEnumControlInterface.
private ControlInterface createEnumControlInterface(VirtualFrame frame) {
return new ControlInterface() {
@Override
public void increaseControlVariable() throws FrameSlotTypeException {
EnumValue controlValue = (EnumValue) frame.getObject(controlSlot);
frame.setObject(controlSlot, controlValue.getNext());
}
@Override
public void decreaseControlVariable() throws FrameSlotTypeException {
EnumValue controlValue = (EnumValue) frame.getObject(controlSlot);
frame.setObject(controlSlot, controlValue.getNext());
}
};
}
use of cz.cuni.mff.d3s.trupple.language.runtime.customvalues.EnumValue in project TrufflePascal by Aspect26.
the class ForNode method executeVoid.
@Override
public void executeVoid(VirtualFrame frame) {
try {
ControlInterface controlInterface = null;
switch(controlSlot.getKind()) {
case Int:
controlInterface = this.createIntControlInterface(frame);
break;
case Long:
controlInterface = this.createLongControlInterface(frame);
break;
case Byte:
controlInterface = this.createCharControlInterface(frame);
break;
case Object:
Object controlValue = frame.getObject(controlSlot);
if (controlValue instanceof EnumValue) {
controlInterface = this.createEnumControlInterface(frame);
break;
} else {
throw new PascalRuntimeException("Unsupported control variable type");
}
}
this.execute(frame, controlInterface, ascending);
} catch (FrameSlotTypeException | UnexpectedResultException e) {
throw new PascalRuntimeException("Something went wrong.");
}
}
Aggregations