From 11437af5ae793c12c78dea0587edea848b4b07c9 Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Sat, 21 Feb 2015 23:01:12 +0400 Subject: [PATCH] Fix https://github.com/konsoletyper/teavm/issues/73 --- .../teavm/codegen/DefaultNamingStrategy.java | 37 +++++-------------- .../java/org/teavm/javascript/Renderer.java | 5 +-- 2 files changed, 11 insertions(+), 31 deletions(-) diff --git a/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java b/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java index 80123b3c5..1510b3570 100644 --- a/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java +++ b/teavm-core/src/main/java/org/teavm/codegen/DefaultNamingStrategy.java @@ -66,32 +66,13 @@ public class DefaultNamingStrategy implements NamingStrategy { } private String getNameFor(MethodReference method, char classifier) { - MethodReference origMethod = method; - method = getRealMethod(method); - if (method == null) { - throw new NamingException("Can't provide name for method as it was not found: " + origMethod); - } - ClassReader clsHolder = classSource.get(method.getClassName()); - MethodReader methodHolder = clsHolder.getMethod(method.getDescriptor()); - if (methodHolder.hasModifier(ElementModifier.STATIC) || - method.getDescriptor().getName().equals("") || - methodHolder.getLevel() == AccessLevel.PRIVATE) { - String key = classifier + method.toString(); - String alias = privateAliases.get(key); - if (alias == null) { - alias = aliasProvider.getAlias(method); - privateAliases.put(key, alias); - } - return alias; - } else { - String key = classifier + method.getDescriptor().toString(); - String alias = aliases.get(key); - if (alias == null) { - alias = aliasProvider.getAlias(method); - aliases.put(key, alias); - } - return alias; + String key = classifier + method.getDescriptor().toString(); + String alias = aliases.get(key); + if (alias == null) { + alias = aliasProvider.getAlias(method); + aliases.put(key, alias); } + return alias; } @Override @@ -106,13 +87,13 @@ public class DefaultNamingStrategy implements NamingStrategy { private String getFullNameFor(MethodReference method, char classifier) throws NamingException { MethodReference originalMethod = method; - if (!minifying) { - return getNameFor(method.getClassName()) + "_" + getNameFor(method, classifier); - } method = getRealMethod(method); if (method == null) { throw new NamingException("Can't provide name for method as it was not found: " + originalMethod); } + if (!minifying) { + return getNameFor(method.getClassName()) + "_" + getNameFor(method, classifier); + } String key = classifier + method.toString(); String alias = privateAliases.get(key); if (alias == null) { diff --git a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java index 706eda6ba..a20cadb5c 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java @@ -1604,7 +1604,6 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext } String name = expr.getAsyncTarget() == null ? naming.getNameFor(expr.getMethod()) : naming.getNameForAsync(expr.getMethod()); - String fullName = naming.getFullNameFor(expr.getMethod()); DeferredCallSite callSite = prevCallSite; boolean shouldEraseCallSite = lastCallSite == null; if (lastCallSite == null) { @@ -1615,7 +1614,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext enterPriority(Priority.COMMA, Associativity.NONE, false); switch (expr.getType()) { case STATIC: - writer.append(fullName).append("("); + writer.appendMethodBody(expr.getMethod()).append("("); prevCallSite = debugEmitter.emitCallSite(); for (int i = 0; i < expr.getArguments().size(); ++i) { if (i > 0) { @@ -1626,7 +1625,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext } break; case SPECIAL: - writer.append(fullName).append("("); + writer.appendMethodBody(expr.getMethod()).append("("); prevCallSite = debugEmitter.emitCallSite(); expr.getArguments().get(0).acceptVisitor(this); hasParams = true;