mirror of
https://github.com/revanced/smali.git
synced 2025-05-23 18:16:23 +02:00
Fix an NPE when generating the error message for the case of multiple .locals or .registers directives in a method
git-svn-id: https://smali.googlecode.com/svn/trunk@722 55b6fa8a-2a1e-11de-a435-ffa8d773f76a
This commit is contained in:
parent
af7330e5d5
commit
9f69ec12ea
@ -341,12 +341,12 @@ statements_and_directives
|
||||
|
||||
registers_directive
|
||||
: (
|
||||
REGISTERS_DIRECTIVE regCount=integral_literal -> ^(I_REGISTERS[$REGISTERS_DIRECTIVE, "I_REGISTERS"] $regCount)
|
||||
| LOCALS_DIRECTIVE regCount2=integral_literal -> ^(I_LOCALS[$LOCALS_DIRECTIVE, "I_LOCALS"] $regCount2)
|
||||
directive=REGISTERS_DIRECTIVE regCount=integral_literal -> ^(I_REGISTERS[$REGISTERS_DIRECTIVE, "I_REGISTERS"] $regCount)
|
||||
| directive=LOCALS_DIRECTIVE regCount2=integral_literal -> ^(I_LOCALS[$LOCALS_DIRECTIVE, "I_LOCALS"] $regCount2)
|
||||
)
|
||||
{
|
||||
if ($statements_and_directives::hasRegistersDirective) {
|
||||
throw new SemanticException(input, $registers_directive.tree, "There can only be a single .registers or .locals directive in a method");
|
||||
throw new SemanticException(input, $directive, "There can only be a single .registers or .locals directive in a method");
|
||||
}
|
||||
$statements_and_directives::hasRegistersDirective=true;
|
||||
};
|
||||
|
@ -28,8 +28,10 @@
|
||||
|
||||
package org.jf.smali;
|
||||
|
||||
import org.antlr.runtime.CommonToken;
|
||||
import org.antlr.runtime.IntStream;
|
||||
import org.antlr.runtime.RecognitionException;
|
||||
import org.antlr.runtime.Token;
|
||||
import org.antlr.runtime.tree.CommonTree;
|
||||
|
||||
public class SemanticException extends RecognitionException {
|
||||
@ -56,6 +58,16 @@ public class SemanticException extends RecognitionException {
|
||||
this.errorMessage = String.format(errorMessage, messageArguments);
|
||||
}
|
||||
|
||||
SemanticException(IntStream input, Token token, String errorMessage, Object... messageArguments) {
|
||||
super();
|
||||
this.input = input;
|
||||
this.token = token;
|
||||
this.index = ((CommonToken)token).getStartIndex();
|
||||
this.line = token.getLine();
|
||||
this.charPositionInLine = token.getCharPositionInLine();
|
||||
this.errorMessage = String.format(errorMessage, messageArguments);
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user