Created MainMemoryParser
[Mograsim.git] / plugins / net.mograsim.machine / src / net / mograsim / machine / isa / AsmLabel.java
1 package net.mograsim.machine.isa;
2
3 import java.util.Objects;
4
5 public final class AsmLabel implements AsmElement
6 {
7         private final String name;
8         private AsmInstruction inst;
9
10         public AsmLabel(String name)
11         {
12                 this.name = Objects.requireNonNull(name);
13         }
14
15         public String getName()
16         {
17                 return name;
18         }
19
20         public void setInst(AsmInstruction inst)
21         {
22                 if (inst != null)
23                         throw new IllegalStateException("Instrution already set for " + name);
24                 this.inst = inst;
25         }
26
27         @Override
28         public String toString()
29         {
30                 return name + ":";
31         }
32
33         @Override
34         public int hashCode()
35         {
36                 return Objects.hash(inst, name);
37         }
38
39         @Override
40         public boolean equals(Object obj)
41         {
42                 if (this == obj)
43                         return true;
44                 if (!(obj instanceof AsmLabel))
45                         return false;
46                 AsmLabel other = (AsmLabel) obj;
47                 return Objects.equals(inst, other.inst) && Objects.equals(name, other.name);
48         }
49 }