这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions smali/src/main/jflex/smaliLexer.jflex
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.jf.smali;

import static java.lang.Math.toIntExact;

import java.io.*;
import java.util.Stack;
import org.antlr.runtime.*;
Expand Down Expand Up @@ -104,9 +106,9 @@ import static org.jf.smali.smaliParser.*;
if (hidden) {
token.setChannel(Token.HIDDEN_CHANNEL);
}

token.setStartIndex(yychar);
token.setStopIndex(yychar + yylength() - 1);
// yychar is long, but antlr CommonToken only takes an int.
token.setStartIndex(toIntExact(yychar));
token.setStopIndex(stopIndex());
token.setLine(getLine());
token.setCharPositionInLine(getColumn());
return token;
Expand All @@ -126,9 +128,9 @@ import static org.jf.smali.smaliParser.*;

private Token invalidToken(String message, String text) {
InvalidToken token = new InvalidToken(message, text);

token.setStartIndex(yychar);
token.setStopIndex(yychar + yylength() - 1);
// yychar is long, but antlr CommonToken only takes an int.
token.setStartIndex(toIntExact(yychar));
token.setStopIndex(stopIndex());
token.setLine(getLine());
token.setCharPositionInLine(getColumn());

Expand All @@ -145,7 +147,8 @@ import static org.jf.smali.smaliParser.*;
sb.setLength(0);
tokenStartLine = getLine();
tokenStartCol = getColumn();
tokenStartChar = yychar;
// yychar is long, but antlr CommonToken only takes an int.
tokenStartChar = toIntExact(yychar);
tokenError = null;
}

Expand All @@ -158,7 +161,7 @@ import static org.jf.smali.smaliParser.*;

CommonToken token = new CommonToken(type, sb.toString());
token.setStartIndex(tokenStartChar);
token.setStopIndex(yychar + yylength() - 1);
token.setStopIndex(stopIndex());
token.setLine(tokenStartLine);
token.setCharPositionInLine(tokenStartCol);
return token;
Expand All @@ -175,7 +178,7 @@ import static org.jf.smali.smaliParser.*;

InvalidToken token = new InvalidToken(message, sb.toString());
token.setStartIndex(tokenStartChar);
token.setStopIndex(yychar + yylength() - 1);
token.setStopIndex(stopIndex());
token.setLine(tokenStartLine);
token.setCharPositionInLine(tokenStartCol);
return token;
Expand Down Expand Up @@ -211,6 +214,12 @@ import static org.jf.smali.smaliParser.*;
}
return processQuotedSimpleName(text);
}

private int stopIndex() {
// jflex yychar is long, but antlr CommonToken only takes an int for
// stopIndex.
return toIntExact(yychar + yylength() - 1);
}
%}

HexPrefix = 0 [xX]
Expand Down