Skip to content

Commit

Permalink
Fix build.
Browse files Browse the repository at this point in the history
  • Loading branch information
fnuecke committed Apr 15, 2024
1 parent 3f2deee commit 354a583
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ static Object checkTargetOrNumber(String name, final int lineNumber, final Map<S
}
}
}

static Object checkTargetOrNumberOrLabel(String name, final int lineNumber, final Map<String, String> defines, final int start, final int end) throws ParseException {
name = defines.getOrDefault(name, name);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@
import java.util.regex.Matcher;

public final class MoveInstructionEmitter extends AbstractInstructionEmitter {
private static void validateLabel(final MachineState state, final String label, final Matcher matcher, final int lineNumber) throws ParseException {
if (!state.labels.containsKey(label)) {
throw new ParseException(Strings.MESSAGE_LABEL_NOT_FOUND, lineNumber, matcher.start("arg1"), matcher.end("arg1"));
}
}

@Override
public Instruction compile(final Matcher matcher, final int lineNumber, final Map<String, String> defines, final List<Validator> validators) throws ParseException {
final Object src = checkTargetOrNumberOrLabel(checkArg(lineNumber, matcher, "arg1", "name"),
Expand All @@ -33,12 +27,18 @@ public Instruction compile(final Matcher matcher, final int lineNumber, final Ma
return new MoveInstruction(target, dst);
} else if (src instanceof final Short value) {
return new MoveImmediateInstruction(value, dst);
} else if (src instanceof String){
} else if (src instanceof String) {
final String label = checkArg(lineNumber, matcher, "arg1", "name");
validators.add(state -> validateLabel(state, label, matcher, lineNumber));
return new MoveLabelInstruction(label, dst);
} else {
throw new AssertionError();
}
}

private static void validateLabel(final MachineState state, final String label, final Matcher matcher, final int lineNumber) throws ParseException {
if (!state.labels.containsKey(label)) {
throw new ParseException(Strings.MESSAGE_LABEL_NOT_FOUND, lineNumber, matcher.start("arg1"), matcher.end("arg1"));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package li.cil.tis3d.common.module.execution.instruction;

import li.cil.tis3d.common.module.execution.Machine;
import li.cil.tis3d.common.module.execution.target.Target;
import li.cil.tis3d.common.module.execution.target.TargetInterface;

public class JumpAbsoluteImmediateInstruction implements Instruction {
private final short pc;
Expand Down

0 comments on commit 354a583

Please sign in to comment.