⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 treenode.java

📁 用Java实现的编译器。把源代码编译成SPARC汇编程序
💻 JAVA
字号:
// $Id: TreeNode.java,v 1.5 1999/09/27 20:01:29 deberg Exp $package java6035.tools.IR;/** * TreeNode  * * is the basic building block of IR trees. Subclasses of the TreeNode class * represent constructs in programming languages. The default subclasses * available in this package are: * * <PRE> * if-else              TreeIf class * instructions         Instruction class * while loops          TreeWhile class * blocks               TreeBlock class * </PRE> */public abstract class TreeNode extends IRObject implements Walkable{    protected static final int SIMPLE_INSTR = 0;    protected static final int BRANCH_INSTR = 1;    protected static final int LABEL_INSTR  = 2;    protected static final int RETURN_INSTR = 3;    protected static final int TREE_IF    = 4;    protected static final int TREE_WHILE = 5;    protected static final int TREE_BLOCK = 6;    protected static final int TREE_PROC  = 7;    private TreeNode parent;    protected abstract int tnkind();       /**     * Returns true if the node is a simple instruction. False     * otherwise      */    public boolean isSimpleInstr()    {	return tnkind() == SIMPLE_INSTR;    }    /**     * Returns true if the node is a branch instruction. False     * otherwise      */    public boolean isBranchInstr()    {	return tnkind() == BRANCH_INSTR;    }    /**     * Returns true if the node is a label instruction. False     * otherwise      */    public boolean isLabelInstr()    {	return tnkind() == LABEL_INSTR;    }    /**     * Returns true if the node is a return instruction. False     * otherwise      */    public boolean isReturnInstr()    {	return tnkind() == RETURN_INSTR;    }    /**     * Returns true if the node is a while node. False otherwise.     */    public boolean isTreeWhile()    {	return tnkind() == TREE_WHILE;    }    /**     * Returns true if the node is an if node. False otherwise.     */    public boolean isTreeIf()    {	return tnkind() == TREE_IF;    }    /**     * Returns true if the node is a block node. False otherwise.     */    public boolean isTreeBlock()    {	return tnkind() == TREE_BLOCK;    }    /**     * Returns true if the node is a procedure node. False otherwise.     */    public boolean isTreeProc()    {	return tnkind() == TREE_PROC;    }    /**     * Returns parent TreeNode     */    public TreeNode getParent()    {	return parent;    }    /**     * Sets parent TreeNode     */    public void setParent(TreeNode parent)    {        this.parent = parent;    }    /**     * Searches for annotation, given an annotation tag.  Returns     * the object if found, otherwise looks in parent, etc...     */    public Object getHierAnnotation(int tag)    {	Object x = annotations.get(new Integer(tag));        if (x != null)            return x;        else            if (parent != null)                return parent.getHierAnnotation(tag);            else                return null;    }}

⌨️ 快捷键说明

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