faster syntax highlighting

This commit is contained in:
honfika@gmail.com
2015-09-16 14:12:13 +02:00
parent 5e42c5b57c
commit e8fb8e2f37
41 changed files with 2129 additions and 2175 deletions

Binary file not shown.

View File

@@ -31,7 +31,7 @@ package com.jpexs.decompiler.flash.abc.methodinfo_parser;
%{
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
boolean isMultiname = false;
long multinameId = 0;

View File

@@ -34,7 +34,7 @@ import java.util.Stack;
%{
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
boolean isMultiname = false;
long multinameId = 0;

View File

@@ -52,7 +52,7 @@ import java.util.Stack;
yypushbackstr(s, YYINITIAL);
}
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
private static String xmlTagName = "";

View File

@@ -1,190 +1,190 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
/* Flash assembler language lexer specification */
package com.jpexs.decompiler.flash.action.parser.pcode;
import com.jpexs.decompiler.flash.action.parser.ActionParseException;
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
%%
%public
%class FlasmLexer
%final
%unicode
%char
%line
%column
%type ASMParsedSymbol
%throws ActionParseException
%{
StringBuffer string = new StringBuffer();
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public FlasmLexer() {
}
public int yychar() {
return yychar;
}
public int yyline() {
return yyline + 1;
}
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
Comment = ";" {InputCharacter}*
WhiteSpace = [ \t\f]+
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
InstructionName = [a-zA-Z][a-zA-Z0-9_]*
Label = {Identifier}:
StartOfBlock = "{"
EndOfBlock = "}"
True = "true"
False = "false"
False = "false"
Null = "null"
Undefined = "undefined"
Infinity = -? "Infinity"
/* integer literals */
PositiveNumberLiteral = 0 | [1-9][0-9]*
NegativeNumberLiteral = - {PositiveNumberLiteral}
NumberLiteral = {PositiveNumberLiteral}|{NegativeNumberLiteral}
/* floating point literals */
FloatLiteral = "NaN" | {Infinity} | -?(({FLit1}|{FLit2}|{FLit3}) {Exponent}?)
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
HexDigit = [0-9a-fA-F]
/* string and character literals */
StringCharacter = [^\r\n\"\\]
Register= register{PositiveNumberLiteral}
Constant= constant{PositiveNumberLiteral}
%state STRING,PARAMETERS
%%
<YYINITIAL> {
/* whitespace */
{WhiteSpace} { }
{Label} {
String s=yytext();
return new ASMParsedSymbol(ASMParsedSymbol.TYPE_LABEL, s.substring(0, s.length() - 1));
}
/* identifiers */
{InstructionName} { yybegin(PARAMETERS);
return new ASMParsedSymbol(ASMParsedSymbol.TYPE_INSTRUCTION_NAME, yytext());
}
{EndOfBlock} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BLOCK_END); }
}
<PARAMETERS> {
/* string literal */
\" {
yybegin(STRING);
string.setLength(0);
}
/* numeric literals */
{NumberLiteral} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_INTEGER, Long.parseLong((yytext()))); }
{FloatLiteral} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext()))); }
{LineTerminator} {yybegin(YYINITIAL); return new ASMParsedSymbol(ASMParsedSymbol.TYPE_EOL); }
{Comment} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_COMMENT, yytext().substring(1));}
{StartOfBlock} { yybegin(YYINITIAL); return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BLOCK_START); }
{True} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BOOLEAN,Boolean.TRUE);}
{False} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BOOLEAN,Boolean.FALSE);}
{Null} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_NULL, new Null());}
{Undefined} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_UNDEFINED, new Undefined());}
{Register} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_REGISTER, new RegisterNumber(Integer.parseInt(yytext().substring(8)))); }
{Constant} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_CONSTANT, new ConstantIndex(Integer.parseInt(yytext().substring(8)))); }
{Identifier} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_IDENTIFIER, yytext()); }
}
<STRING> {
\" {
yybegin(PARAMETERS);
// length also includes the trailing quote
return new ASMParsedSymbol(ASMParsedSymbol.TYPE_STRING, string.toString());
}
{StringCharacter}+ { string.append(yytext()); }
/* escape sequences */
"\\b" { string.append('\b'); }
"\\t" { string.append('\t'); }
"\\n" { string.append('\n'); }
"\\f" { string.append('\f'); }
"\\r" { string.append('\r'); }
"\\\"" { string.append('\"'); }
"\\'" { string.append('\''); }
"\\\\" { string.append('\\'); }
\\x{HexDigit}{2} { char val = (char) Integer.parseInt(yytext().substring(2), 16);
string.append(val); }
\\u{HexDigit}{4} { char val = (char) Integer.parseInt(yytext().substring(2), 16);
string.append(val); }
/* error cases */
\\. { throw new ActionParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); }
{LineTerminator} { throw new ActionParseException("Unterminated string at end of line", yyline + 1); }
}
/* error fallback */
[^] { }
<<EOF>> { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_EOF); }
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
/* Flash assembler language lexer specification */
package com.jpexs.decompiler.flash.action.parser.pcode;
import com.jpexs.decompiler.flash.action.parser.ActionParseException;
import com.jpexs.decompiler.flash.action.swf4.ConstantIndex;
import com.jpexs.decompiler.flash.action.swf4.RegisterNumber;
import com.jpexs.decompiler.flash.ecma.Null;
import com.jpexs.decompiler.flash.ecma.Undefined;
%%
%public
%class FlasmLexer
%final
%unicode
%char
%line
%column
%type ASMParsedSymbol
%throws ActionParseException
%{
StringBuilder string = new StringBuilder();
/**
* Create an empty lexer, yyrset will be called later to reset and assign
* the reader
*/
public FlasmLexer() {
}
public int yychar() {
return yychar;
}
public int yyline() {
return yyline + 1;
}
%}
/* main character classes */
LineTerminator = \r|\n|\r\n
InputCharacter = [^\r\n]
Comment = ";" {InputCharacter}*
WhiteSpace = [ \t\f]+
/* identifiers */
Identifier = [:jletter:][:jletterdigit:]*
InstructionName = [a-zA-Z][a-zA-Z0-9_]*
Label = {Identifier}:
StartOfBlock = "{"
EndOfBlock = "}"
True = "true"
False = "false"
False = "false"
Null = "null"
Undefined = "undefined"
Infinity = -? "Infinity"
/* integer literals */
PositiveNumberLiteral = 0 | [1-9][0-9]*
NegativeNumberLiteral = - {PositiveNumberLiteral}
NumberLiteral = {PositiveNumberLiteral}|{NegativeNumberLiteral}
/* floating point literals */
FloatLiteral = "NaN" | {Infinity} | -?(({FLit1}|{FLit2}|{FLit3}) {Exponent}?)
FLit1 = [0-9]+ \. [0-9]*
FLit2 = \. [0-9]+
FLit3 = [0-9]+
Exponent = [eE] [+-]? [0-9]+
HexDigit = [0-9a-fA-F]
/* string and character literals */
StringCharacter = [^\r\n\"\\]
Register= register{PositiveNumberLiteral}
Constant= constant{PositiveNumberLiteral}
%state STRING,PARAMETERS
%%
<YYINITIAL> {
/* whitespace */
{WhiteSpace} { }
{Label} {
String s=yytext();
return new ASMParsedSymbol(ASMParsedSymbol.TYPE_LABEL, s.substring(0, s.length() - 1));
}
/* identifiers */
{InstructionName} { yybegin(PARAMETERS);
return new ASMParsedSymbol(ASMParsedSymbol.TYPE_INSTRUCTION_NAME, yytext());
}
{EndOfBlock} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BLOCK_END); }
}
<PARAMETERS> {
/* string literal */
\" {
yybegin(STRING);
string.setLength(0);
}
/* numeric literals */
{NumberLiteral} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_INTEGER, Long.parseLong((yytext()))); }
{FloatLiteral} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_FLOAT, Double.parseDouble((yytext()))); }
{LineTerminator} {yybegin(YYINITIAL); return new ASMParsedSymbol(ASMParsedSymbol.TYPE_EOL); }
{Comment} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_COMMENT, yytext().substring(1));}
{StartOfBlock} { yybegin(YYINITIAL); return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BLOCK_START); }
{True} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BOOLEAN,Boolean.TRUE);}
{False} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_BOOLEAN,Boolean.FALSE);}
{Null} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_NULL, Null.INSTANCE);}
{Undefined} {return new ASMParsedSymbol(ASMParsedSymbol.TYPE_UNDEFINED, Undefined.INSTANCE);}
{Register} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_REGISTER, new RegisterNumber(Integer.parseInt(yytext().substring(8)))); }
{Constant} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_CONSTANT, new ConstantIndex(Integer.parseInt(yytext().substring(8)))); }
{Identifier} { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_IDENTIFIER, yytext()); }
}
<STRING> {
\" {
yybegin(PARAMETERS);
// length also includes the trailing quote
return new ASMParsedSymbol(ASMParsedSymbol.TYPE_STRING, string.toString());
}
{StringCharacter}+ { string.append(yytext()); }
/* escape sequences */
"\\b" { string.append('\b'); }
"\\t" { string.append('\t'); }
"\\n" { string.append('\n'); }
"\\f" { string.append('\f'); }
"\\r" { string.append('\r'); }
"\\\"" { string.append('\"'); }
"\\'" { string.append('\''); }
"\\\\" { string.append('\\'); }
\\x{HexDigit}{2} { char val = (char) Integer.parseInt(yytext().substring(2), 16);
string.append(val); }
\\u{HexDigit}{4} { char val = (char) Integer.parseInt(yytext().substring(2), 16);
string.append(val); }
/* error cases */
\\. { throw new ActionParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); }
{LineTerminator} { throw new ActionParseException("Unterminated string at end of line", yyline + 1); }
}
/* error fallback */
[^] { }
<<EOF>> { return new ASMParsedSymbol(ASMParsedSymbol.TYPE_EOF); }

View File

@@ -32,7 +32,7 @@ import java.util.Stack;
%{
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
private static String xmlTagName = "";

View File

@@ -31,7 +31,7 @@ package com.jpexs.decompiler.flash.tags.text;
%{
StringBuffer string = null;
StringBuilder string = null;
boolean finish = false;
boolean parameter = false;
String parameterName = null;
@@ -74,22 +74,22 @@ HexDigit = [0-9a-fA-F]
}
}
/* escape sequences */
"\\[" { if (string == null) string = new StringBuffer(); string.append('['); }
"\\]" { if (string == null) string = new StringBuffer(); string.append(']'); }
"\\b" { if (string == null) string = new StringBuffer(); string.append('\b'); }
"\\t" { if (string == null) string = new StringBuffer(); string.append('\t'); }
"\\n" { if (string == null) string = new StringBuffer(); string.append('\n'); }
"\\f" { if (string == null) string = new StringBuffer(); string.append('\f'); }
"\\r" { if (string == null) string = new StringBuffer(); string.append('\r'); }
"\\\"" { if (string == null) string = new StringBuffer(); string.append('\"'); }
"\\'" { if (string == null) string = new StringBuffer(); string.append('\''); }
"\\\\" { if (string == null) string = new StringBuffer(); string.append('\\'); }
"\\[" { if (string == null) string = new StringBuilder(); string.append('['); }
"\\]" { if (string == null) string = new StringBuilder(); string.append(']'); }
"\\b" { if (string == null) string = new StringBuilder(); string.append('\b'); }
"\\t" { if (string == null) string = new StringBuilder(); string.append('\t'); }
"\\n" { if (string == null) string = new StringBuilder(); string.append('\n'); }
"\\f" { if (string == null) string = new StringBuilder(); string.append('\f'); }
"\\r" { if (string == null) string = new StringBuilder(); string.append('\r'); }
"\\\"" { if (string == null) string = new StringBuilder(); string.append('\"'); }
"\\'" { if (string == null) string = new StringBuilder(); string.append('\''); }
"\\\\" { if (string == null) string = new StringBuilder(); string.append('\\'); }
\\x{HexDigit}{HexDigit} { char val = (char) Integer.parseInt(yytext().substring(2), 16);
string.append(val); }
/* error cases */
\\. { throw new TextParseException("Illegal escape sequence \"" + yytext() + "\"", yyline + 1); }
. { if (string == null) string = new StringBuffer(); string.append(yytext()); }
. { if (string == null) string = new StringBuilder(); string.append(yytext()); }
<<EOF>> { if (finish) {return null;} else {finish=true; return new ParsedSymbol(SymbolType.TEXT, string == null ? null : string.toString());}}
}
@@ -118,5 +118,5 @@ HexDigit = [0-9a-fA-F]
}
/* error fallback */
[^] { if (!parameter) { if (string == null) string = new StringBuffer(); string.append(yytext()); } }
[^] { if (!parameter) { if (string == null) string = new StringBuilder(); string.append(yytext()); } }
<<EOF>> { return null; }

View File

@@ -1788,7 +1788,7 @@ public final class SWF implements SWFContainerItem, Timelined {
// for..in return
if (((ins instanceof ActionEquals) || (ins instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueActionItem)) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
stack.push(new DirectValueActionItem(null, 0, Null.INSTANCE, new ArrayList<>()));
}
if (ins instanceof ActionConstantPool) {

View File

@@ -154,9 +154,9 @@ public class AVM2DeobfuscatorSimple implements SWFDecompilerListener {
} else if (graphTargetItem instanceof FalseItem) {
return makePush(Boolean.FALSE, cpool);
} else if (graphTargetItem instanceof NullAVM2Item) {
return makePush(new Null(), cpool);
return makePush(Null.INSTANCE, cpool);
} else if (graphTargetItem instanceof UndefinedAVM2Item) {
return makePush(new Undefined(), cpool);
return makePush(Undefined.INSTANCE, cpool);
} else {
return null;
}

View File

@@ -77,7 +77,7 @@ public class CoerceAVM2Item extends AVM2Item {
return ret;
}
if (ret instanceof Undefined) {
return new Null();
return Null.INSTANCE;
}
return ret.toString();
case "*":

View File

@@ -49,7 +49,7 @@ public class NullAVM2Item extends AVM2Item {
@Override
public Object getResult() {
return new Null();
return Null.INSTANCE;
}
@Override

View File

@@ -49,7 +49,7 @@ public class UndefinedAVM2Item extends AVM2Item {
@Override
public Object getResult() {
return new Undefined();
return Undefined.INSTANCE;
}
@Override

View File

@@ -24,8 +24,9 @@ import java.util.Stack;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0 from the specification file
* <tt>D:/Dropbox/Programovani/JavaSE/FFDec/libsrc/ffdec_lib/lexers/actionscript3_pcode.flex</tt>
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0
* from the specification file
* <tt>C:/FFDec/jpexs-decompiler/libsrc/ffdec_lib/lexers/actionscript3_pcode.flex</tt>
*/
public final class Flasm3Lexer {
@@ -50,8 +51,9 @@ public final class Flasm3Lexer {
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the
* beginning of a line l is of the form l = 2*k, k a non negative integer
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
* at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1, 2, 2
@@ -2579,8 +2581,8 @@ public final class Flasm3Lexer {
private int zzLexicalState = YYINITIAL;
/**
* this buffer contains the current text to be matched and is the source of
* the yytext() string
* this buffer contains the current text to be matched and is
* the source of the yytext() string
*/
private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
@@ -2600,8 +2602,8 @@ public final class Flasm3Lexer {
private int zzStartRead;
/**
* endRead marks the last character in the buffer, that has been read from
* input
* endRead marks the last character in the buffer, that has been read
* from input
*/
private int zzEndRead;
@@ -2637,15 +2639,15 @@ public final class Flasm3Lexer {
private boolean zzEOFDone;
/**
* The number of occupied positions in zzBuffer beyond zzEndRead. When a
* lead/high surrogate has been read from the input stream into the final
* zzBuffer position, this will have a value of 1; otherwise, it will have a
* value of 0.
* The number of occupied positions in zzBuffer beyond zzEndRead.
* When a lead/high surrogate has been read from the input stream
* into the final zzBuffer position, this will have a value of 1;
* otherwise, it will have a value of 0.
*/
private int zzFinalHighSurrogate = 0;
/* user code: */
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
boolean isMultiname = false;
@@ -2780,8 +2782,6 @@ public final class Flasm3Lexer {
/**
* Closes the input stream.
*
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
zzAtEOF = true; /* indicate end of file */
@@ -2794,12 +2794,12 @@ public final class Flasm3Lexer {
}
/**
* Resets the scanner to read from a new input stream. Does not close the
* old reader.
* Resets the scanner to read from a new input stream.
* Does not close the old reader.
*
* All internal variables are reset, the old input stream
* <b>cannot</b> be reused (internal buffer is discarded and lost). Lexical
* state is set to <tt>ZZ_INITIAL</tt>.
* <b>cannot</b> be reused (internal buffer is discarded and lost).
* Lexical state is set to <tt>ZZ_INITIAL</tt>.
*
* Internal scan buffer is resized down to its initial length, if it has
* grown.
@@ -2823,8 +2823,6 @@ public final class Flasm3Lexer {
/**
* Returns the current lexical state.
*
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -2841,20 +2839,19 @@ public final class Flasm3Lexer {
/**
* Returns the text matched by the current regular expression.
*
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
}
/**
* Returns the character at position <tt>pos</tt> from the matched text.
* Returns the character at position <tt>pos</tt> from the
* matched text.
*
* It is equivalent to yytext().charAt(pos), but faster
*
* @param pos the position of the character to fetch. A value from 0 to
* yylength()-1.
* @param pos the position of the character to fetch.
* A value from 0 to yylength()-1.
*
* @return the character at position pos
*/
@@ -2864,8 +2861,6 @@ public final class Flasm3Lexer {
/**
* Returns the length of the matched text region.
*
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -2874,13 +2869,14 @@ public final class Flasm3Lexer {
/**
* Reports an error that occured while scanning.
*
* In a wellformed scanner (no or only correct usage of yypushback(int) and
* a match-all fallback rule) this method will only be called with things
* that "Can't Possibly Happen". If this method is called, something is
* seriously wrong (e.g. a JFlex bug producing a faulty scanner etc.).
* In a wellformed scanner (no or only correct usage of
* yypushback(int) and a match-all fallback rule) this method
* will only be called with things that "Can't Possibly Happen".
* If this method is called, something is seriously wrong
* (e.g. a JFlex bug producing a faulty scanner etc.).
*
* Usual syntax/scanner level error handling should be done in error
* fallback rules.
* Usual syntax/scanner level error handling should be done
* in error fallback rules.
*
* @param errorCode the code of the errormessage to display
*/
@@ -2900,8 +2896,8 @@ public final class Flasm3Lexer {
*
* They will be read again by then next call of the scanning method
*
* @param number the number of characters to be read again. This number must
* not be greater than yylength()!
* @param number the number of characters to be read again.
* This number must not be greater than yylength()!
*/
public void yypushback(int number) {
if (number > yylength()) {
@@ -2912,12 +2908,11 @@ public final class Flasm3Lexer {
}
/**
* Resumes scanning until the next regular expression is matched, the end of
* input is encountered or an I/O-Error occurs.
* Resumes scanning until the next regular expression is matched,
* the end of input is encountered or an I/O-Error occurs.
*
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
* @throws com.jpexs.decompiler.flash.abc.avm2.parser.AVM2ParseException
*/
public ParsedSymbol yylex() throws java.io.IOException, AVM2ParseException {
int zzInput;

View File

@@ -21,8 +21,9 @@ package com.jpexs.decompiler.flash.abc.methodinfo_parser;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0 from the specification file
* <tt>D:/Dropbox/Programovani/JavaSE/FFDec/libsrc/ffdec_lib/lexers/actionscript3_methodinfo.flex</tt>
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0
* from the specification file
* <tt>C:/FFDec/jpexs-decompiler/libsrc/ffdec_lib/lexers/actionscript3_methodinfo.flex</tt>
*/
public final class MethodInfoLexer {
@@ -45,8 +46,9 @@ public final class MethodInfoLexer {
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the
* beginning of a line l is of the form l = 2*k, k a non negative integer
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
* at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
0, 0, 1, 1
@@ -547,8 +549,8 @@ public final class MethodInfoLexer {
private int zzLexicalState = YYINITIAL;
/**
* this buffer contains the current text to be matched and is the source of
* the yytext() string
* this buffer contains the current text to be matched and is
* the source of the yytext() string
*/
private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
@@ -568,8 +570,8 @@ public final class MethodInfoLexer {
private int zzStartRead;
/**
* endRead marks the last character in the buffer, that has been read from
* input
* endRead marks the last character in the buffer, that has been read
* from input
*/
private int zzEndRead;
@@ -605,15 +607,15 @@ public final class MethodInfoLexer {
private boolean zzEOFDone;
/**
* The number of occupied positions in zzBuffer beyond zzEndRead. When a
* lead/high surrogate has been read from the input stream into the final
* zzBuffer position, this will have a value of 1; otherwise, it will have a
* value of 0.
* The number of occupied positions in zzBuffer beyond zzEndRead.
* When a lead/high surrogate has been read from the input stream
* into the final zzBuffer position, this will have a value of 1;
* otherwise, it will have a value of 0.
*/
private int zzFinalHighSurrogate = 0;
/* user code: */
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
boolean isMultiname = false;
@@ -729,8 +731,6 @@ public final class MethodInfoLexer {
/**
* Closes the input stream.
*
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
zzAtEOF = true; /* indicate end of file */
@@ -743,12 +743,12 @@ public final class MethodInfoLexer {
}
/**
* Resets the scanner to read from a new input stream. Does not close the
* old reader.
* Resets the scanner to read from a new input stream.
* Does not close the old reader.
*
* All internal variables are reset, the old input stream
* <b>cannot</b> be reused (internal buffer is discarded and lost). Lexical
* state is set to <tt>ZZ_INITIAL</tt>.
* <b>cannot</b> be reused (internal buffer is discarded and lost).
* Lexical state is set to <tt>ZZ_INITIAL</tt>.
*
* Internal scan buffer is resized down to its initial length, if it has
* grown.
@@ -772,8 +772,6 @@ public final class MethodInfoLexer {
/**
* Returns the current lexical state.
*
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -790,20 +788,19 @@ public final class MethodInfoLexer {
/**
* Returns the text matched by the current regular expression.
*
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
}
/**
* Returns the character at position <tt>pos</tt> from the matched text.
* Returns the character at position <tt>pos</tt> from the
* matched text.
*
* It is equivalent to yytext().charAt(pos), but faster
*
* @param pos the position of the character to fetch. A value from 0 to
* yylength()-1.
* @param pos the position of the character to fetch.
* A value from 0 to yylength()-1.
*
* @return the character at position pos
*/
@@ -813,8 +810,6 @@ public final class MethodInfoLexer {
/**
* Returns the length of the matched text region.
*
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -823,13 +818,14 @@ public final class MethodInfoLexer {
/**
* Reports an error that occured while scanning.
*
* In a wellformed scanner (no or only correct usage of yypushback(int) and
* a match-all fallback rule) this method will only be called with things
* that "Can't Possibly Happen". If this method is called, something is
* seriously wrong (e.g. a JFlex bug producing a faulty scanner etc.).
* In a wellformed scanner (no or only correct usage of
* yypushback(int) and a match-all fallback rule) this method
* will only be called with things that "Can't Possibly Happen".
* If this method is called, something is seriously wrong
* (e.g. a JFlex bug producing a faulty scanner etc.).
*
* Usual syntax/scanner level error handling should be done in error
* fallback rules.
* Usual syntax/scanner level error handling should be done
* in error fallback rules.
*
* @param errorCode the code of the errormessage to display
*/
@@ -849,8 +845,8 @@ public final class MethodInfoLexer {
*
* They will be read again by then next call of the scanning method
*
* @param number the number of characters to be read again. This number must
* not be greater than yylength()!
* @param number the number of characters to be read again.
* This number must not be greater than yylength()!
*/
public void yypushback(int number) {
if (number > yylength()) {
@@ -861,13 +857,11 @@ public final class MethodInfoLexer {
}
/**
* Resumes scanning until the next regular expression is matched, the end of
* input is encountered or an I/O-Error occurs.
* Resumes scanning until the next regular expression is matched,
* the end of input is encountered or an I/O-Error occurs.
*
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
* @throws
* com.jpexs.decompiler.flash.abc.methodinfo_parser.MethodInfoParseException
*/
public ParsedSymbol yylex() throws java.io.IOException, MethodInfoParseException {
int zzInput;

View File

@@ -268,7 +268,7 @@ public class ActionGraph extends Graph {
}
}
if (switchedObject == null) {
switchedObject = new DirectValueActionItem(null, -1, new Null(), null);
switchedObject = new DirectValueActionItem(null, -1, Null.INSTANCE, null);
}
HashMap<Integer, GraphTargetItem> caseValuesMap = new HashMap<>();

View File

@@ -1065,10 +1065,10 @@ public class ActionListReader {
} else if (!(a instanceof GraphSourceItemContainer)) {
//return in for..in, TODO:Handle this better way
if (((a instanceof ActionEquals) || (a instanceof ActionEquals2)) && (stack.size() == 1) && (stack.peek() instanceof DirectValueActionItem)) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
stack.push(new DirectValueActionItem(null, 0, Null.INSTANCE, new ArrayList<>()));
}
if ((a instanceof ActionStoreRegister) && stack.isEmpty()) {
stack.push(new DirectValueActionItem(null, 0, new Null(), new ArrayList<>()));
stack.push(new DirectValueActionItem(null, 0, Null.INSTANCE, new ArrayList<>()));
}
a.translate(localData, stack, output, Graph.SOP_USE_STATIC/*Graph.SOP_SKIP_STATIC*/, path);
}

View File

@@ -94,7 +94,7 @@ public class DirectValueActionItem extends ActionItem implements SimpleValue {
return (this.constants.get(((ConstantIndex) value).index));
}
if (value instanceof RegisterNumber) {
return new Undefined(); //has not computed value
return Undefined.INSTANCE; //has not computed value
}
return value;
}

View File

@@ -97,7 +97,7 @@ public class GetVariableActionItem extends ActionItem {
@Override
public Object getResult() {
if (computedValue == null) {
return new Undefined();
return Undefined.INSTANCE;
}
return computedResult;
}

View File

@@ -71,7 +71,7 @@ public class ReturnActionItem extends ActionItem implements ExitItem {
int forinlevel = asGenerator.getForInLevel(localData);
for (int i = 0; i < forinlevel; i++) { //Must POP all remaining values from enumerations (for..in)
List<Action> forinret = new ArrayList<>();
forinret.add(new ActionPush(new Null()));
forinret.add(new ActionPush(Null.INSTANCE));
forinret.add(new ActionEquals2());
forinret.add(new ActionNot());
ActionIf aforinif = new ActionIf(0);
@@ -80,7 +80,7 @@ public class ReturnActionItem extends ActionItem implements ExitItem {
ret.addAll(forinret);
}
if (value == null) {
ret.add(new ActionPush(new Undefined()));
ret.add(new ActionPush(Undefined.INSTANCE));
} else {
ret.addAll(value.toSource(localData, generator));
}

View File

@@ -132,7 +132,7 @@ public class ForInActionItem extends LoopActionItem implements Block {
int exprReg = asGenerator.getTempRegister(localData);
loopExpr.add(new ActionStoreRegister(exprReg));
loopExpr.add(new ActionPush(new Null()));
loopExpr.add(new ActionPush(Null.INSTANCE));
loopExpr.add(new ActionEquals2());
ActionIf forInEndIf = new ActionIf(0);
loopExpr.add(forInEndIf);

View File

@@ -947,7 +947,7 @@ public class ActionScript2Parser {
List<GraphTargetItem> args = call(inFunction, inMethod, variables);
VariableActionItem supItem = new VariableActionItem(s.value.toString(), null, false);
variables.add(supItem);
ret = new CallMethodActionItem(null, supItem, new DirectValueActionItem(null, 0, new Undefined(), constantPool), args);
ret = new CallMethodActionItem(null, supItem, new DirectValueActionItem(null, 0, Undefined.INSTANCE, constantPool), args);
} else {//no costructor call, but it could be calling parent methods... => handle in expression
lexer.pushback(ss2);
lexer.pushback(s);
@@ -1142,7 +1142,7 @@ public class ActionScript2Parser {
case RETURN:
GraphTargetItem retexpr = expression(inFunction, inMethod, true, variables);
if (retexpr == null) {
retexpr = new DirectValueActionItem(null, 0, new Undefined(), new ArrayList<>());
retexpr = new DirectValueActionItem(null, 0, Undefined.INSTANCE, new ArrayList<>());
}
ret = new ReturnActionItem(null, retexpr);
break;
@@ -1621,11 +1621,11 @@ public class ActionScript2Parser {
break;
case NULL:
ret = new DirectValueActionItem(null, 0, new Null(), new ArrayList<>());
ret = new DirectValueActionItem(null, 0, Null.INSTANCE, new ArrayList<>());
break;
case UNDEFINED:
ret = new DirectValueActionItem(null, 0, new Undefined(), new ArrayList<>());
ret = new DirectValueActionItem(null, 0, Undefined.INSTANCE, new ArrayList<>());
break;
case FALSE:
ret = new DirectValueActionItem(null, 0, Boolean.FALSE, new ArrayList<>());

View File

@@ -27,7 +27,7 @@ import java.util.Stack;
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0
* from the specification file
* <tt>C:/Dropbox/Programovani/JavaSE/FFDec/libsrc/ffdec_lib/lexers/actionscript_script.flex</tt>
* <tt>C:/FFDec/jpexs-decompiler/libsrc/ffdec_lib/lexers/actionscript_script.flex</tt>
*/
public final class ActionScriptLexer {
@@ -1268,7 +1268,7 @@ public final class ActionScriptLexer {
private int zzFinalHighSurrogate = 0;
/* user code: */
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
private static String xmlTagName = "";

View File

@@ -723,7 +723,7 @@ public class ActionSourceGenerator implements SourceGenerator {
if (!isInterface) {
ifbody.add(new ActionPush((Long) 1L));
ifbody.add(new ActionPush(new Null()));
ifbody.add(new ActionPush(Null.INSTANCE));
ifbody.addAll(typeToActions(globalClassTypeStr, null));
ifbody.add(pushConst("prototype"));
ifbody.add(new ActionGetMember());

View File

@@ -99,10 +99,10 @@ public class ActionPush extends Action {
values.add(sis.readFLOAT("float"));
break;
case 2:
values.add(new Null());
values.add(Null.INSTANCE);
break;
case 3:
values.add(new Undefined());
values.add(Undefined.INSTANCE);
break;
case 4:
values.add(new RegisterNumber(sis.readUI8("registerNumber")));

View File

@@ -1,18 +1,19 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.ecma;
/**
@@ -93,11 +94,8 @@ public class EcmaScript {
if (type(px) != EcmaType.STRING || type(py) != EcmaType.STRING) {
Double nx = toNumber(px);
Double ny = toNumber(py);
Double ny = toNumber(py);
if (nx.isNaN()) {
return new Undefined();
}
if (ny.isNaN()) {
if (nx.isNaN() || ny.isNaN()) {
return Undefined.INSTANCE;
}
if ((nx).compareTo(ny) == 0) {
return false;

View File

@@ -1,24 +1,30 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.ecma;
import java.io.Serializable;
public class Null implements Serializable {
public static Null INSTANCE = new Null();
private Null() {
}
@Override
public String toString() {
return "null";

View File

@@ -1,24 +1,30 @@
/*
* Copyright (C) 2010-2015 JPEXS, All rights reserved.
*
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
* License along with this library.
*/
package com.jpexs.decompiler.flash.ecma;
import java.io.Serializable;
public class Undefined implements Serializable {
public static Undefined INSTANCE = new Undefined();
private Undefined() {
}
@Override
public String toString() {
return "undefined";

View File

@@ -22,7 +22,7 @@ package com.jpexs.decompiler.flash.tags.text;
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0
* from the specification file
* <tt>C:/Projects/FFDec/jpexs-decompiler/libsrc/ffdec_lib/lexers/text.flex</tt>
* <tt>C:/FFDec/jpexs-decompiler/libsrc/ffdec_lib/lexers/text.flex</tt>
*/
public final class TextLexer {
@@ -303,7 +303,7 @@ public final class TextLexer {
private int zzFinalHighSurrogate = 0;
/* user code: */
StringBuffer string = null;
StringBuilder string = null;
boolean finish = false;
@@ -696,7 +696,7 @@ public final class TextLexer {
switch (zzAction < 0 ? zzAction : ZZ_ACTION[zzAction]) {
case 1: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append(yytext());
}
@@ -716,7 +716,7 @@ public final class TextLexer {
case 3: {
if (!parameter) {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append(yytext());
}
@@ -752,7 +752,7 @@ public final class TextLexer {
break;
case 9: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append(']');
}
@@ -760,7 +760,7 @@ public final class TextLexer {
break;
case 10: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('[');
}
@@ -768,7 +768,7 @@ public final class TextLexer {
break;
case 11: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\\');
}
@@ -776,7 +776,7 @@ public final class TextLexer {
break;
case 12: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\b');
}
@@ -784,7 +784,7 @@ public final class TextLexer {
break;
case 13: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\t');
}
@@ -792,7 +792,7 @@ public final class TextLexer {
break;
case 14: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\n');
}
@@ -800,7 +800,7 @@ public final class TextLexer {
break;
case 15: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\f');
}
@@ -808,7 +808,7 @@ public final class TextLexer {
break;
case 16: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\r');
}
@@ -816,7 +816,7 @@ public final class TextLexer {
break;
case 17: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\"');
}
@@ -824,7 +824,7 @@ public final class TextLexer {
break;
case 18: {
if (string == null) {
string = new StringBuffer();
string = new StringBuilder();
}
string.append('\'');
}

View File

@@ -22,8 +22,9 @@ import java.util.Stack;
/**
* This class is a scanner generated by
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0 from the specification file
* <tt>D:/Dropbox/Programovani/JavaSE/FFDec/libsrc/ffdec_lib/lexers/tag_conditions.flex</tt>
* <a href="http://www.jflex.de/">JFlex</a> 1.6.0
* from the specification file
* <tt>C:/FFDec/jpexs-decompiler/libsrc/ffdec_lib/lexers/tag_conditions.flex</tt>
*/
public final class ConditionLexer {
@@ -44,8 +45,9 @@ public final class ConditionLexer {
/**
* ZZ_LEXSTATE[l] is the state in the DFA for the lexical state l
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l at the
* beginning of a line l is of the form l = 2*k, k a non negative integer
* ZZ_LEXSTATE[l+1] is the state in the DFA for the lexical state l
* at the beginning of a line
* l is of the form l = 2*k, k a non negative integer
*/
private static final int ZZ_LEXSTATE[] = {
0, 0
@@ -221,8 +223,8 @@ public final class ConditionLexer {
private int zzLexicalState = YYINITIAL;
/**
* this buffer contains the current text to be matched and is the source of
* the yytext() string
* this buffer contains the current text to be matched and is
* the source of the yytext() string
*/
private char zzBuffer[] = new char[ZZ_BUFFERSIZE];
@@ -242,8 +244,8 @@ public final class ConditionLexer {
private int zzStartRead;
/**
* endRead marks the last character in the buffer, that has been read from
* input
* endRead marks the last character in the buffer, that has been read
* from input
*/
private int zzEndRead;
@@ -279,10 +281,10 @@ public final class ConditionLexer {
private boolean zzEOFDone;
/**
* The number of occupied positions in zzBuffer beyond zzEndRead. When a
* lead/high surrogate has been read from the input stream into the final
* zzBuffer position, this will have a value of 1; otherwise, it will have a
* value of 0.
* The number of occupied positions in zzBuffer beyond zzEndRead.
* When a lead/high surrogate has been read from the input stream
* into the final zzBuffer position, this will have a value of 1;
* otherwise, it will have a value of 0.
*/
private int zzFinalHighSurrogate = 0;
@@ -413,8 +415,6 @@ public final class ConditionLexer {
/**
* Closes the input stream.
*
* @throws java.io.IOException
*/
public final void yyclose() throws java.io.IOException {
zzAtEOF = true; /* indicate end of file */
@@ -427,12 +427,12 @@ public final class ConditionLexer {
}
/**
* Resets the scanner to read from a new input stream. Does not close the
* old reader.
* Resets the scanner to read from a new input stream.
* Does not close the old reader.
*
* All internal variables are reset, the old input stream
* <b>cannot</b> be reused (internal buffer is discarded and lost). Lexical
* state is set to <tt>ZZ_INITIAL</tt>.
* <b>cannot</b> be reused (internal buffer is discarded and lost).
* Lexical state is set to <tt>ZZ_INITIAL</tt>.
*
* Internal scan buffer is resized down to its initial length, if it has
* grown.
@@ -456,8 +456,6 @@ public final class ConditionLexer {
/**
* Returns the current lexical state.
*
* @return
*/
public final int yystate() {
return zzLexicalState;
@@ -474,20 +472,19 @@ public final class ConditionLexer {
/**
* Returns the text matched by the current regular expression.
*
* @return
*/
public final String yytext() {
return new String(zzBuffer, zzStartRead, zzMarkedPos - zzStartRead);
}
/**
* Returns the character at position <tt>pos</tt> from the matched text.
* Returns the character at position <tt>pos</tt> from the
* matched text.
*
* It is equivalent to yytext().charAt(pos), but faster
*
* @param pos the position of the character to fetch. A value from 0 to
* yylength()-1.
* @param pos the position of the character to fetch.
* A value from 0 to yylength()-1.
*
* @return the character at position pos
*/
@@ -497,8 +494,6 @@ public final class ConditionLexer {
/**
* Returns the length of the matched text region.
*
* @return
*/
public final int yylength() {
return zzMarkedPos - zzStartRead;
@@ -507,13 +502,14 @@ public final class ConditionLexer {
/**
* Reports an error that occured while scanning.
*
* In a wellformed scanner (no or only correct usage of yypushback(int) and
* a match-all fallback rule) this method will only be called with things
* that "Can't Possibly Happen". If this method is called, something is
* seriously wrong (e.g. a JFlex bug producing a faulty scanner etc.).
* In a wellformed scanner (no or only correct usage of
* yypushback(int) and a match-all fallback rule) this method
* will only be called with things that "Can't Possibly Happen".
* If this method is called, something is seriously wrong
* (e.g. a JFlex bug producing a faulty scanner etc.).
*
* Usual syntax/scanner level error handling should be done in error
* fallback rules.
* Usual syntax/scanner level error handling should be done
* in error fallback rules.
*
* @param errorCode the code of the errormessage to display
*/
@@ -533,8 +529,8 @@ public final class ConditionLexer {
*
* They will be read again by then next call of the scanning method
*
* @param number the number of characters to be read again. This number must
* not be greater than yylength()!
* @param number the number of characters to be read again.
* This number must not be greater than yylength()!
*/
public void yypushback(int number) {
if (number > yylength()) {
@@ -545,13 +541,11 @@ public final class ConditionLexer {
}
/**
* Resumes scanning until the next regular expression is matched, the end of
* input is encountered or an I/O-Error occurs.
* Resumes scanning until the next regular expression is matched,
* the end of input is encountered or an I/O-Error occurs.
*
* @return the next token
* @exception java.io.IOException if any I/O-Error occurs
* @throws
* com.jpexs.decompiler.flash.types.annotations.parser.AnnotationParseException
*/
public ConditionToken yylex() throws java.io.IOException, AnnotationParseException {
int zzInput;

View File

@@ -39,14 +39,12 @@ public class NotItem extends UnaryOpItem implements LogicalOpItem, Inverted {
@Override
public Object getResult() {
Object ret = EcmaScript.toBoolean(value.getResult());
if (ret == Boolean.TRUE) {
boolean ret = EcmaScript.toBoolean(value.getResult());
if (ret) {
return Boolean.FALSE;
}
if (ret == Boolean.FALSE) {
} else {
return Boolean.TRUE;
}
return ret;
}
@Override

View File

@@ -51,6 +51,6 @@ public class PopItem extends GraphTargetItem {
@Override
public Object getResult() {
return new Null();
return Null.INSTANCE;
}
}

View File

@@ -41,6 +41,7 @@ public class SyntaxDocument extends PlainDocument {
Lexer lexer;
List<Token> tokens;
CompoundUndoMan undo;
boolean ignoreUpdate;
public SyntaxDocument(Lexer lexer) {
super();
@@ -62,12 +63,12 @@ public class SyntaxDocument extends PlainDocument {
tokens = null;
return;
}
List<Token> toks = new ArrayList<Token>(getLength() / 10);
long ts = System.nanoTime();
int len = getLength();
List<Token> toks = new ArrayList<Token>(len / 10);
long ts = System.nanoTime();
try {
Segment seg = new Segment();
getText(0, getLength(), seg);
getText(0, len, seg);
lexer.parse(seg, 0, toks);
} catch (BadLocationException ex) {
log.log(Level.SEVERE, null, ex);
@@ -88,6 +89,9 @@ public class SyntaxDocument extends PlainDocument {
@Override
protected void fireInsertUpdate(DocumentEvent e) {
if (ignoreUpdate) {
return;
}
parse();
super.fireInsertUpdate(e);
}
@@ -98,6 +102,13 @@ public class SyntaxDocument extends PlainDocument {
super.fireRemoveUpdate(e);
}
public void setIgnoreUpdate(boolean value) {
ignoreUpdate = value;
if (!ignoreUpdate) {
parse();
}
}
/**
* Replace the token with the replacement string
* @param token

View File

@@ -21,6 +21,7 @@ import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
@@ -221,9 +222,18 @@ public class LineNumbersRuler extends JPanel
int maxLines = ActionUtils.getLineCount(editor);
SyntaxView.setRenderingHits((Graphics2D) g);
Rectangle bounds = g.getClipBounds();
int minY = bounds.y;
int maxY = minY + bounds.height;
for (int line = 1; line <= maxLines; line++) {
String lineNumber = String.format(numbersFormat, line);
int y = line * lh;
if (y < minY) {
continue;
}
if (y - lh > maxY) {
break;
}
String lineNumber = String.format(numbersFormat, line);
if (line == currentLine) {
g.setColor(currentLineColor);
g.fillRect(0, y - lh + fontMetrics.getDescent() - 1, getWidth(), lh);

View File

@@ -355,6 +355,6 @@ Preprocessor = \u00A7\u00A7 {Identifier}
}
/* error fallback */
.|\n { }
[^] { }
<<EOF>> { return null; }

View File

@@ -18,7 +18,7 @@ import jsyntaxpane.TokenType;
%{
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
/**
@@ -150,5 +150,5 @@ Constant= constant{NumberLiteral}
}
/* error fallback */
.|\n { }
[^] { }
<<EOF>> { return null; }

View File

@@ -19,7 +19,7 @@ import jsyntaxpane.TokenType;
%{
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
boolean isMultiname=false;
@@ -249,5 +249,5 @@ ExceptionTarget = "exceptiontarget "{PositiveNumberLiteral}":"
}
/* error fallback */
.|\n { }
[^] { }
<<EOF>> { return null; }

View File

@@ -18,7 +18,7 @@ import jsyntaxpane.TokenType;
%{
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
boolean isMultiname=false;
@@ -146,5 +146,5 @@ StringCharacter = [^\r\n\"\\]
}
/* error fallback */
.|\n { }
[^] { }
<<EOF>> { return null; }

View File

@@ -18,7 +18,7 @@ import jsyntaxpane.TokenType;
%{
StringBuffer string = new StringBuffer();
StringBuilder string = new StringBuilder();
private int tokenStart = -1;
private static final byte BRACKET = 1;
@@ -89,5 +89,5 @@ Divider = [ \r\n]+
}
/* error fallback */
.|\n { }
[^] { }
<<EOF>> { return null; }

View File

@@ -123,12 +123,19 @@ public class UndoFixedEditorPane extends JEditorPane {
Stopwatch sw = Stopwatch.startNew();
try {
Document doc = getDocument();
setDocument(new SyntaxDocument(null));
doc.remove(0, doc.getLength());
Reader r = new StringReader(t);
EditorKit kit = createEditorKitForContentType(contentType);
Document doc = kit.createDefaultDocument();
if (doc instanceof SyntaxDocument) {
((SyntaxDocument) doc).setIgnoreUpdate(true);
}
kit.read(r, doc, 0);
if (doc instanceof SyntaxDocument) {
((SyntaxDocument) doc).setIgnoreUpdate(false);
}
setDocument(doc);
} catch (BadLocationException | IOException ex) {
Logger.getLogger(UndoFixedEditorPane.class.getName()).log(Level.SEVERE, null, ex);