@@ -22,7 +22,16 @@ public boolean performMutation(MutationLocation location, BufferedWriter writer,
2222 ASTMutationLocation mLocation = (ASTMutationLocation ) location ;
2323 CommonTree parent = (CommonTree ) mLocation .getTree ().getParent ();
2424 CommonTree cast = ASTHelper .getFirstBrotherNamedOfType (smaliParser .I_STATEMENT_FORMAT21c_TYPE , "check-cast" , parent );
25- String varName = cast .getChild (1 ).toString ();
25+ String varName = "" ;
26+ int position = -1 ;
27+ if (cast !=null && (cast .getLine ()-parent .getLine ()<5 )) {
28+ varName = cast .getChild (1 ).toString ();
29+ position = cast .getLine ();
30+ } else {
31+ CommonTree moveResultObject = ASTHelper .getFirstBrotherNamedOfType (smaliParser .I_STATEMENT_FORMAT11x , "move-result-object" , parent );
32+ varName = moveResultObject .getChild (1 ).toString ();
33+ position = moveResultObject .getLine ();
34+ }
2635
2736
2837 List <String > newLines = new ArrayList <String >();
@@ -38,13 +47,13 @@ public boolean performMutation(MutationLocation location, BufferedWriter writer,
3847 newLines .add (" const/4 " +varName +", 0x0" );
3948 newLines .add ("" );
4049
41- for (int i =cast . getLine () ; i < lines .size () ; i ++){
50+ for (int i =position ; i < lines .size () ; i ++){
4251 newLines .add (lines .get (i ));
4352 }
4453
4554 FileHelper .writeLines (location .getFilePath (), newLines );
4655 Helper .mutationSuccess (mutantIndex );
47- Helper .writeBasicLogInfo (mutantIndex , location .getFilePath (), location .getType ().getName (), new int [] {mLocation .getLine (), cast . getLine () }, writer );
56+ Helper .writeBasicLogInfo (mutantIndex , location .getFilePath (), location .getType ().getName (), new int [] {mLocation .getLine (), position }, writer );
4857 writer .write (" For mutant " +mutantIndex +" the element retrieved at line " +location .getStartLine ()+" has been set to null" );
4958 writer .newLine ();
5059 writer .flush ();
0 commit comments