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));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -57,8 +57,8 @@ public class DefaultCallSite implements CallSite {
|
|||
return false;
|
||||
}
|
||||
DefaultCallSite other = (DefaultCallSite) obj;
|
||||
return Objects.equals(callee.getMethod(), other.callee.getMethod()) &&
|
||||
Objects.equals(location, other.location);
|
||||
return Objects.equals(callee.getMethod(), other.callee.getMethod())
|
||||
&& Objects.equals(location, other.location);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,8 +62,8 @@ public class DefaultClassAccessSite implements ClassAccessSite {
|
|||
return false;
|
||||
}
|
||||
DefaultClassAccessSite other = (DefaultClassAccessSite) obj;
|
||||
return Objects.equals(location, other.location) &&
|
||||
Objects.equals(callee, other.callee) &&
|
||||
Objects.equals(className, other.className);
|
||||
return Objects.equals(location, other.location)
|
||||
&& Objects.equals(callee, other.callee)
|
||||
&& Objects.equals(className, other.className);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class DefaultFieldAccessSite implements FieldAccessSite {
|
|||
return false;
|
||||
}
|
||||
DefaultFieldAccessSite other = (DefaultFieldAccessSite) obj;
|
||||
return Objects.equals(location, other.location) && Objects.equals(callee, other.callee) &&
|
||||
Objects.equals(field, other.field);
|
||||
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;
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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,8 +224,8 @@ 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();
|
||||
|
@ -233,8 +233,8 @@ public class Decompiler {
|
|||
Class<?> generatorClass = Class.forName(generatorClassName, true, classLoader);
|
||||
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) {
|
||||
|
|
|
@ -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)) {
|
||||
|
|
|
@ -177,8 +177,8 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
return;
|
||||
}
|
||||
VariableExpr var = (VariableExpr) assignment.getLeftValue();
|
||||
if (var.getLocation() != null && assignment.getLocation() != null &&
|
||||
!assignment.getLocation().equals(var.getLocation())) {
|
||||
if (var.getLocation() != null && assignment.getLocation() != null
|
||||
&& !assignment.getLocation().equals(var.getLocation())) {
|
||||
return;
|
||||
}
|
||||
if (var.getIndex() == index) {
|
||||
|
@ -371,9 +371,9 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
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())) {
|
||||
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());
|
||||
|
@ -419,8 +419,8 @@ class OptimizingVisitor implements StatementVisitor, ExprVisitor {
|
|||
if (stmt instanceof ConditionalStatement) {
|
||||
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;
|
||||
if (exit != null && exit == breakStmt.getTarget()) {
|
||||
|
@ -431,8 +431,8 @@ 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;
|
||||
if (exit != null && exit == breakStmt.getTarget()) {
|
||||
|
@ -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());
|
||||
|
|
|
@ -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)) {
|
||||
|
@ -928,8 +928,8 @@ 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) {
|
||||
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('(');
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
|
@ -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");
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -35,8 +35,8 @@ 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) {
|
||||
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;
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -122,8 +122,8 @@ public class JavaScriptConvGenerator implements Generator {
|
|||
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);
|
||||
|
|
|
@ -223,8 +223,8 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
|
|||
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);
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -717,8 +718,9 @@ class JavascriptNativeProcessor {
|
|||
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);
|
||||
|
@ -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) {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
|
|
|
@ -43,8 +43,9 @@ 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;
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
} 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 -> {
|
||||
|
|
|
@ -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();
|
||||
} 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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
|
|
@ -39,8 +39,8 @@ final class ResourceWriterHelper {
|
|||
} else if (resource instanceof String) {
|
||||
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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,16 +117,16 @@ public final class BenchmarkStarter {
|
|||
context.restore();
|
||||
}
|
||||
|
||||
@JavaScriptBody(args = { "second", "timeSpentCalculating" }, body =
|
||||
"var resultTableBody = document.getElementById('result-table-body');\n" +
|
||||
"var row = document.createElement(\"tr\");\n" +
|
||||
"resultTableBody.appendChild(row);\n" +
|
||||
"var secondCell = document.createElement(\"td\");\n" +
|
||||
"row.appendChild(secondCell);\n" +
|
||||
"secondCell.appendChild(document.createTextNode(second));\n" +
|
||||
"var timeCell = document.createElement(\"td\");\n" +
|
||||
"row.appendChild(timeCell);\n" +
|
||||
"timeCell.appendChild(document.createTextNode(timeSpentCalculating));\n"
|
||||
@JavaScriptBody(args = { "second", "timeSpentCalculating" }, body = ""
|
||||
+ "var resultTableBody = document.getElementById('result-table-body');\n"
|
||||
+ "var row = document.createElement(\"tr\");\n"
|
||||
+ "resultTableBody.appendChild(row);\n"
|
||||
+ "var secondCell = document.createElement(\"td\");\n"
|
||||
+ "row.appendChild(secondCell);\n"
|
||||
+ "secondCell.appendChild(document.createTextNode(second));\n"
|
||||
+ "var timeCell = document.createElement(\"td\");\n"
|
||||
+ "row.appendChild(timeCell);\n"
|
||||
+ "timeCell.appendChild(document.createTextNode(timeSpentCalculating));\n"
|
||||
)
|
||||
private static native void publishResults(int second, double time);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@ public final class Application {
|
|||
HTMLButtonElement deleteButton = (HTMLButtonElement) document.getElementById("delete-button");
|
||||
deleteButton.addEventListener("click", e -> {
|
||||
String key = ((HTMLInputElement) document.getElementById("key")).getValue();
|
||||
|
||||
if (key != null && key.length() > 0) {
|
||||
storage.removeItem(key);
|
||||
draw();
|
||||
|
|
Loading…
Reference in New Issue
Block a user