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