PostInstructionRegisterInfoMethodItem.java revision ffe82bdcb5c914b3a60b630c6d3abe6fc9229dec
1/* 2 * [The "BSD licence"] 3 * Copyright (c) 2010 Ben Gruver 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 3. The name of the author may not be used to endorse or promote products 15 * derived from this software without specific prior written permission. 16 * 17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 * INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 */ 28 29package org.jf.baksmali.Adaptors; 30 31//TODO: uncomment 32/*public class PostInstructionRegisterInfoMethodItem extends MethodItem { 33 private final AnalyzedInstruction analyzedInstruction; 34 private final MethodAnalyzer methodAnalyzer; 35 36 public PostInstructionRegisterInfoMethodItem(AnalyzedInstruction analyzedInstruction, MethodAnalyzer methodAnalyzer, 37 int codeAddress) { 38 super(codeAddress); 39 this.analyzedInstruction = analyzedInstruction; 40 this.methodAnalyzer = methodAnalyzer; 41 } 42 43 @Override 44 public double getSortOrder() { 45 return 100.1; 46 } 47 48 @Override 49 public boolean writeTo(IndentingWriter writer) throws IOException { 50 int registerInfo = baksmali.registerInfo; 51 int registerCount = analyzedInstruction.getRegisterCount(); 52 BitSet registers = new BitSet(registerCount); 53 54 if ((registerInfo & main.ALL) != 0) { 55 registers.set(0, registerCount); 56 } else { 57 if ((registerInfo & main.ALLPOST) != 0) { 58 registers.set(0, registerCount); 59 } else if ((registerInfo & main.DEST) != 0) { 60 addDestRegs(registers, registerCount); 61 } 62 } 63 64 return writeRegisterInfo(writer, registers); 65 } 66 67 private void addDestRegs(BitSet printPostRegister, int registerCount) { 68 for (int registerNum=0; registerNum<registerCount; registerNum++) { 69 if (analyzedInstruction.getPreInstructionRegisterType(registerNum) != 70 analyzedInstruction.getPostInstructionRegisterType(registerNum)) { 71 printPostRegister.set(registerNum); 72 } 73 } 74 } 75 76 private boolean writeRegisterInfo(IndentingWriter writer, BitSet registers) throws IOException { 77 ClassDataItem.EncodedMethod encodedMethod = methodAnalyzer.getMethod(); 78 79 int registerNum = registers.nextSetBit(0); 80 if (registerNum < 0) { 81 return false; 82 } 83 84 writer.write('#'); 85 for (; registerNum >= 0; registerNum = registers.nextSetBit(registerNum + 1)) { 86 87 RegisterType registerType = analyzedInstruction.getPostInstructionRegisterType(registerNum); 88 89 RegisterFormatter.writeTo(writer, encodedMethod.codeItem, registerNum); 90 writer.write('='); 91 92 if (registerType == null) { 93 writer.write("null"); 94 } else { 95 registerType.writeTo(writer); 96 } 97 writer.write(';'); 98 } 99 return true; 100 } 101}*/ 102