private void throwOdexedInstructionException(IntStream input, String odexedInstruction) throws OdexedInstructionException { /*this has to be done in a separate method, otherwise java will complain about the auto-generated code in the rule after the throw not being reachable*/ throw new OdexedInstructionException(input, odexedInstruction); }
public String getErrorHeader(RecognitionException e) { return getSourceName()+"["+ e.line+","+e.charPositionInLine+"]"; }
public String getErrorHeader(RecognitionException e) { return getSourceName()+"["+ e.line+","+e.charPositionInLine+"]"; }
public static BuilderClassDef parse(String path, InputStream is, DexBuilder dexBuilder) throws UnsupportedEncodingException, RecognitionException { File smaliFile = new File(path); InputStreamReader reader = new InputStreamReader(is, "UTF-8"); LexerErrorInterface lexer = new smaliFlexLexer(reader); ((smaliFlexLexer) lexer).setSourceFile(smaliFile); CommonTokenStream tokens = new CommonTokenStream((TokenSource) lexer); smaliParser parser = new smaliParser(tokens); parser.setApiLevel(DEFAULT_API_LEVEL); smaliParser.smali_file_return result = parser.smali_file(); if ((parser.getNumberOfSyntaxErrors() > 0) || (lexer.getNumberOfSyntaxErrors() > 0)) { throw new RuntimeException("Unable to parse: " + smaliFile); } CommonTree t = result.getTree(); CommonTreeNodeStream treeStream = new CommonTreeNodeStream(t); treeStream.setTokenStream(tokens); smaliTreeWalker dexGen = new smaliTreeWalker(treeStream); dexGen.setVerboseErrors(false); dexGen.setDexBuilder(dexBuilder); BuilderClassDef classDef = (BuilderClassDef) dexGen.smali_file(); if (dexGen.getNumberOfSyntaxErrors() != 0) { throw new RuntimeException("Unable to walk: " + smaliFile); } return classDef; }
public final ImmutableFieldReference field_literal() throws RecognitionException { ImmutableFieldReference value = null; TreeRuleReturnScope field_reference241 =null; try { // smaliTreeWalker.g:1418:3: ( ^( I_ENCODED_FIELD field_reference ) ) // smaliTreeWalker.g:1418:5: ^( I_ENCODED_FIELD field_reference ) { match(input,I_ENCODED_FIELD,FOLLOW_I_ENCODED_FIELD_in_field_literal4013); match(input, Token.DOWN, null); pushFollow(FOLLOW_field_reference_in_field_literal4015); field_reference241=field_reference(); state._fsp--; match(input, Token.UP, null); value = (field_reference241!=null?((smaliTreeWalker.field_reference_return)field_reference241).fieldReference:null); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "field_literal"
public final ImmutableMethodReference method_literal() throws RecognitionException { ImmutableMethodReference value = null; ImmutableMethodReference method_reference242 =null; try { // smaliTreeWalker.g:1424:3: ( ^( I_ENCODED_METHOD method_reference ) ) // smaliTreeWalker.g:1424:5: ^( I_ENCODED_METHOD method_reference ) { match(input,I_ENCODED_METHOD,FOLLOW_I_ENCODED_METHOD_in_method_literal4036); match(input, Token.DOWN, null); pushFollow(FOLLOW_method_reference_in_method_literal4038); method_reference242=method_reference(); state._fsp--; match(input, Token.UP, null); value = method_reference242; } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "method_literal"
public final ImmutableMethodHandleReference method_handle_literal() throws RecognitionException { ImmutableMethodHandleReference value = null; ImmutableMethodHandleReference method_handle_reference85 =null; try { // smaliTreeWalker.g:541:3: ( ( I_ENCODED_METHOD_HANDLE method_handle_reference ) ) // smaliTreeWalker.g:541:5: ( I_ENCODED_METHOD_HANDLE method_handle_reference ) { // smaliTreeWalker.g:541:5: ( I_ENCODED_METHOD_HANDLE method_handle_reference ) // smaliTreeWalker.g:541:6: I_ENCODED_METHOD_HANDLE method_handle_reference { match(input,I_ENCODED_METHOD_HANDLE,FOLLOW_I_ENCODED_METHOD_HANDLE_in_method_handle_literal1294); pushFollow(FOLLOW_method_handle_reference_in_method_handle_literal1296); method_handle_reference85=method_handle_reference(); state._fsp--; } value = method_handle_reference85; } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "method_handle_literal"
public final byte byte_literal() throws RecognitionException { byte value = 0; CommonTree BYTE_LITERAL227=null; try { // smaliTreeWalker.g:1351:3: ( BYTE_LITERAL ) // smaliTreeWalker.g:1351:5: BYTE_LITERAL { BYTE_LITERAL227=(CommonTree)match(input,BYTE_LITERAL,FOLLOW_BYTE_LITERAL_in_byte_literal3736); value = LiteralTools.parseByte((BYTE_LITERAL227!=null?BYTE_LITERAL227.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "byte_literal"
public final int integer_literal() throws RecognitionException { int value = 0; CommonTree INTEGER_LITERAL224=null; try { // smaliTreeWalker.g:1342:3: ( INTEGER_LITERAL ) // smaliTreeWalker.g:1342:5: INTEGER_LITERAL { INTEGER_LITERAL224=(CommonTree)match(input,INTEGER_LITERAL,FOLLOW_INTEGER_LITERAL_in_integer_literal3691); value = LiteralTools.parseInt((INTEGER_LITERAL224!=null?INTEGER_LITERAL224.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "integer_literal"
public final short short_literal() throws RecognitionException { short value = 0; CommonTree SHORT_LITERAL226=null; try { // smaliTreeWalker.g:1348:3: ( SHORT_LITERAL ) // smaliTreeWalker.g:1348:5: SHORT_LITERAL { SHORT_LITERAL226=(CommonTree)match(input,SHORT_LITERAL,FOLLOW_SHORT_LITERAL_in_short_literal3721); value = LiteralTools.parseShort((SHORT_LITERAL226!=null?SHORT_LITERAL226.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "short_literal"
public final long long_literal() throws RecognitionException { long value = 0; CommonTree LONG_LITERAL225=null; try { // smaliTreeWalker.g:1345:3: ( LONG_LITERAL ) // smaliTreeWalker.g:1345:5: LONG_LITERAL { LONG_LITERAL225=(CommonTree)match(input,LONG_LITERAL,FOLLOW_LONG_LITERAL_in_long_literal3706); value = LiteralTools.parseLong((LONG_LITERAL225!=null?LONG_LITERAL225.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "long_literal"
public final float float_literal() throws RecognitionException { float value = 0.0f; CommonTree FLOAT_LITERAL228=null; try { // smaliTreeWalker.g:1354:3: ( FLOAT_LITERAL ) // smaliTreeWalker.g:1354:5: FLOAT_LITERAL { FLOAT_LITERAL228=(CommonTree)match(input,FLOAT_LITERAL,FOLLOW_FLOAT_LITERAL_in_float_literal3751); value = LiteralTools.parseFloat((FLOAT_LITERAL228!=null?FLOAT_LITERAL228.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "float_literal"
public final double double_literal() throws RecognitionException { double value = 0.0; CommonTree DOUBLE_LITERAL229=null; try { // smaliTreeWalker.g:1357:3: ( DOUBLE_LITERAL ) // smaliTreeWalker.g:1357:5: DOUBLE_LITERAL { DOUBLE_LITERAL229=(CommonTree)match(input,DOUBLE_LITERAL,FOLLOW_DOUBLE_LITERAL_in_double_literal3766); value = LiteralTools.parseDouble((DOUBLE_LITERAL229!=null?DOUBLE_LITERAL229.getText():null)); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "double_literal"
private static boolean compileSmali(File input, File output) { try { SmaliOptions params = new SmaliOptions(); params.outputDexFile = output.getAbsolutePath(); Smali.assemble(params, input.getAbsolutePath()); } catch (Exception e) { throw new AssertionError("Smali assemble error", e); } return true; } }
/** * Assemble the specified files, using the given options * * @param options a SmaliOptions object with the options to run smali with * @param input The files/directories to process * @return true if assembly completed with no errors, or false if errors were encountered */ public static boolean assemble(final SmaliOptions options, String... input) throws IOException { return assemble(options, Arrays.asList(input)); }
public final void mSTRING_LITERAL() throws RecognitionException { try { int _type = STRING_LITERAL; int _channel = DEFAULT_TOKEN_CHANNEL; StringBuilder sb = new StringBuilder(); // org/jf/smali/expectedTokensTestGrammar.g:129:2: ( BASE_STRING_LITERAL[sb] ) // org/jf/smali/expectedTokensTestGrammar.g:129:4: BASE_STRING_LITERAL[sb] { mBASE_STRING_LITERAL(sb); setText(sb.toString()); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "STRING_LITERAL"
public final void mT__12() throws RecognitionException { try { int _type = T__12; int _channel = DEFAULT_TOKEN_CHANNEL; // org/jf/smali/expectedTokensTestGrammar.g:7:7: ( ')' ) // org/jf/smali/expectedTokensTestGrammar.g:7:9: ')' { match(')'); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "T__12"
public final void mHEX_DIGITS() throws RecognitionException { try { // org/jf/smali/expectedTokensTestGrammar.g:110:2: ( HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT ) // org/jf/smali/expectedTokensTestGrammar.g:110:4: HEX_DIGIT HEX_DIGIT HEX_DIGIT HEX_DIGIT { mHEX_DIGIT(); mHEX_DIGIT(); mHEX_DIGIT(); mHEX_DIGIT(); } } finally { // do for sure before leaving } } // $ANTLR end "HEX_DIGITS"
public final ImmutableFieldReference enum_literal() throws RecognitionException { ImmutableFieldReference value = null; TreeRuleReturnScope field_reference243 =null; try { // smaliTreeWalker.g:1430:3: ( ^( I_ENCODED_ENUM field_reference ) ) // smaliTreeWalker.g:1430:5: ^( I_ENCODED_ENUM field_reference ) { match(input,I_ENCODED_ENUM,FOLLOW_I_ENCODED_ENUM_in_enum_literal4059); match(input, Token.DOWN, null); pushFollow(FOLLOW_field_reference_in_enum_literal4061); field_reference243=field_reference(); state._fsp--; match(input, Token.UP, null); value = (field_reference243!=null?((smaliTreeWalker.field_reference_return)field_reference243).fieldReference:null); } } catch (RecognitionException re) { reportError(re); recover(input,re); } finally { // do for sure before leaving } return value; } // $ANTLR end "enum_literal"
public final void mT__11() throws RecognitionException { try { int _type = T__11; int _channel = DEFAULT_TOKEN_CHANNEL; // org/jf/smali/expectedTokensTestGrammar.g:6:7: ( '(' ) // org/jf/smali/expectedTokensTestGrammar.g:6:9: '(' { match('('); } state.type = _type; state.channel = _channel; } finally { // do for sure before leaving } } // $ANTLR end "T__11"