X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fasm%2Fmodel%2FAsmLabel.java;fp=net.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fasm%2Fmodel%2FAsmLabel.java;h=eb25f53c6958df417acaa981b86490a63672c24e;hb=f14ea37d69488dd51518a36413af7176916b8bd7;hp=0000000000000000000000000000000000000000;hpb=a84700145147c263ad6692c99117a7cf37832378;p=Mograsim.git diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/model/AsmLabel.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/model/AsmLabel.java new file mode 100644 index 00000000..eb25f53c --- /dev/null +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/asm/model/AsmLabel.java @@ -0,0 +1,49 @@ +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); + } +}