+++ /dev/null
-package net.mograsim.plugin.asm.model;
-
-public interface AsmElement
-{
- // only marker at the moment
-}
+++ /dev/null
-package net.mograsim.plugin.asm.model;
-
-import java.util.Objects;
-
-public final class AsmInstruction implements AsmElement
-{
- private final AsmOperation operation;
- private final AsmOperands operands;
-
- public AsmInstruction(AsmOperation operation, AsmOperands operands)
- {
- this.operation = Objects.requireNonNull(operation);
- this.operands = Objects.requireNonNull(operands);
- }
-
- @Override
- public int hashCode()
- {
- return Objects.hash(operands, operation);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (!(obj instanceof AsmInstruction))
- return false;
- AsmInstruction other = (AsmInstruction) obj;
- return Objects.equals(operands, other.operands) && Objects.equals(operation, other.operation);
- }
-
- @Override
- public String toString()
- {
- return String.format("%s %s", operation, operands).trim();
- }
-
-}
+++ /dev/null
-package net.mograsim.plugin.asm.model;
-
-import java.util.Objects;
-
-public final class AsmLabel implements AsmElement
-{
- private final String name;
- private AsmInstruction inst;
-
- public AsmLabel(String name)
- {
- this.name = Objects.requireNonNull(name);
- }
-
- public String getName()
- {
- return name;
- }
-
- public void setInst(AsmInstruction inst)
- {
- if (inst != null)
- throw new IllegalStateException("Instrution already set for " + name);
- this.inst = inst;
- }
-
- @Override
- public String toString()
- {
- return name + ":";
- }
-
- @Override
- public int hashCode()
- {
- return Objects.hash(inst, name);
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (!(obj instanceof AsmLabel))
- return false;
- AsmLabel other = (AsmLabel) obj;
- return Objects.equals(inst, other.inst) && Objects.equals(name, other.name);
- }
-}
+++ /dev/null
-package net.mograsim.plugin.asm.model;
-
-public interface AsmOperand
-{
-
-}
+++ /dev/null
-package net.mograsim.plugin.asm.model;
-
-import java.util.List;
-import java.util.Objects;
-import java.util.stream.Collectors;
-
-public final class AsmOperands
-{
- private final List<AsmOperand> operands;
-
- public AsmOperands(List<AsmOperand> operands)
- {
- this.operands = Objects.requireNonNull(operands);
- }
-
- public List<AsmOperand> getOperands()
- {
- return operands;
- }
-
- @Override
- public int hashCode()
- {
- return operands.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (!(obj instanceof AsmOperands))
- return false;
- AsmOperands other = (AsmOperands) obj;
- return operands.equals(other.operands);
- }
-
- @Override
- public String toString()
- {
- return operands.stream().map(AsmOperand::toString).collect(Collectors.joining(", "));
- }
-}
+++ /dev/null
-package net.mograsim.plugin.asm.model;
-
-import java.util.Objects;
-
-public final class AsmOperation
-{
- private final String mnemonic;
-
- public AsmOperation(String mnemonic)
- {
- this.mnemonic = Objects.requireNonNull(mnemonic.toLowerCase());
- }
-
- public String getMnemonic()
- {
- return mnemonic;
- }
-
- @Override
- public String toString()
- {
- return getMnemonic();
- }
-
- @Override
- public int hashCode()
- {
- return mnemonic.hashCode();
- }
-
- @Override
- public boolean equals(Object obj)
- {
- if (this == obj)
- return true;
- if (!(obj instanceof AsmOperation))
- return false;
- AsmOperation other = (AsmOperation) obj;
- return mnemonic.equals(other.mnemonic);
- }
-}
+++ /dev/null
-package net.mograsim.plugin.asm.model;
-
-public class NumericOperand
-{
-
-}