use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method exception.
public void exception(ExceptionType exception, @Nullable RunningProgram program) {
// For too many events exception we don't want to queue another event for obvious reasons
if (exception != EXCEPT_TOOMANYEVENTS) {
for (int i = 0; i < cardInfo.length; i++) {
CardInfo info = cardInfo[i];
CompiledCard compiledCard = info.getCompiledCard();
if (compiledCard != null) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_EXCEPTION)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
String code = evaluateStringParameter(compiledOpcode, null, 0);
if (exception.getCode().equals(code)) {
runOrQueueEvent(i, event, program == null ? null : program.getCraftTicket(), null);
return;
}
}
}
}
}
String message;
if (program != null) {
CompiledCard card = getCompiledCard(program.getCardIndex());
if (card == null) {
message = TextFormatting.RED + "INTERNAL: " + exception.getDescription();
} else {
CompiledOpcode opcode = program.getCurrentOpcode(this);
int gridX = opcode.getGridX();
int gridY = opcode.getGridY();
message = TextFormatting.RED + "[" + gridX + "," + gridY + "] " + exception.getDescription();
}
} else {
message = TextFormatting.RED + exception.getDescription();
}
lastException = message;
lastExceptionTime = System.currentTimeMillis();
log(message);
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method signal.
@Override
public int signal(String signal) {
int cnt = 0;
for (int i = 0; i < cardInfo.length; i++) {
CardInfo info = cardInfo[i];
CompiledCard compiledCard = info.getCompiledCard();
if (compiledCard != null) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_SIGNAL)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
String sig = evaluateStringParameter(compiledOpcode, null, 0);
if (signal.equals(sig)) {
runOrQueueEvent(i, event, null, null);
cnt++;
}
}
}
}
return cnt;
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method handleCall.
public void handleCall(IProgram program, String signal) {
RunningProgram p = (RunningProgram) program;
CardInfo info = this.cardInfo[p.getCardIndex()];
CompiledCard compiledCard = info.getCompiledCard();
if (compiledCard != null) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_SIGNAL)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
String sig = evaluateStringParameter(compiledOpcode, null, 0);
if (signal.equals(sig)) {
p.pushCall(p.getCurrentOpcode(this).getPrimaryIndex());
p.setCurrent(event.getIndex());
return;
}
}
}
throw new ProgException(EXCEPT_MISSINGSIGNAL);
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method receiveMessage.
public void receiveMessage(String name, @Nullable Parameter value) {
for (int i = 0; i < cardInfo.length; i++) {
CardInfo info = cardInfo[i];
CompiledCard compiledCard = info.getCompiledCard();
if (compiledCard != null) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_MESSAGE)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
String messageName = evaluateStringParameter(compiledOpcode, null, 0);
if (name.equals(messageName)) {
runOrQueueEvent(i, event, null, value);
}
}
}
}
}
use of mcjty.rftoolscontrol.logic.compiled.CompiledOpcode in project RFToolsControl by McJty.
the class ProcessorTileEntity method handleEventsTimer.
private void handleEventsTimer(int i, CompiledCard compiledCard) {
for (CompiledEvent event : compiledCard.getEvents(Opcodes.EVENT_TIMER)) {
int index = event.getIndex();
CompiledOpcode compiledOpcode = compiledCard.getOpcodes().get(index);
int ticks = evaluateIntParameter(compiledOpcode, null, 0);
if (ticks > 0 && tickCount % ticks == 0) {
runOrDropEvent(i, event, null, null);
}
}
}
Aggregations