cleanup
This commit is contained in:
@@ -25,15 +25,13 @@ public class ExpressionCodegen extends JetVisitor {
|
|||||||
private final Stack<StackValue> myStack = new Stack<StackValue>();
|
private final Stack<StackValue> myStack = new Stack<StackValue>();
|
||||||
|
|
||||||
private final InstructionAdapter v;
|
private final InstructionAdapter v;
|
||||||
private final JetStandardLibrary stdlib;
|
|
||||||
private final FrameMap myMap;
|
private final FrameMap myMap;
|
||||||
private final JetTypeMapper typeMapper;
|
private final JetTypeMapper typeMapper;
|
||||||
private final Type returnType;
|
private final Type returnType;
|
||||||
private final BindingContext bindingContext;
|
private final BindingContext bindingContext;
|
||||||
|
|
||||||
public ExpressionCodegen(MethodVisitor v, BindingContext bindingContext, JetStandardLibrary stdlib, FrameMap myMap,
|
public ExpressionCodegen(MethodVisitor v, BindingContext bindingContext, FrameMap myMap, JetTypeMapper typeMapper,
|
||||||
JetTypeMapper typeMapper, Type returnType) {
|
Type returnType) {
|
||||||
this.stdlib = stdlib;
|
|
||||||
this.myMap = myMap;
|
this.myMap = myMap;
|
||||||
this.typeMapper = typeMapper;
|
this.typeMapper = typeMapper;
|
||||||
this.returnType = returnType;
|
this.returnType = returnType;
|
||||||
@@ -171,10 +169,6 @@ public class ExpressionCodegen extends JetVisitor {
|
|||||||
v.goTo(label);
|
v.goTo(label);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unboxBoolean() {
|
|
||||||
v.invokevirtual("java/lang/Boolean", "booleanValue", "()Z");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void generateSingleBranchIf(JetExpression expression, boolean inverse) {
|
private void generateSingleBranchIf(JetExpression expression, boolean inverse) {
|
||||||
Label endLabel = new Label();
|
Label endLabel = new Label();
|
||||||
|
|
||||||
@@ -344,18 +338,11 @@ public class ExpressionCodegen extends JetVisitor {
|
|||||||
PsiMethod method = (PsiMethod) declarationPsiElement;
|
PsiMethod method = (PsiMethod) declarationPsiElement;
|
||||||
pushMethodArguments(expression, method);
|
pushMethodArguments(expression, method);
|
||||||
|
|
||||||
if (method.hasModifierProperty(PsiModifier.STATIC)) {
|
final boolean isStatic = method.hasModifierProperty(PsiModifier.STATIC);
|
||||||
v.visitMethodInsn(Opcodes.INVOKESTATIC,
|
v.visitMethodInsn(isStatic ? Opcodes.INVOKESTATIC : Opcodes.INVOKEVIRTUAL,
|
||||||
JetTypeMapper.jvmName(method.getContainingClass()),
|
JetTypeMapper.jvmName(method.getContainingClass()),
|
||||||
method.getName(),
|
method.getName(),
|
||||||
getMethodDescriptor(method));
|
getMethodDescriptor(method));
|
||||||
}
|
|
||||||
else {
|
|
||||||
v.visitMethodInsn(Opcodes.INVOKEVIRTUAL,
|
|
||||||
JetTypeMapper.jvmName(method.getContainingClass()),
|
|
||||||
method.getName(),
|
|
||||||
getMethodDescriptor(method));
|
|
||||||
}
|
|
||||||
final Type type = psiTypeToAsm(method.getReturnType());
|
final Type type = psiTypeToAsm(method.getReturnType());
|
||||||
if (type != Type.VOID_TYPE) {
|
if (type != Type.VOID_TYPE) {
|
||||||
myStack.push(StackValue.onStack(type));
|
myStack.push(StackValue.onStack(type));
|
||||||
@@ -384,17 +371,6 @@ public class ExpressionCodegen extends JetVisitor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void unbox(PsiType type) {
|
|
||||||
if (type instanceof PsiPrimitiveType) {
|
|
||||||
if (type == PsiType.INT) {
|
|
||||||
v.invokevirtual("java/lang/Integer", "intValue", "()I");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw new UnsupportedOperationException("Don't know how to unbox type " + type);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String getMethodDescriptor(PsiMethod method) {
|
private static String getMethodDescriptor(PsiMethod method) {
|
||||||
Type returnType = method.isConstructor() ? Type.VOID_TYPE : psiTypeToAsm(method.getReturnType());
|
Type returnType = method.isConstructor() ? Type.VOID_TYPE : psiTypeToAsm(method.getReturnType());
|
||||||
PsiParameter[] parameters = method.getParameterList().getParameters();
|
PsiParameter[] parameters = method.getParameterList().getParameters();
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ public class FunctionCodegen {
|
|||||||
frameMap.enter(parameter, parameterTypes[i].getSize());
|
frameMap.enter(parameter, parameterTypes[i].getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, bindingContext, standardLibrary, frameMap, typeMapper, returnType);
|
ExpressionCodegen codegen = new ExpressionCodegen(mv, bindingContext, frameMap, typeMapper, returnType);
|
||||||
bodyExpression.accept(codegen);
|
bodyExpression.accept(codegen);
|
||||||
generateReturn(mv, bodyExpression, codegen);
|
generateReturn(mv, bodyExpression, codegen);
|
||||||
mv.visitMaxs(0, 0);
|
mv.visitMaxs(0, 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user