/** * Get all statements added to the Summary. * * This builds a copy of the internal list and may contain 'null'-values if no * instruction has been placed at a particular pc. * * @return The statements of the summary */ public SSAInstruction[] getStatements() { SSAInstruction[] ret = new SSAInstruction[this.instructions.size()]; ret = this.instructions.toArray(ret); // Remove Reserved for (int i=0; i<ret.length; ++i) { if (ret[i].equals(RESERVED)) { ret[i] = null; } } return ret; }
/** * Returns if the ProgramCounter is reserved. * * @param programCounter the ProgramCounter in question * @return true if the position is reserved * @throws IllegalArgumentException if the ProgramCounter is negative */ public boolean isReserved(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("The Program-Counter may not be negative"); } if (instructions.size() - 1 < programCounter) return false; if (instructions.get(programCounter) == null) return false; return (instructions.get(programCounter).equals(RESERVED)); }
/** * Returns if the ProgramCounter is reserved. * * @param programCounter the ProgramCounter in question * @return true if the position is reserved * @throws IllegalArgumentException if the ProgramCounter is negative */ public boolean isReserved(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("The Program-Counter may not be negative"); } if (instructions.size() - 1 < programCounter) return false; if (instructions.get(programCounter) == null) return false; return (instructions.get(programCounter).equals(RESERVED)); }
/** * Get all statements added to the Summary. * * This builds a copy of the internal list and may contain 'null'-values if no * instruction has been placed at a particular pc. * * @return The statements of the summary */ public SSAInstruction[] getStatements() { SSAInstruction[] ret = new SSAInstruction[this.instructions.size()]; ret = this.instructions.toArray(ret); // Remove Reserved for (int i=0; i<ret.length; ++i) { if (ret[i].equals(RESERVED)) { ret[i] = null; } } return ret; }
/** * @param programCounter the ProgramCounter to retrieve the Instruction from * @return The instruction or null if there is none * @throws IllegalArgumentException if the ProgramCounter is negative */ public SSAInstruction getStatementAt(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("Program-Counter may not be negative!"); } if (this.instructions.size() <= programCounter) { return null; } if (this.instructions.get(programCounter).equals(RESERVED)) { return null; } return this.instructions.get(programCounter); }
/** * @param programCounter the ProgramCounter to retrieve the Instruction from * @return The instruction or null if there is none * @throws IllegalArgumentException if the ProgramCounter is negative */ public SSAInstruction getStatementAt(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("Program-Counter may not be negative!"); } if (this.instructions.size() <= programCounter) { return null; } if (this.instructions.get(programCounter).equals(RESERVED)) { return null; } return this.instructions.get(programCounter); }
/** * Not exactly dual to {@link #isFree(int)}. * * Returns whether an instruction is located at ProgramCounter. Thus it is a shortcut * to {@link #getStatementAt(int)} != null. * <p> * It is not the exact dual to {@link #isFree(int)} as it does not consider reserved * ProgramCounters. * * @param programCounter the ProgramCounter in question * @return true if there's an instruction at that program counter * @throws IllegalArgumentException if the ProgramCounter is negative */ public boolean isUsed(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("The Program-Counter may not be negative"); } if (instructions.size() - 1 < programCounter) return false; if (instructions.get(programCounter) == null) return false; if (instructions.get(programCounter).equals(RESERVED)) return false; return true; }
/** * Not exactly dual to {@link #isFree(int)}. * * Returns whether an instruction is located at ProgramCounter. Thus it is a shortcut * to {@link #getStatementAt(int)} != null. * <p> * It is not the exact dual to {@link #isFree(int)} as it does not consider reserved * ProgramCounters. * * @param programCounter the ProgramCounter in question * @return true if there's an instruction at that program counter * @throws IllegalArgumentException if the ProgramCounter is negative */ public boolean isUsed(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("The Program-Counter may not be negative"); } if (instructions.size() - 1 < programCounter) return false; if (instructions.get(programCounter) == null) return false; if (instructions.get(programCounter).equals(RESERVED)) return false; return true; }
/** * Returns if the ProgramCounter is writable. * * The ProgramCounter is not writable if there is already an instruction located at that * ProgramCounter or if the reserved ProgramCounters forbid usage. Thus the answer may * depend on the setting of {@link #allowReserved(boolean)}. * * @param programCounter the ProgramCounter in question * @return true if you may write to the location * @throws IllegalArgumentException if the ProgramCounter is negative */ public boolean isFree(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("The Program-Counter may not be negative"); } if (instructions.size() - 1 < programCounter) return true; if (instructions.get(programCounter) == null) return true; if (instructions.get(programCounter).equals(RESERVED)) return false; return false; }
/** * Returns if the ProgramCounter is writable. * * The ProgramCounter is not writable if there is already an instruction located at that * ProgramCounter or if the reserved ProgramCounters forbid usage. Thus the answer may * depend on the setting of {@link #allowReserved(boolean)}. * * @param programCounter the ProgramCounter in question * @return true if you may write to the location * @throws IllegalArgumentException if the ProgramCounter is negative */ public boolean isFree(int programCounter) { if (programCounter < 0) { throw new IllegalArgumentException("The Program-Counter may not be negative"); } if (instructions.size() - 1 < programCounter) return true; if (instructions.get(programCounter) == null) return true; if (instructions.get(programCounter).equals(RESERVED)) return false; return false; }
/** * This is horribly inefficient. * * @return the basic block which contains the instruction */ private static SSACFG.BasicBlock findBlock(IR ir, SSAInstruction s) { if (s == null) { Assertions.UNREACHABLE(); } for (ISSABasicBlock issaBasicBlock : ir.getControlFlowGraph()) { SSACFG.BasicBlock b = (SSACFG.BasicBlock) issaBasicBlock; for (SSAInstruction x : b) { if (s.equals(x)) { return b; } } } Assertions.UNREACHABLE("no block for " + s + " in IR " + ir); return null; }
/** * This is horribly inefficient. * * @return the basic block which contains the instruction */ private static SSACFG.BasicBlock findBlock(IR ir, SSAInstruction s) { if (s == null) { Assertions.UNREACHABLE(); } for (ISSABasicBlock issaBasicBlock : ir.getControlFlowGraph()) { SSACFG.BasicBlock b = (SSACFG.BasicBlock) issaBasicBlock; for (SSAInstruction x : b) { if (s.equals(x)) { return b; } } } Assertions.UNREACHABLE("no block for " + s + " in IR " + ir); return null; }