Rename achieved -> reached. Fix - operator generation in minified mode

This commit is contained in:
Alexey Andreev 2015-10-21 12:08:30 +03:00
parent bb16e891b9
commit 2640234391
10 changed files with 18 additions and 23 deletions

View File

@ -52,7 +52,7 @@ public class SystemNativeGenerator implements Generator, DependencyPlugin {
}
@Override
public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) {
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
switch (method.getReference().getName()) {
case "doArrayCopy":
achieveArrayCopy(method);

View File

@ -39,7 +39,7 @@ public class ArrayNativeGenerator implements Generator, DependencyPlugin {
ValueType.INTEGER, ValueType.LONG, ValueType.FLOAT, ValueType.DOUBLE, ValueType.BOOLEAN };
@Override
public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) {
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
switch (method.getReference().getName()) {
case "getLength":
achieveGetLength(agent, method);

View File

@ -382,7 +382,7 @@ public class DependencyChecker implements DependencyInfo {
private void activateDependencyPlugin(MethodDependency methodDep, CallLocation location) {
attachDependencyPlugin(methodDep);
if (methodDep.dependencyPlugin != null) {
methodDep.dependencyPlugin.methodAchieved(agent, methodDep, location);
methodDep.dependencyPlugin.methodReached(agent, methodDep, location);
}
}

View File

@ -22,5 +22,5 @@ import org.teavm.model.CallLocation;
* @author Alexey Andreev
*/
public interface DependencyPlugin {
void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location);
void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location);
}

View File

@ -1525,10 +1525,8 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
case NEGATE:
if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) {
writer.append('(');
} else if (outerPrecedence.ordinal() >= Precedence.ADDITION.ordinal()) {
writer.append(' ');
}
writer.append("-");
writer.append(" -");
precedence = Precedence.UNARY;
expr.getOperand().acceptVisitor(this);
if (outerPrecedence.ordinal() > Precedence.UNARY.ordinal()) {
@ -1664,16 +1662,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
}
String str = constantToString(expr.getValue());
if (str.startsWith("-")) {
if (precedence.ordinal() >= Precedence.UNARY.ordinal()) {
writer.append('(');
} else {
writer.append(' ');
}
}
writer.append(str);
if (str.startsWith("-") && precedence.ordinal() >= Precedence.UNARY.ordinal()) {
writer.append(')');
}
if (expr.getLocation() != null) {
popLocation();
}

View File

@ -717,13 +717,16 @@ public class AstWriter {
private void printUnary(UnaryExpression node, int precedence) throws IOException {
int innerPrecedence = node.isPostfix() ? PRECEDENCE_POSTFIX : PRECEDENCE_PREFIX;
if (innerPrecedence > precedence) {
writer.append('(');
}
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())) {
writer.append(' ');
}
@ -768,13 +771,14 @@ public class AstWriter {
}
print(node.getLeft(), leftPrecedence);
String op = AstNode.operatorToString(node.getType());
boolean ws = requiresWhitespaces(node.getType());
if (ws) {
if (ws || op.startsWith("-")) {
writer.append(' ');
} else {
writer.ws();
}
writer.append(AstNode.operatorToString(node.getType()));
writer.append(op);
if (ws) {
writer.append(' ');
} else {

View File

@ -169,7 +169,7 @@ public class JSNativeGenerator implements Injector, DependencyPlugin, Generator
}
@Override
public void methodAchieved(final DependencyAgent agent, final MethodDependency method,
public void methodReached(final DependencyAgent agent, final MethodDependency method,
final CallLocation location) {
switch (method.getReference().getName()) {
case "invoke":

View File

@ -98,7 +98,7 @@ public class AsyncMethodGenerator implements Generator, DependencyPlugin {
}
@Override
public void methodAchieved(DependencyAgent checker, MethodDependency method, CallLocation location) {
public void methodReached(DependencyAgent checker, MethodDependency method, CallLocation location) {
MethodReference ref = method.getReference();
MethodReference asyncRef = getAsyncReference(ref);
MethodDependency asyncMethod = checker.linkMethod(asyncRef, location);

View File

@ -41,7 +41,7 @@ import org.teavm.platform.PlatformRunnable;
*/
public class PlatformGenerator implements Generator, Injector, DependencyPlugin {
@Override
public void methodAchieved(DependencyAgent agent, MethodDependency method, CallLocation location) {
public void methodReached(DependencyAgent agent, MethodDependency method, CallLocation location) {
switch (method.getReference().getName()) {
case "asJavaClass":
method.getResult().propagate(agent.getType("java.lang.Class"));

View File

@ -32,7 +32,7 @@ import org.teavm.platform.PlatformQueue;
*/
public class PlatformQueueGenerator implements Injector, DependencyPlugin {
@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",
Object.class, PlatformObject.class), null);
addMethod.getVariable(1).connect(method.getResult());