mirror of
https://github.com/Eaglercraft-TeaVM-Fork/eagler-teavm.git
synced 2024-12-22 08:14:09 -08:00
Rename achieved -> reached. Fix - operator generation in minified mode
This commit is contained in:
parent
bb16e891b9
commit
2640234391
|
@ -52,7 +52,7 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "doArrayCopy":
|
case "doArrayCopy":
|
||||||
achieveArrayCopy(method);
|
achieveArrayCopy(method);
|
||||||
|
|
|
@ -39,7 +39,7 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
|
||||||
ValueType.INTEGER, ValueType.LONG, ValueType.FLOAT, ValueType.DOUBLE, ValueType.BOOLEAN };
|
ValueType.INTEGER, ValueType.LONG, ValueType.FLOAT, ValueType.DOUBLE, ValueType.BOOLEAN };
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "getLength":
|
case "getLength":
|
||||||
achieveGetLength(agent, method);
|
achieveGetLength(agent, method);
|
||||||
|
|
|
@ -382,7 +382,7 @@ public class DependencyChecker implements DependencyInfo {
|
||||||
private void activateDependencyPlugin(MethodDependency methodDep, CallLocation location) {
|
private void activateDependencyPlugin(MethodDependency methodDep, CallLocation location) {
|
||||||
attachDependencyPlugin(methodDep);
|
attachDependencyPlugin(methodDep);
|
||||||
if (methodDep.dependencyPlugin != null) {
|
if (methodDep.dependencyPlugin != null) {
|
||||||
methodDep.dependencyPlugin.methodAchieved(agent, methodDep, location);
|
methodDep.dependencyPlugin.methodReached(agent, methodDep, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,5 +22,5 @@ import org.teavm.model.CallLocation;
|
||||||
* @author Alexey Andreev
|
* @author Alexey Andreev
|
||||||
*/
|
*/
|
||||||
public interface DependencyPlugin {
|
public interface DependencyPlugin {
|
||||||
void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location);
|
void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1525,10 +1525,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
case NEGATE:
|
case NEGATE:
|
||||||
if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) {
|
if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) {
|
||||||
writer.append('(');
|
writer.append('(');
|
||||||
} else if (outerPrecedence.ordinal() >= Precedence.ADDITION.ordinal()) {
|
|
||||||
writer.append(' ');
|
|
||||||
}
|
}
|
||||||
writer.append("-");
|
writer.append(" -");
|
||||||
precedence = Precedence.UNARY;
|
precedence = Precedence.UNARY;
|
||||||
expr.getOperand().acceptVisitor(this);
|
expr.getOperand().acceptVisitor(this);
|
||||||
if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) {
|
if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) {
|
||||||
|
@ -1664,16 +1662,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
|
||||||
}
|
}
|
||||||
String str = constantToString(expr.getValue());
|
String str = constantToString(expr.getValue());
|
||||||
if (str.startsWith("-")) {
|
if (str.startsWith("-")) {
|
||||||
if (precedence.ordinal() >= Precedence.UNARY.ordinal()) {
|
writer.append(' ');
|
||||||
writer.append('(');
|
|
||||||
} else {
|
|
||||||
writer.append(' ');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
writer.append(str);
|
writer.append(str);
|
||||||
if (str.startsWith("-") && precedence.ordinal() >= Precedence.UNARY.ordinal()) {
|
|
||||||
writer.append(')');
|
|
||||||
}
|
|
||||||
if (expr.getLocation() != null) {
|
if (expr.getLocation() != null) {
|
||||||
popLocation();
|
popLocation();
|
||||||
}
|
}
|
||||||
|
|
|
@ -717,13 +717,16 @@ public class AstWriter {
|
||||||
private void printUnary(UnaryExpression node, int precedence) throws IOException {
|
private void printUnary(UnaryExpression node, int precedence) throws IOException {
|
||||||
int innerPrecedence = node.isPostfix() ? PRECEDENCE_POSTFIX : PRECEDENCE_PREFIX;
|
int innerPrecedence = node.isPostfix() ? PRECEDENCE_POSTFIX : PRECEDENCE_PREFIX;
|
||||||
|
|
||||||
|
|
||||||
if (innerPrecedence > precedence) {
|
if (innerPrecedence > precedence) {
|
||||||
writer.append('(');
|
writer.append('(');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!node.isPostfix()) {
|
if (!node.isPostfix()) {
|
||||||
writer.append(AstNode.operatorToString(node.getType()));
|
String op = AstNode.operatorToString(node.getType());
|
||||||
|
if (op.startsWith("-")) {
|
||||||
|
writer.append(' ');
|
||||||
|
}
|
||||||
|
writer.append(op);
|
||||||
if (requiresWhitespaces(node.getType())) {
|
if (requiresWhitespaces(node.getType())) {
|
||||||
writer.append(' ');
|
writer.append(' ');
|
||||||
}
|
}
|
||||||
|
@ -768,13 +771,14 @@ public class AstWriter {
|
||||||
}
|
}
|
||||||
print(node.getLeft(), leftPrecedence);
|
print(node.getLeft(), leftPrecedence);
|
||||||
|
|
||||||
|
String op = AstNode.operatorToString(node.getType());
|
||||||
boolean ws = requiresWhitespaces(node.getType());
|
boolean ws = requiresWhitespaces(node.getType());
|
||||||
if (ws) {
|
if (ws || op.startsWith("-")) {
|
||||||
writer.append(' ');
|
writer.append(' ');
|
||||||
} else {
|
} else {
|
||||||
writer.ws();
|
writer.ws();
|
||||||
}
|
}
|
||||||
writer.append(AstNode.operatorToString(node.getType()));
|
writer.append(op);
|
||||||
if (ws) {
|
if (ws) {
|
||||||
writer.append(' ');
|
writer.append(' ');
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -169,7 +169,7 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(final DependencyAgent agent, final MethodDependency method,
|
public void methodReached(final DependencyAgent agent, final MethodDependency method,
|
||||||
final CallLocation location) {
|
final CallLocation location) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "invoke":
|
case "invoke":
|
||||||
|
|
|
@ -98,7 +98,7 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyAgent checker, MethodDependency method, CallLocation location) {
|
public void methodReached(DependencyAgent checker, MethodDependency method, CallLocation location) {
|
||||||
MethodReference ref = method.getReference();
|
MethodReference ref = method.getReference();
|
||||||
MethodReference asyncRef = getAsyncReference(ref);
|
MethodReference asyncRef = getAsyncReference(ref);
|
||||||
MethodDependency asyncMethod = checker.linkMethod(asyncRef, location);
|
MethodDependency asyncMethod = checker.linkMethod(asyncRef, location);
|
||||||
|
|
|
@ -41,7 +41,7 @@ import org.teavm.platform.PlatformRunnable;
|
||||||
*/
|
*/
|
||||||
public class PlatformGenerator implements Generator, Injector, DependencyPlugin {
|
public class PlatformGenerator implements Generator, Injector, DependencyPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||||
switch (method.getReference().getName()) {
|
switch (method.getReference().getName()) {
|
||||||
case "asJavaClass":
|
case "asJavaClass":
|
||||||
method.getResult().propagate(agent.getType("java.lang.Class"));
|
method.getResult().propagate(agent.getType("java.lang.Class"));
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.teavm.platform.PlatformQueue;
|
||||||
*/
|
*/
|
||||||
public class PlatformQueueGenerator implements Injector, DependencyPlugin {
|
public class PlatformQueueGenerator implements Injector, DependencyPlugin {
|
||||||
@Override
|
@Override
|
||||||
public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
|
||||||
MethodDependency addMethod = agent.linkMethod(new MethodReference(PlatformQueue.class, "wrap",
|
MethodDependency addMethod = agent.linkMethod(new MethodReference(PlatformQueue.class, "wrap",
|
||||||
Object.class, PlatformObject.class), null);
|
Object.class, PlatformObject.class), null);
|
||||||
addMethod.getVariable(1).connect(method.getResult());
|
addMethod.getVariable(1).connect(method.getResult());
|
||||||
|
|
Loading…
Reference in New Issue
Block a user