labeldescriptor.java

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

JAVA
72
字号
// $Id: LabelDescriptor.java,v 1.2 1999/09/27 20:01:28 deberg Exp $package java6035.tools.IR;/** * LabelDescriptor * * represents a label in the low level IR tree, such as procedure and * block entry point. Calling the constructor will generate a unique  * label with the given suffix. LabelDescriptor has a reference count * that can help to determine the usage of a label. */public class LabelDescriptor extends Descriptor {    private static int counter = 0;    private LabelInstr lab;    private int ref_count = 0;    /**     * Creates a low IR label with "_Lxxx" as prefix, where xxx is a     * unique number throughout the program.     *     * @param suffix   Suffix of the label.     */    public LabelDescriptor(String suffix, LabelInstr lab)    {        super("_L"+getCounter()+suffix);	this.lab = lab;	this.ref_count = 0;    }    public void ref()    {	ref_count++;    }    public void unref()    {	ref_count--;    }    public int getRef()    {	return ref_count;    }    /**     * Returns the instruction that defines this label.     */    public LabelInstr getLabelInstr()    {	return this.lab;    }    /**     * return a counter, increment the counter to get the next one.     */    public static int getCounter()    {        counter++;        return counter-1;    }}

⌨️ 快捷键说明

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