From ad3fa3b53190049c5ae5547e5301552c9ad25eef Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Mon, 7 Apr 2014 13:01:19 +0400 Subject: [PATCH] Fixes bugs --- .../org/teavm/classlib/java/lang/TString.java | 3 ++ .../org/teavm/classlib/java/lang/TSystem.java | 7 ++- .../java/org/teavm/javascript/Renderer.java | 44 ++++++++++--------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java index f50977e12..efadef73b 100644 --- a/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java +++ b/teavm-classlib/src/main/java/org/teavm/classlib/java/lang/TString.java @@ -508,6 +508,9 @@ public class TString extends TObject implements TSerializable, TComparable nonInitMethods = new ArrayList<>(); List virtualMethods = new ArrayList<>(); + + writer.append("function ").appendClass(cls.getName()).append("_$clinit()").ws() + .append("{").softNewLine().indent(); + writer.appendClass(cls.getName()).append("_$clinit").ws().append("=").ws() + .append("function(){};").newLine(); + List stubNames = new ArrayList<>(); + for (MethodNode method : cls.getMethods()) { + if (!method.getModifiers().contains(NodeModifier.STATIC) && + !method.getReference().getName().equals("")) { + nonInitMethods.add(method); + } else { + renderBody(method, true); + stubNames.add(naming.getFullNameFor(method.getReference())); + } + } + MethodHolder methodHolder = classSource.get(cls.getName()).getMethod( + new MethodDescriptor("", ValueType.VOID)); + if (methodHolder != null) { + writer.appendMethodBody(new MethodReference(cls.getName(), methodHolder.getDescriptor())) + .append("();").softNewLine(); + } + writer.outdent().append("}").newLine(); if (!cls.getModifiers().contains(NodeModifier.INTERFACE)) { - writer.append("function ").appendClass(cls.getName()).append("_$clinit()").ws() - .append("{").softNewLine().indent(); - writer.appendClass(cls.getName()).append("_$clinit").ws().append("=").ws() - .append("function(){};").newLine(); - List stubNames = new ArrayList<>(); - for (MethodNode method : cls.getMethods()) { - if (!method.getModifiers().contains(NodeModifier.STATIC) && - !method.getReference().getName().equals("")) { - nonInitMethods.add(method); - } else { - renderBody(method, true); - stubNames.add(naming.getFullNameFor(method.getReference())); - } - } - MethodHolder methodHolder = classSource.get(cls.getName()).getMethod( - new MethodDescriptor("", ValueType.VOID)); - if (methodHolder != null) { - writer.appendMethodBody(new MethodReference(cls.getName(), methodHolder.getDescriptor())) - .append("();").softNewLine(); - } - writer.outdent().append("}").newLine(); for (MethodNode method : cls.getMethods()) { cls.getMethods(); if (!method.getModifiers().contains(NodeModifier.STATIC)) { @@ -286,6 +287,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext writer.append("]);").newLine(); } } + for (MethodNode method : nonInitMethods) { renderBody(method, false); }