labelinstr.java

来自「用Java实现的编译器。把源代码编译成SPARC汇编程序」· Java 代码 · 共 88 行

JAVA
88
字号
// $Id: LabelInstr.java,v 1.5 1999/11/12 17:58:18 deberg Exp $package java6035.tools.IR;/** * The LabelInstr class captures a label, as a branch target. */public class LabelInstr extends Instruction{    protected String label;    /**     * Creates a label instruction with the given suffix as the suffix of the     * label.     */    public LabelInstr(String suffix)    {	label = LabelInstr.getUniqueLabel(suffix);    }    public void setLabel(String label)    {        this.label = label;    }    private static int counter = 0;    /**     * Returns a unique string label.     */    protected static String getUniqueLabel(String suffix)    {	counter++;        return new String("_L"+(counter-1)+"_"+suffix);    }    /**     * Returns the label for this label instruction.     */    public String getLabel()    {	return label;    }    /**     * Returns the type of the instruction.     */    protected int tnkind()    {	return LABEL_INSTR;    }    /**     * Walkable: returns the name of the node.     */    public String getNodeName()    {	return "label "+label;    }    /**     * Walkable: returns 0.     */    public int getNeighborCount()    {	return 0;    }    /**     * Walkable: returns null.     */    public Object getNeighbor(int index)    {	return null;    }    public String PPrint(int indent, boolean recursive)    {        String output = new String();        for(int i=0;i<indent;i++) output += " ";        output += "(label_instruction "+label+")\n";        return output;    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?