Remove suspicious code from intrinsics

This commit is contained in:
Alexander Udalov
2012-11-28 19:38:17 +04:00
parent 2dafbdc45a
commit fad9169005
3 changed files with 2 additions and 70 deletions
@@ -1907,7 +1907,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
invokeMethodWithArguments(callableMethod, receiver, calleeExpression);
}
public void invokeMethodWithArguments(CallableMethod callableMethod, StackValue receiver, JetExpression calleeExpression) {
private void invokeMethodWithArguments(CallableMethod callableMethod, StackValue receiver, JetExpression calleeExpression) {
Call call = bindingContext.get(CALL, calleeExpression);
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, calleeExpression);
@@ -1917,7 +1917,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
}
protected void invokeMethodWithArguments(
private void invokeMethodWithArguments(
@NotNull CallableMethod callableMethod,
@NotNull ResolvedCall<? extends CallableDescriptor> resolvedCall,
@NotNull Call call,
@@ -21,7 +21,6 @@ import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
@@ -219,12 +218,6 @@ public class IntrinsicMethods {
if (descriptor instanceof SimpleFunctionDescriptor) {
SimpleFunctionDescriptor functionDescriptor = (SimpleFunctionDescriptor) descriptor;
if (functionDescriptor.getReceiverParameter() == null) {
FqNameUnsafe ownerFqName = DescriptorUtils.getFQName(descriptor.getContainingDeclaration());
if (ownerFqName.equalsTo("jet.String")) {
return new PsiMethodCall(functionDescriptor);
}
}
if (isEnumClassObject(functionDescriptor.getContainingDeclaration())) {
if ("values".equals(functionDescriptor.getName().getName())) {
@@ -1,61 +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.intrinsics;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.asm4.Type;
import org.jetbrains.asm4.commons.InstructionAdapter;
import org.jetbrains.jet.codegen.CallableMethod;
import org.jetbrains.jet.codegen.ExpressionCodegen;
import org.jetbrains.jet.codegen.OwnerKind;
import org.jetbrains.jet.codegen.StackValue;
import org.jetbrains.jet.codegen.state.GenerationState;
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.psi.JetBinaryExpression;
import org.jetbrains.jet.lang.psi.JetCallElement;
import org.jetbrains.jet.lang.psi.JetCallExpression;
import org.jetbrains.jet.lang.psi.JetExpression;
import java.util.List;
/**
* @author yole
* @author alex.tkachman
*/
public class PsiMethodCall implements IntrinsicMethod {
private final SimpleFunctionDescriptor method;
public PsiMethodCall(SimpleFunctionDescriptor method) {
this.method = method;
}
@Override
public StackValue generate(
ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element,
List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state
) {
final CallableMethod callableMethod =
state.getTypeMapper().mapToCallableMethod(method, false, false, OwnerKind.IMPLEMENTATION);
if(element instanceof JetBinaryExpression) {
codegen.invokeMethodWithArguments(callableMethod, receiver, ((JetBinaryExpression)element).getOperationReference());
} else {
codegen.invokeMethodWithArguments(callableMethod, (JetCallElement) element, receiver);
}
return StackValue.onStack(callableMethod.getSignature().getAsmMethod().getReturnType());
}
}