use of org.jetbrains.org.objectweb.asm.Type in project kotlin by JetBrains.
the class StackValue method enumEntry.
@NotNull
public static Field enumEntry(@NotNull ClassDescriptor descriptor, @NotNull KotlinTypeMapper typeMapper) {
DeclarationDescriptor enumClass = descriptor.getContainingDeclaration();
assert DescriptorUtils.isEnumClass(enumClass) : "Enum entry should be declared in enum class: " + descriptor;
Type type = typeMapper.mapType((ClassDescriptor) enumClass);
return field(type, type, descriptor.getName().asString(), true, none(), descriptor);
}
use of org.jetbrains.org.objectweb.asm.Type in project kotlin by JetBrains.
the class StackValue method receiver.
public static StackValue receiver(ResolvedCall<?> resolvedCall, StackValue receiver, ExpressionCodegen codegen, @Nullable Callable callableMethod) {
ReceiverValue callDispatchReceiver = resolvedCall.getDispatchReceiver();
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
if (descriptor instanceof SyntheticFieldDescriptor) {
callDispatchReceiver = ((SyntheticFieldDescriptor) descriptor).getDispatchReceiverForBackend();
}
ReceiverValue callExtensionReceiver = resolvedCall.getExtensionReceiver();
if (callDispatchReceiver != null || callExtensionReceiver != null || isLocalFunCall(callableMethod) || isCallToMemberObjectImportedByName(resolvedCall)) {
ReceiverParameterDescriptor dispatchReceiverParameter = descriptor.getDispatchReceiverParameter();
ReceiverParameterDescriptor extensionReceiverParameter = descriptor.getExtensionReceiverParameter();
if (descriptor instanceof SyntheticFieldDescriptor) {
dispatchReceiverParameter = ((SyntheticFieldDescriptor) descriptor).getDispatchReceiverParameterForBackend();
}
boolean hasExtensionReceiver = callExtensionReceiver != null;
StackValue dispatchReceiver = platformStaticCallIfPresent(genReceiver(hasExtensionReceiver ? none() : receiver, codegen, resolvedCall, callableMethod, callDispatchReceiver, false), descriptor);
StackValue extensionReceiver = genReceiver(receiver, codegen, resolvedCall, callableMethod, callExtensionReceiver, true);
Type type = CallReceiver.calcType(resolvedCall, dispatchReceiverParameter, extensionReceiverParameter, codegen.typeMapper, callableMethod, codegen.getState());
assert type != null : "Could not map receiver type for " + resolvedCall;
return new CallReceiver(dispatchReceiver, extensionReceiver, type);
}
return receiver;
}
use of org.jetbrains.org.objectweb.asm.Type in project kotlin by JetBrains.
the class JvmSerializerExtension method serializeProperty.
@Override
public void serializeProperty(@NotNull PropertyDescriptor descriptor, @NotNull ProtoBuf.Property.Builder proto) {
SignatureSerializer signatureSerializer = new SignatureSerializer();
PropertyGetterDescriptor getter = descriptor.getGetter();
PropertySetterDescriptor setter = descriptor.getSetter();
Method getterMethod = getter == null ? null : bindings.get(METHOD_FOR_FUNCTION, getter);
Method setterMethod = setter == null ? null : bindings.get(METHOD_FOR_FUNCTION, setter);
Pair<Type, String> field = bindings.get(FIELD_FOR_PROPERTY, descriptor);
Method syntheticMethod = bindings.get(SYNTHETIC_METHOD_FOR_PROPERTY, descriptor);
JvmProtoBuf.JvmPropertySignature signature = signatureSerializer.propertySignature(descriptor, field != null ? field.second : null, field != null ? field.first.getDescriptor() : null, syntheticMethod != null ? signatureSerializer.methodSignature(null, syntheticMethod) : null, getterMethod != null ? signatureSerializer.methodSignature(null, getterMethod) : null, setterMethod != null ? signatureSerializer.methodSignature(null, setterMethod) : null);
proto.setExtension(JvmProtoBuf.propertySignature, signature);
}
use of org.jetbrains.org.objectweb.asm.Type in project kotlin by JetBrains.
the class JvmSignatureWriter method makeJvmMethodSignature.
@NotNull
public JvmMethodGenericSignature makeJvmMethodSignature(@NotNull String name) {
List<Type> types = new ArrayList<Type>(kotlinParameterTypes.size());
for (JvmMethodParameterSignature parameter : kotlinParameterTypes) {
types.add(parameter.getAsmType());
}
Method asmMethod = new Method(name, jvmReturnType, types.toArray(new Type[types.size()]));
return new JvmMethodGenericSignature(asmMethod, kotlinParameterTypes, makeJavaGenericSignature());
}
use of org.jetbrains.org.objectweb.asm.Type in project kotlin by JetBrains.
the class CodegenContext method lookupInContext.
public StackValue lookupInContext(DeclarationDescriptor d, @Nullable StackValue result, GenerationState state, boolean ignoreNoOuter) {
StackValue myOuter = null;
if (closure != null) {
EnclosedValueDescriptor answer = closure.getCaptureVariables().get(d);
if (answer != null) {
return StackValue.changeReceiverForFieldAndSharedVar(answer.getInnerValue(), result);
}
for (LocalLookup.LocalLookupCase aCase : LocalLookup.LocalLookupCase.values()) {
if (aCase.isCase(d)) {
Type classType = state.getTypeMapper().mapType(getThisDescriptor());
StackValue.StackValueWithSimpleReceiver innerValue = aCase.innerValue(d, enclosingLocalLookup, state, closure, classType);
if (innerValue == null) {
break;
} else {
return StackValue.changeReceiverForFieldAndSharedVar(innerValue, result);
}
}
}
myOuter = getOuterExpression(result, ignoreNoOuter, false);
result = myOuter;
}
StackValue resultValue;
if (myOuter != null && getEnclosingClass() == d) {
resultValue = result;
} else {
resultValue = parentContext != null ? parentContext.lookupInContext(d, result, state, ignoreNoOuter) : null;
}
if (myOuter != null && resultValue != null && !isStaticField(resultValue)) {
closure.setCaptureThis();
}
return resultValue;
}
Aggregations