Fix invalid call sites in debug information for INVOKEVIRTUAL

This commit is contained in:
konsoletyper 2014-09-13 19:38:04 +04:00
parent ce78bdb07f
commit dc3faa1727
2 changed files with 4 additions and 33 deletions

View File

@ -1284,6 +1284,9 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
if (injector != null) { if (injector != null) {
injector.generate(new InjectorContextImpl(expr.getArguments()), expr.getMethod()); injector.generate(new InjectorContextImpl(expr.getArguments()), expr.getMethod());
} else { } else {
if (expr.getType() == InvocationType.DYNAMIC) {
expr.getArguments().get(0).acceptVisitor(this);
}
String className = naming.getNameFor(expr.getMethod().getClassName()); String className = naming.getNameFor(expr.getMethod().getClassName());
String name = naming.getNameFor(expr.getMethod()); String name = naming.getNameFor(expr.getMethod());
String fullName = naming.getFullNameFor(expr.getMethod()); String fullName = naming.getFullNameFor(expr.getMethod());
@ -1293,6 +1296,7 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
lastCallSite = callSite; lastCallSite = callSite;
} }
boolean virtual = false; boolean virtual = false;
System.out.println("Render invocation of " + expr.getMethod());
switch (expr.getType()) { switch (expr.getType()) {
case STATIC: case STATIC:
writer.append(fullName).append("("); writer.append(fullName).append("(");
@ -1316,7 +1320,6 @@ public class Renderer implements ExprVisitor, StatementVisitor, RenderingContext
writer.append(")"); writer.append(")");
break; break;
case DYNAMIC: case DYNAMIC:
expr.getArguments().get(0).acceptVisitor(this);
writer.append(".").append(name).append("("); writer.append(".").append(name).append("(");
prevCallSite = debugEmitter.emitCallSite(); prevCallSite = debugEmitter.emitCallSite();
for (int i = 1; i < expr.getArguments().size(); ++i) { for (int i = 1; i < expr.getArguments().size(); ++i) {

View File

@ -33,10 +33,8 @@ import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.ide.FileStoreEditorInput; import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.part.FileEditorInput;
import org.teavm.debugging.CallFrame; import org.teavm.debugging.CallFrame;
import org.teavm.debugging.Value;
import org.teavm.debugging.javascript.JavaScriptCallFrame; import org.teavm.debugging.javascript.JavaScriptCallFrame;
import org.teavm.debugging.javascript.JavaScriptLocation; import org.teavm.debugging.javascript.JavaScriptLocation;
import org.teavm.debugging.javascript.JavaScriptValue;
import org.teavm.eclipse.debugger.*; import org.teavm.eclipse.debugger.*;
import org.teavm.model.MethodDescriptor; import org.teavm.model.MethodDescriptor;
import org.teavm.model.MethodReference; import org.teavm.model.MethodReference;
@ -96,23 +94,12 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug
@Override @Override
public String getText(Object element) { public String getText(Object element) {
System.out.println(element.getClass().getName());
if (element instanceof TeaVMJavaStackFrame) { if (element instanceof TeaVMJavaStackFrame) {
TeaVMJavaStackFrame stackFrame = (TeaVMJavaStackFrame)element; TeaVMJavaStackFrame stackFrame = (TeaVMJavaStackFrame)element;
return callFrameAsString(stackFrame.getCallFrame()); return callFrameAsString(stackFrame.getCallFrame());
} else if (element instanceof TeaVMJSStackFrame) { } else if (element instanceof TeaVMJSStackFrame) {
TeaVMJSStackFrame stackFrame = (TeaVMJSStackFrame)element; TeaVMJSStackFrame stackFrame = (TeaVMJSStackFrame)element;
return callFrameAsString(stackFrame.getCallFrame()); 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) { } else if (element instanceof TeaVMDebugTarget) {
return ((TeaVMDebugTarget)element).getName(); return ((TeaVMDebugTarget)element).getName();
} else if (element instanceof TeaVMThread) { } else if (element instanceof TeaVMThread) {
@ -121,25 +108,6 @@ public class TeaVMDebugModelPresentation extends LabelProvider implements IDebug
return super.getText(element); 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) { private String callFrameAsString(CallFrame callFrame) {
MethodReference method = callFrame.getMethod(); MethodReference method = callFrame.getMethod();