📄 branchinstr.java
字号:
// $Id: BranchInstr.java,v 1.4 1999/10/06 03:39:42 deberg Exp $package java6035.tools.IR;/** * The BranchInstr class captures a branch statement. This class optionally * takes a Rhs value as the branch conditional. */public class BranchInstr extends Instruction{ protected Rhs cond; protected LabelInstr target; /** * Creates a branch instruction to label. */ public BranchInstr(LabelInstr label) { this(null, label); } /** * Creates a branch instruction with a conditional cond */ public BranchInstr(Rhs cond, LabelInstr label) { this.cond = cond; this.target = label; if (this.target == null) throw new IRException ("BranchInstr: constructor: target null"); } /** * Returns the type of the instruction. */ protected int tnkind() { return BRANCH_INSTR; } /** * Returns the conditional, if branch is conditional. */ public Rhs getConditional() { return cond; } /** * Sets the conditional. */ public void setConditional(Rhs cond) { this.cond = cond; } /** * Returns the branch target. */ public LabelInstr getTarget() { return target; } /** * Sets the branch target. */ public void setTarget(LabelInstr target) { this.target = target; if (this.target == null) throw new IRException ("BranchInstr: setTarget: target null"); } /** * Walkable: returns the name of the node. */ public String getNodeName() { return "branch"; } /** * Walkable: returns the number of neighbors from this node. */ public int getNeighborCount() { if (cond != null) return 2; return 1; } /** * Walkable: returns a specific neighbor: 0, label instr; 1, conditional * value if there is one. */ public Object getNeighbor(int index) { if (index == 0) return this.target; else if (cond != null && index == 1) return this.cond; else return null; } public String PPrint(int indent, boolean recursive) { String output = new String(); for(int i=0;i<indent;i++) output += " "; output += "(branch_instruction to " + this.target.getLabel() + "\n"; if (recursive) { if (this.cond != null) { output += this.cond.PPrint(indent+2, recursive); } } for(int i=0;i<indent;i++) output += " "; output += ") /* branch to " + this.target.getLabel() + " */\n"; return output; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -