Rename parameter

This commit is contained in:
Natalia Ukhorskaya
2013-12-12 15:13:42 +04:00
parent 69ed9bc47a
commit 1c9b093728
34 changed files with 99 additions and 99 deletions
@@ -35,7 +35,7 @@ public class ArrayGet implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -33,7 +33,7 @@ public class ArrayIndices implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -45,7 +45,7 @@ public class ArrayIterator implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -35,7 +35,7 @@ public class ArraySet implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -33,7 +33,7 @@ public class ArraySize implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -43,17 +43,17 @@ public class BinaryOp implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
boolean nullable = expectedType.getSort() == Type.OBJECT;
assert !nullable : "Return type of BinaryOp intrinsic should be of primitive type : " + expectedType;
boolean nullable = returnType.getSort() == Type.OBJECT;
assert !nullable : "Return type of BinaryOp intrinsic should be of primitive type : " + returnType;
Type operandType = numberFunctionOperandType(expectedType);
Type operandType = numberFunctionOperandType(returnType);
if (arguments.size() == 1) {
// Intrinsic is called as an ordinary function
@@ -66,9 +66,9 @@ public class BinaryOp implements IntrinsicMethod {
codegen.gen(arguments.get(0), operandType);
codegen.gen(arguments.get(1), shift() ? Type.INT_TYPE : operandType);
}
v.visitInsn(expectedType.getOpcode(opcode));
v.visitInsn(returnType.getOpcode(opcode));
return StackValue.onStack(expectedType);
return StackValue.onStack(returnType);
}
private boolean shift() {
@@ -35,7 +35,7 @@ public class CompareTo implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -36,7 +36,7 @@ public class Concat implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -51,12 +51,12 @@ public class Concat implements IntrinsicMethod {
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
genStringBuilderConstructor(v);
v.swap(); // StringBuilder LHS
genInvokeAppendMethod(v, expectedType); // StringBuilder(LHS)
genInvokeAppendMethod(v, returnType); // StringBuilder(LHS)
codegen.invokeAppend(arguments.get(0));
}
v.invokevirtual("java/lang/StringBuilder", "toString", "()Ljava/lang/String;");
StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE).put(expectedType, v);
return StackValue.onStack(expectedType);
StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE).put(returnType, v);
return StackValue.onStack(returnType);
}
}
@@ -17,7 +17,7 @@ public class CopyToArray implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
@Nullable StackValue receiver,
@@ -28,11 +28,11 @@ public class CopyToArray implements IntrinsicMethod {
v.dup();
v.invokeinterface("java/util/Collection", "size", "()I");
v.newarray(expectedType.getElementType());
v.newarray(returnType.getElementType());
v.invokeinterface("java/util/Collection", "toArray", "([Ljava/lang/Object;)[Ljava/lang/Object;");
StackValue.coerce(Type.getType("[Ljava/lang/Object;"), expectedType, v);
StackValue.coerce(Type.getType("[Ljava/lang/Object;"), returnType, v);
return StackValue.onStack(expectedType);
return StackValue.onStack(returnType);
}
}
@@ -34,7 +34,7 @@ public class EnumName implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -42,7 +42,7 @@ public class EnumName implements IntrinsicMethod {
) {
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
v.invokevirtual("java/lang/Enum", "name", "()Ljava/lang/String;");
StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE).put(expectedType, v);
return StackValue.onStack(expectedType);
StackValue.onStack(AsmTypeConstants.JAVA_STRING_TYPE).put(returnType, v);
return StackValue.onStack(returnType);
}
}
@@ -34,7 +34,7 @@ public class EnumOrdinal implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -42,7 +42,7 @@ public class EnumOrdinal implements IntrinsicMethod {
) {
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
v.invokevirtual("java/lang/Enum", "ordinal", "()I");
StackValue.onStack(Type.INT_TYPE).put(expectedType, v);
return StackValue.onStack(expectedType);
StackValue.onStack(Type.INT_TYPE).put(returnType, v);
return StackValue.onStack(returnType);
}
}
@@ -37,7 +37,7 @@ public class Equals implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -35,7 +35,7 @@ public class HashCode implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -37,7 +37,7 @@ public class IdentityEquals implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -43,21 +43,21 @@ public class Increment implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
boolean nullable = expectedType.getSort() == Type.OBJECT;
assert !nullable : "Return type of Increment intrinsic should be of primitive type : " + expectedType;
boolean nullable = returnType.getSort() == Type.OBJECT;
assert !nullable : "Return type of Increment intrinsic should be of primitive type : " + returnType;
if (arguments.size() > 0) {
JetExpression operand = arguments.get(0);
while (operand instanceof JetParenthesizedExpression) {
operand = ((JetParenthesizedExpression) operand).getExpression();
}
if (operand instanceof JetReferenceExpression && expectedType == Type.INT_TYPE) {
if (operand instanceof JetReferenceExpression && returnType == Type.INT_TYPE) {
int index = codegen.indexOfLocal((JetReferenceExpression) operand);
if (index >= 0) {
return StackValue.preIncrement(index, myDelta);
@@ -67,15 +67,15 @@ public class Increment implements IntrinsicMethod {
value.dupReceiver(v);
value.dupReceiver(v);
value.put(expectedType, v);
genIncrement(expectedType, myDelta, v);
value.store(expectedType, v);
value.put(expectedType, v);
value.put(returnType, v);
genIncrement(returnType, myDelta, v);
value.store(returnType, v);
value.put(returnType, v);
}
else {
receiver.put(expectedType, v);
genIncrement(expectedType, myDelta, v);
receiver.put(returnType, v);
genIncrement(returnType, myDelta, v);
}
return StackValue.onStack(expectedType);
return StackValue.onStack(returnType);
}
}
@@ -31,7 +31,7 @@ import java.util.List;
public interface IntrinsicMethod extends Callable {
StackValue generate(
ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, @Nullable PsiElement element,
ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type returnType, @Nullable PsiElement element,
@Nullable List<JetExpression> arguments, @Nullable StackValue receiver, @NotNull GenerationState state
);
}
@@ -35,23 +35,23 @@ public class Inv implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
boolean nullable = expectedType.getSort() == Type.OBJECT;
assert !nullable : "Return type of Inv intrinsic should be of primitive type : " + expectedType;
boolean nullable = returnType.getSort() == Type.OBJECT;
assert !nullable : "Return type of Inv intrinsic should be of primitive type : " + returnType;
receiver.put(numberFunctionOperandType(expectedType), v);
if (expectedType == Type.LONG_TYPE) {
receiver.put(numberFunctionOperandType(returnType), v);
if (returnType == Type.LONG_TYPE) {
v.lconst(-1L);
}
else {
v.iconst(-1);
}
v.xor(expectedType);
return StackValue.onStack(expectedType);
v.xor(returnType);
return StackValue.onStack(returnType);
}
}
@@ -33,7 +33,7 @@ public class IteratorIterator implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -33,42 +33,42 @@ public class IteratorNext implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
String name;
if (expectedType == Type.CHAR_TYPE) {
if (returnType == Type.CHAR_TYPE) {
name = "Char";
}
else if (expectedType == Type.BOOLEAN_TYPE) {
else if (returnType == Type.BOOLEAN_TYPE) {
name = "Boolean";
}
else if (expectedType == Type.BYTE_TYPE) {
else if (returnType == Type.BYTE_TYPE) {
name = "Byte";
}
else if (expectedType == Type.SHORT_TYPE) {
else if (returnType == Type.SHORT_TYPE) {
name = "Short";
}
else if (expectedType == Type.INT_TYPE) {
else if (returnType == Type.INT_TYPE) {
name = "Int";
}
else if (expectedType == Type.LONG_TYPE) {
else if (returnType == Type.LONG_TYPE) {
name = "Long";
}
else if (expectedType == Type.FLOAT_TYPE) {
else if (returnType == Type.FLOAT_TYPE) {
name = "Float";
}
else if (expectedType == Type.DOUBLE_TYPE) {
else if (returnType == Type.DOUBLE_TYPE) {
name = "Double";
}
else {
throw new UnsupportedOperationException();
}
receiver.put(AsmTypeConstants.OBJECT_TYPE, v);
v.invokevirtual("jet/" + name + "Iterator", "next" + name, "()" + expectedType.getDescriptor());
return StackValue.onStack(expectedType);
v.invokevirtual("jet/" + name + "Iterator", "next" + name, "()" + returnType.getDescriptor());
return StackValue.onStack(returnType);
}
}
@@ -41,7 +41,7 @@ public class JavaClassArray implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -52,6 +52,6 @@ public class JavaClassArray implements IntrinsicMethod {
assert call != null;
Map.Entry<ValueParameterDescriptor, ResolvedValueArgument> next = call.getValueArguments().entrySet().iterator().next();
codegen.genVarargs(next.getKey(), (VarargValueArgument) next.getValue());
return StackValue.onStack(expectedType);
return StackValue.onStack(returnType);
}
}
@@ -37,7 +37,7 @@ public class JavaClassProperty implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -33,13 +33,13 @@ public class NewArray implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
codegen.generateNewArray((JetCallExpression) element);
return StackValue.onStack(expectedType);
return StackValue.onStack(returnType);
}
}
@@ -32,7 +32,7 @@ public class Not implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -32,13 +32,13 @@ public class NumberCast implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
receiver.put(expectedType, v);
return StackValue.onStack(expectedType);
receiver.put(returnType, v);
return StackValue.onStack(returnType);
}
}
@@ -46,19 +46,19 @@ public class PropertyOfProgressionOrRange implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
String ownerInternalName = JvmClassName.byFqNameWithoutInnerClasses(this.ownerClass).getInternalName();
Type boxedType = boxType(expectedType);
Type boxedType = boxType(returnType);
String getterName = PropertyCodegen.getterName(propertyName);
receiver.put(receiver.type, v);
v.invokevirtual(ownerInternalName, getterName, "()" + boxedType.getDescriptor());
StackValue.coerce(boxedType, expectedType, v);
return StackValue.onStack(expectedType);
StackValue.coerce(boxedType, returnType, v);
return StackValue.onStack(returnType);
}
}
@@ -37,7 +37,7 @@ public class RangeTo implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -49,8 +49,8 @@ public class RangeTo implements IntrinsicMethod {
receiver.put(leftType, v);
codegen.gen(arguments.get(0), rightType);
v.invokestatic("jet/runtime/Ranges", "rangeTo",
"(" + receiver.type.getDescriptor() + leftType.getDescriptor() + ")" + expectedType.getDescriptor());
return StackValue.onStack(expectedType);
"(" + receiver.type.getDescriptor() + leftType.getDescriptor() + ")" + returnType.getDescriptor());
return StackValue.onStack(returnType);
}
else {
JetBinaryExpression expression = (JetBinaryExpression) element;
@@ -60,8 +60,8 @@ public class RangeTo implements IntrinsicMethod {
codegen.gen(expression.getLeft(), leftType);
codegen.gen(expression.getRight(), rightType);
v.invokestatic("jet/runtime/Ranges", "rangeTo",
"(" + leftType.getDescriptor() + rightType.getDescriptor() + ")" + expectedType.getDescriptor());
return StackValue.onStack(expectedType);
"(" + leftType.getDescriptor() + rightType.getDescriptor() + ")" + returnType.getDescriptor());
return StackValue.onStack(returnType);
// }
// else {
// throw new UnsupportedOperationException("ranges are only supported for int objects");
@@ -45,13 +45,13 @@ public class StaticField implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.asString(), expectedType.getDescriptor());
return StackValue.onStack(expectedType);
v.getstatic(JvmClassName.byFqNameWithoutInnerClasses(ownerClass).getInternalName(), propertyName.asString(), returnType.getDescriptor());
return StackValue.onStack(returnType);
}
}
@@ -33,7 +33,7 @@ public class StringGetChar implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -33,7 +33,7 @@ public class StringLength implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -33,7 +33,7 @@ public class StringPlus implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -36,7 +36,7 @@ public class StupidSync implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@@ -44,7 +44,7 @@ public class StupidSync implements IntrinsicMethod {
) {
codegen.pushMethodArguments((JetCallExpression) element, Arrays.asList(AsmTypeConstants.OBJECT_TYPE, AsmTypeConstants.JET_FUNCTION0_TYPE));
v.invokestatic("jet/runtime/Intrinsics", "stupidSync", "(Ljava/lang/Object;Ljet/Function0;)Ljava/lang/Object;");
StackValue.onStack(AsmTypeConstants.OBJECT_TYPE).put(expectedType, v);
return StackValue.onStack(expectedType);
StackValue.onStack(AsmTypeConstants.OBJECT_TYPE).put(returnType, v);
return StackValue.onStack(returnType);
}
}
@@ -34,7 +34,7 @@ public class ToString implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@@ -36,16 +36,16 @@ public class UnaryMinus implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
PsiElement element,
List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
boolean nullable = expectedType.getSort() == Type.OBJECT;
assert !nullable : "Return type of UnaryMinus intrinsic should be of primitive type : " + expectedType;
boolean nullable = returnType.getSort() == Type.OBJECT;
assert !nullable : "Return type of UnaryMinus intrinsic should be of primitive type : " + returnType;
Type operandType = numberFunctionOperandType(expectedType);
Type operandType = numberFunctionOperandType(returnType);
if (arguments.size() == 1) {
codegen.gen(arguments.get(0), operandType);
@@ -53,6 +53,6 @@ public class UnaryMinus implements IntrinsicMethod {
else {
receiver.put(operandType, v);
}
return StackValue.onStack(genNegate(expectedType, v));
return StackValue.onStack(genNegate(returnType, v));
}
}
@@ -35,22 +35,22 @@ public class UnaryPlus implements IntrinsicMethod {
public StackValue generate(
ExpressionCodegen codegen,
InstructionAdapter v,
@NotNull Type expectedType,
@NotNull Type returnType,
@Nullable PsiElement element,
@Nullable List<JetExpression> arguments,
StackValue receiver,
@NotNull GenerationState state
) {
boolean nullable = expectedType.getSort() == Type.OBJECT;
assert !nullable : "Return type of UnaryPlus intrinsic should be of primitive type : " + expectedType;
boolean nullable = returnType.getSort() == Type.OBJECT;
assert !nullable : "Return type of UnaryPlus intrinsic should be of primitive type : " + returnType;
if (receiver != null && receiver != StackValue.none()) {
receiver.put(expectedType, v);
receiver.put(returnType, v);
}
else {
assert arguments != null;
codegen.gen(arguments.get(0), expectedType);
codegen.gen(arguments.get(0), returnType);
}
return StackValue.onStack(expectedType);
return StackValue.onStack(returnType);
}
}