mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Apply new checkstyle rules
This commit is contained in:
parent
c20209e651
commit
4548705620
|
@ -63,20 +63,19 @@
|
|||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoWhitespaceAfter">
|
||||
<property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS,TYPECAST"/>
|
||||
<property name="tokens" value="BNOT,DEC,DOT,INC,LNOT,UNARY_MINUS,UNARY_PLUS"/>
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="allowLineBreaks" value="true"/>
|
||||
<property name="tokens" value="SEMI,POST_DEC,POST_INC"/>
|
||||
</module>
|
||||
<module name="OperatorWrap">
|
||||
<property name="option" value="eol"/>
|
||||
</module>
|
||||
<module name="OperatorWrap"/>
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter">
|
||||
<property name="tokens" value="COMMA,SEMI"/>
|
||||
<property name="tokens" value="COMMA,SEMI,TYPECAST"/>
|
||||
</module>
|
||||
<module name="WhitespaceAround"/>
|
||||
</module>
|
||||
<module name="RegexpHeader">
|
||||
<property name="headerFile" value="${config_loc}/license-regexp.txt"/>
|
||||
|
|
6
pom.xml
6
pom.xml
|
@ -69,6 +69,7 @@
|
|||
<html4j.version>1.1</html4j.version>
|
||||
<jetty.version>9.2.1.v20140609</jetty.version>
|
||||
<slf4j.version>1.7.7</slf4j.version>
|
||||
<checker.version>1.9.3</checker.version>
|
||||
</properties>
|
||||
|
||||
<modules>
|
||||
|
@ -164,6 +165,11 @@
|
|||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.checkerframework</groupId>
|
||||
<artifactId>checker</artifactId>
|
||||
<version>${checker.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
|
|
@ -436,8 +436,8 @@ public class ChromeRDPDebugger implements JavaScriptDebugger, ChromeRDPExchangeC
|
|||
} else {
|
||||
CallFunctionResponse response = mapper.reader(CallFunctionResponse.class).readValue(node);
|
||||
RemoteObjectDTO result = response.getResult();
|
||||
sync.add(new RepresentationWrapper(result.getValue() != null ?
|
||||
result.getValue().getTextValue() : null));
|
||||
sync.add(new RepresentationWrapper(result.getValue() != null
|
||||
? result.getValue().getTextValue() : null));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ChromeRDPDebuggerEndpoint implements ChromeRDPExchange {
|
|||
session.setMaxIdleTimeout(0);
|
||||
Object debugger = session.getUserProperties().get("chrome.rdp");
|
||||
if (debugger instanceof ChromeRDPExchangeConsumer) {
|
||||
this.debugger = (ChromeRDPExchangeConsumer)debugger;
|
||||
this.debugger = (ChromeRDPExchangeConsumer) debugger;
|
||||
this.debugger.setExchange(this);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ public class RDPValue implements JavaScriptValue {
|
|||
this.debugger = debugger;
|
||||
this.objectId = objectId;
|
||||
this.innerStructure = innerStructure;
|
||||
properties = objectId != null ? new RDPScope(debugger, objectId) :
|
||||
Collections.<String, RDPLocalVariable>emptyMap();
|
||||
properties = objectId != null ? new RDPScope(debugger, objectId)
|
||||
: Collections.<String, RDPLocalVariable>emptyMap();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -69,7 +69,7 @@ public class RDPValue implements JavaScriptValue {
|
|||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public Map<String, JavaScriptVariable> getProperties() {
|
||||
return (Map<String, JavaScriptVariable>)properties;
|
||||
return (Map<String, JavaScriptVariable>) properties;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -149,7 +149,7 @@ public final class TeaVMTestRunner {
|
|||
}
|
||||
|
||||
try {
|
||||
return (TestAdapter)cons.newInstance();
|
||||
return (TestAdapter) cons.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
System.err.println("Error instantiating adapter: " + adapterName);
|
||||
e.printStackTrace(System.err);
|
||||
|
@ -187,7 +187,7 @@ public final class TeaVMTestRunner {
|
|||
}
|
||||
|
||||
try {
|
||||
return (ClassHolderTransformer)cons.newInstance();
|
||||
return (ClassHolderTransformer) cons.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
System.err.println("Error instantiating transformer: " + transformerName);
|
||||
e.printStackTrace(System.err);
|
||||
|
|
|
@ -45,6 +45,10 @@
|
|||
<artifactId>hppc</artifactId>
|
||||
<version>0.6.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.checkerframework</groupId>
|
||||
<artifactId>checker</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<name>TeaVM core</name>
|
||||
|
|
|
@ -71,7 +71,7 @@ public class AstIO {
|
|||
node.getModifiers().addAll(unpackModifiers(input.readInt()));
|
||||
int varCount = input.readShort();
|
||||
for (int i = 0; i < varCount; ++i) {
|
||||
node.getVariables().add((int)input.readShort());
|
||||
node.getVariables().add((int) input.readShort());
|
||||
}
|
||||
int paramDebugNameCount = input.readShort();
|
||||
for (int i = 0; i < paramDebugNameCount; ++i) {
|
||||
|
@ -116,7 +116,7 @@ public class AstIO {
|
|||
node.getModifiers().addAll(unpackModifiers(input.readInt()));
|
||||
int varCount = input.readShort();
|
||||
for (int i = 0; i < varCount; ++i) {
|
||||
node.getVariables().add((int)input.readShort());
|
||||
node.getVariables().add((int) input.readShort());
|
||||
}
|
||||
int paramDebugNameCount = input.readShort();
|
||||
for (int i = 0; i < paramDebugNameCount; ++i) {
|
||||
|
@ -345,10 +345,10 @@ public class AstIO {
|
|||
try {
|
||||
output.writeByte(16);
|
||||
writeSequence(statement.getProtectedBody());
|
||||
output.writeInt(statement.getExceptionType() != null ?
|
||||
symbolTable.lookup(statement.getExceptionType()) : -1);
|
||||
output.writeShort(statement.getExceptionVariable() != null ?
|
||||
statement.getExceptionVariable() : -1);
|
||||
output.writeInt(statement.getExceptionType() != null
|
||||
? symbolTable.lookup(statement.getExceptionType()) : -1);
|
||||
output.writeShort(statement.getExceptionVariable() != null
|
||||
? statement.getExceptionVariable() : -1);
|
||||
writeSequence(statement.getHandler());
|
||||
} catch (IOException e) {
|
||||
throw new IOExceptionWrapper(e);
|
||||
|
@ -430,19 +430,19 @@ public class AstIO {
|
|||
output.writeByte(3);
|
||||
} else if (value instanceof Integer) {
|
||||
output.writeByte(4);
|
||||
output.writeInt((Integer)value);
|
||||
output.writeInt((Integer) value);
|
||||
} else if (value instanceof Long) {
|
||||
output.writeByte(5);
|
||||
output.writeLong((Long)value);
|
||||
output.writeLong((Long) value);
|
||||
} else if (value instanceof Float) {
|
||||
output.writeByte(6);
|
||||
output.writeFloat((Float)value);
|
||||
output.writeFloat((Float) value);
|
||||
} else if (value instanceof Double) {
|
||||
output.writeByte(7);
|
||||
output.writeDouble((Double)value);
|
||||
output.writeDouble((Double) value);
|
||||
} else if (value instanceof String) {
|
||||
output.writeByte(8);
|
||||
output.writeUTF((String)value);
|
||||
output.writeUTF((String) value);
|
||||
} else if (value instanceof ValueType) {
|
||||
output.writeByte(9);
|
||||
output.writeInt(symbolTable.lookup(value.toString()));
|
||||
|
|
|
@ -157,19 +157,19 @@ public class DiskCachedClassHolderSource implements ClassHolderSource {
|
|||
output.writeByte(0);
|
||||
} else if (value instanceof Integer) {
|
||||
output.writeByte(1);
|
||||
output.writeInt((Integer)value);
|
||||
output.writeInt((Integer) value);
|
||||
} else if (value instanceof Long) {
|
||||
output.writeByte(2);
|
||||
output.writeLong((Long)value);
|
||||
output.writeLong((Long) value);
|
||||
} else if (value instanceof Float) {
|
||||
output.writeByte(3);
|
||||
output.writeFloat((Float)value);
|
||||
output.writeFloat((Float) value);
|
||||
} else if (value instanceof Double) {
|
||||
output.writeByte(4);
|
||||
output.writeDouble((Double)value);
|
||||
output.writeDouble((Double) value);
|
||||
} else if (value instanceof String) {
|
||||
output.writeByte(5);
|
||||
output.writeUTF((String)value);
|
||||
output.writeUTF((String) value);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -155,8 +155,8 @@ public class DiskRegularMethodNodeCache implements MethodNodeCache {
|
|||
|
||||
private File getMethodFile(MethodReference method, boolean async) {
|
||||
File dir = new File(directory, method.getClassName().replace('.', '/'));
|
||||
return new File(dir, FileNameEncoder.encodeFileName(method.getDescriptor().toString()) + ".teavm-ast" +
|
||||
(async ? "-async" : ""));
|
||||
return new File(dir, FileNameEncoder.encodeFileName(method.getDescriptor().toString()) + ".teavm-ast"
|
||||
+ (async ? "-async" : ""));
|
||||
}
|
||||
|
||||
static class AstDependencyAnalyzer implements StatementVisitor, ExprVisitor {
|
||||
|
|
|
@ -67,8 +67,8 @@ public class ProgramIO {
|
|||
for (TryCatchBlock tryCatch : basicBlock.getTryCatchBlocks()) {
|
||||
data.writeInt(tryCatch.getExceptionType() != null ? symbolTable.lookup(
|
||||
tryCatch.getExceptionType()) : -1);
|
||||
data.writeShort(tryCatch.getExceptionVariable() != null ?
|
||||
tryCatch.getExceptionVariable().getIndex() : -1);
|
||||
data.writeShort(tryCatch.getExceptionVariable() != null
|
||||
? tryCatch.getExceptionVariable().getIndex() : -1);
|
||||
data.writeShort(tryCatch.getHandler().getIndex());
|
||||
}
|
||||
InstructionLocation location = null;
|
||||
|
@ -87,7 +87,7 @@ public class ProgramIO {
|
|||
}
|
||||
insn.acceptVisitor(insnWriter);
|
||||
} catch (IOExceptionWrapper e) {
|
||||
throw (IOException)e.getCause();
|
||||
throw (IOException) e.getCause();
|
||||
}
|
||||
}
|
||||
data.writeByte(-1);
|
||||
|
|
|
@ -41,8 +41,8 @@ public class DefaultCallGraph implements CallGraph {
|
|||
@Override
|
||||
public Collection<DefaultFieldAccessSite> getFieldAccess(FieldReference reference) {
|
||||
Set<DefaultFieldAccessSite> resultSet = fieldAccessSites.get(reference);
|
||||
return resultSet != null ? Collections.unmodifiableSet(resultSet) :
|
||||
Collections.<DefaultFieldAccessSite>emptySet();
|
||||
return resultSet != null ? Collections.unmodifiableSet(resultSet)
|
||||
: Collections.<DefaultFieldAccessSite>emptySet();
|
||||
}
|
||||
|
||||
void addFieldAccess(DefaultFieldAccessSite accessSite) {
|
||||
|
@ -57,8 +57,8 @@ public class DefaultCallGraph implements CallGraph {
|
|||
@Override
|
||||
public Collection<DefaultClassAccessSite> getClassAccess(String className) {
|
||||
Set<DefaultClassAccessSite> resultSet = classAccessSites.get(className);
|
||||
return resultSet != null ? Collections.unmodifiableSet(resultSet) :
|
||||
Collections.<DefaultClassAccessSite>emptySet();
|
||||
return resultSet != null ? Collections.unmodifiableSet(resultSet)
|
||||
: Collections.<DefaultClassAccessSite>emptySet();
|
||||
}
|
||||
|
||||
void addClassAccess(DefaultClassAccessSite accessSite) {
|
||||
|
|
|
@ -56,9 +56,9 @@ public class DefaultCallSite implements CallSite {
|
|||
if (!(obj instanceof DefaultCallSite)) {
|
||||
return false;
|
||||
}
|
||||
DefaultCallSite other = (DefaultCallSite)obj;
|
||||
return Objects.equals(callee.getMethod(), other.callee.getMethod()) &&
|
||||
Objects.equals(location, other.location);
|
||||
DefaultCallSite other = (DefaultCallSite) obj;
|
||||
return Objects.equals(callee.getMethod(), other.callee.getMethod())
|
||||
&& Objects.equals(location, other.location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -61,9 +61,9 @@ public class DefaultClassAccessSite implements ClassAccessSite {
|
|||
if (!(obj instanceof DefaultClassAccessSite)) {
|
||||
return false;
|
||||
}
|
||||
DefaultClassAccessSite other = (DefaultClassAccessSite)obj;
|
||||
return Objects.equals(location, other.location) &&
|
||||
Objects.equals(callee, other.callee) &&
|
||||
Objects.equals(className, other.className);
|
||||
DefaultClassAccessSite other = (DefaultClassAccessSite) obj;
|
||||
return Objects.equals(location, other.location)
|
||||
&& Objects.equals(callee, other.callee)
|
||||
&& Objects.equals(className, other.className);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,8 +62,8 @@ public class DefaultFieldAccessSite implements FieldAccessSite {
|
|||
if (!(obj instanceof DefaultFieldAccessSite)) {
|
||||
return false;
|
||||
}
|
||||
DefaultFieldAccessSite other = (DefaultFieldAccessSite)obj;
|
||||
return Objects.equals(location, other.location) && Objects.equals(callee, other.callee) &&
|
||||
Objects.equals(field, other.field);
|
||||
DefaultFieldAccessSite other = (DefaultFieldAccessSite) obj;
|
||||
return Objects.equals(location, other.location) && Objects.equals(callee, other.callee)
|
||||
&& Objects.equals(field, other.field);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,8 +155,8 @@ public class DefaultNamingStrategy implements NamingStrategy {
|
|||
ClassReader clsHolder = classSource.get(cls);
|
||||
cls = clsHolder.getParent();
|
||||
if (cls == null) {
|
||||
throw new NamingException("Can't provide name for field as the field not found: " +
|
||||
initialCls + "." + field);
|
||||
throw new NamingException("Can't provide name for field as the field not found: "
|
||||
+ initialCls + "." + field);
|
||||
}
|
||||
}
|
||||
return cls;
|
||||
|
|
|
@ -46,7 +46,7 @@ public class SourceWriter implements Appendable, LocationProvider {
|
|||
}
|
||||
|
||||
public SourceWriter append(String value) throws IOException {
|
||||
append((CharSequence)value);
|
||||
append((CharSequence) value);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -154,7 +154,7 @@ public class SourceWriter implements Appendable, LocationProvider {
|
|||
}
|
||||
}
|
||||
|
||||
public SourceWriter newLine() throws IOException{
|
||||
public SourceWriter newLine() throws IOException {
|
||||
innerWriter.append('\n');
|
||||
column = 0;
|
||||
++line;
|
||||
|
@ -181,7 +181,7 @@ public class SourceWriter implements Appendable, LocationProvider {
|
|||
return this;
|
||||
}
|
||||
|
||||
public SourceWriter softNewLine() throws IOException{
|
||||
public SourceWriter softNewLine() throws IOException {
|
||||
if (!minified) {
|
||||
innerWriter.append('\n');
|
||||
column = 0;
|
||||
|
|
|
@ -40,8 +40,8 @@ public class DJGraph {
|
|||
|
||||
public DJGraph(Graph src, int[] weight) {
|
||||
if (src.size() != weight.length) {
|
||||
throw new IllegalArgumentException("Node count " + src.size() + " is not equal to weight array " +
|
||||
weight.length);
|
||||
throw new IllegalArgumentException("Node count " + src.size() + " is not equal to weight array "
|
||||
+ weight.length);
|
||||
}
|
||||
this.cfg = new MutableDirectedGraph(src);
|
||||
domTree = GraphUtils.buildDominatorTree(src);
|
||||
|
|
|
@ -95,8 +95,8 @@ public class Debugger {
|
|||
return;
|
||||
}
|
||||
CallFrame recentFrame = callStack[0];
|
||||
if (recentFrame.getLocation() == null || recentFrame.getLocation().getFileName() == null ||
|
||||
recentFrame.getLocation().getLine() < 0) {
|
||||
if (recentFrame.getLocation() == null || recentFrame.getLocation().getFileName() == null
|
||||
|| recentFrame.getLocation().getLine() < 0) {
|
||||
jsStep(enterMethod);
|
||||
return;
|
||||
}
|
||||
|
@ -105,8 +105,8 @@ public class Debugger {
|
|||
boolean exits;
|
||||
String script = frame.getOriginalLocation().getScript();
|
||||
DebugInformation debugInfo = debugInformationMap.get(script);
|
||||
if (frame.getLocation() != null && frame.getLocation().getFileName() != null &&
|
||||
frame.getLocation().getLine() >= 0 && debugInfo != null) {
|
||||
if (frame.getLocation() != null && frame.getLocation().getFileName() != null
|
||||
&& frame.getLocation().getLine() >= 0 && debugInfo != null) {
|
||||
exits = addFollowing(debugInfo, frame.getLocation(), script, new HashSet<>(), successors);
|
||||
if (enterMethod) {
|
||||
CallSiteSuccessorFinder successorFinder = new CallSiteSuccessorFinder(debugInfo, script,
|
||||
|
|
|
@ -116,13 +116,13 @@ public class DebugInformation {
|
|||
|
||||
public MethodReference getExactMethod(int index) {
|
||||
long item = exactMethods[index];
|
||||
int classIndex = (int)(item >>> 32);
|
||||
int methodIndex = (int)item;
|
||||
int classIndex = (int) (item >>> 32);
|
||||
int methodIndex = (int) item;
|
||||
return new MethodReference(classNames[classIndex], MethodDescriptor.parse(methods[methodIndex]));
|
||||
}
|
||||
|
||||
public int getExactMethodId(int classNameId, int methodId) {
|
||||
long full = ((long)classNameId << 32) | methodId;
|
||||
long full = ((long) classNameId << 32) | methodId;
|
||||
Integer id = exactMethodMap.get(full);
|
||||
return id != null ? id : -1;
|
||||
}
|
||||
|
@ -501,7 +501,7 @@ public class DebugInformation {
|
|||
int lastClass = -1;
|
||||
for (int i = 0; i < exactMethods.length; ++i) {
|
||||
long exactMethod = exactMethods[i];
|
||||
int classIndex = (int)(exactMethod >>> 32);
|
||||
int classIndex = (int) (exactMethod >>> 32);
|
||||
if (classIndex != lastClass) {
|
||||
if (lastClass >= 0) {
|
||||
ClassMetadata clsData = classesMetadata.get(lastClass);
|
||||
|
@ -510,7 +510,7 @@ public class DebugInformation {
|
|||
}
|
||||
lastClass = classIndex;
|
||||
}
|
||||
int methodIndex = (int)exactMethod;
|
||||
int methodIndex = (int) exactMethod;
|
||||
methods.add(methodIndex);
|
||||
}
|
||||
if (lastClass >= 0) {
|
||||
|
@ -563,7 +563,7 @@ public class DebugInformation {
|
|||
}
|
||||
|
||||
private Integer getExactMethodIndex(int classIndex, int methodIndex) {
|
||||
long entry = ((long)classIndex << 32) | methodIndex;
|
||||
long entry = ((long) classIndex << 32) | methodIndex;
|
||||
return exactMethodMap.get(entry);
|
||||
}
|
||||
|
||||
|
@ -663,8 +663,8 @@ public class DebugInformation {
|
|||
MethodReference[] references = new MethodReference[end - start];
|
||||
for (int i = 0; i < references.length; ++i) {
|
||||
long item = exactMethods[data[start + i]];
|
||||
int classIndex = (int)(item >>> 32);
|
||||
int methodIndex = (int)item;
|
||||
int classIndex = (int) (item >>> 32);
|
||||
int methodIndex = (int) item;
|
||||
references[i] = new MethodReference(classNames[classIndex],
|
||||
MethodDescriptor.parse(methods[methodIndex]));
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
|||
}
|
||||
if (currentClass != null) {
|
||||
int classIndex = classes.index(currentClass);
|
||||
long fullIndex = ((long)classIndex << 32) | methodIndex;
|
||||
long fullIndex = ((long) classIndex << 32) | methodIndex;
|
||||
if (!exactMethodMap.containsKey(fullIndex)) {
|
||||
exactMethodMap.put(fullIndex, exactMethods.size());
|
||||
exactMethods.add(fullIndex);
|
||||
|
@ -171,7 +171,7 @@ public class DebugInformationBuilder implements DebugInformationEmitter {
|
|||
private int getExactMethodIndex(MethodReference method) {
|
||||
int methodIndex = methods.index(method.getDescriptor().toString());
|
||||
int classIndex = classes.index(method.getClassName());
|
||||
long fullIndex = ((long)classIndex << 32) | methodIndex;
|
||||
long fullIndex = ((long) classIndex << 32) | methodIndex;
|
||||
Integer exactMethodIndex = exactMethodMap.get(fullIndex);
|
||||
if (exactMethodIndex == null) {
|
||||
exactMethodIndex = exactMethods.size();
|
||||
|
|
|
@ -269,7 +269,7 @@ class DebugInformationReader {
|
|||
for (int i = 0; i < result.length; ++i) {
|
||||
lastClass += readNumber();
|
||||
lastMethod += readNumber();
|
||||
result[i] = ((long)lastClass << 32) | lastMethod;
|
||||
result[i] = ((long) lastClass << 32) | lastMethod;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class DebugInformationReader {
|
|||
if (r < 0) {
|
||||
throw new EOFException();
|
||||
}
|
||||
byte b = (byte)r;
|
||||
byte b = (byte) r;
|
||||
number |= (b & 0x7F) << shift;
|
||||
shift += 7;
|
||||
if ((b & 0x80) == 0) {
|
||||
|
|
|
@ -108,8 +108,8 @@ class DebugInformationWriter {
|
|||
writeUnsignedNumber(array.length);
|
||||
for (int i = 0; i < array.length; ++i) {
|
||||
long item = array[i];
|
||||
int classIndex = (int)(item >> 32);
|
||||
int methodIndex = (int)item;
|
||||
int classIndex = (int) (item >> 32);
|
||||
int methodIndex = (int) item;
|
||||
writeNumber(classIndex - lastClass);
|
||||
lastClass = classIndex;
|
||||
writeNumber(methodIndex - lastMethod);
|
||||
|
@ -249,7 +249,7 @@ class DebugInformationWriter {
|
|||
|
||||
private void writeUnsignedNumber(int number) throws IOException {
|
||||
do {
|
||||
byte b = (byte)(number & 0x7F);
|
||||
byte b = (byte) (number & 0x7F);
|
||||
if ((number & 0xFFFFFF80) != 0) {
|
||||
b |= 0x80;
|
||||
}
|
||||
|
|
|
@ -39,13 +39,13 @@ public class ExactMethodIterator {
|
|||
}
|
||||
|
||||
public boolean isEndReached() {
|
||||
return methodIndex >= debugInformation.methodMapping.size() &&
|
||||
classIndex >= debugInformation.classMapping.size();
|
||||
return methodIndex >= debugInformation.methodMapping.size()
|
||||
&& classIndex >= debugInformation.classMapping.size();
|
||||
}
|
||||
|
||||
private void read() {
|
||||
if (classIndex < debugInformation.classMapping.size() &&
|
||||
methodIndex < debugInformation.methodMapping.size()) {
|
||||
if (classIndex < debugInformation.classMapping.size()
|
||||
&& methodIndex < debugInformation.methodMapping.size()) {
|
||||
RecordArray.Record classRecord = debugInformation.classMapping.get(classIndex);
|
||||
RecordArray.Record methodRecord = debugInformation.methodMapping.get(methodIndex);
|
||||
GeneratedLocation classLoc = DebugInformation.key(classRecord);
|
||||
|
|
|
@ -62,7 +62,7 @@ public class GeneratedLocation implements Comparable<GeneratedLocation> {
|
|||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
GeneratedLocation other = (GeneratedLocation)obj;
|
||||
GeneratedLocation other = (GeneratedLocation) obj;
|
||||
return line == other.line && column == other.column;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,13 +37,11 @@ public class SourceLocationIterator {
|
|||
}
|
||||
|
||||
public boolean isEndReached() {
|
||||
return fileIndex >= debugInformation.fileMapping.size() &&
|
||||
lineIndex >= debugInformation.lineMapping.size();
|
||||
return fileIndex >= debugInformation.fileMapping.size() && lineIndex >= debugInformation.lineMapping.size();
|
||||
}
|
||||
|
||||
private void read() {
|
||||
if (fileIndex < debugInformation.fileMapping.size() &&
|
||||
lineIndex < debugInformation.lineMapping.size()) {
|
||||
if (fileIndex < debugInformation.fileMapping.size() && lineIndex < debugInformation.lineMapping.size()) {
|
||||
RecordArray.Record fileRecord = debugInformation.fileMapping.get(fileIndex);
|
||||
RecordArray.Record lineRecord = debugInformation.lineMapping.get(lineIndex);
|
||||
GeneratedLocation fileLoc = DebugInformation.key(fileRecord);
|
||||
|
|
|
@ -52,7 +52,7 @@ public class JavaScriptLocation {
|
|||
if (!(obj instanceof JavaScriptLocation)) {
|
||||
return false;
|
||||
}
|
||||
JavaScriptLocation other = (JavaScriptLocation)obj;
|
||||
JavaScriptLocation other = (JavaScriptLocation) obj;
|
||||
return Objects.equals(other.script, script) && other.line == line && other.column == column;
|
||||
}
|
||||
|
||||
|
|
|
@ -430,7 +430,7 @@ public class DependencyChecker implements DependencyInfo {
|
|||
return;
|
||||
}
|
||||
ValueType depType = depAnnot.getValue("value").getJavaClass();
|
||||
String depClassName = ((ValueType.Object)depType).getClassName();
|
||||
String depClassName = ((ValueType.Object) depType).getClassName();
|
||||
Class<?> depClass;
|
||||
try {
|
||||
depClass = Class.forName(depClassName, true, classLoader);
|
||||
|
@ -438,7 +438,7 @@ public class DependencyChecker implements DependencyInfo {
|
|||
throw new RuntimeException("Dependency plugin not found: " + depClassName, e);
|
||||
}
|
||||
try {
|
||||
methodDep.dependencyPlugin = (DependencyPlugin)depClass.newInstance();
|
||||
methodDep.dependencyPlugin = (DependencyPlugin) depClass.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException e) {
|
||||
throw new RuntimeException("Can't instantiate dependency plugin " + depClassName, e);
|
||||
}
|
||||
|
|
|
@ -220,8 +220,8 @@ class DependencyGraphBuilder {
|
|||
public void consume(DependencyType type) {
|
||||
String className = type.getName();
|
||||
if (DependencyChecker.shouldLog) {
|
||||
System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". " +
|
||||
"Target class is " + className);
|
||||
System.out.println("Virtual call of " + methodDesc + " detected on " + node.getTag() + ". "
|
||||
+ "Target class is " + className);
|
||||
}
|
||||
if (className.startsWith("[")) {
|
||||
className = "java.lang.Object";
|
||||
|
@ -286,10 +286,10 @@ class DependencyGraphBuilder {
|
|||
node.propagate(dependencyChecker.getType("java.lang.Class"));
|
||||
}
|
||||
while (cst instanceof ValueType.Array) {
|
||||
cst = ((ValueType.Array)cst).getItemType();
|
||||
cst = ((ValueType.Array) cst).getItemType();
|
||||
}
|
||||
if (cst instanceof ValueType.Object) {
|
||||
final String className = ((ValueType.Object)cst).getClassName();
|
||||
final String className = ((ValueType.Object) cst).getClassName();
|
||||
dependencyChecker.linkClass(className, new CallLocation(caller.getMethod(), currentLocation));
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ class DependencyGraphBuilder {
|
|||
DependencyNode valueNode = nodes[value.getIndex()];
|
||||
DependencyNode receiverNode = nodes[receiver.getIndex()];
|
||||
if (targetType instanceof ValueType.Object) {
|
||||
String targetClsName = ((ValueType.Object)targetType).getClassName();
|
||||
String targetClsName = ((ValueType.Object) targetType).getClassName();
|
||||
final ClassReader targetClass = dependencyChecker.getClassSource().get(targetClsName);
|
||||
if (targetClass != null) {
|
||||
if (valueNode != null && receiverNode != null) {
|
||||
|
@ -426,9 +426,9 @@ class DependencyGraphBuilder {
|
|||
|
||||
private String extractClassName(ValueType itemType) {
|
||||
while (itemType instanceof ValueType.Array) {
|
||||
itemType = ((ValueType.Array)itemType).getItemType();
|
||||
itemType = ((ValueType.Array) itemType).getItemType();
|
||||
}
|
||||
return itemType instanceof ValueType.Object ? ((ValueType.Object)itemType).getClassName() : null;
|
||||
return itemType instanceof ValueType.Object ? ((ValueType.Object) itemType).getClassName() : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -437,11 +437,11 @@ class DependencyGraphBuilder {
|
|||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < dimensions.size(); ++i) {
|
||||
sb.append('[');
|
||||
itemType = ((ValueType.Array)itemType).getItemType();
|
||||
itemType = ((ValueType.Array) itemType).getItemType();
|
||||
}
|
||||
String itemTypeStr;
|
||||
if (itemType instanceof ValueType.Object) {
|
||||
itemTypeStr = ((ValueType.Object)itemType).getClassName();
|
||||
itemTypeStr = ((ValueType.Object) itemType).getClassName();
|
||||
} else {
|
||||
itemTypeStr = itemType.toString();
|
||||
}
|
||||
|
|
|
@ -52,19 +52,19 @@ public class Linker {
|
|||
BasicBlock block = program.basicBlockAt(i);
|
||||
for (Instruction insn : block.getInstructions()) {
|
||||
if (insn instanceof InvokeInstruction) {
|
||||
InvokeInstruction invoke = (InvokeInstruction)insn;
|
||||
InvokeInstruction invoke = (InvokeInstruction) insn;
|
||||
MethodDependencyInfo linkedMethod = dependency.getMethodImplementation(invoke.getMethod());
|
||||
if (linkedMethod != null) {
|
||||
invoke.setMethod(linkedMethod.getReference());
|
||||
}
|
||||
} else if (insn instanceof GetFieldInstruction) {
|
||||
GetFieldInstruction getField = (GetFieldInstruction)insn;
|
||||
GetFieldInstruction getField = (GetFieldInstruction) insn;
|
||||
FieldDependencyInfo linkedField = dependency.getField(getField.getField());
|
||||
if (linkedField != null) {
|
||||
getField.setField(linkedField.getReference());
|
||||
}
|
||||
} else if (insn instanceof PutFieldInstruction) {
|
||||
PutFieldInstruction getField = (PutFieldInstruction)insn;
|
||||
PutFieldInstruction getField = (PutFieldInstruction) insn;
|
||||
FieldDependencyInfo linkedField = dependency.getField(getField.getField());
|
||||
if (linkedField != null) {
|
||||
getField.setField(linkedField.getReference());
|
||||
|
|
|
@ -111,31 +111,31 @@ public class Problem {
|
|||
if (!(param instanceof String)) {
|
||||
return index;
|
||||
}
|
||||
consumer.appendClass((String)param);
|
||||
consumer.appendClass((String) param);
|
||||
break;
|
||||
case TYPE:
|
||||
if (!(param instanceof ValueType)) {
|
||||
return index;
|
||||
}
|
||||
consumer.appendType((ValueType)param);
|
||||
consumer.appendType((ValueType) param);
|
||||
break;
|
||||
case METHOD:
|
||||
if (!(param instanceof MethodReference)) {
|
||||
return index;
|
||||
}
|
||||
consumer.appendMethod((MethodReference)param);
|
||||
consumer.appendMethod((MethodReference) param);
|
||||
break;
|
||||
case FIELD:
|
||||
if (!(param instanceof FieldReference)) {
|
||||
return index;
|
||||
}
|
||||
consumer.appendField((FieldReference)param);
|
||||
consumer.appendField((FieldReference) param);
|
||||
break;
|
||||
case LOCATION:
|
||||
if (!(param instanceof InstructionLocation)) {
|
||||
return index;
|
||||
}
|
||||
consumer.appendLocation((InstructionLocation)param);
|
||||
consumer.appendLocation((InstructionLocation) param);
|
||||
break;
|
||||
}
|
||||
next += 2;
|
||||
|
|
|
@ -49,7 +49,7 @@ class AsyncCallsFinder implements StatementVisitor, ExprVisitor {
|
|||
statement.getRightValue().acceptVisitor(this);
|
||||
return;
|
||||
}
|
||||
InvocationExpr invocation = (InvocationExpr)statement.getRightValue();
|
||||
InvocationExpr invocation = (InvocationExpr) statement.getRightValue();
|
||||
asyncCalls.add(invocation.getMethod());
|
||||
}
|
||||
|
||||
|
|
|
@ -202,8 +202,8 @@ public class Decompiler {
|
|||
if (method.getModifiers().contains(ElementModifier.ABSTRACT)) {
|
||||
continue;
|
||||
}
|
||||
if (method.getAnnotations().get(InjectedBy.class.getName()) != null ||
|
||||
methodsToPass.contains(method.getReference())) {
|
||||
if (method.getAnnotations().get(InjectedBy.class.getName()) != null
|
||||
|| methodsToPass.contains(method.getReference())) {
|
||||
continue;
|
||||
}
|
||||
MethodNode methodNode = decompile(method);
|
||||
|
@ -215,8 +215,8 @@ public class Decompiler {
|
|||
}
|
||||
|
||||
public MethodNode decompile(MethodHolder method) {
|
||||
return method.getModifiers().contains(ElementModifier.NATIVE) ? decompileNative(method) :
|
||||
!asyncMethods.contains(method.getReference()) ? decompileRegular(method) : decompileAsync(method);
|
||||
return method.getModifiers().contains(ElementModifier.NATIVE) ? decompileNative(method)
|
||||
: !asyncMethods.contains(method.getReference()) ? decompileRegular(method) : decompileAsync(method);
|
||||
}
|
||||
|
||||
public NativeMethodNode decompileNative(MethodHolder method) {
|
||||
|
@ -224,17 +224,17 @@ public class Decompiler {
|
|||
if (generator == null) {
|
||||
AnnotationHolder annotHolder = method.getAnnotations().get(GeneratedBy.class.getName());
|
||||
if (annotHolder == null) {
|
||||
throw new DecompilationException("Method " + method.getOwnerName() + "." + method.getDescriptor() +
|
||||
" is native, but no " + GeneratedBy.class.getName() + " annotation found");
|
||||
throw new DecompilationException("Method " + method.getOwnerName() + "." + method.getDescriptor()
|
||||
+ " is native, but no " + GeneratedBy.class.getName() + " annotation found");
|
||||
}
|
||||
ValueType annotValue = annotHolder.getValues().get("value").getJavaClass();
|
||||
String generatorClassName = ((ValueType.Object)annotValue).getClassName();
|
||||
String generatorClassName = ((ValueType.Object) annotValue).getClassName();
|
||||
try {
|
||||
Class<?> generatorClass = Class.forName(generatorClassName, true, classLoader);
|
||||
generator = (Generator)generatorClass.newInstance();
|
||||
generator = (Generator) generatorClass.newInstance();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
throw new DecompilationException("Error instantiating generator " + generatorClassName +
|
||||
" for native method " + method.getOwnerName() + "." + method.getDescriptor());
|
||||
throw new DecompilationException("Error instantiating generator " + generatorClassName
|
||||
+ " for native method " + method.getOwnerName() + "." + method.getDescriptor());
|
||||
}
|
||||
}
|
||||
NativeMethodNode methodNode = new NativeMethodNode(new MethodReference(method.getOwnerName(),
|
||||
|
@ -323,8 +323,8 @@ public class Decompiler {
|
|||
try {
|
||||
part = getRegularMethodStatement(splitter.getProgram(i), splitter.getBlockSuccessors(i), i > 0);
|
||||
} catch (RuntimeException e) {
|
||||
StringBuilder sb = new StringBuilder("Error decompiling method " + method.getReference() +
|
||||
" part " + i + ":\n");
|
||||
StringBuilder sb = new StringBuilder("Error decompiling method " + method.getReference()
|
||||
+ " part " + i + ":\n");
|
||||
sb.append(new ListingBuilder().buildListing(splitter.getProgram(i), " "));
|
||||
throw new DecompilationException(sb.toString(), e);
|
||||
}
|
||||
|
@ -539,8 +539,8 @@ public class Decompiler {
|
|||
bookmark.offset = bookmark.block.body.size();
|
||||
bookmark.exceptionHandler = tryCatch.getHandler().getIndex();
|
||||
bookmark.exceptionType = tryCatch.getExceptionType();
|
||||
bookmark.exceptionVariable = tryCatch.getExceptionVariable() != null ?
|
||||
tryCatch.getExceptionVariable().getIndex() : null;
|
||||
bookmark.exceptionVariable = tryCatch.getExceptionVariable() != null
|
||||
? tryCatch.getExceptionVariable().getIndex() : null;
|
||||
bookmark.block.tryCatches.add(bookmark);
|
||||
tryCatchBookmarks.add(bookmark);
|
||||
}
|
||||
|
@ -581,8 +581,8 @@ public class Decompiler {
|
|||
}
|
||||
result.add(block);
|
||||
int mappedIndex = indexer.nodeAt(currentNode.getEnd());
|
||||
if (mappedIndex >= 0 && (blockMap[mappedIndex] == null ||
|
||||
!(blockMap[mappedIndex].statement instanceof WhileStatement))) {
|
||||
if (mappedIndex >= 0 && (blockMap[mappedIndex] == null
|
||||
|| !(blockMap[mappedIndex].statement instanceof WhileStatement))) {
|
||||
blockMap[mappedIndex] = block;
|
||||
}
|
||||
if (loop) {
|
||||
|
|
|
@ -34,7 +34,7 @@ class EscapingStatementFinder implements StatementVisitor {
|
|||
if (!(statement instanceof SequentialStatement)) {
|
||||
return false;
|
||||
}
|
||||
SequentialStatement seq = (SequentialStatement)statement;
|
||||
SequentialStatement seq = (SequentialStatement) statement;
|
||||
for (int i = seq.getSequence().size() - 1; i >= 0; --i) {
|
||||
if (!isEmpty(seq.getSequence().get(i))) {
|
||||
return false;
|
||||
|
|
|
@ -27,12 +27,12 @@ final class ExprOptimizer {
|
|||
|
||||
public static Expr invert(Expr expr) {
|
||||
if (expr instanceof UnaryExpr) {
|
||||
UnaryExpr unary = (UnaryExpr)expr;
|
||||
UnaryExpr unary = (UnaryExpr) expr;
|
||||
if (unary.getOperation() == UnaryOperation.NOT) {
|
||||
return unary.getOperand();
|
||||
}
|
||||
} else if (expr instanceof BinaryExpr) {
|
||||
BinaryExpr binary = (BinaryExpr)expr;
|
||||
BinaryExpr binary = (BinaryExpr) expr;
|
||||
Expr a = binary.getFirstOperand();
|
||||
Expr b = binary.getSecondOperand();
|
||||
switch (binary.getOperation()) {
|
||||
|
|
|
@ -67,8 +67,8 @@ public class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, Me
|
|||
if (asyncFamilyMethods.contains(method.getReference())) {
|
||||
consumer.consume(method.getReference());
|
||||
}
|
||||
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC) ||
|
||||
method.getReference().getName().equals("<init>"))) {
|
||||
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC)
|
||||
|| method.getReference().getName().equals("<init>"))) {
|
||||
consumer.consume(method.getReference());
|
||||
}
|
||||
if (!method.getModifiers().contains(NodeModifier.STATIC)) {
|
||||
|
@ -258,16 +258,16 @@ public class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, Me
|
|||
@Override
|
||||
public void visit(ConstantExpr expr) {
|
||||
if (expr.getValue() instanceof ValueType) {
|
||||
visitType((ValueType)expr.getValue());
|
||||
visitType((ValueType) expr.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
private void visitType(ValueType type) {
|
||||
while (type instanceof ValueType.Array) {
|
||||
type = ((ValueType.Array)type).getItemType();
|
||||
type = ((ValueType.Array) type).getItemType();
|
||||
}
|
||||
if (type instanceof ValueType.Object) {
|
||||
String clsName = ((ValueType.Object)type).getClassName();
|
||||
String clsName = ((ValueType.Object) type).getClassName();
|
||||
consumer.consume(clsName);
|
||||
consumer.consumeFunction("$rt_cls");
|
||||
}
|
||||
|
@ -340,7 +340,7 @@ public class NameFrequencyEstimator implements StatementVisitor, ExprVisitor, Me
|
|||
expr.getExpr().acceptVisitor(this);
|
||||
visitType(expr.getType());
|
||||
if (expr.getType() instanceof ValueType.Object) {
|
||||
String clsName = ((ValueType.Object)expr.getType()).getClassName();
|
||||
String clsName = ((ValueType.Object) expr.getType()).getClassName();
|
||||
ClassReader cls = classSource.get(clsName);
|
||||
if (cls == null || cls.hasModifier(ElementModifier.INTERFACE)) {
|
||||
consumer.consumeFunction("$rt_isInstance");
|
||||
|
|
|
@ -44,7 +44,7 @@ public class NullPointerExceptionTransformer implements ClassHolderTransformer {
|
|||
for (int i = 0; i < block.getInstructions().size(); ++i) {
|
||||
Instruction insn = block.getInstructions().get(i);
|
||||
if (insn instanceof InvokeInstruction) {
|
||||
InvokeInstruction invoke = (InvokeInstruction)insn;
|
||||
InvokeInstruction invoke = (InvokeInstruction) insn;
|
||||
if (invoke.getType() != InvocationType.VIRTUAL) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -35,11 +35,11 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
}
|
||||
|
||||
private static boolean isZero(Expr expr) {
|
||||
return expr instanceof ConstantExpr && Integer.valueOf(0).equals(((ConstantExpr)expr).getValue());
|
||||
return expr instanceof ConstantExpr && Integer.valueOf(0).equals(((ConstantExpr) expr).getValue());
|
||||
}
|
||||
|
||||
private static boolean isComparison(Expr expr) {
|
||||
return expr instanceof BinaryExpr && ((BinaryExpr)expr).getOperation() == BinaryOperation.COMPARE;
|
||||
return expr instanceof BinaryExpr && ((BinaryExpr) expr).getOperation() == BinaryOperation.COMPARE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +55,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
expr.getSecondOperand().acceptVisitor(this);
|
||||
Expr b = resultExpr;
|
||||
if (b instanceof ConstantExpr && expr.getOperation() == BinaryOperation.SUBTRACT) {
|
||||
if (tryMakePositive((ConstantExpr)b)) {
|
||||
if (tryMakePositive((ConstantExpr) b)) {
|
||||
expr.setOperation(BinaryOperation.ADD);
|
||||
}
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
case LESS_OR_EQUALS:
|
||||
case GREATER:
|
||||
case GREATER_OR_EQUALS: {
|
||||
BinaryExpr comparison = (BinaryExpr)p;
|
||||
BinaryExpr comparison = (BinaryExpr) p;
|
||||
Expr result = BinaryExpr.binary(expr.getOperation(),
|
||||
comparison.getFirstOperand(), comparison.getSecondOperand());
|
||||
result.setLocation(comparison.getLocation());
|
||||
|
@ -102,7 +102,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
expr.getOperand().acceptVisitor(this);
|
||||
Expr operand = resultExpr;
|
||||
if (expr.getOperation() == UnaryOperation.NEGATE && operand instanceof ConstantExpr) {
|
||||
ConstantExpr constantExpr = (ConstantExpr)operand;
|
||||
ConstantExpr constantExpr = (ConstantExpr) operand;
|
||||
if (tryMakePositive(constantExpr)) {
|
||||
resultExpr = expr;
|
||||
return;
|
||||
|
@ -114,23 +114,23 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
|
||||
private boolean tryMakePositive(ConstantExpr constantExpr) {
|
||||
Object value = constantExpr.getValue();
|
||||
if (value instanceof Integer && (Integer)value < 0) {
|
||||
constantExpr.setValue(-(Integer)value);
|
||||
if (value instanceof Integer && (Integer) value < 0) {
|
||||
constantExpr.setValue(-(Integer) value);
|
||||
return true;
|
||||
} else if (value instanceof Float && (Float)value < 0) {
|
||||
constantExpr.setValue(-(Float)value);
|
||||
} else if (value instanceof Float && (Float) value < 0) {
|
||||
constantExpr.setValue(-(Float) value);
|
||||
return true;
|
||||
} else if (value instanceof Byte && (Byte)value < 0) {
|
||||
constantExpr.setValue(-(Byte)value);
|
||||
} else if (value instanceof Byte && (Byte) value < 0) {
|
||||
constantExpr.setValue(-(Byte) value);
|
||||
return true;
|
||||
} else if (value instanceof Short && (Short)value < 0) {
|
||||
constantExpr.setValue(-(Short)value);
|
||||
} else if (value instanceof Short && (Short) value < 0) {
|
||||
constantExpr.setValue(-(Short) value);
|
||||
return true;
|
||||
} else if (value instanceof Long && (Long)value < 0) {
|
||||
constantExpr.setValue(-(Long)value);
|
||||
} else if (value instanceof Long && (Long) value < 0) {
|
||||
constantExpr.setValue(-(Long) value);
|
||||
return true;
|
||||
} else if (value instanceof Double && (Double)value < 0) {
|
||||
constantExpr.setValue(-(Double)value);
|
||||
} else if (value instanceof Double && (Double) value < 0) {
|
||||
constantExpr.setValue(-(Double) value);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -169,16 +169,16 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
if (!(last instanceof AssignmentStatement)) {
|
||||
return;
|
||||
}
|
||||
AssignmentStatement assignment = (AssignmentStatement)last;
|
||||
AssignmentStatement assignment = (AssignmentStatement) last;
|
||||
if (assignment.isAsync()) {
|
||||
return;
|
||||
}
|
||||
if (!(assignment.getLeftValue() instanceof VariableExpr)) {
|
||||
return;
|
||||
}
|
||||
VariableExpr var = (VariableExpr)assignment.getLeftValue();
|
||||
if (var.getLocation() != null && assignment.getLocation() != null &&
|
||||
!assignment.getLocation().equals(var.getLocation())) {
|
||||
VariableExpr var = (VariableExpr) assignment.getLeftValue();
|
||||
if (var.getLocation() != null && assignment.getLocation() != null
|
||||
&& !assignment.getLocation().equals(var.getLocation())) {
|
||||
return;
|
||||
}
|
||||
if (var.getIndex() == index) {
|
||||
|
@ -231,22 +231,22 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
if (!(last instanceof AssignmentStatement)) {
|
||||
return false;
|
||||
}
|
||||
AssignmentStatement assignment = (AssignmentStatement)last;
|
||||
AssignmentStatement assignment = (AssignmentStatement) last;
|
||||
if (!(assignment.getLeftValue() instanceof VariableExpr)) {
|
||||
return false;
|
||||
}
|
||||
VariableExpr var = (VariableExpr)assignment.getLeftValue();
|
||||
VariableExpr var = (VariableExpr) assignment.getLeftValue();
|
||||
if (!(expr.getArguments().get(0) instanceof VariableExpr)) {
|
||||
return false;
|
||||
}
|
||||
VariableExpr target = (VariableExpr)expr.getArguments().get(0);
|
||||
VariableExpr target = (VariableExpr) expr.getArguments().get(0);
|
||||
if (target.getIndex() != var.getIndex()) {
|
||||
return false;
|
||||
}
|
||||
if (!(assignment.getRightValue() instanceof NewExpr)) {
|
||||
return false;
|
||||
}
|
||||
NewExpr constructed = (NewExpr)assignment.getRightValue();
|
||||
NewExpr constructed = (NewExpr) assignment.getRightValue();
|
||||
if (!constructed.getConstructedClass().equals(expr.getMethod().getClassName())) {
|
||||
return false;
|
||||
}
|
||||
|
@ -306,7 +306,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
public void visit(AssignmentStatement statement) {
|
||||
if (statement.getLeftValue() == null) {
|
||||
statement.getRightValue().acceptVisitor(this);
|
||||
if (resultExpr instanceof InvocationExpr && tryApplyConstructor((InvocationExpr)resultExpr)) {
|
||||
if (resultExpr instanceof InvocationExpr && tryApplyConstructor((InvocationExpr) resultExpr)) {
|
||||
resultStmt = new SequentialStatement();
|
||||
} else {
|
||||
statement.setRightValue(resultExpr);
|
||||
|
@ -345,7 +345,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
for (int i = 0; i < statements.size(); ++i) {
|
||||
Statement part = statements.get(i);
|
||||
if (part instanceof SequentialStatement) {
|
||||
if (!processSequenceImpl(((SequentialStatement)part).getSequence())) {
|
||||
if (!processSequenceImpl(((SequentialStatement) part).getSequence())) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
|
@ -353,7 +353,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
part.acceptVisitor(this);
|
||||
part = resultStmt;
|
||||
if (part instanceof SequentialStatement) {
|
||||
if (!processSequenceImpl(((SequentialStatement)part).getSequence())) {
|
||||
if (!processSequenceImpl(((SequentialStatement) part).getSequence())) {
|
||||
return false;
|
||||
}
|
||||
continue;
|
||||
|
@ -369,11 +369,11 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
private void wieldTryCatch(List<Statement> statements) {
|
||||
for (int i = 0; i < statements.size() - 1; ++i) {
|
||||
if (statements.get(i) instanceof TryCatchStatement && statements.get(i + 1) instanceof TryCatchStatement) {
|
||||
TryCatchStatement first = (TryCatchStatement)statements.get(i);
|
||||
TryCatchStatement second = (TryCatchStatement)statements.get(i + 1);
|
||||
if (Objects.equals(first.getExceptionType(), second.getExceptionType()) &&
|
||||
Objects.equals(first.getExceptionVariable(), second.getExceptionVariable()) &&
|
||||
briefStatementComparison(first.getHandler(), second.getHandler())) {
|
||||
TryCatchStatement first = (TryCatchStatement) statements.get(i);
|
||||
TryCatchStatement second = (TryCatchStatement) statements.get(i + 1);
|
||||
if (Objects.equals(first.getExceptionType(), second.getExceptionType())
|
||||
&& Objects.equals(first.getExceptionVariable(), second.getExceptionVariable())
|
||||
&& briefStatementComparison(first.getHandler(), second.getHandler())) {
|
||||
first.getProtectedBody().addAll(second.getProtectedBody());
|
||||
statements.remove(i + 1);
|
||||
wieldTryCatch(first.getProtectedBody());
|
||||
|
@ -393,8 +393,8 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
Statement first = firstSeq.get(0);
|
||||
Statement second = secondSeq.get(0);
|
||||
if (first instanceof BreakStatement && second instanceof BreakStatement) {
|
||||
BreakStatement firstBreak = (BreakStatement)first;
|
||||
BreakStatement secondBreak = (BreakStatement)second;
|
||||
BreakStatement firstBreak = (BreakStatement) first;
|
||||
BreakStatement secondBreak = (BreakStatement) second;
|
||||
return firstBreak.getTarget() == secondBreak.getTarget();
|
||||
}
|
||||
return false;
|
||||
|
@ -406,7 +406,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
}
|
||||
Statement last = statements.get(statements.size() - 1);
|
||||
if (last instanceof BreakStatement && exit != null) {
|
||||
IdentifiedStatement target = ((BreakStatement)last).getTarget();
|
||||
IdentifiedStatement target = ((BreakStatement) last).getTarget();
|
||||
if (exit == target) {
|
||||
statements.remove(statements.size() - 1);
|
||||
}
|
||||
|
@ -417,12 +417,12 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
for (int i = 0; i < statements.size(); ++i) {
|
||||
Statement stmt = statements.get(i);
|
||||
if (stmt instanceof ConditionalStatement) {
|
||||
ConditionalStatement cond = (ConditionalStatement)stmt;
|
||||
ConditionalStatement cond = (ConditionalStatement) stmt;
|
||||
check_conditional: {
|
||||
last = cond.getConsequent().isEmpty() ? null :
|
||||
cond.getConsequent().get(cond.getConsequent().size() - 1);
|
||||
last = cond.getConsequent().isEmpty() ? null
|
||||
: cond.getConsequent().get(cond.getConsequent().size() - 1);
|
||||
if (last instanceof BreakStatement) {
|
||||
BreakStatement breakStmt = (BreakStatement)last;
|
||||
BreakStatement breakStmt = (BreakStatement) last;
|
||||
if (exit != null && exit == breakStmt.getTarget()) {
|
||||
cond.getConsequent().remove(cond.getConsequent().size() - 1);
|
||||
List<Statement> remaining = statements.subList(i + 1, statements.size());
|
||||
|
@ -431,10 +431,10 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
break check_conditional;
|
||||
}
|
||||
}
|
||||
last = cond.getAlternative().isEmpty() ? null :
|
||||
cond.getAlternative().get(cond.getAlternative().size() - 1);
|
||||
last = cond.getAlternative().isEmpty() ? null
|
||||
: cond.getAlternative().get(cond.getAlternative().size() - 1);
|
||||
if (last instanceof BreakStatement) {
|
||||
BreakStatement breakStmt = (BreakStatement)last;
|
||||
BreakStatement breakStmt = (BreakStatement) last;
|
||||
if (exit != null && exit == breakStmt.getTarget()) {
|
||||
cond.getAlternative().remove(cond.getAlternative().size() - 1);
|
||||
List<Statement> remaining = statements.subList(i + 1, statements.size());
|
||||
|
@ -450,7 +450,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
}
|
||||
normalizeConditional(cond);
|
||||
if (cond.getConsequent().size() == 1 && cond.getConsequent().get(0) instanceof ConditionalStatement) {
|
||||
ConditionalStatement innerCond = (ConditionalStatement)cond.getConsequent().get(0);
|
||||
ConditionalStatement innerCond = (ConditionalStatement) cond.getConsequent().get(0);
|
||||
if (innerCond.getAlternative().isEmpty()) {
|
||||
if (cond.getAlternative().isEmpty()) {
|
||||
cond.getConsequent().clear();
|
||||
|
@ -458,8 +458,8 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
cond.setCondition(Expr.binary(BinaryOperation.AND, cond.getCondition(),
|
||||
innerCond.getCondition(), cond.getCondition().getLocation()));
|
||||
--i;
|
||||
} else if (cond.getAlternative().size() != 1 ||
|
||||
!(cond.getAlternative().get(0) instanceof ConditionalStatement)) {
|
||||
} else if (cond.getAlternative().size() != 1
|
||||
|| !(cond.getAlternative().get(0) instanceof ConditionalStatement)) {
|
||||
cond.setCondition(ExprOptimizer.invert(cond.getCondition()));
|
||||
cond.getConsequent().clear();
|
||||
cond.getConsequent().addAll(cond.getAlternative());
|
||||
|
@ -470,13 +470,13 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
}
|
||||
}
|
||||
} else if (stmt instanceof BlockStatement) {
|
||||
BlockStatement nestedBlock = (BlockStatement)stmt;
|
||||
BlockStatement nestedBlock = (BlockStatement) stmt;
|
||||
eliminateRedundantBreaks(nestedBlock.getBody(), nestedBlock);
|
||||
} else if (stmt instanceof WhileStatement) {
|
||||
WhileStatement whileStmt = (WhileStatement)stmt;
|
||||
WhileStatement whileStmt = (WhileStatement) stmt;
|
||||
eliminateRedundantBreaks(whileStmt.getBody(), null);
|
||||
} else if (stmt instanceof SwitchStatement) {
|
||||
SwitchStatement switchStmt = (SwitchStatement)stmt;
|
||||
SwitchStatement switchStmt = (SwitchStatement) stmt;
|
||||
for (SwitchClause clause : switchStmt.getClauses()) {
|
||||
eliminateRedundantBreaks(clause.getBody(), null);
|
||||
}
|
||||
|
@ -546,7 +546,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
@Override
|
||||
public void visit(WhileStatement statement) {
|
||||
if (statement.getBody().size() == 1 && statement.getBody().get(0) instanceof WhileStatement) {
|
||||
WhileStatement innerLoop = (WhileStatement)statement.getBody().get(0);
|
||||
WhileStatement innerLoop = (WhileStatement) statement.getBody().get(0);
|
||||
BreakToContinueReplacer replacer = new BreakToContinueReplacer(innerLoop, statement);
|
||||
replacer.visitSequence(innerLoop.getBody());
|
||||
statement.getBody().clear();
|
||||
|
@ -555,7 +555,7 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
List<Statement> statements = processSequence(statement.getBody());
|
||||
for (int i = 0; i < statements.size(); ++i) {
|
||||
if (statements.get(i) instanceof ContinueStatement) {
|
||||
ContinueStatement continueStmt = (ContinueStatement)statements.get(i);
|
||||
ContinueStatement continueStmt = (ContinueStatement) statements.get(i);
|
||||
if (continueStmt.getTarget() == statement) {
|
||||
statements.subList(i, statements.size()).clear();
|
||||
break;
|
||||
|
@ -573,9 +573,9 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
}
|
||||
while (true) {
|
||||
if (!statement.getBody().isEmpty() && statement.getBody().get(0) instanceof ConditionalStatement) {
|
||||
ConditionalStatement cond = (ConditionalStatement)statement.getBody().get(0);
|
||||
ConditionalStatement cond = (ConditionalStatement) statement.getBody().get(0);
|
||||
if (cond.getConsequent().size() == 1 && cond.getConsequent().get(0) instanceof BreakStatement) {
|
||||
BreakStatement breakStmt = (BreakStatement)cond.getConsequent().get(0);
|
||||
BreakStatement breakStmt = (BreakStatement) cond.getConsequent().get(0);
|
||||
if (breakStmt.getTarget() == statement) {
|
||||
statement.getBody().remove(0);
|
||||
if (statement.getCondition() != null) {
|
||||
|
|
|
@ -363,8 +363,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
new MethodDescriptor("<clinit>", ValueType.VOID));
|
||||
List<MethodNode> clinitMethods = new ArrayList<>();
|
||||
for (MethodNode method : cls.getMethods()) {
|
||||
if (clinit == null || (!method.getModifiers().contains(NodeModifier.STATIC) &&
|
||||
!method.getReference().getName().equals("<init>"))) {
|
||||
if (clinit == null || (!method.getModifiers().contains(NodeModifier.STATIC)
|
||||
&& !method.getReference().getName().equals("<init>"))) {
|
||||
nonInitMethods.add(method);
|
||||
} else {
|
||||
clinitMethods.add(method);
|
||||
|
@ -451,8 +451,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
List<String> stubNames = new ArrayList<>();
|
||||
List<MethodNode> virtualMethods = new ArrayList<>();
|
||||
for (MethodNode method : cls.getMethods()) {
|
||||
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC) ||
|
||||
method.getReference().getName().equals("<init>"))) {
|
||||
if (clinit != null && (method.getModifiers().contains(NodeModifier.STATIC)
|
||||
|| method.getReference().getName().equals("<init>"))) {
|
||||
stubNames.add(naming.getFullNameFor(method.getReference()));
|
||||
}
|
||||
if (!method.getModifiers().contains(NodeModifier.STATIC)) {
|
||||
|
@ -485,14 +485,14 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
|
||||
private static Object getDefaultValue(ValueType type) {
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
ValueType.Primitive primitive = (ValueType.Primitive)type;
|
||||
ValueType.Primitive primitive = (ValueType.Primitive) type;
|
||||
switch (primitive.getKind()) {
|
||||
case BOOLEAN:
|
||||
return false;
|
||||
case BYTE:
|
||||
return (byte)0;
|
||||
return (byte) 0;
|
||||
case SHORT:
|
||||
return (short)0;
|
||||
return (short) 0;
|
||||
case INTEGER:
|
||||
return 0;
|
||||
case CHARACTER:
|
||||
|
@ -893,7 +893,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
popLocation();
|
||||
}
|
||||
if (statement.getLeftValue() instanceof VariableExpr) {
|
||||
VariableExpr receiver = (VariableExpr)statement.getLeftValue();
|
||||
VariableExpr receiver = (VariableExpr) statement.getLeftValue();
|
||||
debugEmitter.emitVariable(statement.getDebugNames().toArray(new String[0]),
|
||||
variableName(receiver.getIndex()));
|
||||
}
|
||||
|
@ -928,9 +928,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
visitStatements(statement.getConsequent());
|
||||
if (!statement.getAlternative().isEmpty()) {
|
||||
writer.outdent().append("}").ws();
|
||||
if (statement.getAlternative().size() == 1 &&
|
||||
statement.getAlternative().get(0) instanceof ConditionalStatement) {
|
||||
statement = (ConditionalStatement)statement.getAlternative().get(0);
|
||||
if (statement.getAlternative().size() == 1
|
||||
&& statement.getAlternative().get(0) instanceof ConditionalStatement) {
|
||||
statement = (ConditionalStatement) statement.getAlternative().get(0);
|
||||
writer.append("else ");
|
||||
continue;
|
||||
}
|
||||
|
@ -1194,8 +1194,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
if (index < variableNames.length()) {
|
||||
sb.append(Character.toString(variableNames.charAt(index)));
|
||||
} else {
|
||||
sb.append(Character.toString(variableNames.charAt(index % variableNames.length())) +
|
||||
index / variableNames.length());
|
||||
sb.append(Character.toString(variableNames.charAt(index % variableNames.length()))
|
||||
+ index / variableNames.length());
|
||||
}
|
||||
if (!minifying && names != null && !names.isEmpty()) {
|
||||
List<String> nameList = new ArrayList<>(names);
|
||||
|
@ -1249,9 +1249,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
precedence.associativity = this.associativity;
|
||||
precedenceStack.push(precedence);
|
||||
wasGrouped = false;
|
||||
if (autoGroup && (priority.ordinal() < this.priority.ordinal() ||
|
||||
priority.ordinal() == this.priority.ordinal() &&
|
||||
(associativity != this.associativity || associativity == Associativity.NONE))) {
|
||||
if (autoGroup && (priority.ordinal() < this.priority.ordinal()
|
||||
|| priority.ordinal() == this.priority.ordinal()
|
||||
&& (associativity != this.associativity || associativity == Associativity.NONE))) {
|
||||
wasGrouped = true;
|
||||
writer.append('(');
|
||||
}
|
||||
|
@ -1548,10 +1548,10 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
return "null";
|
||||
}
|
||||
if (cst instanceof ValueType) {
|
||||
ValueType type = (ValueType)cst;
|
||||
ValueType type = (ValueType) cst;
|
||||
return naming.getNameForFunction("$rt_cls") + "(" + typeToClsString(naming, type) + ")";
|
||||
} else if (cst instanceof String) {
|
||||
String string = (String)cst;
|
||||
String string = (String) cst;
|
||||
Integer index = stringPoolMap.get(string);
|
||||
if (index == null) {
|
||||
index = stringPool.size();
|
||||
|
@ -1560,16 +1560,16 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
}
|
||||
return "$rt_s(" + index + ")";
|
||||
} else if (cst instanceof Long) {
|
||||
long value = (Long)cst;
|
||||
long value = (Long) cst;
|
||||
if (value == 0) {
|
||||
return "Long_ZERO";
|
||||
} else if ((int)value == value) {
|
||||
} else if ((int) value == value) {
|
||||
return "Long_fromInt(" + value + ")";
|
||||
} else {
|
||||
return "new Long(" + (value & 0xFFFFFFFFL) + ", " + (value >>> 32) + ")";
|
||||
}
|
||||
} else if (cst instanceof Character) {
|
||||
return Integer.toString((Character)cst);
|
||||
return Integer.toString((Character) cst);
|
||||
} else {
|
||||
return cst.toString();
|
||||
}
|
||||
|
@ -1579,16 +1579,16 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
int arrayCount = 0;
|
||||
while (type instanceof ValueType.Array) {
|
||||
arrayCount++;
|
||||
type = ((ValueType.Array)type).getItemType();
|
||||
type = ((ValueType.Array) type).getItemType();
|
||||
}
|
||||
String value;
|
||||
if (type instanceof ValueType.Object) {
|
||||
ValueType.Object objType = (ValueType.Object)type;
|
||||
ValueType.Object objType = (ValueType.Object) type;
|
||||
value = naming.getNameFor(objType.getClassName());
|
||||
} else if (type instanceof ValueType.Void) {
|
||||
value = "$rt_voidcls()";
|
||||
} else if (type instanceof ValueType.Primitive) {
|
||||
ValueType.Primitive primitiveType = (ValueType.Primitive)type;
|
||||
ValueType.Primitive primitiveType = (ValueType.Primitive) type;
|
||||
switch (primitiveType.getKind()) {
|
||||
case BOOLEAN:
|
||||
value = "$rt_booleancls()";
|
||||
|
@ -1854,7 +1854,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
ValueType type = expr.getType();
|
||||
enterPriority(Priority.COMMA, Associativity.NONE, false);
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
writer.append("$rt_createBooleanArray(");
|
||||
expr.getLength().acceptVisitor(this);
|
||||
|
@ -1919,11 +1919,11 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
}
|
||||
ValueType type = expr.getType();
|
||||
for (int i = 0; i < expr.getDimensions().size(); ++i) {
|
||||
type = ((ValueType.Array)type).getItemType();
|
||||
type = ((ValueType.Array) type).getItemType();
|
||||
}
|
||||
enterPriority(Priority.COMMA, Associativity.NONE, false);
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
writer.append("$rt_createBooleanMultiArray(");
|
||||
break;
|
||||
|
@ -1981,7 +1981,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
pushLocation(expr.getLocation());
|
||||
}
|
||||
if (expr.getType() instanceof ValueType.Object) {
|
||||
String clsName = ((ValueType.Object)expr.getType()).getClassName();
|
||||
String clsName = ((ValueType.Object) expr.getType()).getClassName();
|
||||
ClassHolder cls = classSource.get(clsName);
|
||||
if (cls != null && !cls.getModifiers().contains(ElementModifier.INTERFACE)) {
|
||||
enterPriority(Priority.COMPARISON, Associativity.LEFT, true);
|
||||
|
@ -2041,7 +2041,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
sequence.add(statement);
|
||||
List<Statement> protectedBody = statement.getProtectedBody();
|
||||
while (protectedBody.size() == 1 && protectedBody.get(0) instanceof TryCatchStatement) {
|
||||
TryCatchStatement nextStatement = (TryCatchStatement)protectedBody.get(0);
|
||||
TryCatchStatement nextStatement = (TryCatchStatement) protectedBody.get(0);
|
||||
sequence.add(nextStatement);
|
||||
protectedBody = nextStatement.getProtectedBody();
|
||||
}
|
||||
|
@ -2082,7 +2082,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
if (!end || statement.getPart() != currentPart + 1) {
|
||||
writer.append("continue ").append(mainLoopName()).append(";").softNewLine();
|
||||
}
|
||||
} catch (IOException ex){
|
||||
} catch (IOException ex) {
|
||||
throw new RenderingException("IO error occured", ex);
|
||||
}
|
||||
}
|
||||
|
@ -2104,7 +2104,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
statement.getObjectRef().acceptVisitor(this);
|
||||
writer.append(");").softNewLine();
|
||||
}
|
||||
} catch (IOException ex){
|
||||
} catch (IOException ex) {
|
||||
throw new RenderingException("IO error occured", ex);
|
||||
}
|
||||
}
|
||||
|
@ -2132,7 +2132,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
statement.getObjectRef().acceptVisitor(this);
|
||||
writer.append(");").softNewLine();
|
||||
}
|
||||
} catch (IOException ex){
|
||||
} catch (IOException ex) {
|
||||
throw new RenderingException("IO error occured", ex);
|
||||
}
|
||||
}
|
||||
|
@ -2149,7 +2149,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
|||
AnnotationHolder injectedByAnnot = method.getAnnotations().get(InjectedBy.class.getName());
|
||||
if (injectedByAnnot != null) {
|
||||
ValueType type = injectedByAnnot.getValues().get("value").getJavaClass();
|
||||
holder = new InjectorHolder(instantiateInjector(((ValueType.Object)type).getClassName()));
|
||||
holder = new InjectorHolder(instantiateInjector(((ValueType.Object) type).getClassName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -437,8 +437,8 @@ class StatementGenerator implements InstructionVisitor {
|
|||
|
||||
@Override
|
||||
public void visit(ExitInstruction insn) {
|
||||
ReturnStatement stmt = Statement.exitFunction(insn.getValueToReturn() != null ?
|
||||
Expr.var(insn.getValueToReturn().getIndex()) : null);
|
||||
ReturnStatement stmt = Statement.exitFunction(insn.getValueToReturn() != null
|
||||
? Expr.var(insn.getValueToReturn().getIndex()) : null);
|
||||
stmt.setLocation(currentLocation);
|
||||
statements.add(stmt);
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ public class UnwrapArrayExpr extends Expr {
|
|||
|
||||
@Override
|
||||
protected UnwrapArrayExpr clone(Map<Expr, Expr> cache) {
|
||||
UnwrapArrayExpr copy = (UnwrapArrayExpr)cache.get(this);
|
||||
UnwrapArrayExpr copy = (UnwrapArrayExpr) cache.get(this);
|
||||
if (copy == null) {
|
||||
copy = new UnwrapArrayExpr(elementType);
|
||||
copy.array = array != null ? array.clone(cache) : null;
|
||||
|
|
|
@ -102,63 +102,63 @@ public class AnnotationValue {
|
|||
if (type != BOOLEAN) {
|
||||
throw new IllegalStateException("There is no boolean value");
|
||||
}
|
||||
return (Boolean)value;
|
||||
return (Boolean) value;
|
||||
}
|
||||
|
||||
public byte getByte() {
|
||||
if (type != BYTE) {
|
||||
throw new IllegalStateException("There is no byte value");
|
||||
}
|
||||
return (Byte)value;
|
||||
return (Byte) value;
|
||||
}
|
||||
|
||||
public short getShort() {
|
||||
if (type != SHORT) {
|
||||
throw new IllegalStateException("There is no short value");
|
||||
}
|
||||
return (Short)value;
|
||||
return (Short) value;
|
||||
}
|
||||
|
||||
public int getInt() {
|
||||
if (type != INT) {
|
||||
throw new IllegalStateException("There is no int value");
|
||||
}
|
||||
return (Integer)value;
|
||||
return (Integer) value;
|
||||
}
|
||||
|
||||
public long getLong() {
|
||||
if (type != LONG) {
|
||||
throw new IllegalStateException("There is no long value");
|
||||
}
|
||||
return (Long)value;
|
||||
return (Long) value;
|
||||
}
|
||||
|
||||
public float getFloat() {
|
||||
if (type != FLOAT) {
|
||||
throw new IllegalStateException("There is no float value");
|
||||
}
|
||||
return (Float)value;
|
||||
return (Float) value;
|
||||
}
|
||||
|
||||
public double getDouble() {
|
||||
if (type != DOUBLE) {
|
||||
throw new IllegalStateException("There is no double value");
|
||||
}
|
||||
return (Double)value;
|
||||
return (Double) value;
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
if (type != STRING) {
|
||||
throw new IllegalStateException("There is no String value");
|
||||
}
|
||||
return (String)value;
|
||||
return (String) value;
|
||||
}
|
||||
|
||||
public ValueType getJavaClass() {
|
||||
if (type != CLASS) {
|
||||
throw new IllegalStateException("There is no ValueType value");
|
||||
}
|
||||
return (ValueType)value;
|
||||
return (ValueType) value;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
|
@ -166,21 +166,21 @@ public class AnnotationValue {
|
|||
if (type != LIST) {
|
||||
throw new IllegalStateException("There is no List value");
|
||||
}
|
||||
return Collections.unmodifiableList((List<AnnotationValue>)value);
|
||||
return Collections.unmodifiableList((List<AnnotationValue>) value);
|
||||
}
|
||||
|
||||
public FieldReference getEnumValue() {
|
||||
if (type != ENUM) {
|
||||
throw new IllegalStateException("There is no enum value");
|
||||
}
|
||||
return (FieldReference)value;
|
||||
return (FieldReference) value;
|
||||
}
|
||||
|
||||
public AnnotationReader getAnnotation() {
|
||||
if (type != ANNOTATION) {
|
||||
throw new IllegalStateException("There is no annotation value");
|
||||
}
|
||||
return (AnnotationReader)value;
|
||||
return (AnnotationReader) value;
|
||||
}
|
||||
|
||||
public byte getType() {
|
||||
|
|
|
@ -58,7 +58,7 @@ public class CallLocation {
|
|||
if (!(obj instanceof CallLocation)) {
|
||||
return false;
|
||||
}
|
||||
CallLocation other = (CallLocation)obj;
|
||||
CallLocation other = (CallLocation) obj;
|
||||
return Objects.equals(method, other.method) && Objects.equals(sourceLocation, other.sourceLocation);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -58,8 +58,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
|
|||
|
||||
public void addMethod(MethodHolder method) {
|
||||
if (method.getOwner() != null) {
|
||||
throw new IllegalArgumentException("Method " + method.getDescriptor() +
|
||||
" is already in another class (" + method.getOwner().getName() + ")");
|
||||
throw new IllegalArgumentException("Method " + method.getDescriptor()
|
||||
+ " is already in another class (" + method.getOwner().getName() + ")");
|
||||
}
|
||||
method.setOwner(this);
|
||||
MethodHolder oldMethod = methods.put(method.getDescriptor(), method);
|
||||
|
@ -70,8 +70,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
|
|||
|
||||
public void removeMethod(MethodHolder method) {
|
||||
if (method.getOwner() != this) {
|
||||
throw new IllegalArgumentException("Method " + method.getOwner().getName() +
|
||||
"." + method.getDescriptor() + " is not a member of " + getName());
|
||||
throw new IllegalArgumentException("Method " + method.getOwner().getName()
|
||||
+ "." + method.getDescriptor() + " is not a member of " + getName());
|
||||
}
|
||||
methods.remove(method.getDescriptor());
|
||||
method.setOwner(null);
|
||||
|
@ -89,8 +89,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
|
|||
|
||||
public void addField(FieldHolder field) {
|
||||
if (field.getOwner() != null) {
|
||||
throw new IllegalArgumentException("Field " + field.getName() + " is already " +
|
||||
"in another class (" + field.getOwner().getName() + ")");
|
||||
throw new IllegalArgumentException("Field " + field.getName() + " is already "
|
||||
+ "in another class (" + field.getOwner().getName() + ")");
|
||||
}
|
||||
field.setOwner(this);
|
||||
FieldHolder oldField = fields.put(field.getName(), field);
|
||||
|
@ -101,8 +101,8 @@ public class ClassHolder extends ElementHolder implements ClassReader {
|
|||
|
||||
public void removeField(FieldHolder field) {
|
||||
if (field.getOwner() != this) {
|
||||
throw new IllegalArgumentException("Field " + field.getOwner().getName() + "." +
|
||||
field.getName() + " is not a member of " + getName());
|
||||
throw new IllegalArgumentException("Field " + field.getOwner().getName() + "."
|
||||
+ field.getName() + " is not a member of " + getName());
|
||||
}
|
||||
fields.remove(field.getName());
|
||||
field.setOwner(null);
|
||||
|
|
|
@ -49,7 +49,7 @@ public class FieldReference {
|
|||
if (!(obj instanceof FieldReference)) {
|
||||
return false;
|
||||
}
|
||||
FieldReference other = (FieldReference)obj;
|
||||
FieldReference other = (FieldReference) obj;
|
||||
return className.equals(other.className) && fieldName.equals(other.fieldName);
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class InstructionLocation {
|
|||
if (!(obj instanceof InstructionLocation)) {
|
||||
return false;
|
||||
}
|
||||
InstructionLocation other = (InstructionLocation)obj;
|
||||
InstructionLocation other = (InstructionLocation) obj;
|
||||
return Objects.equals(fileName, other.fileName) && line == other.line;
|
||||
}
|
||||
|
||||
|
|
|
@ -67,8 +67,7 @@ public class MethodDescriptor {
|
|||
|
||||
public ValueType parameterType(int index) {
|
||||
if (index >= signature.length - 1) {
|
||||
throw new IndexOutOfBoundsException(String.valueOf(index) + "/" +
|
||||
(signature.length - 1));
|
||||
throw new IndexOutOfBoundsException(String.valueOf(index) + "/" + (signature.length - 1));
|
||||
}
|
||||
return signature[index];
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ public class MethodReference {
|
|||
if (!(obj instanceof MethodReference)) {
|
||||
return false;
|
||||
}
|
||||
MethodReference other = (MethodReference)obj;
|
||||
MethodReference other = (MethodReference) obj;
|
||||
return toString().equals(other.toString());
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ public abstract class ValueType {
|
|||
if (supertype instanceof ValueType.Object) {
|
||||
return !(this instanceof Primitive);
|
||||
} else if (supertype instanceof Array && this instanceof Array) {
|
||||
return ((Array)this).getItemType().isSubtypeOf(((Array)supertype).getItemType());
|
||||
return ((Array) this).getItemType().isSubtypeOf(((Array) supertype).getItemType());
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -138,10 +138,10 @@ public class AsyncMethodFinder {
|
|||
if (method == null) {
|
||||
return;
|
||||
}
|
||||
if (method.getAnnotations().get(Sync.class.getName()) != null ||
|
||||
method.getAnnotations().get(InjectedBy.class.getName()) != null) {
|
||||
diagnostics.error(new CallLocation(methodRef), "Method {{m0}} is claimed to be synchronous, " +
|
||||
"but it is has invocations of asynchronous methods", methodRef);
|
||||
if (method.getAnnotations().get(Sync.class.getName()) != null
|
||||
|| method.getAnnotations().get(InjectedBy.class.getName()) != null) {
|
||||
diagnostics.error(new CallLocation(methodRef), "Method {{m0}} is claimed to be synchronous, "
|
||||
+ "but it is has invocations of asynchronous methods", methodRef);
|
||||
return;
|
||||
}
|
||||
for (CallSite callSite : node.getCallerCallSites()) {
|
||||
|
|
|
@ -64,7 +64,7 @@ public class AsyncProgramSplitter {
|
|||
for (int i = 0; i < sourceBlock.getInstructions().size(); ++i) {
|
||||
Instruction insn = sourceBlock.getInstructions().get(i);
|
||||
if (insn instanceof InvokeInstruction) {
|
||||
InvokeInstruction invoke = (InvokeInstruction)insn;
|
||||
InvokeInstruction invoke = (InvokeInstruction) insn;
|
||||
if (!asyncMethods.contains(findRealMethod(invoke.getMethod()))) {
|
||||
continue;
|
||||
}
|
||||
|
@ -92,7 +92,7 @@ public class AsyncProgramSplitter {
|
|||
|
||||
// If this instruction already separates program, end with current block and refer to the
|
||||
// existing part
|
||||
long key = ((long)step.source << 32) | i;
|
||||
long key = ((long) step.source << 32) | i;
|
||||
if (partMap.containsKey(key)) {
|
||||
step.targetPart.blockSuccessors[targetBlock.getIndex()] = partMap.get(key);
|
||||
continue taskLoop;
|
||||
|
|
|
@ -107,7 +107,7 @@ class InterferenceGraphBuilder {
|
|||
for (int i = 0; i < program.basicBlockCount(); ++i) {
|
||||
BasicBlock block = program.basicBlockAt(i);
|
||||
for (Phi phi : block.getPhis()) {
|
||||
for(Incoming incoming : phi.getIncomings()) {
|
||||
for (Incoming incoming : phi.getIncomings()) {
|
||||
outgoings.get(incoming.getSource().getIndex()).add(incoming);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -67,8 +67,8 @@ public class ListingBuilder {
|
|||
block.readInstruction(j, stringifier);
|
||||
if (!Objects.equals(location, stringifier.getLocation())) {
|
||||
location = stringifier.getLocation();
|
||||
sb.append(prefix).append(" at ").append(location != null ? location.toString() :
|
||||
"unknown location").append('\n');
|
||||
sb.append(prefix).append(" at ").append(location != null ? location.toString()
|
||||
: "unknown location").append('\n');
|
||||
}
|
||||
sb.append(prefix).append(" ").append(insnSb).append("\n");
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ public class LivenessAnalyzer {
|
|||
}
|
||||
|
||||
public BitSet liveIn(int block) {
|
||||
return (BitSet)liveVars[block].clone();
|
||||
return (BitSet) liveVars[block].clone();
|
||||
}
|
||||
|
||||
public void analyze(Program program) {
|
||||
|
|
|
@ -137,10 +137,10 @@ public class MissingItemsProcessor {
|
|||
|
||||
private boolean checkClass(InstructionLocation location, ValueType type) {
|
||||
while (type instanceof ValueType.Array) {
|
||||
type = ((ValueType.Array)type).getItemType();
|
||||
type = ((ValueType.Array) type).getItemType();
|
||||
}
|
||||
if (type instanceof ValueType.Object) {
|
||||
return checkClass(location, ((ValueType.Object)type).getClassName());
|
||||
return checkClass(location, ((ValueType.Object) type).getClassName());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -171,7 +171,7 @@ public class RegisterAllocator {
|
|||
if (!(insn instanceof AssignInstruction)) {
|
||||
continue;
|
||||
}
|
||||
AssignInstruction assignment = (AssignInstruction)insn;
|
||||
AssignInstruction assignment = (AssignInstruction) insn;
|
||||
boolean interfere = false;
|
||||
int copyClass = congruenceClasses.find(assignment.getReceiver().getIndex());
|
||||
int origClass = congruenceClasses.find(assignment.getAssignee().getIndex());
|
||||
|
|
|
@ -62,8 +62,8 @@ public class TypeInferer {
|
|||
Graph graph = builder.build();
|
||||
Graph arrayElemGraph = builder.build();
|
||||
for (int i = 0; i < sz; ++i) {
|
||||
if ((i >= graph.size() || graph.incomingEdgesCount(i) == 0) &&
|
||||
(i >= arrayElemGraph.size() || arrayElemGraph.incomingEdgesCount(i) == 0)) {
|
||||
if ((i >= graph.size() || graph.incomingEdgesCount(i) == 0)
|
||||
&& (i >= arrayElemGraph.size() || arrayElemGraph.incomingEdgesCount(i) == 0)) {
|
||||
stack.push(i);
|
||||
}
|
||||
}
|
||||
|
@ -110,7 +110,7 @@ public class TypeInferer {
|
|||
|
||||
VariableType convert(ValueType type) {
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
case BYTE:
|
||||
case SHORT:
|
||||
|
@ -125,7 +125,7 @@ public class TypeInferer {
|
|||
return VariableType.LONG;
|
||||
}
|
||||
} else if (type instanceof ValueType.Array) {
|
||||
ValueType item = ((ValueType.Array)type).getItemType();
|
||||
ValueType item = ((ValueType.Array) type).getItemType();
|
||||
return convertArray(item);
|
||||
}
|
||||
return VariableType.OBJECT;
|
||||
|
@ -189,7 +189,7 @@ public class TypeInferer {
|
|||
|
||||
VariableType convertArray(ValueType type) {
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
case BYTE:
|
||||
return VariableType.BYTE_ARRAY;
|
||||
|
|
|
@ -151,8 +151,8 @@ public class UsageExtractor implements InstructionVisitor {
|
|||
|
||||
@Override
|
||||
public void visit(PutFieldInstruction insn) {
|
||||
usedVariables = insn.getInstance() != null ? new Variable[] { insn.getInstance(), insn.getValue() } :
|
||||
new Variable[] { insn.getValue() };
|
||||
usedVariables = insn.getInstance() != null ? new Variable[] { insn.getInstance(), insn.getValue() }
|
||||
: new Variable[] { insn.getValue() };
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -40,7 +40,7 @@ public class ArrayUnwrapMotion implements MethodOptimization {
|
|||
for (int i = 0; i < instructions.size(); ++i) {
|
||||
Instruction insn = instructions.get(i);
|
||||
if (insn instanceof UnwrapArrayInstruction) {
|
||||
UnwrapArrayInstruction unwrap = (UnwrapArrayInstruction)insn;
|
||||
UnwrapArrayInstruction unwrap = (UnwrapArrayInstruction) insn;
|
||||
instructions.set(i, new EmptyInstruction());
|
||||
int def = whereDefined(instructions, i, unwrap.getArray());
|
||||
if (def < 0) {
|
||||
|
|
|
@ -49,7 +49,7 @@ public class Devirtualization {
|
|||
if (!(insn instanceof InvokeInstruction)) {
|
||||
continue;
|
||||
}
|
||||
InvokeInstruction invoke = (InvokeInstruction)insn;
|
||||
InvokeInstruction invoke = (InvokeInstruction) insn;
|
||||
if (invoke.getType() != InvocationType.VIRTUAL) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ public class EmptyBlockElimination implements MethodOptimization {
|
|||
int lastNonEmpty = program.basicBlockCount() - 1;
|
||||
for (int i = program.basicBlockCount() - 2; i > 0; --i) {
|
||||
BasicBlock block = program.basicBlockAt(i);
|
||||
if (block.getPhis().isEmpty() && block.getInstructions().size() == 1 &&
|
||||
block.getLastInstruction() instanceof JumpInstruction) {
|
||||
JumpInstruction insn = (JumpInstruction)block.getLastInstruction();
|
||||
if (block.getPhis().isEmpty() && block.getInstructions().size() == 1
|
||||
&& block.getLastInstruction() instanceof JumpInstruction) {
|
||||
JumpInstruction insn = (JumpInstruction) block.getLastInstruction();
|
||||
if (insn.getTarget().getIndex() == i + 1) {
|
||||
blockMapping[i] = lastNonEmpty;
|
||||
}
|
||||
|
|
|
@ -91,10 +91,10 @@ public class ClassRefsRenamer implements InstructionVisitor {
|
|||
|
||||
private ValueType rename(ValueType type) {
|
||||
if (type instanceof ValueType.Array) {
|
||||
ValueType itemType = ((ValueType.Array)type).getItemType();
|
||||
ValueType itemType = ((ValueType.Array) type).getItemType();
|
||||
return ValueType.arrayOf(rename(itemType));
|
||||
} else if (type instanceof ValueType.Object) {
|
||||
String className = ((ValueType.Object)type).getClassName();
|
||||
String className = ((ValueType.Object) type).getClassName();
|
||||
return ValueType.object(classNameMapper.map(className));
|
||||
} else {
|
||||
return type;
|
||||
|
@ -103,8 +103,8 @@ public class ClassRefsRenamer implements InstructionVisitor {
|
|||
|
||||
private void rename(AnnotationContainer source, AnnotationContainer target) {
|
||||
for (AnnotationHolder annot : source.all()) {
|
||||
if (!annot.getType().equals(Rename.class.getName()) &&
|
||||
!annot.getType().equals(Superclass.class.getName())) {
|
||||
if (!annot.getType().equals(Rename.class.getName())
|
||||
&& !annot.getType().equals(Superclass.class.getName())) {
|
||||
target.add(rename(annot));
|
||||
}
|
||||
}
|
||||
|
@ -287,11 +287,9 @@ public class ClassRefsRenamer implements InstructionVisitor {
|
|||
|
||||
@Override
|
||||
public void visit(MonitorEnterInstruction insn) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(MonitorExitInstruction insn) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,8 +99,8 @@ public class ClasspathResourceMapper implements Mapper<String, ClassHolder>, Cla
|
|||
int index = name.lastIndexOf('.');
|
||||
String className = name.substring(index + 1);
|
||||
String packageName = index > 0 ? name.substring(0, index) : "";
|
||||
ClassHolder classHolder = innerMapper.map(transformation.packagePrefix + packageName +
|
||||
"." + transformation.classPrefix + className);
|
||||
ClassHolder classHolder = innerMapper.map(transformation.packagePrefix + packageName
|
||||
+ "." + transformation.classPrefix + className);
|
||||
if (classHolder != null) {
|
||||
classHolder = renamer.rename(classHolder);
|
||||
}
|
||||
|
@ -117,8 +117,8 @@ public class ClasspathResourceMapper implements Mapper<String, ClassHolder>, Cla
|
|||
String className = name.substring(index + 1);
|
||||
String packageName = name.substring(0, index);
|
||||
if (className.startsWith(transformation.classPrefix)) {
|
||||
return packageName.substring(transformation.packagePrefix.length()) + "." +
|
||||
className.substring(transformation.classPrefix.length());
|
||||
return packageName.substring(transformation.packagePrefix.length()) + "."
|
||||
+ className.substring(transformation.classPrefix.length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ public final class Parser {
|
|||
}
|
||||
}
|
||||
for (Object obj : node.fields) {
|
||||
FieldNode fieldNode = (FieldNode)obj;
|
||||
FieldNode fieldNode = (FieldNode) obj;
|
||||
cls.addField(parseField(fieldNode));
|
||||
}
|
||||
String fullFileName = node.name.substring(0, node.name.lastIndexOf('/') + 1) + node.sourceFile;
|
||||
|
@ -172,7 +172,7 @@ public final class Parser {
|
|||
annotNodes.addAll(invisibleAnnotations);
|
||||
}
|
||||
for (Object obj : annotNodes) {
|
||||
AnnotationNode annotNode = (AnnotationNode)obj;
|
||||
AnnotationNode annotNode = (AnnotationNode) obj;
|
||||
String desc = annotNode.desc;
|
||||
if (desc.startsWith("L") && desc.endsWith(";")) {
|
||||
desc = desc.substring(1, desc.length() - 1);
|
||||
|
@ -189,7 +189,7 @@ public final class Parser {
|
|||
return;
|
||||
}
|
||||
for (int i = 0; i < values.size(); i += 2) {
|
||||
String key = (String)values.get(i);
|
||||
String key = (String) values.get(i);
|
||||
Object value = values.get(i + 1);
|
||||
annot.getValues().put(key, parseAnnotationValue(value));
|
||||
}
|
||||
|
@ -197,41 +197,41 @@ public final class Parser {
|
|||
|
||||
private static AnnotationValue parseAnnotationValue(Object value) {
|
||||
if (value instanceof String[]) {
|
||||
String[] enumInfo = (String[])value;
|
||||
ValueType.Object object = (ValueType.Object)ValueType.parse(enumInfo[0]);
|
||||
String[] enumInfo = (String[]) value;
|
||||
ValueType.Object object = (ValueType.Object) ValueType.parse(enumInfo[0]);
|
||||
return new AnnotationValue(new FieldReference(object.getClassName(), enumInfo[1]));
|
||||
} else if (value instanceof Type) {
|
||||
Type cls = (Type)value;
|
||||
Type cls = (Type) value;
|
||||
return new AnnotationValue(ValueType.parse(cls.getDescriptor()));
|
||||
} else if (value instanceof List<?>) {
|
||||
List<?> originalList = (List<?>)value;
|
||||
List<?> originalList = (List<?>) value;
|
||||
List<AnnotationValue> resultList = new ArrayList<>();
|
||||
for (Object item : originalList) {
|
||||
resultList.add(parseAnnotationValue(item));
|
||||
}
|
||||
return new AnnotationValue(resultList);
|
||||
} else if (value instanceof AnnotationNode) {
|
||||
AnnotationNode annotNode = (AnnotationNode)value;
|
||||
ValueType.Object object = (ValueType.Object)ValueType.parse(annotNode.desc);
|
||||
AnnotationNode annotNode = (AnnotationNode) value;
|
||||
ValueType.Object object = (ValueType.Object) ValueType.parse(annotNode.desc);
|
||||
AnnotationHolder annotation = new AnnotationHolder(object.getClassName());
|
||||
parseAnnotationValues(annotation, annotNode.values);
|
||||
return new AnnotationValue(annotation);
|
||||
} else if (value instanceof String) {
|
||||
return new AnnotationValue((String)value);
|
||||
return new AnnotationValue((String) value);
|
||||
} else if (value instanceof Boolean) {
|
||||
return new AnnotationValue((Boolean)value);
|
||||
return new AnnotationValue((Boolean) value);
|
||||
} else if (value instanceof Byte) {
|
||||
return new AnnotationValue((Byte)value);
|
||||
return new AnnotationValue((Byte) value);
|
||||
} else if (value instanceof Short) {
|
||||
return new AnnotationValue((Short)value);
|
||||
return new AnnotationValue((Short) value);
|
||||
} else if (value instanceof Integer) {
|
||||
return new AnnotationValue((Integer)value);
|
||||
return new AnnotationValue((Integer) value);
|
||||
} else if (value instanceof Long) {
|
||||
return new AnnotationValue((Long)value);
|
||||
return new AnnotationValue((Long) value);
|
||||
} else if (value instanceof Float) {
|
||||
return new AnnotationValue((Float)value);
|
||||
return new AnnotationValue((Float) value);
|
||||
} else if (value instanceof Double) {
|
||||
return new AnnotationValue((Double)value);
|
||||
return new AnnotationValue((Double) value);
|
||||
} else if (value.getClass().isArray()) {
|
||||
List<AnnotationValue> resultList = new ArrayList<>();
|
||||
int size = Array.getLength(value);
|
||||
|
|
|
@ -176,10 +176,10 @@ public class ProgramParser implements VariableDebugInformation {
|
|||
for (int i = 0; i < instructions.size(); ++i) {
|
||||
AbstractInsnNode node = instructions.get(i);
|
||||
if (node instanceof LabelNode) {
|
||||
labelIndexes.put(((LabelNode)node).getLabel(), i);
|
||||
labelIndexes.put(((LabelNode) node).getLabel(), i);
|
||||
}
|
||||
if (node instanceof LineNumberNode) {
|
||||
LineNumberNode lineNumberNode = (LineNumberNode)node;
|
||||
LineNumberNode lineNumberNode = (LineNumberNode) node;
|
||||
lineNumbers.put(lineNumberNode.start.getLabel(), lineNumberNode.line);
|
||||
}
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ public class ProgramParser implements VariableDebugInformation {
|
|||
InsnList instructions = method.instructions;
|
||||
Deque<Step> workStack = new ArrayDeque<>();
|
||||
for (Object obj : method.tryCatchBlocks) {
|
||||
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
|
||||
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode) obj;
|
||||
if (tryCatchNode.start == tryCatchNode.handler) {
|
||||
continue;
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ public class ProgramParser implements VariableDebugInformation {
|
|||
}
|
||||
}
|
||||
for (Object obj : method.tryCatchBlocks) {
|
||||
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode)obj;
|
||||
TryCatchBlockNode tryCatchNode = (TryCatchBlockNode) obj;
|
||||
if (tryCatchNode.start == tryCatchNode.handler) {
|
||||
continue;
|
||||
}
|
||||
|
@ -298,7 +298,7 @@ public class ProgramParser implements VariableDebugInformation {
|
|||
}
|
||||
AbstractInsnNode insnNode = methodNode.instructions.get(i);
|
||||
if (insnNode instanceof LabelNode) {
|
||||
Label label = ((LabelNode)insnNode).getLabel();
|
||||
Label label = ((LabelNode) insnNode).getLabel();
|
||||
Integer lineNumber = lineNumbers.get(label);
|
||||
if (lineNumber != null && !lineNumber.equals(lastLineNumber)) {
|
||||
lastLineNumber = lineNumber;
|
||||
|
@ -340,7 +340,7 @@ public class ProgramParser implements VariableDebugInformation {
|
|||
|
||||
private void emitNextBasicBlock() {
|
||||
if (index + 1 < basicBlocks.size()) {
|
||||
getBasicBlock(index+ 1);
|
||||
getBasicBlock(index + 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -591,21 +591,21 @@ public class ProgramParser implements VariableDebugInformation {
|
|||
@Override
|
||||
public void visitLdcInsn(Object cst) {
|
||||
if (cst instanceof Integer) {
|
||||
pushConstant((Integer)cst);
|
||||
pushConstant((Integer) cst);
|
||||
} else if (cst instanceof Float) {
|
||||
pushConstant((Float)cst);
|
||||
pushConstant((Float) cst);
|
||||
} else if (cst instanceof Long) {
|
||||
pushConstant((Long)cst);
|
||||
pushConstant((Long) cst);
|
||||
} else if (cst instanceof Double) {
|
||||
pushConstant((Double)cst);
|
||||
pushConstant((Double) cst);
|
||||
} else if (cst instanceof String) {
|
||||
StringConstantInstruction insn = new StringConstantInstruction();
|
||||
insn.setConstant((String)cst);
|
||||
insn.setConstant((String) cst);
|
||||
insn.setReceiver(getVariable(pushSingle()));
|
||||
addInstruction(insn);
|
||||
} else if (cst instanceof Type) {
|
||||
ClassConstantInstruction insn = new ClassConstantInstruction();
|
||||
insn.setConstant(ValueType.parse(((Type)cst).getDescriptor()));
|
||||
insn.setConstant(ValueType.parse(((Type) cst).getDescriptor()));
|
||||
insn.setReceiver(getVariable(pushSingle()));
|
||||
addInstruction(insn);
|
||||
} else {
|
||||
|
@ -1055,7 +1055,7 @@ public class ProgramParser implements VariableDebugInformation {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case Opcodes.DUP2_X1:{
|
||||
case Opcodes.DUP2_X1: {
|
||||
if (stack.type == SINGLE) {
|
||||
popSingle();
|
||||
popSingle();
|
||||
|
|
|
@ -77,7 +77,7 @@ public class SSATransformer {
|
|||
++index;
|
||||
ValueType arg = arguments[i];
|
||||
if (arg instanceof ValueType.Primitive) {
|
||||
PrimitiveType kind = ((ValueType.Primitive)arg).getKind();
|
||||
PrimitiveType kind = ((ValueType.Primitive) arg).getKind();
|
||||
if (kind == PrimitiveType.LONG || kind == PrimitiveType.DOUBLE) {
|
||||
variableMap[index] = variableMap[index - 1];
|
||||
++index;
|
||||
|
|
|
@ -51,7 +51,7 @@ public class JUnitTestAdapter implements TestAdapter {
|
|||
AnnotationReader annot = method.getAnnotations().get(Test.class.getName());
|
||||
AnnotationValue expectedAnnot = annot.getValue("expected");
|
||||
if (expectedAnnot != null) {
|
||||
String className = ((ValueType.Object)expectedAnnot.getJavaClass()).getClassName();
|
||||
String className = ((ValueType.Object) expectedAnnot.getJavaClass()).getClassName();
|
||||
return Collections.singletonList(className);
|
||||
}
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -221,8 +221,8 @@ public class TeaVMTestTool {
|
|||
allTestsWriter.append(",");
|
||||
}
|
||||
firstMethod = false;
|
||||
allTestsWriter.append("\n { name : \"" + methodRef.getName() + "\", script : \"" +
|
||||
scriptName + "\", expected : [");
|
||||
allTestsWriter.append("\n { name : \"" + methodRef.getName() + "\", script : \""
|
||||
+ scriptName + "\", expected : [");
|
||||
MethodHolder methodHolder = classSource.get(testClass).getMethod(
|
||||
methodRef.getDescriptor());
|
||||
boolean firstException = true;
|
||||
|
@ -322,7 +322,7 @@ public class TeaVMTestTool {
|
|||
if (!file.exists()) {
|
||||
file.createNewFile();
|
||||
}
|
||||
try(OutputStream out = new FileOutputStream(file)) {
|
||||
try (OutputStream out = new FileOutputStream(file)) {
|
||||
IOUtils.copy(in, out);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
|
@ -348,8 +348,8 @@ public class TeaVMTestTool {
|
|||
vm.add(transformer);
|
||||
}
|
||||
File file = new File(outputDir, targetName);
|
||||
DebugInformationBuilder debugInfoBuilder = sourceMapsGenerated || debugInformationGenerated ?
|
||||
new DebugInformationBuilder() : null;
|
||||
DebugInformationBuilder debugInfoBuilder = sourceMapsGenerated || debugInformationGenerated
|
||||
? new DebugInformationBuilder() : null;
|
||||
try (Writer innerWriter = new OutputStreamWriter(new FileOutputStream(file), "UTF-8")) {
|
||||
MethodReference cons = new MethodReference(methodRef.getClassName(), "<init>", ValueType.VOID);
|
||||
MethodReference exceptionMsg = new MethodReference(ExceptionHelper.class, "showException",
|
||||
|
|
|
@ -282,8 +282,8 @@ public class TeaVMTool {
|
|||
vm.setMinifying(minifying);
|
||||
vm.setBytecodeLogging(bytecodeLogging);
|
||||
vm.setProperties(properties);
|
||||
DebugInformationBuilder debugEmitter = debugInformationGenerated || sourceMapsFileGenerated ?
|
||||
new DebugInformationBuilder() : null;
|
||||
DebugInformationBuilder debugEmitter = debugInformationGenerated || sourceMapsFileGenerated
|
||||
? new DebugInformationBuilder() : null;
|
||||
vm.setDebugEmitter(debugEmitter);
|
||||
vm.setIncremental(incremental);
|
||||
if (incremental) {
|
||||
|
|
|
@ -240,8 +240,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
public TeaVMEntryPoint entryPoint(String name, MethodReference ref) {
|
||||
if (name != null) {
|
||||
if (entryPoints.containsKey(name)) {
|
||||
throw new IllegalArgumentException("Entry point with public name `" + name + "' already defined " +
|
||||
"for method " + ref);
|
||||
throw new IllegalArgumentException("Entry point with public name `" + name + "' already defined "
|
||||
+ "for method " + ref);
|
||||
}
|
||||
}
|
||||
TeaVMEntryPoint entryPoint = new TeaVMEntryPoint(name, ref, dependencyChecker.linkMethod(ref, null));
|
||||
|
@ -276,8 +276,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
|
||||
public void exportType(String name, String className) {
|
||||
if (exportedClasses.containsKey(name)) {
|
||||
throw new IllegalArgumentException("Class with public name `" + name + "' already defined for class " +
|
||||
className);
|
||||
throw new IllegalArgumentException("Class with public name `" + name + "' already defined for class "
|
||||
+ className);
|
||||
}
|
||||
dependencyChecker.linkClass(className, null).initClass(null);
|
||||
exportedClasses.put(name, className);
|
||||
|
@ -562,8 +562,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
List<String> classOrder = decompiler.getClassOrdering(classes.getClassNames());
|
||||
List<ClassNode> classNodes = new ArrayList<>();
|
||||
int index = 0;
|
||||
try (PrintWriter bytecodeLogger = bytecodeLogging ?
|
||||
new PrintWriter(new OutputStreamWriter(logStream, "UTF-8")) : null) {
|
||||
try (PrintWriter bytecodeLogger = bytecodeLogging
|
||||
? new PrintWriter(new OutputStreamWriter(logStream, "UTF-8")) : null) {
|
||||
for (String className : classOrder) {
|
||||
ClassHolder cls = classes.get(className);
|
||||
for (MethodHolder method : cls.getMethods()) {
|
||||
|
@ -583,11 +583,11 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
}
|
||||
|
||||
private void preprocessNativeMethod(MethodHolder method) {
|
||||
if (!method.getModifiers().contains(ElementModifier.NATIVE) ||
|
||||
methodGenerators.get(method.getReference()) != null ||
|
||||
methodInjectors.get(method.getReference()) != null ||
|
||||
method.getAnnotations().get(GeneratedBy.class.getName()) != null ||
|
||||
method.getAnnotations().get(InjectedBy.class.getName()) != null) {
|
||||
if (!method.getModifiers().contains(ElementModifier.NATIVE)
|
||||
|| methodGenerators.get(method.getReference()) != null
|
||||
|| methodInjectors.get(method.getReference()) != null
|
||||
|| method.getAnnotations().get(GeneratedBy.class.getName()) != null
|
||||
|| method.getAnnotations().get(InjectedBy.class.getName()) != null) {
|
||||
return;
|
||||
}
|
||||
method.getModifiers().remove(ElementModifier.NATIVE);
|
||||
|
@ -628,8 +628,8 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
}
|
||||
|
||||
boolean noCache = method.getAnnotations().get(NoCache.class.getName()) != null;
|
||||
Program optimizedProgram = incremental && !noCache && programCache != null ?
|
||||
programCache.get(method.getReference()) : null;
|
||||
Program optimizedProgram = incremental && !noCache && programCache != null
|
||||
? programCache.get(method.getReference()) : null;
|
||||
if (optimizedProgram == null) {
|
||||
optimizedProgram = ProgramUtils.copy(method.getProgram());
|
||||
if (optimizedProgram.basicBlockCount() > 0) {
|
||||
|
@ -681,12 +681,12 @@ public class TeaVM implements TeaVMHost, ServiceRepository {
|
|||
|
||||
private void printType(PrintWriter writer, ValueType type) {
|
||||
if (type instanceof ValueType.Object) {
|
||||
writer.print(((ValueType.Object)type).getClassName());
|
||||
writer.print(((ValueType.Object) type).getClassName());
|
||||
} else if (type instanceof ValueType.Array) {
|
||||
printType(writer, ((ValueType.Array)type).getItemType());
|
||||
printType(writer, ((ValueType.Array) type).getItemType());
|
||||
writer.print("[]");
|
||||
} else if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
writer.print("boolean");
|
||||
break;
|
||||
|
|
|
@ -36,8 +36,8 @@ public abstract class IDBFactory implements JSObject {
|
|||
return factory;
|
||||
}
|
||||
|
||||
@JSBody(params = {}, script = "return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || " +
|
||||
"window.msIndexedDB;")
|
||||
@JSBody(params = {}, script = "return window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || "
|
||||
+ "window.msIndexedDB;")
|
||||
static native IDBFactory getInstanceImpl();
|
||||
|
||||
public abstract IDBOpenDBRequest open(String name, int version);
|
||||
|
|
|
@ -37,7 +37,7 @@ public abstract class IDBIndex implements JSObject, IDBCursorSource {
|
|||
if (JS.getType(result) == JSType.STRING) {
|
||||
return new String[] { JS.unwrapString(result) };
|
||||
} else {
|
||||
return JS.unwrapStringArray((JSStringArray)result);
|
||||
return JS.unwrapStringArray((JSStringArray) result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class IDBObjectStore implements JSObject, IDBCursorSource {
|
|||
if (JS.getType(result) == JSType.STRING) {
|
||||
return new String[] { JS.unwrapString(result) };
|
||||
} else {
|
||||
return JS.unwrapStringArray((JSStringArray)result);
|
||||
return JS.unwrapStringArray((JSStringArray) result);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ public class HTML4JPlugin implements TeaVMPlugin {
|
|||
host.add(new JavaScriptResourceInterceptor());
|
||||
EntryPointGenerator entryPointGen = new EntryPointGenerator(host.getProperties()
|
||||
.getProperty("html4j.entryPoints", ""));
|
||||
host.add((DependencyListener)entryPointGen);
|
||||
host.add((RendererListener)entryPointGen);
|
||||
host.add((DependencyListener) entryPointGen);
|
||||
host.add((RendererListener) entryPointGen);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,8 +63,8 @@ public class JavaScriptBodyDependency extends AbstractDependencyListener {
|
|||
@Override
|
||||
public void classReached(DependencyAgent agent, String className, CallLocation location) {
|
||||
ClassReader cls = agent.getClassSource().get(className);
|
||||
if (cls != null && !cls.hasModifier(ElementModifier.ABSTRACT) &&
|
||||
!cls.hasModifier(ElementModifier.INTERFACE)) {
|
||||
if (cls != null && !cls.hasModifier(ElementModifier.ABSTRACT)
|
||||
&& !cls.hasModifier(ElementModifier.INTERFACE)) {
|
||||
allClassesNode.propagate(agent.getType(className));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ public class JavaScriptBodyGenerator implements Generator {
|
|||
}
|
||||
writer.append(")").ws().append("{").indent().softNewLine();
|
||||
writer.append(body).softNewLine();
|
||||
writer.outdent().append("}).call(").append(!method.hasModifier(ElementModifier.STATIC) ?
|
||||
context.getParameterName(0) : "null");
|
||||
writer.outdent().append("}).call(").append(!method.hasModifier(ElementModifier.STATIC)
|
||||
? context.getParameterName(0) : "null");
|
||||
for (int i = 0; i < args.size(); ++i) {
|
||||
writer.append(",").ws();
|
||||
wrapParameter(writer, context.getParameterName(i + 1));
|
||||
|
@ -121,7 +121,7 @@ public class JavaScriptBodyGenerator implements Generator {
|
|||
if (type instanceof ValueType.Object) {
|
||||
return ValueType.object("java.lang.Object");
|
||||
} else if (type instanceof ValueType.Array) {
|
||||
ValueType.Array array = (ValueType.Array)type;
|
||||
ValueType.Array array = (ValueType.Array) type;
|
||||
return ValueType.arrayOf(simplifyParamType(array.getItemType()));
|
||||
} else {
|
||||
return type;
|
||||
|
|
|
@ -116,14 +116,14 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
private void generateFromJavaScript(GeneratorContext context, SourceWriter writer) throws IOException {
|
||||
String obj = context.getParameterName(1);
|
||||
String type = context.getParameterName(2);
|
||||
writer.append("if (" + obj +" === null || " + obj + " === undefined)").ws().append("{")
|
||||
writer.append("if (" + obj + " === null || " + obj + " === undefined)").ws().append("{")
|
||||
.softNewLine().indent();
|
||||
writer.append("return " + obj +";").softNewLine();
|
||||
writer.append("return " + obj + ";").softNewLine();
|
||||
writer.outdent().append("} else if (" + type + ".$meta.item) {").indent().softNewLine();
|
||||
writer.append("var arr = $rt_createArray(" + type + ".$meta.item, " + obj + ".length);").softNewLine();
|
||||
writer.append("for (var i = 0; i < arr.data.length; ++i) {").indent().softNewLine();
|
||||
writer.append("arr.data[i] = ").appendMethodBody(fromJsMethod).append("(" + obj + "[i], " +
|
||||
type + ".$meta.item);").softNewLine();
|
||||
writer.append("arr.data[i] = ").appendMethodBody(fromJsMethod).append("(" + obj + "[i], "
|
||||
+ type + ".$meta.item);").softNewLine();
|
||||
writer.outdent().append("}").softNewLine();
|
||||
writer.append("return arr;").softNewLine();
|
||||
|
||||
|
@ -137,8 +137,8 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
|
||||
writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Character")
|
||||
.append(") {").indent().softNewLine();
|
||||
writer.append("return ").appendMethodBody(valueOfCharMethod).append("(typeof " + obj + " === 'number' ? " +
|
||||
obj + "0xFFFF : " + obj + ".charCodeAt(0));").softNewLine();
|
||||
writer.append("return ").appendMethodBody(valueOfCharMethod).append("(typeof " + obj + " === 'number' ? "
|
||||
+ obj + "0xFFFF : " + obj + ".charCodeAt(0));").softNewLine();
|
||||
|
||||
writer.outdent().append("} else if (" + type + " === ").appendClass("java.lang.Byte")
|
||||
.append(") {").indent().softNewLine();
|
||||
|
@ -161,8 +161,8 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
.append(") {").indent().softNewLine();
|
||||
writer.append("return ").appendMethodBody(valueOfDoubleMethod).append("(" + obj + ");").softNewLine();
|
||||
|
||||
writer.outdent().append("} else if (" + type + " === $rt_intcls() || " + type + " === $rt_bytecls() || " +
|
||||
type + " === $rt_shortcls() ||" + type + " == $rt_charcls()) {").indent().softNewLine();
|
||||
writer.outdent().append("} else if (" + type + " === $rt_intcls() || " + type + " === $rt_bytecls() || "
|
||||
+ type + " === $rt_shortcls() ||" + type + " == $rt_charcls()) {").indent().softNewLine();
|
||||
writer.append("return " + obj + "|0;").softNewLine();
|
||||
|
||||
writer.outdent().append("} else if (" + type + " === $rt_longcls()) {").indent().softNewLine();
|
||||
|
|
|
@ -46,8 +46,8 @@ public class JavaScriptResourceInterceptor extends AbstractRendererListener {
|
|||
String resourceName = packageName.replace('.', '/') + "/" + path;
|
||||
try (InputStream input = context.getClassLoader().getResourceAsStream(resourceName)) {
|
||||
if (input == null) {
|
||||
throw new RenderingException("Error processing JavaScriptResource annotation on class " +
|
||||
className + ". Resource not found: " + resourceName);
|
||||
throw new RenderingException("Error processing JavaScriptResource annotation on class "
|
||||
+ className + ". Resource not found: " + resourceName);
|
||||
}
|
||||
StringWriter writer = new StringWriter();
|
||||
IOUtils.copy(input, writer);
|
||||
|
|
|
@ -87,8 +87,8 @@ abstract class JsCallback {
|
|||
int sigEnd = body.indexOf(')', sigBeg);
|
||||
int colon4 = body.indexOf("::", next);
|
||||
if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) {
|
||||
throw new IllegalStateException("Wrong format of instance callback. Should be: " +
|
||||
"'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body);
|
||||
throw new IllegalStateException("Wrong format of instance callback. Should be: "
|
||||
+ "'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body);
|
||||
}
|
||||
String fqn = body.substring(next + 2, colon4);
|
||||
String method = body.substring(colon4 + 2, sigBeg);
|
||||
|
@ -96,8 +96,8 @@ abstract class JsCallback {
|
|||
|
||||
int paramBeg = body.indexOf('(', sigEnd + 1);
|
||||
if (paramBeg == -1) {
|
||||
throw new IllegalStateException("Wrong format of instance callback. " +
|
||||
"Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body);
|
||||
throw new IllegalStateException("Wrong format of instance callback. "
|
||||
+ "Should be: 'inst.@pkg.Class::method(Ljava/lang/Object;)(param)':\n" + body);
|
||||
}
|
||||
|
||||
sb.append(callMethod(refId, fqn, method, params));
|
||||
|
@ -127,8 +127,8 @@ abstract class JsCallback {
|
|||
int sigEnd = body.indexOf(')', sigBeg);
|
||||
int colon4 = body.indexOf("::", next);
|
||||
if (sigBeg == -1 || sigEnd == -1 || colon4 == -1) {
|
||||
throw new IllegalStateException("Wrong format of static callback. Should be: " +
|
||||
"'@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body);
|
||||
throw new IllegalStateException("Wrong format of static callback. Should be: "
|
||||
+ "'@pkg.Class::staticMethod(Ljava/lang/Object;)(param)':\n" + body);
|
||||
}
|
||||
String fqn = body.substring(next + 1, colon4);
|
||||
String method = body.substring(colon4 + 2, sigBeg);
|
||||
|
|
|
@ -50,23 +50,23 @@ public final class JS {
|
|||
}
|
||||
|
||||
public static <T extends JSObject> JSArray<T> createArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newArray(size);
|
||||
return ((JSGlobal) JS.getGlobal()).newArray(size);
|
||||
}
|
||||
|
||||
public static JSIntArray createIntArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newIntArray(size);
|
||||
return ((JSGlobal) JS.getGlobal()).newIntArray(size);
|
||||
}
|
||||
|
||||
public static JSStringArray createStringArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newStringArray(size);
|
||||
return ((JSGlobal) JS.getGlobal()).newStringArray(size);
|
||||
}
|
||||
|
||||
public static JSBooleanArray createBooleanArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newBooleanArray(size);
|
||||
return ((JSGlobal) JS.getGlobal()).newBooleanArray(size);
|
||||
}
|
||||
|
||||
public static JSDoubleArray createDoubleArray(int size) {
|
||||
return ((JSGlobal)JS.getGlobal()).newDoubleArray(size);
|
||||
return ((JSGlobal) JS.getGlobal()).newDoubleArray(size);
|
||||
}
|
||||
|
||||
@InjectedBy(JSNativeGenerator.class)
|
||||
|
@ -326,11 +326,11 @@ public final class JS {
|
|||
public static native boolean unwrapBoolean(JSObject obj);
|
||||
|
||||
public static byte unwrapByte(JSObject obj) {
|
||||
return (byte)unwrapInt(obj);
|
||||
return (byte) unwrapInt(obj);
|
||||
}
|
||||
|
||||
public static short unwrapShort(JSObject obj) {
|
||||
return (short)unwrapInt(obj);
|
||||
return (short) unwrapInt(obj);
|
||||
}
|
||||
|
||||
@InjectedBy(JSNativeGenerator.class)
|
||||
|
@ -351,7 +351,7 @@ public final class JS {
|
|||
|
||||
public static <T extends JSObject> T[] unwrapArray(Class<T> type, JSArray<T> array) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T[] result = (T[])Array.newInstance(type, array.getLength());
|
||||
T[] result = (T[]) Array.newInstance(type, array.getLength());
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
result[i] = array.get(i);
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ public final class JS {
|
|||
|
||||
public static <T extends JSObject> T[][] unwrapArray2(Class<T> type, JSArray<JSArray<T>> array) {
|
||||
@SuppressWarnings("unchecked")
|
||||
T[][] result = (T[][])Array.newInstance(Array.newInstance(type, 0).getClass(), array.getLength());
|
||||
T[][] result = (T[][]) Array.newInstance(Array.newInstance(type, 0).getClass(), array.getLength());
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
result[i] = unwrapArray(type, array.get(i));
|
||||
}
|
||||
|
@ -370,7 +370,7 @@ public final class JS {
|
|||
public static <T extends JSObject> T[][][] unwrapArray3(Class<T> type, JSArray<JSArray<JSArray<T>>> array) {
|
||||
Class<?> baseType = Array.newInstance(type, 0).getClass();
|
||||
@SuppressWarnings("unchecked")
|
||||
T[][][] result = (T[][][])Array.newInstance(Array.newInstance(baseType, 0).getClass(), array.getLength());
|
||||
T[][][] result = (T[][][]) Array.newInstance(Array.newInstance(baseType, 0).getClass(), array.getLength());
|
||||
for (int i = 0; i < result.length; ++i) {
|
||||
result[i] = unwrapArray2(type, array.get(i));
|
||||
}
|
||||
|
|
|
@ -129,9 +129,9 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
|
|||
case "wrap":
|
||||
if (methodRef.getDescriptor().parameterType(0).isObject("java.lang.String")) {
|
||||
if (context.getArgument(0) instanceof ConstantExpr) {
|
||||
ConstantExpr constant = (ConstantExpr)context.getArgument(0);
|
||||
ConstantExpr constant = (ConstantExpr) context.getArgument(0);
|
||||
if (constant.getValue() instanceof String) {
|
||||
writer.append('"').append(Renderer.escapeString((String)constant.getValue())).append('"');
|
||||
writer.append('"').append(Renderer.escapeString((String) constant.getValue())).append('"');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -219,20 +219,20 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
|
|||
if (!(propertyName instanceof InvocationExpr)) {
|
||||
return null;
|
||||
}
|
||||
InvocationExpr invoke = (InvocationExpr)propertyName;
|
||||
InvocationExpr invoke = (InvocationExpr) propertyName;
|
||||
if (!invoke.getMethod().getClassName().equals(JS.class.getName())) {
|
||||
return null;
|
||||
}
|
||||
if (!invoke.getMethod().getName().equals("wrap") ||
|
||||
!invoke.getMethod().getDescriptor().parameterType(0).isObject("java.lang.String")) {
|
||||
if (!invoke.getMethod().getName().equals("wrap")
|
||||
|| !invoke.getMethod().getDescriptor().parameterType(0).isObject("java.lang.String")) {
|
||||
return null;
|
||||
}
|
||||
Expr arg = invoke.getArguments().get(0);
|
||||
if (!(arg instanceof ConstantExpr)) {
|
||||
return null;
|
||||
}
|
||||
ConstantExpr constant = (ConstantExpr)arg;
|
||||
return constant.getValue() instanceof String ? (String)constant.getValue() : null;
|
||||
ConstantExpr constant = (ConstantExpr) arg;
|
||||
return constant.getValue() instanceof String ? (String) constant.getValue() : null;
|
||||
}
|
||||
|
||||
private boolean isIdentifier(String name) {
|
||||
|
|
|
@ -94,8 +94,8 @@ class JSODependencyListener extends AbstractDependencyListener {
|
|||
}
|
||||
addInterfaces(exposedCls, cls);
|
||||
for (MethodReader method : cls.getMethods()) {
|
||||
if (exposedCls.inheritedMethods.containsKey(method.getDescriptor()) ||
|
||||
exposedCls.methods.containsKey(method.getDescriptor())) {
|
||||
if (exposedCls.inheritedMethods.containsKey(method.getDescriptor())
|
||||
|| exposedCls.methods.containsKey(method.getDescriptor())) {
|
||||
MethodDependency methodDep = agent.linkMethod(method.getReference(), null);
|
||||
methodDep.getVariable(0).propagate(agent.getType(name));
|
||||
methodDep.use();
|
||||
|
|
|
@ -48,8 +48,8 @@ public class JSObjectClassTransformer implements ClassHolderTransformer {
|
|||
for (MethodHolder method : cls.getMethods().toArray(new MethodHolder[0])) {
|
||||
if (method.getAnnotations().get(JSBody.class.getName()) != null) {
|
||||
processor.processJSBody(cls, method);
|
||||
} else if (method.getProgram() != null &&
|
||||
method.getAnnotations().get(JSBodyImpl.class.getName()) == null) {
|
||||
} else if (method.getProgram() != null
|
||||
&& method.getAnnotations().get(JSBodyImpl.class.getName()) == null) {
|
||||
processor.processProgram(method);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -172,8 +172,8 @@ class JavascriptNativeProcessor {
|
|||
if (method.hasModifier(ElementModifier.STATIC)) {
|
||||
continue;
|
||||
}
|
||||
if (method.hasModifier(ElementModifier.FINAL) && method.getProgram() != null &&
|
||||
method.getProgram().basicBlockCount() > 0) {
|
||||
if (method.hasModifier(ElementModifier.FINAL) && method.getProgram() != null
|
||||
&& method.getProgram().basicBlockCount() > 0) {
|
||||
ValueType[] staticSignature = getStaticSignature(method.getReference());
|
||||
MethodHolder callerMethod = new MethodHolder(new MethodDescriptor(method.getName() + "$static",
|
||||
staticSignature));
|
||||
|
@ -282,8 +282,8 @@ class JavascriptNativeProcessor {
|
|||
}
|
||||
if (isNative(cls.getName())) {
|
||||
for (MethodReader method : cls.getMethods()) {
|
||||
if (!method.hasModifier(ElementModifier.STATIC) && !method.hasModifier(ElementModifier.FINAL) &&
|
||||
method.getLevel() != AccessLevel.PRIVATE) {
|
||||
if (!method.hasModifier(ElementModifier.STATIC) && !method.hasModifier(ElementModifier.FINAL)
|
||||
&& method.getLevel() != AccessLevel.PRIVATE) {
|
||||
methods.add(method.getDescriptor());
|
||||
}
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ class JavascriptNativeProcessor {
|
|||
if (!(insn instanceof InvokeInstruction)) {
|
||||
continue;
|
||||
}
|
||||
InvokeInstruction invoke = (InvokeInstruction)insn;
|
||||
InvokeInstruction invoke = (InvokeInstruction) insn;
|
||||
if (!nativeRepos.isJavaScriptClass(invoke.getMethod().getClassName())) {
|
||||
continue;
|
||||
}
|
||||
|
@ -339,8 +339,8 @@ class JavascriptNativeProcessor {
|
|||
if (overriden != null) {
|
||||
CallLocation callLocation = new CallLocation(methodToProcess.getReference(),
|
||||
insn.getLocation());
|
||||
diagnostics.error(callLocation, "JS final method {{m0}} overrides {{M1}}. " +
|
||||
"Overriding final method of overlay types is prohibited.",
|
||||
diagnostics.error(callLocation, "JS final method {{m0}} overrides {{M1}}. "
|
||||
+ "Overriding final method of overlay types is prohibited.",
|
||||
method.getReference(), overriden.getReference());
|
||||
}
|
||||
if (method.getProgram() != null && method.getProgram().basicBlockCount() > 0) {
|
||||
|
@ -361,8 +361,8 @@ class JavascriptNativeProcessor {
|
|||
if (annot.getValue("value") != null) {
|
||||
propertyName = annot.getValue("value").getString();
|
||||
} else {
|
||||
propertyName = method.getName().charAt(0) == 'i' ? cutPrefix(method.getName(), 2) :
|
||||
cutPrefix(method.getName(), 3);
|
||||
propertyName = method.getName().charAt(0) == 'i' ? cutPrefix(method.getName(), 2)
|
||||
: cutPrefix(method.getName(), 3);
|
||||
}
|
||||
Variable result = invoke.getReceiver() != null ? program.createVariable() : null;
|
||||
addPropertyGet(propertyName, invoke.getInstance(), result, invoke.getLocation());
|
||||
|
@ -382,8 +382,8 @@ class JavascriptNativeProcessor {
|
|||
method.parameterType(0));
|
||||
addPropertySet(propertyName, invoke.getInstance(), wrapped, invoke.getLocation());
|
||||
} else {
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript property " +
|
||||
"declaration", invoke.getMethod());
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript property "
|
||||
+ "declaration", invoke.getMethod());
|
||||
continue;
|
||||
}
|
||||
} else if (method.getAnnotations().get(JSIndexer.class.getName()) != null) {
|
||||
|
@ -402,8 +402,8 @@ class JavascriptNativeProcessor {
|
|||
invoke.getLocation());
|
||||
addIndexerSet(invoke.getInstance(), index, value, invoke.getLocation());
|
||||
} else {
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript indexer " +
|
||||
"declaration", invoke.getMethod());
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript indexer "
|
||||
+ "declaration", invoke.getMethod());
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -412,16 +412,16 @@ class JavascriptNativeProcessor {
|
|||
boolean isConstructor = false;
|
||||
if (constructorAnnot != null) {
|
||||
if (!isSupportedType(method.getResultType())) {
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript " +
|
||||
"constructor declaration", invoke.getMethod());
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript "
|
||||
+ "constructor declaration", invoke.getMethod());
|
||||
continue;
|
||||
}
|
||||
AnnotationValue nameVal = constructorAnnot.getValue("value");
|
||||
name = nameVal != null ? constructorAnnot.getValue("value").getString() : "";
|
||||
if (name.isEmpty()) {
|
||||
if (!method.getName().startsWith("new") || method.getName().length() == 3) {
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not declared as a native " +
|
||||
"JavaScript constructor, but its name does not satisfy conventions",
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not declared as a native "
|
||||
+ "JavaScript constructor, but its name does not satisfy conventions",
|
||||
invoke.getMethod());
|
||||
continue;
|
||||
}
|
||||
|
@ -437,15 +437,15 @@ class JavascriptNativeProcessor {
|
|||
}
|
||||
}
|
||||
if (method.getResultType() != ValueType.VOID && !isSupportedType(method.getResultType())) {
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " +
|
||||
"declaration", invoke.getMethod());
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
|
||||
+ "declaration", invoke.getMethod());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
for (ValueType arg : method.getParameterTypes()) {
|
||||
if (!isSupportedType(arg)) {
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method " +
|
||||
"or constructor declaration", invoke.getMethod());
|
||||
diagnostics.error(callLocation, "Method {{m0}} is not a proper native JavaScript method "
|
||||
+ "or constructor declaration", invoke.getMethod());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -487,8 +487,8 @@ class JavascriptNativeProcessor {
|
|||
AnnotationHolder bodyAnnot = methodToProcess.getAnnotations().get(JSBody.class.getName());
|
||||
int jsParamCount = bodyAnnot.getValue("params").getList().size();
|
||||
if (methodToProcess.parameterCount() != jsParamCount) {
|
||||
diagnostics.error(location, "JSBody method {{m0}} declares " + methodToProcess.parameterCount() +
|
||||
" parameters, but annotation specifies " + jsParamCount, methodToProcess);
|
||||
diagnostics.error(location, "JSBody method {{m0}} declares " + methodToProcess.parameterCount()
|
||||
+ " parameters, but annotation specifies " + jsParamCount, methodToProcess);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -524,8 +524,9 @@ class JavascriptNativeProcessor {
|
|||
for (int i = 0; i < paramCount; ++i) {
|
||||
proxyParamTypes[i] = ValueType.parse(JSObject.class);
|
||||
}
|
||||
proxyParamTypes[paramCount] = methodToProcess.getResultType() == ValueType.VOID ? ValueType.VOID :
|
||||
ValueType.parse(JSObject.class);
|
||||
proxyParamTypes[paramCount] = methodToProcess.getResultType() == ValueType.VOID
|
||||
? ValueType.VOID
|
||||
: ValueType.parse(JSObject.class);
|
||||
|
||||
// create proxy method
|
||||
MethodHolder proxyMethod = new MethodHolder("$js_body$_" + methodIndexGenerator++, proxyParamTypes);
|
||||
|
@ -649,7 +650,7 @@ class JavascriptNativeProcessor {
|
|||
|
||||
private Variable unwrap(CallLocation location, Variable var, ValueType type) {
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
return unwrap(var, "unwrapBoolean", ValueType.parse(JSObject.class), ValueType.BOOLEAN,
|
||||
location.getSourceLocation());
|
||||
|
@ -675,7 +676,7 @@ class JavascriptNativeProcessor {
|
|||
break;
|
||||
}
|
||||
} else if (type instanceof ValueType.Object) {
|
||||
String className = ((ValueType.Object)type).getClassName();
|
||||
String className = ((ValueType.Object) type).getClassName();
|
||||
if (className.equals(JSObject.class.getName())) {
|
||||
return var;
|
||||
} else if (className.equals("java.lang.String")) {
|
||||
|
@ -692,7 +693,7 @@ class JavascriptNativeProcessor {
|
|||
return result;
|
||||
}
|
||||
} else if (type instanceof ValueType.Array) {
|
||||
return unwrapArray(location, var, (ValueType.Array)type);
|
||||
return unwrapArray(location, var, (ValueType.Array) type);
|
||||
}
|
||||
diagnostics.error(location, "Unsupported type: {{t0}}", type);
|
||||
return var;
|
||||
|
@ -703,7 +704,7 @@ class JavascriptNativeProcessor {
|
|||
int degree = 0;
|
||||
while (itemType instanceof ValueType.Array) {
|
||||
++degree;
|
||||
itemType = ((ValueType.Array)itemType).getItemType();
|
||||
itemType = ((ValueType.Array) itemType).getItemType();
|
||||
}
|
||||
if (degree > 3) {
|
||||
diagnostics.error(location, "Unsupported type: {{t0}}", type);
|
||||
|
@ -711,14 +712,15 @@ class JavascriptNativeProcessor {
|
|||
}
|
||||
|
||||
if (itemType instanceof ValueType.Object) {
|
||||
String className = ((ValueType.Object)itemType).getClassName();
|
||||
String className = ((ValueType.Object) itemType).getClassName();
|
||||
if (className.equals("java.lang.String")) {
|
||||
String methodName = "unwrapStringArray";
|
||||
if (degree > 1) {
|
||||
methodName += degree;
|
||||
}
|
||||
ValueType argType = degree == 1 ? ValueType.parse(JSStringArray.class) :
|
||||
ValueType.parse(JSArray.class);
|
||||
ValueType argType = degree == 1
|
||||
? ValueType.parse(JSStringArray.class)
|
||||
: ValueType.parse(JSArray.class);
|
||||
return unwrap(var, methodName, argType, type, location.getSourceLocation());
|
||||
} else if (isNative(className)) {
|
||||
return unwrapObjectArray(location, var, degree, itemType, type);
|
||||
|
@ -804,7 +806,7 @@ class JavascriptNativeProcessor {
|
|||
|
||||
private Variable wrapArgument(CallLocation location, Variable var, ValueType type) {
|
||||
if (type instanceof ValueType.Object) {
|
||||
String className = ((ValueType.Object)type).getClassName();
|
||||
String className = ((ValueType.Object) type).getClassName();
|
||||
ClassReader cls = classSource.get(className);
|
||||
if (cls.getAnnotations().get(JSFunctor.class.getName()) != null) {
|
||||
return wrapFunctor(location, var, cls);
|
||||
|
@ -838,7 +840,7 @@ class JavascriptNativeProcessor {
|
|||
|
||||
private Variable wrap(Variable var, ValueType type, InstructionLocation location) {
|
||||
if (type instanceof ValueType.Object) {
|
||||
String className = ((ValueType.Object)type).getClassName();
|
||||
String className = ((ValueType.Object) type).getClassName();
|
||||
if (!className.equals("java.lang.String")) {
|
||||
return var;
|
||||
}
|
||||
|
@ -856,7 +858,7 @@ class JavascriptNativeProcessor {
|
|||
|
||||
private ValueType getWrappedType(ValueType type) {
|
||||
if (type instanceof ValueType.Array) {
|
||||
ValueType itemType = ((ValueType.Array)type).getItemType();
|
||||
ValueType itemType = ((ValueType.Array) type).getItemType();
|
||||
return ValueType.arrayOf(getWrappedType(itemType));
|
||||
} else if (type instanceof ValueType.Object) {
|
||||
if (type.isObject("java.lang.String")) {
|
||||
|
@ -871,9 +873,9 @@ class JavascriptNativeProcessor {
|
|||
|
||||
private ValueType getWrapperType(ValueType type) {
|
||||
if (type instanceof ValueType.Array) {
|
||||
ValueType itemType = ((ValueType.Array)type).getItemType();
|
||||
ValueType itemType = ((ValueType.Array) type).getItemType();
|
||||
if (itemType instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)itemType).getKind()) {
|
||||
switch (((ValueType.Primitive) itemType).getKind()) {
|
||||
case BOOLEAN:
|
||||
return ValueType.parse(JSBooleanArray.class);
|
||||
case BYTE:
|
||||
|
@ -926,8 +928,8 @@ class JavascriptNativeProcessor {
|
|||
}
|
||||
|
||||
private boolean isProperSetter(MethodDescriptor desc) {
|
||||
if (desc.parameterCount() != 1 || !isSupportedType(desc.parameterType(0)) ||
|
||||
desc.getResultType() != ValueType.VOID) {
|
||||
if (desc.parameterCount() != 1 || !isSupportedType(desc.parameterType(0))
|
||||
|| desc.getResultType() != ValueType.VOID) {
|
||||
return false;
|
||||
}
|
||||
return isProperPrefix(desc.getName(), "set");
|
||||
|
@ -942,13 +944,13 @@ class JavascriptNativeProcessor {
|
|||
}
|
||||
|
||||
private boolean isProperGetIndexer(MethodDescriptor desc) {
|
||||
return desc.parameterCount() == 1 && isSupportedType(desc.parameterType(0)) &&
|
||||
isSupportedType(desc.getResultType());
|
||||
return desc.parameterCount() == 1 && isSupportedType(desc.parameterType(0))
|
||||
&& isSupportedType(desc.getResultType());
|
||||
}
|
||||
|
||||
private boolean isProperSetIndexer(MethodDescriptor desc) {
|
||||
return desc.parameterCount() == 2 && isSupportedType(desc.parameterType(0)) &&
|
||||
isSupportedType(desc.parameterType(0)) && desc.getResultType() == ValueType.VOID;
|
||||
return desc.parameterCount() == 2 && isSupportedType(desc.parameterType(0))
|
||||
&& isSupportedType(desc.parameterType(0)) && desc.getResultType() == ValueType.VOID;
|
||||
}
|
||||
|
||||
private String cutPrefix(String name, int prefixLength) {
|
||||
|
@ -967,16 +969,16 @@ class JavascriptNativeProcessor {
|
|||
return false;
|
||||
}
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case LONG:
|
||||
return false;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
} else if (type instanceof ValueType.Array) {
|
||||
return isSupportedType(((ValueType.Array)type).getItemType());
|
||||
return isSupportedType(((ValueType.Array) type).getItemType());
|
||||
} else if (type instanceof ValueType.Object) {
|
||||
String typeName = ((ValueType.Object)type).getClassName();
|
||||
String typeName = ((ValueType.Object) type).getClassName();
|
||||
return typeName.equals("java.lang.String") || nativeRepos.isJavaScriptClass(typeName);
|
||||
} else {
|
||||
return false;
|
||||
|
|
|
@ -33,7 +33,7 @@ public final class Platform {
|
|||
}
|
||||
|
||||
public static PlatformObject getPlatformObject(Object obj) {
|
||||
return (PlatformObject)JS.marshall(obj);
|
||||
return (PlatformObject) JS.marshall(obj);
|
||||
}
|
||||
|
||||
@GeneratedBy(PlatformGenerator.class)
|
||||
|
@ -41,8 +41,8 @@ public final class Platform {
|
|||
public static native Object clone(Object obj);
|
||||
|
||||
public static boolean isInstance(PlatformObject obj, PlatformClass cls) {
|
||||
return obj != null && !JS.isUndefined(obj.getPlatformClass().getMetadata()) &&
|
||||
isAssignable(obj.getPlatformClass(), cls);
|
||||
return obj != null && !JS.isUndefined(obj.getPlatformClass().getMetadata())
|
||||
&& isAssignable(obj.getPlatformClass(), cls);
|
||||
}
|
||||
|
||||
public static boolean isAssignable(PlatformClass from, PlatformClass to) {
|
||||
|
@ -63,15 +63,15 @@ public final class Platform {
|
|||
public static native Class<?> asJavaClass(PlatformObject obj);
|
||||
|
||||
public static PlatformPrimitives getPrimitives() {
|
||||
return (PlatformPrimitives)JS.getGlobal();
|
||||
return (PlatformPrimitives) JS.getGlobal();
|
||||
}
|
||||
|
||||
public static PlatformConsole getConsole() {
|
||||
return (PlatformConsole)JS.getGlobal();
|
||||
return (PlatformConsole) JS.getGlobal();
|
||||
}
|
||||
|
||||
public static int nextObjectId() {
|
||||
return ((PlatformHelper)JS.getGlobal()).nextId();
|
||||
return ((PlatformHelper) JS.getGlobal()).nextId();
|
||||
}
|
||||
|
||||
public static <T> T newInstance(PlatformClass cls) {
|
||||
|
@ -127,14 +127,14 @@ public final class Platform {
|
|||
public static native int schedule(PlatformRunnable runnable, int timeout);
|
||||
|
||||
public static void killSchedule(int id) {
|
||||
((PlatformHelper)JS.getGlobal()).killSchedule(id);
|
||||
((PlatformHelper) JS.getGlobal()).killSchedule(id);
|
||||
}
|
||||
|
||||
public static <T> PlatformQueue<T> createQueue() {
|
||||
return ((PlatformHelper)JS.getGlobal()).newQueue();
|
||||
return ((PlatformHelper) JS.getGlobal()).newQueue();
|
||||
}
|
||||
|
||||
public static PlatformString stringFromCharCode(int charCode) {
|
||||
return ((PlatformHelper)JS.getGlobal()).getStringClass().fromCharCode(charCode);
|
||||
return ((PlatformHelper) JS.getGlobal()).getStringClass().fromCharCode(charCode);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ public class AnnotationDependencySupport extends AbstractDependencyListener {
|
|||
|
||||
@Override
|
||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
if (method.getReference().getClassName().equals(Platform.class.getName()) &&
|
||||
method.getReference().getName().equals("getAnnotations")) {
|
||||
if (method.getReference().getClassName().equals(Platform.class.getName())
|
||||
&& method.getReference().getName().equals("getAnnotations")) {
|
||||
method.getResult().propagate(agent.getType("[" + Annotation.class.getName()));
|
||||
agent.linkMethod(new MethodReference(PlatformAnnotationProvider.class, "getAnnotations",
|
||||
Annotation[].class), location);
|
||||
|
|
|
@ -133,7 +133,7 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
|
|||
} else if (returnType instanceof ValueType.Array) {
|
||||
return className.startsWith("[");
|
||||
} else {
|
||||
return isSubclass(classSource, className, ((ValueType.Object)returnType).getClassName());
|
||||
return isSubclass(classSource, className, ((ValueType.Object) returnType).getClassName());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -31,9 +31,9 @@ public class AsyncMethodProcessor implements ClassHolderTransformer {
|
|||
@Override
|
||||
public void transformClass(ClassHolder cls, ClassReaderSource innerSource, Diagnostics diagnostics) {
|
||||
for (MethodHolder method : cls.getMethods()) {
|
||||
if (method.hasModifier(ElementModifier.NATIVE) &&
|
||||
method.getAnnotations().get(Async.class.getName()) != null &&
|
||||
method.getAnnotations().get(GeneratedBy.class.getName()) == null) {
|
||||
if (method.hasModifier(ElementModifier.NATIVE)
|
||||
&& method.getAnnotations().get(Async.class.getName()) != null
|
||||
&& method.getAnnotations().get(GeneratedBy.class.getName()) == null) {
|
||||
ValueType[] signature = new ValueType[method.parameterCount() + 2];
|
||||
for (int i = 0; i < method.parameterCount(); ++i) {
|
||||
signature[i] = method.parameterType(i);
|
||||
|
@ -43,10 +43,10 @@ public class AsyncMethodProcessor implements ClassHolderTransformer {
|
|||
MethodDescriptor asyncDesc = new MethodDescriptor(method.getName(), signature);
|
||||
MethodHolder asyncMethod = cls.getMethod(asyncDesc);
|
||||
if (asyncMethod != null) {
|
||||
if (asyncMethod.hasModifier(ElementModifier.STATIC) !=
|
||||
method.hasModifier(ElementModifier.STATIC)) {
|
||||
diagnostics.error(new CallLocation(method.getReference()), "Methods {{m0}} and {{m1}} must " +
|
||||
"both be either static or non-static",
|
||||
if (asyncMethod.hasModifier(ElementModifier.STATIC)
|
||||
!= method.hasModifier(ElementModifier.STATIC)) {
|
||||
diagnostics.error(new CallLocation(method.getReference()), "Methods {{m0}} and {{m1}} must "
|
||||
+ "both be either static or non-static",
|
||||
method.getReference(), asyncMethod.getReference());
|
||||
}
|
||||
AnnotationHolder annot = new AnnotationHolder(GeneratedBy.class.getName());
|
||||
|
|
|
@ -35,8 +35,8 @@ class BuildTimeResourceProxyBuilder {
|
|||
|
||||
static {
|
||||
defaultValues.put(boolean.class, false);
|
||||
defaultValues.put(byte.class, (byte)0);
|
||||
defaultValues.put(short.class, (short)0);
|
||||
defaultValues.put(byte.class, (byte) 0);
|
||||
defaultValues.put(short.class, (short) 0);
|
||||
defaultValues.put(int.class, 0);
|
||||
defaultValues.put(float.class, 0F);
|
||||
defaultValues.put(double.class, 0.0);
|
||||
|
@ -70,8 +70,8 @@ class BuildTimeResourceProxyBuilder {
|
|||
|
||||
BuildTimeResourceProxyFactory create() {
|
||||
if (!rootIface.isInterface()) {
|
||||
throw new IllegalArgumentException("Error creating a new resource of type " + rootIface.getName() +
|
||||
" that is not an interface");
|
||||
throw new IllegalArgumentException("Error creating a new resource of type " + rootIface.getName()
|
||||
+ " that is not an interface");
|
||||
}
|
||||
scanIface(rootIface);
|
||||
|
||||
|
@ -102,8 +102,8 @@ class BuildTimeResourceProxyBuilder {
|
|||
|
||||
private void scanIface(Class<?> iface) {
|
||||
if (!Resource.class.isAssignableFrom(iface)) {
|
||||
throw new IllegalArgumentException("Error creating a new resource of type " + iface.getName() + "." +
|
||||
" This type does not implement the " + Resource.class.getName() + " interface");
|
||||
throw new IllegalArgumentException("Error creating a new resource of type " + iface.getName() + "."
|
||||
+ " This type does not implement the " + Resource.class.getName() + " interface");
|
||||
}
|
||||
|
||||
// Scan methods
|
||||
|
@ -127,18 +127,18 @@ class BuildTimeResourceProxyBuilder {
|
|||
Class<?> getterType = property.getValue();
|
||||
Class<?> setterType = setters.get(propertyName);
|
||||
if (setterType == null) {
|
||||
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName +
|
||||
" has a getter, but does not have a setter");
|
||||
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName
|
||||
+ " has a getter, but does not have a setter");
|
||||
}
|
||||
if (!setterType.equals(getterType)) {
|
||||
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName +
|
||||
" has a getter and a setter of different types");
|
||||
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName
|
||||
+ " has a getter and a setter of different types");
|
||||
}
|
||||
}
|
||||
for (String propertyName : setters.keySet()) {
|
||||
if (!getters.containsKey(propertyName)) {
|
||||
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName +
|
||||
" has a setter, but does not have a getter");
|
||||
throw new IllegalArgumentException("Property " + iface.getName() + "." + propertyName
|
||||
+ " has a setter, but does not have a getter");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -148,8 +148,8 @@ class BuildTimeResourceProxyBuilder {
|
|||
Class<?> propertyType = property.getValue();
|
||||
if (!allowedPropertyTypes.contains(propertyType)) {
|
||||
if (!propertyType.isInterface() || !Resource.class.isAssignableFrom(propertyType)) {
|
||||
throw new IllegalArgumentException("Property " + rootIface.getName() + "." + propertyName +
|
||||
" has an illegal type " + propertyType.getName());
|
||||
throw new IllegalArgumentException("Property " + rootIface.getName() + "." + propertyName
|
||||
+ " has an illegal type " + propertyType.getName());
|
||||
}
|
||||
}
|
||||
if (!propertyTypes.containsKey(propertyName)) {
|
||||
|
@ -164,45 +164,45 @@ class BuildTimeResourceProxyBuilder {
|
|||
}
|
||||
|
||||
private void throwInvalidMethod(Method method) {
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." +
|
||||
method.getName() + " is not likely to be either getter or setter");
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
|
||||
+ method.getName() + " is not likely to be either getter or setter");
|
||||
}
|
||||
|
||||
private void scanGetter(Method method) {
|
||||
String propertyName = extractPropertyName(method.getName().substring(3));
|
||||
if (propertyName == null || method.getReturnType().equals(void.class) ||
|
||||
method.getParameterTypes().length > 0) {
|
||||
if (propertyName == null || method.getReturnType().equals(void.class)
|
||||
|| method.getParameterTypes().length > 0) {
|
||||
throwInvalidMethod(method);
|
||||
}
|
||||
if (getters.put(propertyName, method.getReturnType()) != null) {
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." +
|
||||
method.getName() + " is a duplicate getter for property " + propertyName);
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
|
||||
+ method.getName() + " is a duplicate getter for property " + propertyName);
|
||||
}
|
||||
methods.put(method, new BuildTimeResourceGetter(getPropertyIndex(propertyName)));
|
||||
}
|
||||
|
||||
private void scanBooleanGetter(Method method) {
|
||||
String propertyName = extractPropertyName(method.getName().substring(2));
|
||||
if (propertyName == null || !method.getReturnType().equals(boolean.class) ||
|
||||
method.getParameterTypes().length > 0) {
|
||||
if (propertyName == null || !method.getReturnType().equals(boolean.class)
|
||||
|| method.getParameterTypes().length > 0) {
|
||||
throwInvalidMethod(method);
|
||||
}
|
||||
if (getters.put(propertyName, method.getReturnType()) != null) {
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." +
|
||||
method.getName() + " is a duplicate getter for property " + propertyName);
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
|
||||
+ method.getName() + " is a duplicate getter for property " + propertyName);
|
||||
}
|
||||
methods.put(method, new BuildTimeResourceGetter(getPropertyIndex(propertyName)));
|
||||
}
|
||||
|
||||
private void scanSetter(Method method) {
|
||||
String propertyName = extractPropertyName(method.getName().substring(3));
|
||||
if (propertyName == null || !method.getReturnType().equals(void.class) ||
|
||||
method.getParameterTypes().length != 1) {
|
||||
if (propertyName == null || !method.getReturnType().equals(void.class)
|
||||
|| method.getParameterTypes().length != 1) {
|
||||
throwInvalidMethod(method);
|
||||
}
|
||||
if (setters.put(propertyName, method.getParameterTypes()[0]) != null) {
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "." +
|
||||
method.getName() + " is a duplicate setter for property " + propertyName);
|
||||
throw new IllegalArgumentException("Method " + method.getDeclaringClass().getName() + "."
|
||||
+ method.getName() + " is a duplicate setter for property " + propertyName);
|
||||
}
|
||||
methods.put(method, new BuildTimeResourceSetter(getPropertyIndex(propertyName)));
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ class BuildTimeResourceWriterMethod implements BuildTimeResourceMethod {
|
|||
|
||||
@Override
|
||||
public Object invoke(BuildTimeResourceProxy proxy, Object[] args) throws Throwable {
|
||||
SourceWriter writer = (SourceWriter)args[0];
|
||||
SourceWriter writer = (SourceWriter) args[0];
|
||||
writer.append('{');
|
||||
for (int i = 0; i < propertyNames.length; ++i) {
|
||||
if (i > 0) {
|
||||
|
|
|
@ -43,14 +43,15 @@ public class ClassScopedMetadataProviderNativeGenerator implements Generator {
|
|||
return;
|
||||
}
|
||||
if (!method.hasModifier(ElementModifier.NATIVE)) {
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Method {{m0}} is marked with " +
|
||||
"{{c1}} annotation, but it is not native", methodRef, ClassScopedMetadataProvider.class.getName());
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Method {{m0}} is marked with "
|
||||
+ "{{c1}} annotation, but it is not native", methodRef,
|
||||
ClassScopedMetadataProvider.class.getName());
|
||||
return;
|
||||
}
|
||||
|
||||
// Find and instantiate metadata generator
|
||||
ValueType generatorType = providerAnnot.getValue("value").getJavaClass();
|
||||
String generatorClassName = ((ValueType.Object)generatorType).getClassName();
|
||||
String generatorClassName = ((ValueType.Object) generatorType).getClassName();
|
||||
Class<?> generatorClass;
|
||||
try {
|
||||
generatorClass = Class.forName(generatorClassName, true, context.getClassLoader());
|
||||
|
@ -63,24 +64,24 @@ public class ClassScopedMetadataProviderNativeGenerator implements Generator {
|
|||
try {
|
||||
cons = generatorClass.getConstructor();
|
||||
} catch (NoSuchMethodException e) {
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have " +
|
||||
"a public no-arg constructor", generatorClassName);
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have "
|
||||
+ "a public no-arg constructor", generatorClassName);
|
||||
return;
|
||||
}
|
||||
ClassScopedMetadataGenerator generator;
|
||||
try {
|
||||
generator = (ClassScopedMetadataGenerator)cons.newInstance();
|
||||
generator = (ClassScopedMetadataGenerator) cons.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata " +
|
||||
"generator {{c0}}", generatorClassName);
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata "
|
||||
+ "generator {{c0}}", generatorClassName);
|
||||
return;
|
||||
}
|
||||
DefaultMetadataGeneratorContext metadataContext = new DefaultMetadataGeneratorContext(context.getClassSource(),
|
||||
context.getClassLoader(), context.getProperties(), context);
|
||||
|
||||
Map<String, Resource> resourceMap = generator.generateMetadata(metadataContext, methodRef);
|
||||
writer.append("var p").ws().append("=").ws().append("\"" + Renderer.escapeString("$$res_" +
|
||||
writer.getNaming().getFullNameFor(methodRef)) + "\"").append(";").softNewLine();
|
||||
writer.append("var p").ws().append("=").ws().append("\"" + Renderer.escapeString("$$res_"
|
||||
+ writer.getNaming().getFullNameFor(methodRef)) + "\"").append(";").softNewLine();
|
||||
for (Map.Entry<String, Resource> entry : resourceMap.entrySet()) {
|
||||
writer.appendClass(entry.getKey()).append("[p]").ws().append("=").ws();
|
||||
ResourceWriterHelper.write(writer, entry.getValue());
|
||||
|
|
|
@ -50,8 +50,8 @@ public class EnumDependencySupport extends AbstractDependencyListener {
|
|||
|
||||
@Override
|
||||
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||
if (method.getReference().getClassName().equals(Platform.class.getName()) &&
|
||||
method.getReference().getName().equals("getEnumConstants")) {
|
||||
if (method.getReference().getClassName().equals(Platform.class.getName())
|
||||
&& method.getReference().getName().equals("getEnumConstants")) {
|
||||
allEnums.connect(method.getResult().getArrayItem());
|
||||
final MethodReference ref = method.getReference();
|
||||
allEnums.addConsumer(type -> {
|
||||
|
|
|
@ -42,7 +42,7 @@ public class MetadataProviderNativeGenerator implements Generator {
|
|||
|
||||
// Find and instantiate metadata generator
|
||||
ValueType generatorType = providerAnnot.getValue("value").getJavaClass();
|
||||
String generatorClassName = ((ValueType.Object)generatorType).getClassName();
|
||||
String generatorClassName = ((ValueType.Object) generatorType).getClassName();
|
||||
Class<?> generatorClass;
|
||||
try {
|
||||
generatorClass = Class.forName(generatorClassName, true, context.getClassLoader());
|
||||
|
@ -55,16 +55,16 @@ public class MetadataProviderNativeGenerator implements Generator {
|
|||
try {
|
||||
cons = generatorClass.getConstructor();
|
||||
} catch (NoSuchMethodException e) {
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have " +
|
||||
"a public no-arg constructor", generatorClassName);
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Metadata generator {{c0}} does not have "
|
||||
+ "a public no-arg constructor", generatorClassName);
|
||||
return;
|
||||
}
|
||||
MetadataGenerator generator;
|
||||
try {
|
||||
generator = (MetadataGenerator)cons.newInstance();
|
||||
generator = (MetadataGenerator) cons.newInstance();
|
||||
} catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata " +
|
||||
"generator {{c0}}", generatorClassName);
|
||||
context.getDiagnostics().error(new CallLocation(methodRef), "Error instantiating metadata "
|
||||
+ "generator {{c0}}", generatorClassName);
|
||||
return;
|
||||
}
|
||||
DefaultMetadataGeneratorContext metadataContext = new DefaultMetadataGeneratorContext(context.getClassSource(),
|
||||
|
|
|
@ -45,8 +45,8 @@ class MetadataProviderTransformer implements ClassHolderTransformer {
|
|||
if (providerAnnot != null) {
|
||||
ValueType[] params = method.getParameterTypes();
|
||||
if (params.length != 1 && params[0].isObject(PlatformClass.class.getName())) {
|
||||
diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} " +
|
||||
"must take exactly one parameter of type {{c2}}",
|
||||
diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} marked with {{c1}} "
|
||||
+ "must take exactly one parameter of type {{c2}}",
|
||||
method.getReference(), ClassScopedMetadataProvider.class.getName(),
|
||||
PlatformClass.class.getName());
|
||||
}
|
||||
|
@ -111,8 +111,8 @@ class MetadataProviderTransformer implements ClassHolderTransformer {
|
|||
return false;
|
||||
}
|
||||
if (!method.hasModifier(ElementModifier.NATIVE)) {
|
||||
diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} is marked with " +
|
||||
"{{c1}} annotation, but it is not native", method.getReference(),
|
||||
diagnostics.error(new CallLocation(method.getReference()), "Method {{m0}} is marked with "
|
||||
+ "{{c1}} annotation, but it is not native", method.getReference(),
|
||||
MetadataProvider.class.getName());
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class ResourceAccessorInjector implements Injector {
|
|||
|
||||
private void writePropertyAccessor(InjectorContext context, Expr property) throws IOException {
|
||||
if (property instanceof ConstantExpr) {
|
||||
String str = (String)((ConstantExpr)property).getValue();
|
||||
String str = (String) ((ConstantExpr) property).getValue();
|
||||
if (str.isEmpty()) {
|
||||
context.getWriter().append("[\"\"]");
|
||||
return;
|
||||
|
@ -125,7 +125,7 @@ class ResourceAccessorInjector implements Injector {
|
|||
|
||||
private void writeStringExpr(InjectorContext context, Expr expr) throws IOException {
|
||||
if (expr instanceof ConstantExpr) {
|
||||
String str = (String)((ConstantExpr)expr).getValue();
|
||||
String str = (String) ((ConstantExpr) expr).getValue();
|
||||
context.getWriter().append('"');
|
||||
context.writeEscaped(str);
|
||||
context.getWriter().append('"');
|
||||
|
|
|
@ -46,7 +46,7 @@ class ResourceProgramTransformer {
|
|||
for (int i = 0; i < instructions.size(); ++i) {
|
||||
Instruction insn = instructions.get(i);
|
||||
if (insn instanceof InvokeInstruction) {
|
||||
InvokeInstruction invoke = (InvokeInstruction)insn;
|
||||
InvokeInstruction invoke = (InvokeInstruction) insn;
|
||||
List<Instruction> replacement = transformInvoke(invoke);
|
||||
if (replacement != null) {
|
||||
instructions.set(i, new EmptyInstruction());
|
||||
|
@ -62,8 +62,8 @@ class ResourceProgramTransformer {
|
|||
return null;
|
||||
}
|
||||
MethodReference method = insn.getMethod();
|
||||
if (method.getClassName().equals(ResourceArray.class.getName()) ||
|
||||
method.getClassName().equals(ResourceMap.class.getName())) {
|
||||
if (method.getClassName().equals(ResourceArray.class.getName())
|
||||
|| method.getClassName().equals(ResourceMap.class.getName())) {
|
||||
if (method.getName().equals("keys")) {
|
||||
return transformKeys(insn);
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ class ResourceProgramTransformer {
|
|||
ValueType type = insn.getMethod().getDescriptor().getResultType();
|
||||
List<Instruction> instructions = new ArrayList<>();
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
getAndCastProperty(insn, property, instructions, boolean.class);
|
||||
return instructions;
|
||||
|
@ -166,7 +166,7 @@ class ResourceProgramTransformer {
|
|||
break;
|
||||
}
|
||||
} else if (type instanceof ValueType.Object) {
|
||||
switch (((ValueType.Object)type).getClassName()) {
|
||||
switch (((ValueType.Object) type).getClassName()) {
|
||||
case "java.lang.String": {
|
||||
Variable resultVar = insn.getProgram().createVariable();
|
||||
getProperty(insn, property, instructions, resultVar);
|
||||
|
@ -218,8 +218,8 @@ class ResourceProgramTransformer {
|
|||
InvokeInstruction castInvoke = new InvokeInstruction();
|
||||
castInvoke.setType(InvocationType.SPECIAL);
|
||||
String primitiveCapitalized = primitive.getName();
|
||||
primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0)) +
|
||||
primitiveCapitalized.substring(1);
|
||||
primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0))
|
||||
+ primitiveCapitalized.substring(1);
|
||||
castInvoke.setMethod(new MethodReference(ResourceAccessor.class, "castTo" + primitiveCapitalized,
|
||||
Object.class, primitive));
|
||||
castInvoke.getArguments().add(resultVar);
|
||||
|
@ -231,7 +231,7 @@ class ResourceProgramTransformer {
|
|||
ValueType type = insn.getMethod().getDescriptor().parameterType(0);
|
||||
List<Instruction> instructions = new ArrayList<>();
|
||||
if (type instanceof ValueType.Primitive) {
|
||||
switch (((ValueType.Primitive)type).getKind()) {
|
||||
switch (((ValueType.Primitive) type).getKind()) {
|
||||
case BOOLEAN:
|
||||
castAndSetProperty(insn, property, instructions, boolean.class);
|
||||
return instructions;
|
||||
|
@ -255,7 +255,7 @@ class ResourceProgramTransformer {
|
|||
break;
|
||||
}
|
||||
} else if (type instanceof ValueType.Object) {
|
||||
switch (((ValueType.Object)type).getClassName()) {
|
||||
switch (((ValueType.Object) type).getClassName()) {
|
||||
case "java.lang.String": {
|
||||
Variable castVar = insn.getProgram().createVariable();
|
||||
InvokeInstruction castInvoke = new InvokeInstruction();
|
||||
|
@ -300,8 +300,8 @@ class ResourceProgramTransformer {
|
|||
InvokeInstruction castInvoke = new InvokeInstruction();
|
||||
castInvoke.setType(InvocationType.SPECIAL);
|
||||
String primitiveCapitalized = primitive.getName();
|
||||
primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0)) +
|
||||
primitiveCapitalized.substring(1);
|
||||
primitiveCapitalized = Character.toUpperCase(primitiveCapitalized.charAt(0))
|
||||
+ primitiveCapitalized.substring(1);
|
||||
castInvoke.setMethod(new MethodReference(ResourceAccessor.class, "castFrom" + primitiveCapitalized,
|
||||
primitive, Object.class));
|
||||
castInvoke.getArguments().add(insn.getArguments().get(0));
|
||||
|
|
|
@ -31,16 +31,16 @@ final class ResourceWriterHelper {
|
|||
writer.append("null");
|
||||
} else {
|
||||
if (resource instanceof ResourceWriter) {
|
||||
((ResourceWriter)resource).write(writer);
|
||||
((ResourceWriter) resource).write(writer);
|
||||
} else if (resource instanceof Number) {
|
||||
writer.append(resource);
|
||||
} else if (resource instanceof Boolean) {
|
||||
writer.append(resource == Boolean.TRUE ? "true" : "false");
|
||||
} else if (resource instanceof String) {
|
||||
writeString(writer, (String)resource);
|
||||
writeString(writer, (String) resource);
|
||||
} else {
|
||||
throw new RuntimeException("Error compiling resources. Value of illegal type found: " +
|
||||
resource.getClass());
|
||||
throw new RuntimeException("Error compiling resources. Value of illegal type found: "
|
||||
+ resource.getClass());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ public final class AsyncProgram {
|
|||
prime[2] = true;
|
||||
prime[3] = true;
|
||||
nextPrime: for (int i = 5; i < prime.length; i += 2) {
|
||||
int maxPrime = (int)Math.sqrt(i);
|
||||
int maxPrime = (int) Math.sqrt(i);
|
||||
for (int j = 3; j <= maxPrime; j += 2) {
|
||||
Thread.yield();
|
||||
if (prime[j] && i % j == 0) {
|
||||
|
|
|
@ -71,18 +71,18 @@ public class Scene {
|
|||
int parts = 30;
|
||||
for (int i = 0; i < parts; ++i) {
|
||||
PolygonShape shape = new PolygonShape();
|
||||
double angle1 = i / (double)parts * 2 * Math.PI;
|
||||
double angle1 = i / (double) parts * 2 * Math.PI;
|
||||
double x1 = 2.7 * Math.cos(angle1);
|
||||
double y1 = 2.7 * Math.sin(angle1);
|
||||
double angle2 = (i + 1) / (double)parts * 2 * Math.PI;
|
||||
double angle2 = (i + 1) / (double) parts * 2 * Math.PI;
|
||||
double x2 = 2.7 * Math.cos(angle2);
|
||||
double y2 = 2.7 * Math.sin(angle2);
|
||||
double angle = (angle1 + angle2) / 2;
|
||||
double x = 0.01 * Math.cos(angle);
|
||||
double y = 0.01 * Math.sin(angle);
|
||||
|
||||
shape.set(new Vec2[] { new Vec2((float)x1, (float)y1), new Vec2((float)x2, (float)y2),
|
||||
new Vec2((float)(x2 - x), (float)(y2 - y)), new Vec2((float)(x1 - x), (float)(y1 - y)) }, 4);
|
||||
shape.set(new Vec2[] { new Vec2((float) x1, (float) y1), new Vec2((float) x2, (float) y2),
|
||||
new Vec2((float) (x2 - x), (float) (y2 - y)), new Vec2((float) (x1 - x), (float) (y1 - y)) }, 4);
|
||||
fixture.shape = shape;
|
||||
reel.createFixture(fixture);
|
||||
}
|
||||
|
@ -137,10 +137,10 @@ public class Scene {
|
|||
|
||||
public void calculate() {
|
||||
long currentTime = System.currentTimeMillis();
|
||||
int timeToCalculate = (int)(currentTime - lastCalculated);
|
||||
int timeToCalculate = (int) (currentTime - lastCalculated);
|
||||
long relativeTime = currentTime - startTime;
|
||||
while (timeToCalculate > 10) {
|
||||
int period = (int)((relativeTime + 5000) / 10000);
|
||||
int period = (int) ((relativeTime + 5000) / 10000);
|
||||
reel.applyTorque(period % 2 == 0 ? 8f : -8f);
|
||||
world.step(0.01f, 20, 40);
|
||||
lastCalculated += 10;
|
||||
|
@ -149,7 +149,7 @@ public class Scene {
|
|||
}
|
||||
|
||||
public int timeUntilNextStep() {
|
||||
return (int)Math.max(0, lastCalculated + 10 - System.currentTimeMillis());
|
||||
return (int) Math.max(0, lastCalculated + 10 - System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
|
|
|
@ -43,7 +43,7 @@ public class BenchmarkStarter implements EntryPoint {
|
|||
@Override
|
||||
public void onModuleLoad() {
|
||||
document = RootPanel.getBodyElement().getOwnerDocument();
|
||||
canvas = (CanvasElement)document.getElementById("benchmark-canvas");
|
||||
canvas = (CanvasElement) document.getElementById("benchmark-canvas");
|
||||
resultTableBody = document.getElementById("result-table-body");
|
||||
startMillisecond = System.currentTimeMillis();
|
||||
makeStep();
|
||||
|
@ -53,7 +53,7 @@ public class BenchmarkStarter implements EntryPoint {
|
|||
double start = Performance.now();
|
||||
scene.calculate();
|
||||
double end = Performance.now();
|
||||
int second = (int)((System.currentTimeMillis() - startMillisecond) / 1000);
|
||||
int second = (int) ((System.currentTimeMillis() - startMillisecond) / 1000);
|
||||
if (second > currentSecond) {
|
||||
Element row = document.createElement("tr");
|
||||
resultTableBody.appendChild(row);
|
||||
|
@ -94,13 +94,13 @@ public class BenchmarkStarter implements EntryPoint {
|
|||
for (Fixture fixture = body.getFixtureList(); fixture != null; fixture = fixture.getNext()) {
|
||||
Shape shape = fixture.getShape();
|
||||
if (shape.getType() == ShapeType.CIRCLE) {
|
||||
CircleShape circle = (CircleShape)shape;
|
||||
CircleShape circle = (CircleShape) shape;
|
||||
context.beginPath();
|
||||
context.arc(circle.m_p.x, circle.m_p.y, circle.getRadius(), 0, Math.PI * 2, true);
|
||||
context.closePath();
|
||||
context.stroke();
|
||||
} else if (shape.getType() == ShapeType.POLYGON) {
|
||||
PolygonShape poly = (PolygonShape)shape;
|
||||
PolygonShape poly = (PolygonShape) shape;
|
||||
Vec2[] vertices = poly.getVertices();
|
||||
context.beginPath();
|
||||
context.moveTo(vertices[0].x, vertices[0].y);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user