got rid of unneeded ReceiverContext
This commit is contained in:
@@ -1916,7 +1916,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
||||
}
|
||||
|
||||
private StackValue generateReceiver(DeclarationDescriptor provided) {
|
||||
if (context.getReceiverDescriptor() == provided) {
|
||||
if (context.getCallableDescriptorWithReceiver() == provided) {
|
||||
StackValue result = context.getReceiverExpression(typeMapper);
|
||||
return castToRequiredTypeOfInterfaceIfNeeded(result, provided, null);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import static org.jetbrains.jet.codegen.binding.CodegenBinding.CLOSURE;
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
class ClosureContext extends ReceiverContext {
|
||||
class ClosureContext extends CodegenContext {
|
||||
private final ClassDescriptor classDescriptor;
|
||||
|
||||
public ClosureContext(
|
||||
|
||||
@@ -101,7 +101,14 @@ public abstract class CodegenContext {
|
||||
}
|
||||
}
|
||||
|
||||
public CallableDescriptor getReceiverDescriptor() {
|
||||
/**
|
||||
* This method returns not null only if context descriptor corresponds to method or function which has receiver
|
||||
*/
|
||||
@Nullable public final CallableDescriptor getCallableDescriptorWithReceiver() {
|
||||
if(contextDescriptor instanceof CallableDescriptor) {
|
||||
final CallableDescriptor callableDescriptor = (CallableDescriptor) getContextDescriptor();
|
||||
return callableDescriptor.getReceiverParameter().exists() ? callableDescriptor : null;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -183,7 +190,7 @@ public abstract class CodegenContext {
|
||||
frameMap.enterTemp(OBJECT_TYPE); // 0 slot for this
|
||||
}
|
||||
|
||||
CallableDescriptor receiverDescriptor = getReceiverDescriptor();
|
||||
CallableDescriptor receiverDescriptor = getCallableDescriptorWithReceiver();
|
||||
if (receiverDescriptor != null) {
|
||||
Type type = mapper.mapType(receiverDescriptor.getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
frameMap.enterTemp(type); // Next slot for receiver
|
||||
@@ -230,8 +237,8 @@ public abstract class CodegenContext {
|
||||
}
|
||||
|
||||
public StackValue getReceiverExpression(JetTypeMapper typeMapper) {
|
||||
assert getReceiverDescriptor() != null;
|
||||
Type asmType = typeMapper.mapType(getReceiverDescriptor().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
assert getCallableDescriptorWithReceiver() != null;
|
||||
Type asmType = typeMapper.mapType(getCallableDescriptorWithReceiver().getReceiverParameter().getType(), JetTypeMapperMode.VALUE);
|
||||
return hasThisDescriptor() ? StackValue.local(1, asmType) : StackValue.local(0, asmType);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ import org.jetbrains.jet.lang.descriptors.PropertyAccessorDescriptor;
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class MethodContext extends ReceiverContext {
|
||||
public class MethodContext extends CodegenContext {
|
||||
public MethodContext(
|
||||
@NotNull FunctionDescriptor contextType,
|
||||
OwnerKind contextKind,
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.codegen.context;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.codegen.OwnerKind;
|
||||
import org.jetbrains.jet.codegen.binding.MutableClosure;
|
||||
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
abstract class ReceiverContext extends CodegenContext {
|
||||
public ReceiverContext(
|
||||
CallableDescriptor contextDescriptor,
|
||||
OwnerKind contextKind,
|
||||
CodegenContext parentContext,
|
||||
@Nullable MutableClosure closure,
|
||||
ClassDescriptor thisDescriptor,
|
||||
@Nullable LocalLookup localLookup
|
||||
) {
|
||||
super(contextDescriptor, contextKind, parentContext, closure, thisDescriptor, localLookup);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CallableDescriptor getReceiverDescriptor() {
|
||||
final CallableDescriptor callableDescriptor = (CallableDescriptor) getContextDescriptor();
|
||||
return callableDescriptor.getReceiverParameter().exists() ? callableDescriptor : null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user