/* (non-Javadoc) * @see com.k99k.smali.Sentence#exec() */ @Override public boolean exec() { this.doComm(this.line); this.line = this.line.replaceAll(",", ""); String[] ws = this.line.split(" "); if (ws.length < 2) { this.out.append("exec move error. line:").append(this.line); this.mgr.err(this); log.error(this.mgr.getMeth().getName() + " moveERR:" + this.line); return false; } String key = ws[0]; if (key.startsWith("move-result")) { Sentence last = null; // 向上定位到非STRUCT句 for (int i = 0; i < this.lineNum; i++) { last = this.mgr.getLastSentence(i); if (last == null) { this.out.append("exec move error. last sentence is null. line:").append(this.line); this.mgr.err(this); log.error(this.mgr.getMeth().getName() + " moveERR:" + this.line); return false; } else if (last.getType() == Sentence.TYPE_STRUCT) { continue; } if (last.getVar() == null) { this.out.append("exec move error. last sentence's var is null. line:").append(this.line); this.mgr.err(this); log.error(this.mgr.getMeth().getName() + " moveERR:" + this.line); return false; } else { break; } } // 使用前一个invoke语句生成的Var,改变其name后加入到Var集合 Var v = last.getVar(); String name = ws[1]; Var leftVar = this.mgr.getVar(name); if (leftVar != null && ComputeSentence.isLocalVar(leftVar, this.mgr.isStatic())) { this.out.append(leftVar.getOut()).append(" = "); this.type = Sentence.TYPE_LINE; } else { v.setName(name); this.mgr.setVar(v); } this.var = v; this.out.append(v.getOut()); // this.setOut(v.getOut()); // 将last语句显示去掉 last.setType(Sentence.TYPE_NOT_LINE); last.over(); } else if (key.equals("move-exception")) { // 不处理,已由try catch处理 Var v1 = this.mgr.getVar(ws[1]); if (v1 == null) { v1 = new Var(this); } v1.setOut("[exception]"); v1.setClassName(ws[0]); v1.setKey("move-exception"); v1.setSen(this); v1.setValue("[exception]"); this.mgr.setVar(v1); } else { // move变量 Var v1 = this.mgr.getVar(ws[1]); Var v2 = this.mgr.getVar(ws[2]); boolean show = false; if (v1 == null) { v1 = new Var(this); v1.setName(ws[1]); v1.setKey(ws[0]); v1.setClassName(v2.getClassName()); v1.setOut(v2.getOut()); show = false; } else { show = ComputeSentence.isLocalVar(v1, this.mgr.isStatic()); // v1.setSen(this); // if (ws[0].startsWith("move-object") || v1.isUsed() || // StringUtil.isDigits(v1.getOut())|| v1.getOut().equals(v2.getOut())) { // //引用的变化导致需要输出也要变动,另外move用过的v1,out为数字的v1也需要变动 // //FIXME move-object引用变化可能有风险 // v1.setOut(v2.getOut()); // show = false; // } } // v2.setName(ws[1]); v1.setValue(v2.getValue()); this.mgr.setVar(v1); this.var = v1; if (show && (!v2.getOut().equals("[exception]"))) { this.setOut(v1.getOut() + " = " + v2.getOut()); this.type = Sentence.TYPE_LINE; } else { v1.setOut(v2.getOut()); } // //FIXME // 用过了,目前仅在move中使用,还有get,put,cast,compute(compute应该不能用),未使用,如果使用需要注意v1==v2的情况,另注意p0,p1的情况 // if (v2.getSen() != null) { // //非参数的设置成used // v2.setUsed(true); // } } this.over(); return true; }