From dc3faa172717968abbf61c2e2b5f2ed3fc47b76f Mon Sep 17 00:00:00 2001 From: konsoletyper Date: Sat, 13 Sep 2014 19:38:04 +0400 Subject: [PATCH] Fix invalid call sites in debug information for INVOKEVIRTUAL --- .../java/org/teavm/javascript/Renderer.java | 5 ++- .../ui/TeaVMDebugModelPresentation.java | 32 ------------------- 2 files changed, 4 insertions(+), 33 deletions(-) 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 fc935d71c..555877ab3 100644 --- a/teavm-core/src/main/java/org/teavm/javascript/Renderer.java +++ b/teavm-core/src/main/java/org/teavm/javascript/Renderer.java @@ -1284,6 +1284,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext if (injector != null) { injector.generate(new InjectorContextImpl(expr.getArguments()), expr.getMethod()); } else { + if (expr.getType() == InvocationType.DYNAMIC) { + expr.getArguments().get(0).acceptVisitor(this); + } String className = naming.getNameFor(expr.getMethod().getClassName()); String name = naming.getNameFor(expr.getMethod()); String fullName = naming.getFullNameFor(expr.getMethod()); @@ -1293,6 +1296,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext lastCallSite = callSite; } boolean virtual = false; + System.out.println("Render invocation of " + expr.getMethod()); switch (expr.getType()) { case STATIC: writer.append(fullName).append("("); @@ -1316,7 +1320,6 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext writer.append(")"); break; case DYNAMIC: - expr.getArguments().get(0).acceptVisitor(this); writer.append(".").append(name).append("("); prevCallSite = debugEmitter.emitCallSite(); for (int i = 1; i < expr.getArguments().size(); ++i) { diff --git a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java index a12be407e..85bb05cc3 100644 --- a/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java +++ b/teavm-eclipse/teavm-eclipse-plugin/src/main/java/org/teavm/eclipse/debugger/ui/TeaVMDebugModelPresentation.java @@ -33,10 +33,8 @@ import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.part.FileEditorInput; import org.teavm.debugging.CallFrame; -import org.teavm.debugging.Value; import org.teavm.debugging.javascript.JavaScriptCallFrame; import org.teavm.debugging.javascript.JavaScriptLocation; -import org.teavm.debugging.javascript.JavaScriptValue; import org.teavm.eclipse.debugger.*; import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodReference; @@ -96,23 +94,12 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug @Override public String getText(Object element) { - System.out.println(element.getClass().getName()); if (element instanceof TeaVMJavaStackFrame) { TeaVMJavaStackFrame stackFrame = (TeaVMJavaStackFrame)element; return callFrameAsString(stackFrame.getCallFrame()); } else if (element instanceof TeaVMJSStackFrame) { TeaVMJSStackFrame stackFrame = (TeaVMJSStackFrame)element; return callFrameAsString(stackFrame.getCallFrame()); - } else if (element instanceof TeaVMJavaVariable) { - TeaVMJavaVariable var = (TeaVMJavaVariable)element; - return getText((TeaVMJavaValue)var.getValue()); - } else if (element instanceof TeaVMJavaValue) { - return getText((TeaVMJavaValue)element); - } else if (element instanceof TeaVMJSVariable) { - TeaVMJSVariable var = (TeaVMJSVariable)element; - return getText((TeaVMJSValue)var.getValue()); - } else if (element instanceof TeaVMJSValue) { - return getText((TeaVMJSValue)element); } else if (element instanceof TeaVMDebugTarget) { return ((TeaVMDebugTarget)element).getName(); } else if (element instanceof TeaVMThread) { @@ -121,25 +108,6 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug return super.getText(element); } - private String getText(TeaVMJavaValue value) { - TeaVMDebugTarget debugTarget = value.getDebugTarget(); - Value teavmValue = value.getTeavmValue(); - if (teavmValue.getInstanceId() == null) { - return teavmValue.getType() + " (id: " + debugTarget.getId(teavmValue.getInstanceId()) + ")"; - } else { - return teavmValue.getRepresentation(); - } - } - - private String getText(TeaVMJSValue value) { - TeaVMDebugTarget debugTarget = value.getDebugTarget(); - JavaScriptValue jsValue = value.getJavaScriptValue(); - if (jsValue.getInstanceId() == null) { - return jsValue.getClassName() + " (id: " + debugTarget.getId(jsValue.getInstanceId()) + ")"; - } else { - return jsValue.getRepresentation(); - } - } private String callFrameAsString(CallFrame callFrame) { MethodReference method = callFrame.getMethod();