Package com.litecoding.smali2java.entity.smali

Examples of com.litecoding.smali2java.entity.smali.Instruction


 
  /*
   * Internal methods
   */
  private Object generateCmdFromRules(ArrayList<Rule> rules) {
    Instruction command = null;
   
    boolean cmdDetermined = false;
    for(Rule innerRule : rules) {
      if(innerRule instanceof Rule_padding ||
        innerRule instanceof Rule_optPadding ||
        innerRule instanceof Rule_listSeparator)
        continue;
     
      if(innerRule instanceof Rule_codeLabel) {
          Label innerLabel = EntityFactory.createLabel(innerRule.rules.get(1).spelling);
          command.addArgument(innerLabel);
      } else if(innerRule instanceof Terminal_StringValue) {
        if(!cmdDetermined) {
          cmdDetermined = true;
          command = EntityFactory.createInstruction(innerRule.spelling, null);
        }       
      } else if(innerRule instanceof Rule_codeRegisterV ||
          innerRule instanceof Rule_codeRegisterVDst ||
          innerRule instanceof Rule_codeRegisterP ||
          innerRule instanceof Rule_codeRegister ||
          innerRule instanceof Rule_codeRegisterV64 ||
          innerRule instanceof Rule_codeRegisterV64Dst ||
          innerRule instanceof Rule_codeRegisterP64 ||
          innerRule instanceof Rule_codeRegister64 ||
          innerRule instanceof Rule_codeRegisterRet ||
          innerRule instanceof Rule_codeRegisterRet64 ||
          innerRule instanceof Rule_codeRegisterGroup ||
          innerRule instanceof Rule_smaliClassRef ||
          innerRule instanceof Rule_smaliFieldRef ||
          innerRule instanceof Rule_smaliMethodRef) {
        command.getArguments().add((SmaliCodeEntity)innerRule.accept(this));
      } else if(innerRule instanceof Rule_intValue ||
          innerRule instanceof Rule_strValue) {
        Value innerValue = new Value();
        innerValue.setName(innerRule.spelling);
        command.getArguments().add(innerValue);
      } else if(innerRule instanceof Rule_todoStubLine) {
        System.err.println("Warning: " + command.getName() + " is not fully supported");
      }
    }
       
    return command;
  }
View Full Code Here


      SmaliMethod smaliMethod, SmaliBlock rootBlock) {
    List<Renderable> entities = new ArrayList<Renderable>();
   
    SmaliClass smaliClass = smaliMethod.getSmaliClass();
    List<Instruction> instructions = rootBlock.instructions;
    Instruction instruction = instructions.get(0); //TODO: fix for super(CONST, ...)
    List<SmaliCodeEntity> args = instruction.getArguments();
   
    if("invoke-direct".equals(instruction.getOpcodeData().getName())) {
      //maybe this() or super() call
      MethodRef methodRef = (MethodRef) args.get(args.size() - 1);
     
      if(methodRef.isConstructor()) {
        //this is this() or super() call
View Full Code Here

    for(SmaliCodeEntity codeEntity : smaliMethod.getCommands()) {
      //label for outer breaking
      mainLoop:
   
      if(codeEntity instanceof Instruction) {
        Instruction instruction = (Instruction) codeEntity;
        switch(instruction.getOpcodeData().getType()) {
        case OpcodeData.TYPE_GOTO: {
          block.internalIsEmpty = false;
          block.isEndsByGoto = true;
          block.internalNextLabelIfTrue = (Label) instruction.getArguments().get(0);
         
          //register block in labeled & all
          if(block.smaliLabel != null)
            labeledBlocks.put(block.smaliLabel.getName(), block);
          allBlocks.add(block);
         
          block = new SmaliBlock();
          break mainLoop;
        }
        case OpcodeData.TYPE_CONDITION: {
          block.internalIsEmpty = false;
          block.isEndsByCondition = true;
          block.condition = instruction;
          block.internalNextLabelIfTrue =
              (Label) instruction.getArguments().get(instruction.getArguments().size() - 1);
                   
          //register block in labeled & all
          if(block.smaliLabel != null)
            labeledBlocks.put(block.smaliLabel.getName(), block);
          allBlocks.add(block);
View Full Code Here

  private static void buildBlockTimelineForward(ArrayList<Instruction> lines,
      RegisterTimeline timeline) {
    int linesCount = lines.size();
   
    //processing all instructions
    Instruction instruction = null;
    List<RegisterInfo> currSlice = null;
    List<RegisterInfo> prevSlice = null;
    for(int i = 0; i < linesCount; i++) {
      instruction = lines.get(i);
      prevSlice = currSlice;
      currSlice = timeline.getSlice(i);
     
      //filling type of destination register
      String dstType = "(UNKNOWN)";
      OpcodeData opcodeData = instruction.getOpcodeData();
      if(opcodeData.getType() == OpcodeData.TYPE_GET) {
        //TODO: handle aget*
        List<SmaliCodeEntity> args = instruction.getArguments();
        FieldRef srcField = (FieldRef) args.get(args.size() - 1);
        dstType = srcField.getType();
      } else if(opcodeData.getType() == OpcodeData.TYPE_CONST) {
        if(opcodeData.getOpcode() == Opcodes.OP_CONST_STRING)
          dstType = "Ljava/lang/String;";
        else
          dstType = "(BY CONST)";
      } else if(opcodeData.getType() == OpcodeData.TYPE_NEW) {
        if(opcodeData.getOpcode() == Opcodes.OP_NEW_INSTANCE) {
          List<SmaliCodeEntity> args = instruction.getArguments();
          ClassRef srcClass = (ClassRef) args.get(args.size() - 1);
          dstType = srcClass.getName();
        } else
          dstType = "(BY NEW)";
      }

     
      for(SmaliCodeEntity entity : instruction.getArguments()) {
        if(entity instanceof Register) {
          Register var = (Register) entity;
          boolean is64bit = var.info.is64bit;
          if(var.isParameter()) {
            int idx = var.getMappedId();
View Full Code Here

TOP

Related Classes of com.litecoding.smali2java.entity.smali.Instruction

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.