add static import of Opcodes.*
This commit is contained in:
@@ -27,6 +27,8 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
* @author alex.tkacman
|
||||
@@ -112,13 +114,13 @@ public class CallableMethod implements Callable {
|
||||
v.iconst(mask);
|
||||
String desc = getSignature().getAsmMethod().getDescriptor().replace(")", "I)");
|
||||
if ("<init>".equals(getSignature().getAsmMethod().getName())) {
|
||||
v.visitMethodInsn(Opcodes.INVOKESPECIAL, defaultImplOwner.getInternalName(), "<init>", desc);
|
||||
v.visitMethodInsn(INVOKESPECIAL, defaultImplOwner.getInternalName(), "<init>", desc);
|
||||
}
|
||||
else {
|
||||
if (getInvokeOpcode() != Opcodes.INVOKESTATIC) {
|
||||
if (getInvokeOpcode() != INVOKESTATIC) {
|
||||
desc = desc.replace("(", "(" + defaultImplParam.getDescriptor());
|
||||
}
|
||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, defaultImplOwner.getInternalName(),
|
||||
v.visitMethodInsn(INVOKESTATIC, defaultImplOwner.getInternalName(),
|
||||
getSignature().getAsmMethod().getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, desc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,7 +126,7 @@ public abstract class ClassBodyCodegen {
|
||||
|
||||
private void generateStaticInitializer() {
|
||||
if (staticInitializerChunks.size() > 0) {
|
||||
final MethodVisitor mv = v.newMethod(null, ACC_PUBLIC | Opcodes.ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
final MethodVisitor mv = v.newMethod(null, ACC_PUBLIC | ACC_STATIC, "<clinit>", "()V", null, null);
|
||||
if (state.getClassBuilderMode() == ClassBuilderMode.FULL) {
|
||||
mv.visitCode();
|
||||
|
||||
@@ -136,7 +136,7 @@ public abstract class ClassBodyCodegen {
|
||||
chunk.generate(v);
|
||||
}
|
||||
|
||||
mv.visitInsn(Opcodes.RETURN);
|
||||
mv.visitInsn(RETURN);
|
||||
FunctionCodegen.endVisit(v, "static initializer", myClass);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.*;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContext.*;
|
||||
@@ -1244,7 +1245,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
v.areturn(returnType);
|
||||
}
|
||||
else {
|
||||
v.visitInsn(Opcodes.RETURN);
|
||||
v.visitInsn(RETURN);
|
||||
}
|
||||
return StackValue.none();
|
||||
}
|
||||
@@ -1405,7 +1406,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (value instanceof StackValue.FieldForSharedVar) {
|
||||
StackValue.FieldForSharedVar fieldForSharedVar = (StackValue.FieldForSharedVar) value;
|
||||
Type sharedType = StackValue.sharedTypeForType(value.type);
|
||||
v.visitFieldInsn(Opcodes.GETFIELD, fieldForSharedVar.owner.getInternalName(), fieldForSharedVar.name,
|
||||
v.visitFieldInsn(GETFIELD, fieldForSharedVar.owner.getInternalName(), fieldForSharedVar.name,
|
||||
sharedType.getDescriptor());
|
||||
}
|
||||
|
||||
@@ -1558,9 +1559,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
if (isInsideClass || isStatic || propertyDescriptor.getGetter() == null) {
|
||||
owner = ownerParam = typeMapper.getOwner(propertyDescriptor, contextKind());
|
||||
isInterface = overridesTrait;
|
||||
invokeOpcode = isStatic ? Opcodes.INVOKESTATIC :
|
||||
overridesTrait ? Opcodes.INVOKEINTERFACE
|
||||
: Opcodes.INVOKEVIRTUAL;
|
||||
invokeOpcode = isStatic ? INVOKESTATIC :
|
||||
overridesTrait ? INVOKEINTERFACE
|
||||
: INVOKEVIRTUAL;
|
||||
}
|
||||
else {
|
||||
isInterface = CodegenUtil.isInterface(containingDeclaration) || overridesTrait;
|
||||
@@ -3520,7 +3521,7 @@ The "returned" value of try expression with no finally is either the last expres
|
||||
throw new UnsupportedOperationException("tuple too large");
|
||||
}
|
||||
if (entries.size() == 0) {
|
||||
v.visitFieldInsn(Opcodes.GETSTATIC, "jet/Tuple0", "INSTANCE", "Ljet/Tuple0;");
|
||||
v.visitFieldInsn(GETSTATIC, "jet/Tuple0", "INSTANCE", "Ljet/Tuple0;");
|
||||
return StackValue.onStack(JET_TUPLE0_TYPE);
|
||||
}
|
||||
|
||||
|
||||
@@ -559,8 +559,8 @@ public class JetTypeMapper {
|
||||
ownerForDefaultParam.getInternalName() + (originalIsInterface ? JvmAbi.TRAIT_IMPL_SUFFIX : ""));
|
||||
|
||||
invokeOpcode = isInterface
|
||||
? (superCall ? Opcodes.INVOKESTATIC : Opcodes.INVOKEINTERFACE)
|
||||
: (isAccessor ? Opcodes.INVOKESTATIC : (superCall ? Opcodes.INVOKESPECIAL : Opcodes.INVOKEVIRTUAL));
|
||||
? (superCall ? INVOKESTATIC : INVOKEINTERFACE)
|
||||
: (isAccessor ? INVOKESTATIC : (superCall ? INVOKESPECIAL : INVOKEVIRTUAL));
|
||||
if (isInterface && superCall) {
|
||||
descriptor = mapSignature(functionDescriptor, false, OwnerKind.TRAIT_IMPL);
|
||||
owner = JvmClassName.byInternalName(owner.getInternalName() + JvmAbi.TRAIT_IMPL_SUFFIX);
|
||||
|
||||
@@ -40,6 +40,7 @@ import org.jetbrains.jet.lang.types.lang.JetStandardLibrary;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.lang.resolve.BindingContextUtils.*;
|
||||
|
||||
/**
|
||||
@@ -73,9 +74,9 @@ public class PropertyCodegen {
|
||||
generateSetter(p, propertyDescriptor);
|
||||
}
|
||||
else if (kind instanceof OwnerKind.DelegateKind) {
|
||||
generateDefaultGetter(propertyDescriptor, Opcodes.ACC_PUBLIC, p);
|
||||
generateDefaultGetter(propertyDescriptor, ACC_PUBLIC, p);
|
||||
if (propertyDescriptor.isVar()) {
|
||||
generateDefaultSetter(propertyDescriptor, Opcodes.ACC_PUBLIC, p);
|
||||
generateDefaultSetter(propertyDescriptor, ACC_PUBLIC, p);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -98,16 +99,16 @@ public class PropertyCodegen {
|
||||
}
|
||||
int modifiers;
|
||||
if (kind == OwnerKind.NAMESPACE) {
|
||||
modifiers = Opcodes.ACC_STATIC;
|
||||
modifiers = ACC_STATIC;
|
||||
}
|
||||
else {
|
||||
modifiers = Opcodes.ACC_PRIVATE;
|
||||
modifiers = ACC_PRIVATE;
|
||||
}
|
||||
if (!propertyDescriptor.isVar()) {
|
||||
modifiers |= Opcodes.ACC_FINAL;
|
||||
modifiers |= ACC_FINAL;
|
||||
}
|
||||
if (JetStandardLibrary.getInstance().isVolatile(propertyDescriptor)) {
|
||||
modifiers |= Opcodes.ACC_VOLATILE;
|
||||
modifiers |= ACC_VOLATILE;
|
||||
}
|
||||
Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||
FieldVisitor fieldVisitor = v.newField(p, modifiers, propertyDescriptor.getName().getName(), type.getDescriptor(), null, value);
|
||||
@@ -163,8 +164,8 @@ public class PropertyCodegen {
|
||||
assert propertyDescriptor != null;
|
||||
int flags = JetTypeMapper.getAccessModifiers(propertyDescriptor, 0) |
|
||||
(propertyDescriptor.getModality() == Modality.ABSTRACT
|
||||
? Opcodes.ACC_ABSTRACT
|
||||
: (propertyDescriptor.getModality() == Modality.FINAL ? Opcodes.ACC_FINAL : 0));
|
||||
? ACC_ABSTRACT
|
||||
: (propertyDescriptor.getModality() == Modality.FINAL ? ACC_FINAL : 0));
|
||||
generateDefaultGetter(propertyDescriptor, flags, p);
|
||||
}
|
||||
|
||||
@@ -178,17 +179,17 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
if (kind == OwnerKind.NAMESPACE) {
|
||||
flags |= Opcodes.ACC_STATIC;
|
||||
flags |= ACC_STATIC;
|
||||
}
|
||||
|
||||
PsiElement psiElement = descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
||||
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
||||
if (isTrait && !(kind instanceof OwnerKind.DelegateKind)) {
|
||||
flags |= Opcodes.ACC_ABSTRACT;
|
||||
flags |= ACC_ABSTRACT;
|
||||
}
|
||||
|
||||
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
||||
flags |= Opcodes.ACC_FINAL;
|
||||
flags |= ACC_FINAL;
|
||||
}
|
||||
|
||||
JvmPropertyAccessorSignature signature = state.getInjector().getJetTypeMapper().mapGetterSignature(propertyDescriptor, kind);
|
||||
@@ -232,7 +233,7 @@ public class PropertyCodegen {
|
||||
}
|
||||
else {
|
||||
iv.visitFieldInsn(
|
||||
kind == OwnerKind.NAMESPACE ? Opcodes.GETSTATIC : Opcodes.GETFIELD,
|
||||
kind == OwnerKind.NAMESPACE ? GETSTATIC : GETFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind).getInternalName(),
|
||||
propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
@@ -270,7 +271,7 @@ public class PropertyCodegen {
|
||||
int modifiers = JetTypeMapper.getAccessModifiers(propertyDescriptor, 0);
|
||||
PropertySetterDescriptor setter = propertyDescriptor.getSetter();
|
||||
int flags = setter == null ? modifiers : JetTypeMapper.getAccessModifiers(setter, modifiers);
|
||||
flags |= (propertyDescriptor.getModality() == Modality.ABSTRACT ? Opcodes.ACC_ABSTRACT : 0);
|
||||
flags |= (propertyDescriptor.getModality() == Modality.ABSTRACT ? ACC_ABSTRACT : 0);
|
||||
generateDefaultSetter(propertyDescriptor, flags, p);
|
||||
}
|
||||
|
||||
@@ -284,17 +285,17 @@ public class PropertyCodegen {
|
||||
}
|
||||
|
||||
if (kind == OwnerKind.NAMESPACE) {
|
||||
flags |= Opcodes.ACC_STATIC;
|
||||
flags |= ACC_STATIC;
|
||||
}
|
||||
|
||||
PsiElement psiElement = descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
||||
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
||||
if (isTrait && !(kind instanceof OwnerKind.DelegateKind)) {
|
||||
flags |= Opcodes.ACC_ABSTRACT;
|
||||
flags |= ACC_ABSTRACT;
|
||||
}
|
||||
|
||||
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
||||
flags |= Opcodes.ACC_FINAL;
|
||||
flags |= ACC_FINAL;
|
||||
}
|
||||
|
||||
JvmPropertyAccessorSignature signature = state.getInjector().getJetTypeMapper().mapSetterSignature(propertyDescriptor, kind);
|
||||
@@ -339,13 +340,13 @@ public class PropertyCodegen {
|
||||
}
|
||||
else {
|
||||
iv.load(paramCode, type);
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD,
|
||||
iv.visitFieldInsn(kind == OwnerKind.NAMESPACE ? PUTSTATIC : PUTFIELD,
|
||||
state.getInjector().getJetTypeMapper().getOwner(propertyDescriptor, kind).getInternalName(),
|
||||
propertyDescriptor.getName().getName(),
|
||||
type.getDescriptor());
|
||||
}
|
||||
|
||||
iv.visitInsn(Opcodes.RETURN);
|
||||
iv.visitInsn(RETURN);
|
||||
}
|
||||
}
|
||||
FunctionCodegen.endVisit(mv, "setter", origin);
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.java.JvmClassName;
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.OBJECT_TYPE;
|
||||
import static org.jetbrains.jet.codegen.context.CodegenBinding.*;
|
||||
|
||||
@@ -102,8 +103,8 @@ public class ScriptCodegen {
|
||||
|
||||
ClassBuilder classBuilder = classFileFactory.newVisitor(className.getInternalName() + ".class");
|
||||
classBuilder.defineClass(scriptDeclaration,
|
||||
Opcodes.V1_6,
|
||||
Opcodes.ACC_PUBLIC,
|
||||
V1_6,
|
||||
ACC_PUBLIC,
|
||||
className.getInternalName(),
|
||||
null,
|
||||
"java/lang/Object",
|
||||
@@ -129,7 +130,7 @@ public class ScriptCodegen {
|
||||
|
||||
Type blockType = jetTypeMapper.mapType(scriptDescriptor.getReturnType(), MapTypeMode.VALUE);
|
||||
|
||||
classBuilder.newField(null, Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL, ScriptNameUtil.LAST_EXPRESSION_VALUE_FIELD_NAME,
|
||||
classBuilder.newField(null, ACC_PUBLIC | ACC_FINAL, ScriptNameUtil.LAST_EXPRESSION_VALUE_FIELD_NAME,
|
||||
blockType.getDescriptor(), null, null);
|
||||
|
||||
JvmMethodSignature jvmSignature = jetTypeMapper.mapScriptSignature(scriptDescriptor, importedScripts);
|
||||
@@ -137,7 +138,7 @@ public class ScriptCodegen {
|
||||
state.setScriptConstructorMethod(jvmSignature.getAsmMethod());
|
||||
|
||||
MethodVisitor mv = classBuilder.newMethod(
|
||||
scriptDeclaration, Opcodes.ACC_PUBLIC, jvmSignature.getAsmMethod().getName(), jvmSignature.getAsmMethod().getDescriptor(),
|
||||
scriptDeclaration, ACC_PUBLIC, jvmSignature.getAsmMethod().getName(), jvmSignature.getAsmMethod().getDescriptor(),
|
||||
null, null);
|
||||
|
||||
mv.visitCode();
|
||||
@@ -208,13 +209,13 @@ public class ScriptCodegen {
|
||||
for (ScriptDescriptor earlierScript : earlierScripts) {
|
||||
JvmClassName earlierClassName;
|
||||
earlierClassName = classNameForScriptDescriptor(bindingContext, earlierScript);
|
||||
int access = Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL;
|
||||
int access = ACC_PRIVATE | ACC_FINAL;
|
||||
classBuilder.newField(null, access, getScriptFieldName(earlierScript), earlierClassName.getDescriptor(), null, null);
|
||||
}
|
||||
|
||||
for (ValueParameterDescriptor parameter : script.getValueParameters()) {
|
||||
Type parameterType = jetTypeMapper.mapType(parameter.getType(), MapTypeMode.VALUE);
|
||||
int access = Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL;
|
||||
int access = ACC_PUBLIC | ACC_FINAL;
|
||||
classBuilder.newField(null, access, parameter.getName().getIdentifier(), parameterType.getDescriptor(), null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import org.jetbrains.jet.lexer.JetTokens;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.codegen.JetTypeMapper.OBJECT_TYPE;
|
||||
|
||||
/**
|
||||
@@ -302,7 +303,7 @@ public abstract class StackValue {
|
||||
}
|
||||
|
||||
public static void putTuple0Instance(InstructionAdapter v) {
|
||||
v.visitFieldInsn(Opcodes.GETSTATIC, "jet/Tuple0", "INSTANCE", "Ljet/Tuple0;");
|
||||
v.visitFieldInsn(GETSTATIC, "jet/Tuple0", "INSTANCE", "Ljet/Tuple0;");
|
||||
}
|
||||
|
||||
protected void putAsBoolean(InstructionAdapter v) {
|
||||
@@ -494,22 +495,22 @@ public abstract class StackValue {
|
||||
public void condJump(Label label, boolean jumpIfFalse, InstructionAdapter v) {
|
||||
int opcode;
|
||||
if (opToken == JetTokens.EQEQ) {
|
||||
opcode = jumpIfFalse ? Opcodes.IFNE : Opcodes.IFEQ;
|
||||
opcode = jumpIfFalse ? IFNE : IFEQ;
|
||||
}
|
||||
else if (opToken == JetTokens.EXCLEQ) {
|
||||
opcode = jumpIfFalse ? Opcodes.IFEQ : Opcodes.IFNE;
|
||||
opcode = jumpIfFalse ? IFEQ : IFNE;
|
||||
}
|
||||
else if (opToken == JetTokens.GT) {
|
||||
opcode = jumpIfFalse ? Opcodes.IFLE : Opcodes.IFGT;
|
||||
opcode = jumpIfFalse ? IFLE : IFGT;
|
||||
}
|
||||
else if (opToken == JetTokens.GTEQ) {
|
||||
opcode = jumpIfFalse ? Opcodes.IFLT : Opcodes.IFGE;
|
||||
opcode = jumpIfFalse ? IFLT : IFGE;
|
||||
}
|
||||
else if (opToken == JetTokens.LT) {
|
||||
opcode = jumpIfFalse ? Opcodes.IFGE : Opcodes.IFLT;
|
||||
opcode = jumpIfFalse ? IFGE : IFLT;
|
||||
}
|
||||
else if (opToken == JetTokens.LTEQ) {
|
||||
opcode = jumpIfFalse ? Opcodes.IFGT : Opcodes.IFLE;
|
||||
opcode = jumpIfFalse ? IFGT : IFLE;
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("don't know how to generate this condjump");
|
||||
@@ -526,7 +527,7 @@ public abstract class StackValue {
|
||||
v.lcmp();
|
||||
}
|
||||
else {
|
||||
opcode += (Opcodes.IF_ICMPEQ - Opcodes.IFEQ);
|
||||
opcode += (IF_ICMPEQ - IFEQ);
|
||||
}
|
||||
v.visitJumpInsn(opcode, label);
|
||||
}
|
||||
@@ -541,10 +542,10 @@ public abstract class StackValue {
|
||||
public void condJump(Label label, boolean jumpIfFalse, InstructionAdapter v) {
|
||||
int opcode;
|
||||
if (opToken == JetTokens.EQEQEQ) {
|
||||
opcode = jumpIfFalse ? Opcodes.IF_ACMPNE : Opcodes.IF_ACMPEQ;
|
||||
opcode = jumpIfFalse ? IF_ACMPNE : IF_ACMPEQ;
|
||||
}
|
||||
else if (opToken == JetTokens.EXCLEQEQEQ) {
|
||||
opcode = jumpIfFalse ? Opcodes.IF_ACMPEQ : Opcodes.IF_ACMPNE;
|
||||
opcode = jumpIfFalse ? IF_ACMPEQ : IF_ACMPNE;
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("don't know how to generate this condjump");
|
||||
@@ -879,7 +880,7 @@ public abstract class StackValue {
|
||||
|
||||
@Override
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
v.visitFieldInsn(isStatic ? Opcodes.GETSTATIC : Opcodes.GETFIELD, owner.getInternalName(), name, this.type.getDescriptor());
|
||||
v.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, owner.getInternalName(), name, this.type.getDescriptor());
|
||||
coerce(type, v);
|
||||
}
|
||||
|
||||
@@ -898,7 +899,7 @@ public abstract class StackValue {
|
||||
@Override
|
||||
public void store(Type topOfStackType, InstructionAdapter v) {
|
||||
coerce(topOfStackType, this.type, v);
|
||||
v.visitFieldInsn(isStatic ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD, owner.getInternalName(), name, this.type.getDescriptor());
|
||||
v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, owner.getInternalName(), name, this.type.getDescriptor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -943,12 +944,12 @@ public abstract class StackValue {
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
if (isSuper && isInterface) {
|
||||
assert getter != null;
|
||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), getter.getName(),
|
||||
v.visitMethodInsn(INVOKESTATIC, methodOwner.getInternalName(), getter.getName(),
|
||||
getter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
||||
}
|
||||
else {
|
||||
if (getter == null) {
|
||||
v.visitFieldInsn(isStatic ? Opcodes.GETSTATIC : Opcodes.GETFIELD, methodOwner.getInternalName(), name,
|
||||
v.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, methodOwner.getInternalName(), name,
|
||||
this.type.getDescriptor());
|
||||
}
|
||||
else {
|
||||
@@ -962,11 +963,11 @@ public abstract class StackValue {
|
||||
public void store(Type topOfStackType, InstructionAdapter v) {
|
||||
if (isSuper && isInterface) {
|
||||
assert setter != null;
|
||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), setter.getName(),
|
||||
v.visitMethodInsn(INVOKESTATIC, methodOwner.getInternalName(), setter.getName(),
|
||||
setter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
||||
}
|
||||
else if (setter == null) {
|
||||
v.visitFieldInsn(isStatic ? Opcodes.PUTSTATIC : Opcodes.PUTFIELD, methodOwner.getInternalName(), name,
|
||||
v.visitFieldInsn(isStatic ? PUTSTATIC : PUTFIELD, methodOwner.getInternalName(), name,
|
||||
this.type.getDescriptor());
|
||||
}
|
||||
else {
|
||||
@@ -1025,7 +1026,7 @@ public abstract class StackValue {
|
||||
v.load(index, OBJECT_TYPE);
|
||||
Type refType = refType(this.type);
|
||||
Type sharedType = sharedTypeForType(this.type);
|
||||
v.visitFieldInsn(Opcodes.GETFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor());
|
||||
v.visitFieldInsn(GETFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor());
|
||||
coerce(refType, this.type, v);
|
||||
coerce(this.type, type, v);
|
||||
if (isReleaseOnPut) {
|
||||
@@ -1040,7 +1041,7 @@ public abstract class StackValue {
|
||||
v.swap();
|
||||
Type refType = refType(this.type);
|
||||
Type sharedType = sharedTypeForType(this.type);
|
||||
v.visitFieldInsn(Opcodes.PUTFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor());
|
||||
v.visitFieldInsn(PUTFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1111,7 +1112,7 @@ public abstract class StackValue {
|
||||
public void put(Type type, InstructionAdapter v) {
|
||||
Type sharedType = sharedTypeForType(this.type);
|
||||
Type refType = refType(this.type);
|
||||
v.visitFieldInsn(Opcodes.GETFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor());
|
||||
v.visitFieldInsn(GETFIELD, sharedType.getInternalName(), "ref", refType.getDescriptor());
|
||||
StackValue.onStack(refType).coerce(this.type, v);
|
||||
StackValue.onStack(this.type).coerce(type, v);
|
||||
}
|
||||
@@ -1119,7 +1120,7 @@ public abstract class StackValue {
|
||||
@Override
|
||||
public void store(Type topOfStackType, InstructionAdapter v) {
|
||||
coerce(topOfStackType, v);
|
||||
v.visitFieldInsn(Opcodes.PUTFIELD, sharedTypeForType(type).getInternalName(), "ref", refType(type).getDescriptor());
|
||||
v.visitFieldInsn(PUTFIELD, sharedTypeForType(type).getInternalName(), "ref", refType(type).getDescriptor());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ import org.jetbrains.jet.lang.types.lang.JetStandardClasses;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
|
||||
public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
||||
public TraitImplBodyCodegen(JetClassOrObject aClass, CodegenContext context, ClassBuilder v, GenerationState state) {
|
||||
super(aClass, context, v, state);
|
||||
@@ -44,8 +46,8 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
||||
|
||||
@Override
|
||||
protected void generateDeclaration() {
|
||||
v.defineClass(myClass, Opcodes.V1_6,
|
||||
Opcodes.ACC_PUBLIC | Opcodes.ACC_FINAL/*| Opcodes.ACC_SUPER*/,
|
||||
v.defineClass(myClass, V1_6,
|
||||
ACC_PUBLIC | ACC_FINAL/*| Opcodes.ACC_SUPER*/,
|
||||
jvmName(),
|
||||
null,
|
||||
"java/lang/Object",
|
||||
|
||||
@@ -29,6 +29,8 @@ import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
@@ -73,6 +75,6 @@ public class BinaryOp implements IntrinsicMethod {
|
||||
}
|
||||
|
||||
private boolean shift() {
|
||||
return opcode == Opcodes.ISHL || opcode == Opcodes.ISHR || opcode == Opcodes.IUSHR;
|
||||
return opcode == ISHL || opcode == ISHR || opcode == IUSHR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +35,7 @@ import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.jetbrains.asm4.Opcodes.*;
|
||||
import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getClassObjectName;
|
||||
|
||||
/**
|
||||
@@ -96,17 +97,17 @@ public class IntrinsicMethods {
|
||||
declareIntrinsicFunction(typeName, Name.identifier("equals"), 1, EQUALS);
|
||||
}
|
||||
|
||||
declareBinaryOp(Name.identifier("plus"), Opcodes.IADD);
|
||||
declareBinaryOp(Name.identifier("minus"), Opcodes.ISUB);
|
||||
declareBinaryOp(Name.identifier("times"), Opcodes.IMUL);
|
||||
declareBinaryOp(Name.identifier("div"), Opcodes.IDIV);
|
||||
declareBinaryOp(Name.identifier("mod"), Opcodes.IREM);
|
||||
declareBinaryOp(Name.identifier("shl"), Opcodes.ISHL);
|
||||
declareBinaryOp(Name.identifier("shr"), Opcodes.ISHR);
|
||||
declareBinaryOp(Name.identifier("ushr"), Opcodes.IUSHR);
|
||||
declareBinaryOp(Name.identifier("and"), Opcodes.IAND);
|
||||
declareBinaryOp(Name.identifier("or"), Opcodes.IOR);
|
||||
declareBinaryOp(Name.identifier("xor"), Opcodes.IXOR);
|
||||
declareBinaryOp(Name.identifier("plus"), IADD);
|
||||
declareBinaryOp(Name.identifier("minus"), ISUB);
|
||||
declareBinaryOp(Name.identifier("times"), IMUL);
|
||||
declareBinaryOp(Name.identifier("div"), IDIV);
|
||||
declareBinaryOp(Name.identifier("mod"), IREM);
|
||||
declareBinaryOp(Name.identifier("shl"), ISHL);
|
||||
declareBinaryOp(Name.identifier("shr"), ISHR);
|
||||
declareBinaryOp(Name.identifier("ushr"), IUSHR);
|
||||
declareBinaryOp(Name.identifier("and"), IAND);
|
||||
declareBinaryOp(Name.identifier("or"), IOR);
|
||||
declareBinaryOp(Name.identifier("xor"), IXOR);
|
||||
|
||||
declareIntrinsicFunction(Name.identifier("Boolean"), Name.identifier("not"), 0, new Not());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user