Label AST. @author Matt
| 9 | * @author Matt |
| 10 | */ |
| 11 | public class LabelAST extends AST implements Compilable { |
| 12 | private final NameAST name; |
| 13 | |
| 14 | /** |
| 15 | * @param line |
| 16 | * Line number this node is written on. |
| 17 | * @param start |
| 18 | * Offset from line start this node starts at. |
| 19 | * @param name |
| 20 | * Label name. |
| 21 | */ |
| 22 | public LabelAST(int line, int start, NameAST name) { |
| 23 | super(line, start); |
| 24 | this.name = name; |
| 25 | } |
| 26 | |
| 27 | /** |
| 28 | * @return Name AST. |
| 29 | */ |
| 30 | public NameAST getName() { |
| 31 | return name; |
| 32 | } |
| 33 | |
| 34 | |
| 35 | @Override |
| 36 | public String print() { |
| 37 | return name.print() + ":"; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public void compile(MethodCompilation compilation) throws AssemblerException { |
| 42 | compilation.addInstruction(compilation.getLabel(getName().getName()), this); |
| 43 | } |
| 44 | } |
nothing calls this directly
no outgoing calls
no test coverage detected