formatting
This commit is contained in:
@@ -47,23 +47,23 @@ public abstract class AnnotationCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void genAnnotations(Annotated annotated) {
|
public void genAnnotations(Annotated annotated) {
|
||||||
if(annotated == null)
|
if (annotated == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if(!(annotated instanceof DeclarationDescriptor))
|
if (!(annotated instanceof DeclarationDescriptor))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, (DeclarationDescriptor) annotated);
|
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, (DeclarationDescriptor) annotated);
|
||||||
|
|
||||||
JetModifierList modifierList = null;
|
JetModifierList modifierList = null;
|
||||||
if(annotated instanceof ConstructorDescriptor && psiElement instanceof JetClass) {
|
if (annotated instanceof ConstructorDescriptor && psiElement instanceof JetClass) {
|
||||||
modifierList = ((JetClass)psiElement).getPrimaryConstructorModifierList();
|
modifierList = ((JetClass)psiElement).getPrimaryConstructorModifierList();
|
||||||
}
|
}
|
||||||
else if (psiElement instanceof JetModifierListOwner) {
|
else if (psiElement instanceof JetModifierListOwner) {
|
||||||
modifierList = ((JetModifierListOwner) psiElement).getModifierList();
|
modifierList = ((JetModifierListOwner) psiElement).getModifierList();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(modifierList == null)
|
if (modifierList == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
|
List<JetAnnotationEntry> annotationEntries = modifierList.getAnnotationEntries();
|
||||||
@@ -109,7 +109,7 @@ public abstract class AnnotationCodegen {
|
|||||||
|
|
||||||
private void genAnnotationValueArgument(AnnotationVisitor annotationVisitor, ResolvedValueArgument valueArgument, String keyName) {
|
private void genAnnotationValueArgument(AnnotationVisitor annotationVisitor, ResolvedValueArgument valueArgument, String keyName) {
|
||||||
List<ValueArgument> valueArguments = valueArgument.getArguments();
|
List<ValueArgument> valueArguments = valueArgument.getArguments();
|
||||||
if(valueArgument instanceof VarargValueArgument) {
|
if (valueArgument instanceof VarargValueArgument) {
|
||||||
AnnotationVisitor visitor = annotationVisitor.visitArray(keyName);
|
AnnotationVisitor visitor = annotationVisitor.visitArray(keyName);
|
||||||
for (ValueArgument argument : valueArguments) {
|
for (ValueArgument argument : valueArguments) {
|
||||||
genAnnotationExpressionValue(visitor, null, argument.getArgumentExpression());
|
genAnnotationExpressionValue(visitor, null, argument.getArgumentExpression());
|
||||||
@@ -127,18 +127,18 @@ public abstract class AnnotationCodegen {
|
|||||||
CompileTimeConstant<?> compileTimeConstant =
|
CompileTimeConstant<?> compileTimeConstant =
|
||||||
bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression);
|
bindingContext.get(BindingContext.COMPILE_TIME_VALUE, expression);
|
||||||
|
|
||||||
if(compileTimeConstant != null) {
|
if (compileTimeConstant != null) {
|
||||||
Object value = compileTimeConstant.getValue();
|
Object value = compileTimeConstant.getValue();
|
||||||
annotationVisitor.visit(keyName, value);
|
annotationVisitor.visit(keyName, value);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(expression instanceof JetDotQualifiedExpression) {
|
if (expression instanceof JetDotQualifiedExpression) {
|
||||||
JetDotQualifiedExpression qualifiedExpression = (JetDotQualifiedExpression)expression;
|
JetDotQualifiedExpression qualifiedExpression = (JetDotQualifiedExpression)expression;
|
||||||
ResolvedCall<? extends CallableDescriptor> call =
|
ResolvedCall<? extends CallableDescriptor> call =
|
||||||
bindingContext.get(BindingContext.RESOLVED_CALL, qualifiedExpression.getSelectorExpression());
|
bindingContext.get(BindingContext.RESOLVED_CALL, qualifiedExpression.getSelectorExpression());
|
||||||
if(call != null) {
|
if (call != null) {
|
||||||
if(call.getResultingDescriptor() instanceof PropertyDescriptor) {
|
if (call.getResultingDescriptor() instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor descriptor = (PropertyDescriptor)call.getResultingDescriptor();
|
PropertyDescriptor descriptor = (PropertyDescriptor)call.getResultingDescriptor();
|
||||||
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName().getName());
|
annotationVisitor.visitEnum(keyName, typeMapper.mapType(descriptor.getReturnType(), MapTypeMode.VALUE).getDescriptor(), descriptor.getName().getName());
|
||||||
return;
|
return;
|
||||||
@@ -146,11 +146,11 @@ public abstract class AnnotationCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(expression instanceof JetCallExpression) {
|
if (expression instanceof JetCallExpression) {
|
||||||
JetCallExpression callExpression = (JetCallExpression)expression;
|
JetCallExpression callExpression = (JetCallExpression)expression;
|
||||||
ResolvedCall<? extends CallableDescriptor> call =
|
ResolvedCall<? extends CallableDescriptor> call =
|
||||||
bindingContext.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
|
bindingContext.get(BindingContext.RESOLVED_CALL, callExpression.getCalleeExpression());
|
||||||
if(call != null) {
|
if (call != null) {
|
||||||
List<AnnotationDescriptor> annotations = call.getResultingDescriptor().getOriginal().getAnnotations();
|
List<AnnotationDescriptor> annotations = call.getResultingDescriptor().getOriginal().getAnnotations();
|
||||||
String value = null;
|
String value = null;
|
||||||
if (annotations != null) {
|
if (annotations != null) {
|
||||||
@@ -161,11 +161,11 @@ public abstract class AnnotationCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(IntrinsicMethods.KOTLIN_JAVA_CLASS_FUNCTION.equals(value)) {
|
if (IntrinsicMethods.KOTLIN_JAVA_CLASS_FUNCTION.equals(value)) {
|
||||||
annotationVisitor.visit(keyName, typeMapper.mapType(call.getResultingDescriptor().getReturnType().getArguments().get(0).getType(), MapTypeMode.VALUE));
|
annotationVisitor.visit(keyName, typeMapper.mapType(call.getResultingDescriptor().getReturnType().getArguments().get(0).getType(), MapTypeMode.VALUE));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(IntrinsicMethods.KOTLIN_ARRAYS_ARRAY.equals(value)) {
|
else if (IntrinsicMethods.KOTLIN_ARRAYS_ARRAY.equals(value)) {
|
||||||
AnnotationVisitor visitor = annotationVisitor.visitArray(keyName);
|
AnnotationVisitor visitor = annotationVisitor.visitArray(keyName);
|
||||||
VarargValueArgument next = (VarargValueArgument)call.getValueArguments().values().iterator().next();
|
VarargValueArgument next = (VarargValueArgument)call.getValueArguments().values().iterator().next();
|
||||||
for (ValueArgument argument : next.getArguments()) {
|
for (ValueArgument argument : next.getArguments()) {
|
||||||
@@ -174,7 +174,7 @@ public abstract class AnnotationCodegen {
|
|||||||
visitor.visitEnd();
|
visitor.visitEnd();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if(call.getResultingDescriptor() instanceof ConstructorDescriptor) {
|
else if (call.getResultingDescriptor() instanceof ConstructorDescriptor) {
|
||||||
ConstructorDescriptor descriptor = (ConstructorDescriptor)call.getResultingDescriptor();
|
ConstructorDescriptor descriptor = (ConstructorDescriptor)call.getResultingDescriptor();
|
||||||
AnnotationVisitor visitor = annotationVisitor.visitAnnotation(keyName, typeMapper
|
AnnotationVisitor visitor = annotationVisitor.visitAnnotation(keyName, typeMapper
|
||||||
.mapType(descriptor.getContainingDeclaration().getDefaultType(), MapTypeMode.VALUE).getDescriptor());
|
.mapType(descriptor.getContainingDeclaration().getDefaultType(), MapTypeMode.VALUE).getDescriptor());
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ public class CallableMethod implements Callable {
|
|||||||
v.visitMethodInsn(Opcodes.INVOKESPECIAL, defaultImplOwner.getInternalName(), "<init>", desc);
|
v.visitMethodInsn(Opcodes.INVOKESPECIAL, defaultImplOwner.getInternalName(), "<init>", desc);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(getInvokeOpcode() != Opcodes.INVOKESTATIC)
|
if (getInvokeOpcode() != Opcodes.INVOKESTATIC)
|
||||||
desc = desc.replace("(", "(" + defaultImplParam.getDescriptor());
|
desc = desc.replace("(", "(" + defaultImplParam.getDescriptor());
|
||||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, defaultImplOwner.getInternalName(),
|
v.visitMethodInsn(Opcodes.INVOKESTATIC, defaultImplOwner.getInternalName(),
|
||||||
getSignature().getAsmMethod().getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, desc);
|
getSignature().getAsmMethod().getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, desc);
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public abstract class ClassBodyCodegen {
|
|||||||
if (p.getValOrVarNode() != null) {
|
if (p.getValOrVarNode() != null) {
|
||||||
PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
|
PropertyDescriptor propertyDescriptor = state.getBindingContext().get(BindingContext.PRIMARY_CONSTRUCTOR_PARAMETER, p);
|
||||||
if (propertyDescriptor != null) {
|
if (propertyDescriptor != null) {
|
||||||
if(!isAnnotation) {
|
if (!isAnnotation) {
|
||||||
propertyCodegen.generateDefaultGetter(propertyDescriptor, ACC_PUBLIC, p);
|
propertyCodegen.generateDefaultGetter(propertyDescriptor, ACC_PUBLIC, p);
|
||||||
if (propertyDescriptor.isVar()) {
|
if (propertyDescriptor.isVar()) {
|
||||||
propertyCodegen.generateDefaultSetter(propertyDescriptor, ACC_PUBLIC, origin);
|
propertyCodegen.generateDefaultSetter(propertyDescriptor, ACC_PUBLIC, origin);
|
||||||
@@ -109,7 +109,7 @@ public abstract class ClassBodyCodegen {
|
|||||||
if (!propertyDescriptor.isVar()) {
|
if (!propertyDescriptor.isVar()) {
|
||||||
modifiers |= Opcodes.ACC_FINAL;
|
modifiers |= Opcodes.ACC_FINAL;
|
||||||
}
|
}
|
||||||
if(state.getInjector().getJetStandardLibrary().isVolatile(propertyDescriptor)) {
|
if (state.getInjector().getJetStandardLibrary().isVolatile(propertyDescriptor)) {
|
||||||
modifiers |= Opcodes.ACC_VOLATILE;
|
modifiers |= Opcodes.ACC_VOLATILE;
|
||||||
}
|
}
|
||||||
Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class ClassCodegen {
|
|||||||
if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) {
|
if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) {
|
||||||
generate(contextForInners, (JetClass) declaration);
|
generate(contextForInners, (JetClass) declaration);
|
||||||
}
|
}
|
||||||
if(declaration instanceof JetClassObject) {
|
if (declaration instanceof JetClassObject) {
|
||||||
generate(contextForInners, ((JetClassObject)declaration).getObjectDeclaration());
|
generate(contextForInners, ((JetClassObject)declaration).getObjectDeclaration());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -77,7 +77,7 @@ public class ClassCodegen {
|
|||||||
classContext.copyAccessors(accessors);
|
classContext.copyAccessors(accessors);
|
||||||
new ImplementationBodyCodegen(aClass, classContext, classBuilder, state).generate();
|
new ImplementationBodyCodegen(aClass, classContext, classBuilder, state).generate();
|
||||||
|
|
||||||
if(aClass instanceof JetClass && ((JetClass)aClass).isTrait()) {
|
if (aClass instanceof JetClass && ((JetClass)aClass).isTrait()) {
|
||||||
ClassBuilder traitBuilder = state.forTraitImplementation(descriptor);
|
ClassBuilder traitBuilder = state.forTraitImplementation(descriptor);
|
||||||
new TraitImplBodyCodegen(aClass, context.intoClass(descriptor, OwnerKind.TRAIT_IMPL, jetTypeMapper), traitBuilder, state).generate();
|
new TraitImplBodyCodegen(aClass, context.intoClass(descriptor, OwnerKind.TRAIT_IMPL, jetTypeMapper), traitBuilder, state).generate();
|
||||||
traitBuilder.done();
|
traitBuilder.done();
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ public class ClosureAnnotator {
|
|||||||
|
|
||||||
public ClassDescriptor classDescriptorForFunctionDescriptor(FunctionDescriptor funDescriptor, JvmClassName name) {
|
public ClassDescriptor classDescriptorForFunctionDescriptor(FunctionDescriptor funDescriptor, JvmClassName name) {
|
||||||
ClassDescriptorImpl classDescriptor = classesForFunctions.get(funDescriptor);
|
ClassDescriptorImpl classDescriptor = classesForFunctions.get(funDescriptor);
|
||||||
if(classDescriptor == null) {
|
if (classDescriptor == null) {
|
||||||
int arity = funDescriptor.getValueParameters().size();
|
int arity = funDescriptor.getValueParameters().size();
|
||||||
|
|
||||||
classDescriptor = new ClassDescriptorImpl(
|
classDescriptor = new ClassDescriptorImpl(
|
||||||
@@ -170,12 +170,12 @@ public class ClosureAnnotator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public JvmClassName classNameForAnonymousClass(JetElement expression) {
|
public JvmClassName classNameForAnonymousClass(JetElement expression) {
|
||||||
if(expression instanceof JetObjectLiteralExpression) {
|
if (expression instanceof JetObjectLiteralExpression) {
|
||||||
JetObjectLiteralExpression jetObjectLiteralExpression = (JetObjectLiteralExpression) expression;
|
JetObjectLiteralExpression jetObjectLiteralExpression = (JetObjectLiteralExpression) expression;
|
||||||
expression = jetObjectLiteralExpression.getObjectDeclaration();
|
expression = jetObjectLiteralExpression.getObjectDeclaration();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(expression instanceof JetFunctionLiteralExpression) {
|
if (expression instanceof JetFunctionLiteralExpression) {
|
||||||
JetFunctionLiteralExpression jetFunctionLiteralExpression = (JetFunctionLiteralExpression) expression;
|
JetFunctionLiteralExpression jetFunctionLiteralExpression = (JetFunctionLiteralExpression) expression;
|
||||||
expression = jetFunctionLiteralExpression.getFunctionLiteral();
|
expression = jetFunctionLiteralExpression.getFunctionLiteral();
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ public class ClosureAnnotator {
|
|||||||
private LinkedList<String> nameStack = new LinkedList<String>();
|
private LinkedList<String> nameStack = new LinkedList<String>();
|
||||||
|
|
||||||
private void recordEnclosing(ClassDescriptor classDescriptor) {
|
private void recordEnclosing(ClassDescriptor classDescriptor) {
|
||||||
if(classStack.size() > 0) {
|
if (classStack.size() > 0) {
|
||||||
ClassDescriptor put = enclosing.put(classDescriptor, classStack.peek());
|
ClassDescriptor put = enclosing.put(classDescriptor, classStack.peek());
|
||||||
assert put == null;
|
assert put == null;
|
||||||
}
|
}
|
||||||
@@ -213,7 +213,7 @@ public class ClosureAnnotator {
|
|||||||
|
|
||||||
String top = nameStack.peek();
|
String top = nameStack.peek();
|
||||||
Integer cnt = anonymousSubclassesCount.get(top);
|
Integer cnt = anonymousSubclassesCount.get(top);
|
||||||
if(cnt == null) {
|
if (cnt == null) {
|
||||||
cnt = 0;
|
cnt = 0;
|
||||||
}
|
}
|
||||||
name = JvmClassName.byInternalName(top + "$" + (cnt + 1));
|
name = JvmClassName.byInternalName(top + "$" + (cnt + 1));
|
||||||
@@ -261,7 +261,7 @@ public class ClosureAnnotator {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void visitObjectDeclaration(JetObjectDeclaration declaration) {
|
public void visitObjectDeclaration(JetObjectDeclaration declaration) {
|
||||||
if(declaration.getParent() instanceof JetObjectLiteralExpression || declaration.getParent() instanceof JetClassObject) {
|
if (declaration.getParent() instanceof JetObjectLiteralExpression || declaration.getParent() instanceof JetClassObject) {
|
||||||
super.visitObjectDeclaration(declaration);
|
super.visitObjectDeclaration(declaration);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
cv.newField(fun, ACC_FINAL, "this$0", enclosingType.getDescriptor(), null, null);
|
cv.newField(fun, ACC_FINAL, "this$0", enclosingType.getDescriptor(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isConst()) {
|
if (isConst()) {
|
||||||
generateConstInstance(fun);
|
generateConstInstance(fun);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,11 +160,11 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
|
|
||||||
final GeneratedAnonymousClassDescriptor answer = new GeneratedAnonymousClassDescriptor(name, constructor, captureThis, captureReceiver);
|
final GeneratedAnonymousClassDescriptor answer = new GeneratedAnonymousClassDescriptor(name, constructor, captureThis, captureReceiver);
|
||||||
for (DeclarationDescriptor descriptor : closure.keySet()) {
|
for (DeclarationDescriptor descriptor : closure.keySet()) {
|
||||||
if(descriptor instanceof VariableDescriptor) {
|
if (descriptor instanceof VariableDescriptor) {
|
||||||
final EnclosedValueDescriptor valueDescriptor = closure.get(descriptor);
|
final EnclosedValueDescriptor valueDescriptor = closure.get(descriptor);
|
||||||
answer.addArg(valueDescriptor.getOuterValue());
|
answer.addArg(valueDescriptor.getOuterValue());
|
||||||
}
|
}
|
||||||
else if(CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
else if (CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||||
final EnclosedValueDescriptor valueDescriptor = closure.get(descriptor);
|
final EnclosedValueDescriptor valueDescriptor = closure.get(descriptor);
|
||||||
answer.addArg(valueDescriptor.getOuterValue());
|
answer.addArg(valueDescriptor.getOuterValue());
|
||||||
}
|
}
|
||||||
@@ -215,7 +215,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
final JvmMethodSignature bridge = erasedInvokeSignature(funDescriptor);
|
final JvmMethodSignature bridge = erasedInvokeSignature(funDescriptor);
|
||||||
final Method delegate = invokeSignature(funDescriptor).getAsmMethod();
|
final Method delegate = invokeSignature(funDescriptor).getAsmMethod();
|
||||||
|
|
||||||
if(bridge.getAsmMethod().getDescriptor().equals(delegate.getDescriptor()))
|
if (bridge.getAsmMethod().getDescriptor().equals(delegate.getDescriptor()))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
final MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE | ACC_VOLATILE, "invoke", bridge.getAsmMethod().getDescriptor(), null, new String[0]);
|
final MethodVisitor mv = cv.newMethod(fun, ACC_PUBLIC | ACC_BRIDGE | ACC_VOLATILE, "invoke", bridge.getAsmMethod().getDescriptor(), null, new String[0]);
|
||||||
@@ -260,15 +260,15 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
ArrayList<DeclarationDescriptor> variableDescriptors = new ArrayList<DeclarationDescriptor>();
|
ArrayList<DeclarationDescriptor> variableDescriptors = new ArrayList<DeclarationDescriptor>();
|
||||||
|
|
||||||
for (DeclarationDescriptor descriptor : closure.keySet()) {
|
for (DeclarationDescriptor descriptor : closure.keySet()) {
|
||||||
if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
|
if (descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
|
||||||
argCount++;
|
argCount++;
|
||||||
variableDescriptors.add(descriptor);
|
variableDescriptors.add(descriptor);
|
||||||
}
|
}
|
||||||
else if(CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
else if (CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||||
argCount++;
|
argCount++;
|
||||||
variableDescriptors.add(descriptor);
|
variableDescriptors.add(descriptor);
|
||||||
}
|
}
|
||||||
else if(descriptor instanceof FunctionDescriptor) {
|
else if (descriptor instanceof FunctionDescriptor) {
|
||||||
assert captureReceiver != null;
|
assert captureReceiver != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -285,7 +285,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (DeclarationDescriptor descriptor : closure.keySet()) {
|
for (DeclarationDescriptor descriptor : closure.keySet()) {
|
||||||
if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
|
if (descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
|
||||||
final Type sharedVarType = state.getInjector().getJetTypeMapper().getSharedVarType(descriptor);
|
final Type sharedVarType = state.getInjector().getJetTypeMapper().getSharedVarType(descriptor);
|
||||||
final Type type;
|
final Type type;
|
||||||
if (sharedVarType != null) {
|
if (sharedVarType != null) {
|
||||||
@@ -296,7 +296,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
}
|
}
|
||||||
argTypes[i++] = type;
|
argTypes[i++] = type;
|
||||||
}
|
}
|
||||||
else if(CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
else if (CodegenUtil.isNamedFun(descriptor, state.getBindingContext()) && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||||
final Type type = state.getInjector().getJetTypeMapper().getClosureAnnotator().classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor)).getAsmType();
|
final Type type = state.getInjector().getJetTypeMapper().getClosureAnnotator().classNameForAnonymousClass((JetElement) BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor)).getAsmType();
|
||||||
argTypes[i++] = type;
|
argTypes[i++] = type;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public abstract class CodegenContext {
|
|||||||
CodegenContext c = this;
|
CodegenContext c = this;
|
||||||
while(true) {
|
while(true) {
|
||||||
DeclarationDescriptor contextDescriptor = c.getContextDescriptor();
|
DeclarationDescriptor contextDescriptor = c.getContextDescriptor();
|
||||||
if(!(contextDescriptor instanceof ClassDescriptor) && !(contextDescriptor instanceof NamespaceDescriptor)) {
|
if (!(contextDescriptor instanceof ClassDescriptor) && !(contextDescriptor instanceof NamespaceDescriptor)) {
|
||||||
c = c.getParentContext();
|
c = c.getParentContext();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -126,7 +126,7 @@ public abstract class CodegenContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CodegenContexts.ConstructorContext intoConstructor(ConstructorDescriptor descriptor, JetTypeMapper typeMapper) {
|
public CodegenContexts.ConstructorContext intoConstructor(ConstructorDescriptor descriptor, JetTypeMapper typeMapper) {
|
||||||
if(descriptor == null) {
|
if (descriptor == null) {
|
||||||
descriptor = new ConstructorDescriptorImpl(getThisDescriptor(), Collections.<AnnotationDescriptor>emptyList(), true)
|
descriptor = new ConstructorDescriptorImpl(getThisDescriptor(), Collections.<AnnotationDescriptor>emptyList(), true)
|
||||||
.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(), Visibilities.PUBLIC);
|
.initialize(Collections.<TypeParameterDescriptor>emptyList(), Collections.<ValueParameterDescriptor>emptyList(), Visibilities.PUBLIC);
|
||||||
}
|
}
|
||||||
@@ -187,13 +187,13 @@ public abstract class CodegenContext {
|
|||||||
public int getTypeInfoConstantIndex(JetType type) {
|
public int getTypeInfoConstantIndex(JetType type) {
|
||||||
if (parentContext != CodegenContexts.STATIC) { return parentContext.getTypeInfoConstantIndex(type); }
|
if (parentContext != CodegenContexts.STATIC) { return parentContext.getTypeInfoConstantIndex(type); }
|
||||||
|
|
||||||
if(typeInfoConstants == null) {
|
if (typeInfoConstants == null) {
|
||||||
typeInfoConstants = new LinkedHashMap<JetType, Integer>();
|
typeInfoConstants = new LinkedHashMap<JetType, Integer>();
|
||||||
reverseTypeInfoConstants = new LinkedHashMap<Integer, JetType>();
|
reverseTypeInfoConstants = new LinkedHashMap<Integer, JetType>();
|
||||||
}
|
}
|
||||||
|
|
||||||
Integer index = typeInfoConstants.get(type);
|
Integer index = typeInfoConstants.get(type);
|
||||||
if(index == null) {
|
if (index == null) {
|
||||||
index = typeInfoConstantsCount++;
|
index = typeInfoConstantsCount++;
|
||||||
typeInfoConstants.put(type, index);
|
typeInfoConstants.put(type, index);
|
||||||
reverseTypeInfoConstants.put(index, type);
|
reverseTypeInfoConstants.put(index, type);
|
||||||
@@ -202,14 +202,14 @@ public abstract class CodegenContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
DeclarationDescriptor getAccessor(DeclarationDescriptor descriptor) {
|
DeclarationDescriptor getAccessor(DeclarationDescriptor descriptor) {
|
||||||
if(accessors == null) {
|
if (accessors == null) {
|
||||||
accessors = new HashMap<DeclarationDescriptor,DeclarationDescriptor>();
|
accessors = new HashMap<DeclarationDescriptor,DeclarationDescriptor>();
|
||||||
}
|
}
|
||||||
descriptor = descriptor.getOriginal();
|
descriptor = descriptor.getOriginal();
|
||||||
DeclarationDescriptor accessor = accessors.get(descriptor);
|
DeclarationDescriptor accessor = accessors.get(descriptor);
|
||||||
if (accessor != null) { return accessor; }
|
if (accessor != null) { return accessor; }
|
||||||
|
|
||||||
if(descriptor instanceof SimpleFunctionDescriptor) {
|
if (descriptor instanceof SimpleFunctionDescriptor) {
|
||||||
SimpleFunctionDescriptorImpl myAccessor = new SimpleFunctionDescriptorImpl(contextDescriptor,
|
SimpleFunctionDescriptorImpl myAccessor = new SimpleFunctionDescriptorImpl(contextDescriptor,
|
||||||
Collections.<AnnotationDescriptor>emptyList(),
|
Collections.<AnnotationDescriptor>emptyList(),
|
||||||
Name.identifier(descriptor.getName() + "$bridge$" + accessors.size()),
|
Name.identifier(descriptor.getName() + "$bridge$" + accessors.size()),
|
||||||
@@ -225,7 +225,7 @@ public abstract class CodegenContext {
|
|||||||
/*isInline = */ false);
|
/*isInline = */ false);
|
||||||
accessor = myAccessor;
|
accessor = myAccessor;
|
||||||
}
|
}
|
||||||
else if(descriptor instanceof PropertyDescriptor) {
|
else if (descriptor instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor pd = (PropertyDescriptor) descriptor;
|
PropertyDescriptor pd = (PropertyDescriptor) descriptor;
|
||||||
PropertyDescriptor myAccessor = new PropertyDescriptor(contextDescriptor,
|
PropertyDescriptor myAccessor = new PropertyDescriptor(contextDescriptor,
|
||||||
Collections.<AnnotationDescriptor>emptyList(),
|
Collections.<AnnotationDescriptor>emptyList(),
|
||||||
@@ -268,8 +268,8 @@ public abstract class CodegenContext {
|
|||||||
public abstract boolean isStatic();
|
public abstract boolean isStatic();
|
||||||
|
|
||||||
public void copyAccessors(HashMap<DeclarationDescriptor, DeclarationDescriptor> accessors) {
|
public void copyAccessors(HashMap<DeclarationDescriptor, DeclarationDescriptor> accessors) {
|
||||||
if(accessors != null) {
|
if (accessors != null) {
|
||||||
if(this.accessors == null) {
|
if (this.accessors == null) {
|
||||||
this.accessors = new HashMap<DeclarationDescriptor,DeclarationDescriptor>();
|
this.accessors = new HashMap<DeclarationDescriptor,DeclarationDescriptor>();
|
||||||
}
|
}
|
||||||
this.accessors.putAll(accessors);
|
this.accessors.putAll(accessors);
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ public class CodegenUtil {
|
|||||||
|
|
||||||
public static boolean isLocalFun(DeclarationDescriptor fd, BindingContext bindingContext) {
|
public static boolean isLocalFun(DeclarationDescriptor fd, BindingContext bindingContext) {
|
||||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, fd);
|
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, fd);
|
||||||
if(psiElement instanceof JetNamedFunction && psiElement.getParent() instanceof JetBlockExpression) {
|
if (psiElement instanceof JetNamedFunction && psiElement.getParent() instanceof JetBlockExpression) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -84,7 +84,7 @@ public class CodegenUtil {
|
|||||||
|
|
||||||
public static boolean isNamedFun(DeclarationDescriptor fd, BindingContext bindingContext) {
|
public static boolean isNamedFun(DeclarationDescriptor fd, BindingContext bindingContext) {
|
||||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, fd);
|
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(bindingContext, fd);
|
||||||
if(psiElement instanceof JetNamedFunction) {
|
if (psiElement instanceof JetNamedFunction) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -126,15 +126,15 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
StackValue castToRequiredTypeOfInterfaceIfNeeded(StackValue inner, DeclarationDescriptor provided, @Nullable ClassDescriptor required) {
|
StackValue castToRequiredTypeOfInterfaceIfNeeded(StackValue inner, DeclarationDescriptor provided, @Nullable ClassDescriptor required) {
|
||||||
if(required == null)
|
if (required == null)
|
||||||
return inner;
|
return inner;
|
||||||
|
|
||||||
if(provided instanceof CallableDescriptor)
|
if (provided instanceof CallableDescriptor)
|
||||||
provided = ((CallableDescriptor)provided).getReceiverParameter().getType().getConstructor().getDeclarationDescriptor();
|
provided = ((CallableDescriptor)provided).getReceiverParameter().getType().getConstructor().getDeclarationDescriptor();
|
||||||
|
|
||||||
assert provided instanceof ClassDescriptor;
|
assert provided instanceof ClassDescriptor;
|
||||||
|
|
||||||
if(!CodegenUtil.isInterface(provided) && CodegenUtil.isInterface(required)) {
|
if (!CodegenUtil.isInterface(provided) && CodegenUtil.isInterface(required)) {
|
||||||
v.checkcast(asmType(required.getDefaultType()));
|
v.checkcast(asmType(required.getDefaultType()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,12 +220,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isEmptyExpression(JetElement expr) {
|
private static boolean isEmptyExpression(JetElement expr) {
|
||||||
if(expr == null)
|
if (expr == null)
|
||||||
return true;
|
return true;
|
||||||
if(expr instanceof JetBlockExpression) {
|
if (expr instanceof JetBlockExpression) {
|
||||||
JetBlockExpression blockExpression = (JetBlockExpression) expr;
|
JetBlockExpression blockExpression = (JetBlockExpression) expr;
|
||||||
List<JetElement> statements = blockExpression.getStatements();
|
List<JetElement> statements = blockExpression.getStatements();
|
||||||
if(statements.size() == 0 || statements.size() == 1 && isEmptyExpression(statements.get(0))) {
|
if (statements.size() == 0 || statements.size() == 1 && isEmptyExpression(statements.get(0))) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,7 +266,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
Label end = continueLabel == null ? new Label() : continueLabel;
|
Label end = continueLabel == null ? new Label() : continueLabel;
|
||||||
|
|
||||||
if(continueLabel != null)
|
if (continueLabel != null)
|
||||||
asmType = Type.VOID_TYPE;
|
asmType = Type.VOID_TYPE;
|
||||||
|
|
||||||
gen(thenExpression, asmType);
|
gen(thenExpression, asmType);
|
||||||
@@ -276,7 +276,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
gen(elseExpression, asmType);
|
gen(elseExpression, asmType);
|
||||||
|
|
||||||
if(end != continueLabel)
|
if (end != continueLabel)
|
||||||
v.mark(end);
|
v.mark(end);
|
||||||
else
|
else
|
||||||
v.goTo(end);
|
v.goTo(end);
|
||||||
@@ -302,7 +302,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
v.goTo(condition);
|
v.goTo(condition);
|
||||||
|
|
||||||
continueLabel = savedContinueLabel;
|
continueLabel = savedContinueLabel;
|
||||||
if(end != continueLabel)
|
if (end != continueLabel)
|
||||||
v.mark(end);
|
v.mark(end);
|
||||||
|
|
||||||
blockStackElements.pop();
|
blockStackElements.pop();
|
||||||
@@ -361,11 +361,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
FunctionDescriptor nextDescriptor = bindingContext.get(BindingContext.LOOP_RANGE_NEXT, loopRange);
|
FunctionDescriptor nextDescriptor = bindingContext.get(BindingContext.LOOP_RANGE_NEXT, loopRange);
|
||||||
DeclarationDescriptor hasNextDescriptor = bindingContext.get(BindingContext.LOOP_RANGE_HAS_NEXT, loopRange);
|
DeclarationDescriptor hasNextDescriptor = bindingContext.get(BindingContext.LOOP_RANGE_HAS_NEXT, loopRange);
|
||||||
|
|
||||||
if(iteratorDescriptor == null)
|
if (iteratorDescriptor == null)
|
||||||
throw new IllegalStateException("No iterator() method " + DiagnosticUtils.atLocation(loopRange));
|
throw new IllegalStateException("No iterator() method " + DiagnosticUtils.atLocation(loopRange));
|
||||||
if(nextDescriptor == null)
|
if (nextDescriptor == null)
|
||||||
throw new IllegalStateException("No next() method " + DiagnosticUtils.atLocation(loopRange));
|
throw new IllegalStateException("No next() method " + DiagnosticUtils.atLocation(loopRange));
|
||||||
if(hasNextDescriptor == null)
|
if (hasNextDescriptor == null)
|
||||||
throw new IllegalStateException("No hasNext method or property" + DiagnosticUtils.atLocation(loopRange));
|
throw new IllegalStateException("No hasNext method or property" + DiagnosticUtils.atLocation(loopRange));
|
||||||
|
|
||||||
final JetParameter loopParameter = expression.getLoopParameter();
|
final JetParameter loopParameter = expression.getLoopParameter();
|
||||||
@@ -383,7 +383,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
v.store(iteratorVar, asmIterType);
|
v.store(iteratorVar, asmIterType);
|
||||||
|
|
||||||
Label end = new Label();
|
Label end = new Label();
|
||||||
if(iteratorType.isNullable()) {
|
if (iteratorType.isNullable()) {
|
||||||
v.load(iteratorVar, TYPE_OBJECT);
|
v.load(iteratorVar, TYPE_OBJECT);
|
||||||
v.ifnull(end);
|
v.ifnull(end);
|
||||||
}
|
}
|
||||||
@@ -393,13 +393,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
v.mark(begin);
|
v.mark(begin);
|
||||||
v.load(iteratorVar, asmIterType);
|
v.load(iteratorVar, asmIterType);
|
||||||
if(hasNextDescriptor instanceof FunctionDescriptor) {
|
if (hasNextDescriptor instanceof FunctionDescriptor) {
|
||||||
FunctionDescriptor hND = (FunctionDescriptor) hasNextDescriptor;
|
FunctionDescriptor hND = (FunctionDescriptor) hasNextDescriptor;
|
||||||
invokeFunctionNoParams(hND, Type.BOOLEAN_TYPE, v);
|
invokeFunctionNoParams(hND, Type.BOOLEAN_TYPE, v);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// hND = ((PropertyDescriptor) hasNextDescriptor).getGetter();
|
// hND = ((PropertyDescriptor) hasNextDescriptor).getGetter();
|
||||||
// if(hND != null)
|
// if (hND != null)
|
||||||
// invokeFunctionNoParams(hND, Type.BOOLEAN_TYPE, v);
|
// invokeFunctionNoParams(hND, Type.BOOLEAN_TYPE, v);
|
||||||
// else
|
// else
|
||||||
intermediateValueForProperty((PropertyDescriptor) hasNextDescriptor, false, null).put(Type.BOOLEAN_TYPE, v);
|
intermediateValueForProperty((PropertyDescriptor) hasNextDescriptor, false, null).put(Type.BOOLEAN_TYPE, v);
|
||||||
@@ -503,7 +503,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
myIndexVar = myFrameMap.enterTemp();
|
myIndexVar = myFrameMap.enterTemp();
|
||||||
|
|
||||||
StackValue value = gen(expression.getLoopRange());
|
StackValue value = gen(expression.getLoopRange());
|
||||||
if(value instanceof StackValue.Local) {
|
if (value instanceof StackValue.Local) {
|
||||||
myArrayVar = ((StackValue.Local)value).index;
|
myArrayVar = ((StackValue.Local)value).index;
|
||||||
localArrayVar = true;
|
localArrayVar = true;
|
||||||
}
|
}
|
||||||
@@ -513,7 +513,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
v.store(myArrayVar, TYPE_OBJECT);
|
v.store(myArrayVar, TYPE_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(expressionType.isNullable()) {
|
if (expressionType.isNullable()) {
|
||||||
v.load(myArrayVar, TYPE_OBJECT);
|
v.load(myArrayVar, TYPE_OBJECT);
|
||||||
v.ifnull(end);
|
v.ifnull(end);
|
||||||
}
|
}
|
||||||
@@ -560,7 +560,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
myIndexVar = lookupLocal(parameterDescriptor);
|
myIndexVar = lookupLocal(parameterDescriptor);
|
||||||
myCountVar = myFrameMap.enterTemp();
|
myCountVar = myFrameMap.enterTemp();
|
||||||
myDeltaVar = myFrameMap.enterTemp();
|
myDeltaVar = myFrameMap.enterTemp();
|
||||||
if(isIntRangeExpr(expression.getLoopRange())) {
|
if (isIntRangeExpr(expression.getLoopRange())) {
|
||||||
JetBinaryExpression rangeExpression = (JetBinaryExpression) expression.getLoopRange();
|
JetBinaryExpression rangeExpression = (JetBinaryExpression) expression.getLoopRange();
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
gen(rangeExpression.getLeft(), Type.INT_TYPE);
|
gen(rangeExpression.getLeft(), Type.INT_TYPE);
|
||||||
@@ -633,13 +633,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
for(int i = blockStackElements.size()-1; i >= 0; --i) {
|
for(int i = blockStackElements.size()-1; i >= 0; --i) {
|
||||||
BlockStackElement stackElement = blockStackElements.get(i);
|
BlockStackElement stackElement = blockStackElements.get(i);
|
||||||
if(stackElement instanceof FinallyBlockStackElement) {
|
if (stackElement instanceof FinallyBlockStackElement) {
|
||||||
FinallyBlockStackElement finallyBlockStackElement = (FinallyBlockStackElement) stackElement;
|
FinallyBlockStackElement finallyBlockStackElement = (FinallyBlockStackElement) stackElement;
|
||||||
JetTryExpression jetTryExpression = finallyBlockStackElement.expression;
|
JetTryExpression jetTryExpression = finallyBlockStackElement.expression;
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
gen(jetTryExpression.getFinallyBlock().getFinalExpression(), Type.VOID_TYPE);
|
gen(jetTryExpression.getFinallyBlock().getFinalExpression(), Type.VOID_TYPE);
|
||||||
}
|
}
|
||||||
else if(stackElement instanceof LoopBlockStackElement) {
|
else if (stackElement instanceof LoopBlockStackElement) {
|
||||||
LoopBlockStackElement loopBlockStackElement = (LoopBlockStackElement) stackElement;
|
LoopBlockStackElement loopBlockStackElement = (LoopBlockStackElement) stackElement;
|
||||||
if (labelElement == null || loopBlockStackElement.targetLabel != null && labelElement.getReferencedName().equals(loopBlockStackElement.targetLabel.getReferencedName())) {
|
if (labelElement == null || loopBlockStackElement.targetLabel != null && labelElement.getReferencedName().equals(loopBlockStackElement.targetLabel.getReferencedName())) {
|
||||||
v.goTo(loopBlockStackElement.breakLabel);
|
v.goTo(loopBlockStackElement.breakLabel);
|
||||||
@@ -660,12 +660,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
for(int i = blockStackElements.size()-1; i >= 0; --i) {
|
for(int i = blockStackElements.size()-1; i >= 0; --i) {
|
||||||
BlockStackElement stackElement = blockStackElements.get(i);
|
BlockStackElement stackElement = blockStackElements.get(i);
|
||||||
if(stackElement instanceof FinallyBlockStackElement) {
|
if (stackElement instanceof FinallyBlockStackElement) {
|
||||||
FinallyBlockStackElement finallyBlockStackElement = (FinallyBlockStackElement) stackElement;
|
FinallyBlockStackElement finallyBlockStackElement = (FinallyBlockStackElement) stackElement;
|
||||||
JetTryExpression jetTryExpression = finallyBlockStackElement.expression;
|
JetTryExpression jetTryExpression = finallyBlockStackElement.expression;
|
||||||
gen(jetTryExpression.getFinallyBlock().getFinalExpression(), Type.VOID_TYPE);
|
gen(jetTryExpression.getFinallyBlock().getFinalExpression(), Type.VOID_TYPE);
|
||||||
}
|
}
|
||||||
else if(stackElement instanceof LoopBlockStackElement) {
|
else if (stackElement instanceof LoopBlockStackElement) {
|
||||||
LoopBlockStackElement loopBlockStackElement = (LoopBlockStackElement) stackElement;
|
LoopBlockStackElement loopBlockStackElement = (LoopBlockStackElement) stackElement;
|
||||||
if (labelElement == null || loopBlockStackElement.targetLabel != null && labelElement.getReferencedName().equals(loopBlockStackElement.targetLabel.getReferencedName())) {
|
if (labelElement == null || loopBlockStackElement.targetLabel != null && labelElement.getReferencedName().equals(loopBlockStackElement.targetLabel.getReferencedName())) {
|
||||||
v.goTo(loopBlockStackElement.continueLabel);
|
v.goTo(loopBlockStackElement.continueLabel);
|
||||||
@@ -687,7 +687,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
gen(expression, Type.VOID_TYPE);
|
gen(expression, Type.VOID_TYPE);
|
||||||
|
|
||||||
if(continueLabel != end)
|
if (continueLabel != end)
|
||||||
v.mark(end);
|
v.mark(end);
|
||||||
return StackValue.none();
|
return StackValue.none();
|
||||||
}
|
}
|
||||||
@@ -775,7 +775,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
ClosureCodegen closureCodegen = new ClosureCodegen(state, this, context);
|
ClosureCodegen closureCodegen = new ClosureCodegen(state, this, context);
|
||||||
final GeneratedAnonymousClassDescriptor closure = closureCodegen.gen(expression);
|
final GeneratedAnonymousClassDescriptor closure = closureCodegen.gen(expression);
|
||||||
|
|
||||||
if(closureCodegen.isConst()) {
|
if (closureCodegen.isConst()) {
|
||||||
v.invokestatic(closure.getClassname().getInternalName(), "$getInstance", "()" + closure.getClassname().getDescriptor());
|
v.invokestatic(closure.getClassname().getInternalName(), "$getInstance", "()" + closure.getClassname().getDescriptor());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -818,22 +818,22 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
v.load(0, TYPE_OBJECT);
|
v.load(0, TYPE_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(closureCodegen.captureReceiver != null) {
|
if (closureCodegen.captureReceiver != null) {
|
||||||
v.load(context.isStatic() ? 0 : 1, closureCodegen.captureReceiver);
|
v.load(context.isStatic() ? 0 : 1, closureCodegen.captureReceiver);
|
||||||
consArgTypes.add(closureCodegen.captureReceiver);
|
consArgTypes.add(closureCodegen.captureReceiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Map.Entry<DeclarationDescriptor, EnclosedValueDescriptor> entry : closureCodegen.closure.entrySet()) {
|
for (Map.Entry<DeclarationDescriptor, EnclosedValueDescriptor> entry : closureCodegen.closure.entrySet()) {
|
||||||
if(entry.getKey() instanceof VariableDescriptor && !(entry.getKey() instanceof PropertyDescriptor)) {
|
if (entry.getKey() instanceof VariableDescriptor && !(entry.getKey() instanceof PropertyDescriptor)) {
|
||||||
Type sharedVarType = typeMapper.getSharedVarType(entry.getKey());
|
Type sharedVarType = typeMapper.getSharedVarType(entry.getKey());
|
||||||
if(sharedVarType == null)
|
if (sharedVarType == null)
|
||||||
sharedVarType = state.getInjector().getJetTypeMapper().mapType(((VariableDescriptor) entry.getKey()).getType(), MapTypeMode.VALUE);
|
sharedVarType = state.getInjector().getJetTypeMapper().mapType(((VariableDescriptor) entry.getKey()).getType(), MapTypeMode.VALUE);
|
||||||
consArgTypes.add(sharedVarType);
|
consArgTypes.add(sharedVarType);
|
||||||
entry.getValue().getOuterValue().put(sharedVarType, v);
|
entry.getValue().getOuterValue().put(sharedVarType, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(closureCodegen.superCall != null) {
|
if (closureCodegen.superCall != null) {
|
||||||
ConstructorDescriptor superConstructor = (ConstructorDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, closureCodegen.superCall.getCalleeExpression().getConstructorReferenceExpression());
|
ConstructorDescriptor superConstructor = (ConstructorDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, closureCodegen.superCall.getCalleeExpression().getConstructorReferenceExpression());
|
||||||
CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor, OwnerKind.IMPLEMENTATION, typeMapper.hasThis0(superConstructor.getContainingDeclaration()));
|
CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor, OwnerKind.IMPLEMENTATION, typeMapper.hasThis0(superConstructor.getContainingDeclaration()));
|
||||||
Type[] argumentTypes = superCallable.getSignature().getAsmMethod().getArgumentTypes();
|
Type[] argumentTypes = superCallable.getSignature().getAsmMethod().getArgumentTypes();
|
||||||
@@ -871,7 +871,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
myFrameMap.enter(variableDescriptor, type.getSize());
|
myFrameMap.enter(variableDescriptor, type.getSize());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(statement instanceof JetNamedFunction) {
|
if (statement instanceof JetNamedFunction) {
|
||||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, statement);
|
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, statement);
|
||||||
myFrameMap.enter(descriptor, 1);
|
myFrameMap.enter(descriptor, 1);
|
||||||
}
|
}
|
||||||
@@ -902,7 +902,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(statement instanceof JetNamedFunction) {
|
if (statement instanceof JetNamedFunction) {
|
||||||
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, statement);
|
DeclarationDescriptor descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, statement);
|
||||||
myFrameMap.leave(descriptor);
|
myFrameMap.leave(descriptor);
|
||||||
}
|
}
|
||||||
@@ -917,7 +917,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
|
final Type sharedVarType = typeMapper.getSharedVarType(variableDescriptor);
|
||||||
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
|
final Type type = sharedVarType != null ? sharedVarType : asmType(variableDescriptor.getType());
|
||||||
if(sharedVarType != null) {
|
if (sharedVarType != null) {
|
||||||
if (answer instanceof StackValue.Shared && index == ((StackValue.Shared) answer).getIndex()) {
|
if (answer instanceof StackValue.Shared && index == ((StackValue.Shared) answer).getIndex()) {
|
||||||
((StackValue.Shared) answer).releaseOnPut();
|
((StackValue.Shared) answer).releaseOnPut();
|
||||||
}
|
}
|
||||||
@@ -952,7 +952,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
private void doFinallyOnReturn() {
|
private void doFinallyOnReturn() {
|
||||||
for(int i = blockStackElements.size()-1; i >= 0; --i) {
|
for(int i = blockStackElements.size()-1; i >= 0; --i) {
|
||||||
BlockStackElement stackElement = blockStackElements.get(i);
|
BlockStackElement stackElement = blockStackElements.get(i);
|
||||||
if(stackElement instanceof FinallyBlockStackElement) {
|
if (stackElement instanceof FinallyBlockStackElement) {
|
||||||
FinallyBlockStackElement finallyBlockStackElement = (FinallyBlockStackElement) stackElement;
|
FinallyBlockStackElement finallyBlockStackElement = (FinallyBlockStackElement) stackElement;
|
||||||
JetTryExpression jetTryExpression = finallyBlockStackElement.expression;
|
JetTryExpression jetTryExpression = finallyBlockStackElement.expression;
|
||||||
blockStackElements.pop();
|
blockStackElements.pop();
|
||||||
@@ -1005,11 +1005,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression);
|
||||||
|
|
||||||
DeclarationDescriptor descriptor;
|
DeclarationDescriptor descriptor;
|
||||||
if(resolvedCall == null) {
|
if (resolvedCall == null) {
|
||||||
descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
|
descriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, expression);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||||
VariableAsFunctionResolvedCall call = (VariableAsFunctionResolvedCall) resolvedCall;
|
VariableAsFunctionResolvedCall call = (VariableAsFunctionResolvedCall) resolvedCall;
|
||||||
resolvedCall = call.getVariableCall();
|
resolvedCall = call.getVariableCall();
|
||||||
}
|
}
|
||||||
@@ -1038,9 +1038,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
if (descriptor instanceof PropertyDescriptor) {
|
if (descriptor instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||||
|
|
||||||
if(propertyDescriptor.isObjectDeclaration()) {
|
if (propertyDescriptor.isObjectDeclaration()) {
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) propertyDescriptor.getReturnType().getConstructor().getDeclarationDescriptor();
|
ClassDescriptor classDescriptor = (ClassDescriptor) propertyDescriptor.getReturnType().getConstructor().getDeclarationDescriptor();
|
||||||
if(classDescriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
if (classDescriptor.getKind() == ClassKind.ENUM_ENTRY) {
|
||||||
ClassDescriptor containing = (ClassDescriptor) classDescriptor.getContainingDeclaration().getContainingDeclaration();
|
ClassDescriptor containing = (ClassDescriptor) classDescriptor.getContainingDeclaration().getContainingDeclaration();
|
||||||
Type type = typeMapper.mapType(containing.getDefaultType(), MapTypeMode.VALUE);
|
Type type = typeMapper.mapType(containing.getDefaultType(), MapTypeMode.VALUE);
|
||||||
StackValue.field(type, JvmClassName.byType(type), classDescriptor.getName().getName(), true).put(TYPE_OBJECT, v);
|
StackValue.field(type, JvmClassName.byType(type), classDescriptor.getName().getName(), true).put(TYPE_OBJECT, v);
|
||||||
@@ -1059,11 +1059,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
final boolean directToField = expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER && contextKind() != OwnerKind.TRAIT_IMPL ;
|
final boolean directToField = expression.getReferencedNameElementType() == JetTokens.FIELD_IDENTIFIER && contextKind() != OwnerKind.TRAIT_IMPL ;
|
||||||
JetExpression r = getReceiverForSelector(expression);
|
JetExpression r = getReceiverForSelector(expression);
|
||||||
final boolean isSuper = r instanceof JetSuperExpression;
|
final boolean isSuper = r instanceof JetSuperExpression;
|
||||||
if(propertyDescriptor.getVisibility() == Visibilities.PRIVATE && !DescriptorUtils
|
if (propertyDescriptor.getVisibility() == Visibilities.PRIVATE && !DescriptorUtils
|
||||||
.isClassObject(propertyDescriptor.getContainingDeclaration())) {
|
.isClassObject(propertyDescriptor.getContainingDeclaration())) {
|
||||||
if(context.getClassOrNamespaceDescriptor() != propertyDescriptor.getContainingDeclaration()) {
|
if (context.getClassOrNamespaceDescriptor() != propertyDescriptor.getContainingDeclaration()) {
|
||||||
DeclarationDescriptor enclosed = propertyDescriptor.getContainingDeclaration();
|
DeclarationDescriptor enclosed = propertyDescriptor.getContainingDeclaration();
|
||||||
if(enclosed != null && enclosed != context.getThisDescriptor()) {
|
if (enclosed != null && enclosed != context.getThisDescriptor()) {
|
||||||
CodegenContext c = context;
|
CodegenContext c = context;
|
||||||
while(c.getContextDescriptor() != enclosed) {
|
while(c.getContextDescriptor() != enclosed) {
|
||||||
c = c.getParentContext();
|
c = c.getParentContext();
|
||||||
@@ -1073,7 +1073,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final StackValue.Property iValue = intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression)r : null);
|
final StackValue.Property iValue = intermediateValueForProperty(propertyDescriptor, directToField, isSuper ? (JetSuperExpression)r : null);
|
||||||
if(!directToField && resolvedCall != null && !isSuper) {
|
if (!directToField && resolvedCall != null && !isSuper) {
|
||||||
receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic
|
receiver.put(propertyDescriptor.getReceiverParameter().exists() || isStatic
|
||||||
? receiver.type
|
? receiver.type
|
||||||
: iValue.methodOwner.getAsmType(), v);
|
: iValue.methodOwner.getAsmType(), v);
|
||||||
@@ -1081,10 +1081,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
else {
|
else {
|
||||||
if (!isStatic) {
|
if (!isStatic) {
|
||||||
if (receiver == StackValue.none()) {
|
if (receiver == StackValue.none()) {
|
||||||
if(resolvedCall == null)
|
if (resolvedCall == null)
|
||||||
receiver = generateThisOrOuter((ClassDescriptor) propertyDescriptor.getContainingDeclaration());
|
receiver = generateThisOrOuter((ClassDescriptor) propertyDescriptor.getContainingDeclaration());
|
||||||
else {
|
else {
|
||||||
if(resolvedCall.getThisObject() instanceof ExtensionReceiver)
|
if (resolvedCall.getThisObject() instanceof ExtensionReceiver)
|
||||||
receiver = generateReceiver(((ExtensionReceiver)resolvedCall.getThisObject()).getDeclarationDescriptor());
|
receiver = generateReceiver(((ExtensionReceiver)resolvedCall.getThisObject()).getDeclarationDescriptor());
|
||||||
else
|
else
|
||||||
receiver = generateThisOrOuter((ClassDescriptor) propertyDescriptor.getContainingDeclaration());
|
receiver = generateThisOrOuter((ClassDescriptor) propertyDescriptor.getContainingDeclaration());
|
||||||
@@ -1092,9 +1092,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
JetType receiverType = bindingContext.get(BindingContext.EXPRESSION_TYPE, r);
|
JetType receiverType = bindingContext.get(BindingContext.EXPRESSION_TYPE, r);
|
||||||
receiver.put(receiverType != null && !isSuper? asmType(receiverType) : TYPE_OBJECT, v);
|
receiver.put(receiverType != null && !isSuper? asmType(receiverType) : TYPE_OBJECT, v);
|
||||||
if(receiverType != null) {
|
if (receiverType != null) {
|
||||||
ClassDescriptor propReceiverDescriptor = (ClassDescriptor) propertyDescriptor.getContainingDeclaration();
|
ClassDescriptor propReceiverDescriptor = (ClassDescriptor) propertyDescriptor.getContainingDeclaration();
|
||||||
if(!CodegenUtil.isInterface(propReceiverDescriptor) && CodegenUtil.isInterface(receiverType.getConstructor().getDeclarationDescriptor())) {
|
if (!CodegenUtil.isInterface(propReceiverDescriptor) && CodegenUtil.isInterface(receiverType.getConstructor().getDeclarationDescriptor())) {
|
||||||
// I hope it happens only in case of required super class for traits
|
// I hope it happens only in case of required super class for traits
|
||||||
assert propReceiverDescriptor != null;
|
assert propReceiverDescriptor != null;
|
||||||
v.checkcast(asmType(propReceiverDescriptor.getDefaultType()));
|
v.checkcast(asmType(propReceiverDescriptor.getDefaultType()));
|
||||||
@@ -1107,7 +1107,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
if (descriptor instanceof ClassDescriptor) {
|
if (descriptor instanceof ClassDescriptor) {
|
||||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||||
if(declaration instanceof JetClass) {
|
if (declaration instanceof JetClass) {
|
||||||
final JetClassObject classObject = ((JetClass) declaration).getClassObject();
|
final JetClassObject classObject = ((JetClass) declaration).getClassObject();
|
||||||
if (classObject == null) {
|
if (classObject == null) {
|
||||||
throw new UnsupportedOperationException("trying to reference a class which doesn't have a class object");
|
throw new UnsupportedOperationException("trying to reference a class which doesn't have a class object");
|
||||||
@@ -1165,10 +1165,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private StackValue stackValueForLocal(DeclarationDescriptor descriptor, int index) {
|
private StackValue stackValueForLocal(DeclarationDescriptor descriptor, int index) {
|
||||||
if(descriptor instanceof VariableDescriptor) {
|
if (descriptor instanceof VariableDescriptor) {
|
||||||
Type sharedVarType = typeMapper.getSharedVarType(descriptor);
|
Type sharedVarType = typeMapper.getSharedVarType(descriptor);
|
||||||
final JetType outType = ((VariableDescriptor) descriptor).getType();
|
final JetType outType = ((VariableDescriptor) descriptor).getType();
|
||||||
if(sharedVarType != null) {
|
if (sharedVarType != null) {
|
||||||
return StackValue.shared(index, asmType(outType));
|
return StackValue.shared(index, asmType(outType));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1191,7 +1191,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
JvmClassName owner;
|
JvmClassName owner;
|
||||||
|
|
||||||
IntrinsicMethod intrinsic = state.getInjector().getIntrinsics().getIntrinsic(functionDescriptor);
|
IntrinsicMethod intrinsic = state.getInjector().getIntrinsics().getIntrinsic(functionDescriptor);
|
||||||
if(intrinsic != null) {
|
if (intrinsic != null) {
|
||||||
intrinsic.generate(this, v, type, null, null, StackValue.onStack(TYPE_OBJECT), state);
|
intrinsic.generate(this, v, type, null, null, StackValue.onStack(TYPE_OBJECT), state);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1237,11 +1237,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
getter = null;
|
getter = null;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(isSuper) {
|
if (isSuper) {
|
||||||
PsiElement enclosingElement = bindingContext.get(BindingContext.LABEL_TARGET, superExpression.getTargetLabel());
|
PsiElement enclosingElement = bindingContext.get(BindingContext.LABEL_TARGET, superExpression.getTargetLabel());
|
||||||
ClassDescriptor enclosed = (ClassDescriptor) bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, enclosingElement);
|
ClassDescriptor enclosed = (ClassDescriptor) bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, enclosingElement);
|
||||||
if(!CodegenUtil.isInterface(containingDeclaration)) {
|
if (!CodegenUtil.isInterface(containingDeclaration)) {
|
||||||
if(enclosed != null && enclosed != context.getThisDescriptor()) {
|
if (enclosed != null && enclosed != context.getThisDescriptor()) {
|
||||||
CodegenContext c = context;
|
CodegenContext c = context;
|
||||||
while(c.getContextDescriptor() != enclosed) {
|
while(c.getContextDescriptor() != enclosed) {
|
||||||
c = c.getParentContext();
|
c = c.getParentContext();
|
||||||
@@ -1308,7 +1308,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
assert callee != null;
|
assert callee != null;
|
||||||
|
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
||||||
if(resolvedCall == null) {
|
if (resolvedCall == null) {
|
||||||
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1320,7 +1320,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
else if (funDescriptor instanceof FunctionDescriptor) {
|
else if (funDescriptor instanceof FunctionDescriptor) {
|
||||||
final FunctionDescriptor fd = (FunctionDescriptor) funDescriptor;
|
final FunctionDescriptor fd = (FunctionDescriptor) funDescriptor;
|
||||||
if(resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||||
VariableAsFunctionResolvedCall call = (VariableAsFunctionResolvedCall) resolvedCall;
|
VariableAsFunctionResolvedCall call = (VariableAsFunctionResolvedCall) resolvedCall;
|
||||||
ResolvedCallWithTrace<FunctionDescriptor> functionCall = call.getFunctionCall();
|
ResolvedCallWithTrace<FunctionDescriptor> functionCall = call.getFunctionCall();
|
||||||
return invokeFunction(expression, functionCall.getResultingDescriptor(), receiver, functionCall);
|
return invokeFunction(expression, functionCall.getResultingDescriptor(), receiver, functionCall);
|
||||||
@@ -1347,8 +1347,8 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
JetSuperExpression superExpression = (JetSuperExpression) receiverExpression;
|
JetSuperExpression superExpression = (JetSuperExpression) receiverExpression;
|
||||||
PsiElement enclosingElement = bindingContext.get(BindingContext.LABEL_TARGET, superExpression.getTargetLabel());
|
PsiElement enclosingElement = bindingContext.get(BindingContext.LABEL_TARGET, superExpression.getTargetLabel());
|
||||||
ClassDescriptor enclosed = (ClassDescriptor) bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, enclosingElement);
|
ClassDescriptor enclosed = (ClassDescriptor) bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, enclosingElement);
|
||||||
if(!CodegenUtil.isInterface(fd.getContainingDeclaration())) {
|
if (!CodegenUtil.isInterface(fd.getContainingDeclaration())) {
|
||||||
if(enclosed != null && enclosed != context.getThisDescriptor()) {
|
if (enclosed != null && enclosed != context.getThisDescriptor()) {
|
||||||
CodegenContext c = context;
|
CodegenContext c = context;
|
||||||
while(c.getContextDescriptor() != enclosed) {
|
while(c.getContextDescriptor() != enclosed) {
|
||||||
c = c.getParentContext();
|
c = c.getParentContext();
|
||||||
@@ -1437,20 +1437,20 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
||||||
assert resolvedCall != null;
|
assert resolvedCall != null;
|
||||||
|
|
||||||
if(resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
if (resolvedCall instanceof VariableAsFunctionResolvedCall) {
|
||||||
resolvedCall = ((VariableAsFunctionResolvedCall)resolvedCall).getFunctionCall();
|
resolvedCall = ((VariableAsFunctionResolvedCall)resolvedCall).getFunctionCall();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor)) { // otherwise already
|
if (!(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor)) { // otherwise already
|
||||||
receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod, state);
|
receiver = StackValue.receiver(resolvedCall, receiver, this, callableMethod, state);
|
||||||
receiver.put(receiver.type, v);
|
receiver.put(receiver.type, v);
|
||||||
if(calleeType != null) {
|
if (calleeType != null) {
|
||||||
StackValue.onStack(receiver.type).put(boxType(receiver.type), v);
|
StackValue.onStack(receiver.type).put(boxType(receiver.type), v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int mask = pushMethodArguments(expression, callableMethod.getValueParameterTypes());
|
int mask = pushMethodArguments(expression, callableMethod.getValueParameterTypes());
|
||||||
if(mask == 0)
|
if (mask == 0)
|
||||||
callableMethod.invoke(v);
|
callableMethod.invoke(v);
|
||||||
else
|
else
|
||||||
callableMethod.invokeWithDefault(v, mask);
|
callableMethod.invokeWithDefault(v, mask);
|
||||||
@@ -1462,11 +1462,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void generateFromResolvedCall(@NotNull ReceiverDescriptor descriptor, @NotNull Type type) {
|
public void generateFromResolvedCall(@NotNull ReceiverDescriptor descriptor, @NotNull Type type) {
|
||||||
if(descriptor instanceof ClassReceiver) {
|
if (descriptor instanceof ClassReceiver) {
|
||||||
Type exprType = asmType(descriptor.getType());
|
Type exprType = asmType(descriptor.getType());
|
||||||
ClassReceiver classReceiver = (ClassReceiver) descriptor;
|
ClassReceiver classReceiver = (ClassReceiver) descriptor;
|
||||||
ClassDescriptor classReceiverDeclarationDescriptor = (ClassDescriptor) classReceiver.getDeclarationDescriptor();
|
ClassDescriptor classReceiverDeclarationDescriptor = (ClassDescriptor) classReceiver.getDeclarationDescriptor();
|
||||||
if(DescriptorUtils.isClassObject(classReceiverDeclarationDescriptor)) {
|
if (DescriptorUtils.isClassObject(classReceiverDeclarationDescriptor)) {
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) classReceiverDeclarationDescriptor.getContainingDeclaration();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) classReceiverDeclarationDescriptor.getContainingDeclaration();
|
||||||
Type classObjType = typeMapper.mapType(containingDeclaration.getDefaultType(), MapTypeMode.IMPL);
|
Type classObjType = typeMapper.mapType(containingDeclaration.getDefaultType(), MapTypeMode.IMPL);
|
||||||
v.getstatic(classObjType.getInternalName(), "$classobj", exprType.getDescriptor());
|
v.getstatic(classObjType.getInternalName(), "$classobj", exprType.getDescriptor());
|
||||||
@@ -1479,20 +1479,20 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
else if (descriptor instanceof ScriptReceiver) {
|
else if (descriptor instanceof ScriptReceiver) {
|
||||||
generateScript((ScriptReceiver) descriptor);
|
generateScript((ScriptReceiver) descriptor);
|
||||||
}
|
}
|
||||||
else if(descriptor instanceof ExtensionReceiver) {
|
else if (descriptor instanceof ExtensionReceiver) {
|
||||||
Type exprType = asmType(descriptor.getType());
|
Type exprType = asmType(descriptor.getType());
|
||||||
ExtensionReceiver extensionReceiver = (ExtensionReceiver) descriptor;
|
ExtensionReceiver extensionReceiver = (ExtensionReceiver) descriptor;
|
||||||
generateReceiver(extensionReceiver.getDeclarationDescriptor()).put(exprType, v);
|
generateReceiver(extensionReceiver.getDeclarationDescriptor()).put(exprType, v);
|
||||||
StackValue.onStack(exprType).put(type, v);
|
StackValue.onStack(exprType).put(type, v);
|
||||||
}
|
}
|
||||||
else if(descriptor instanceof ExpressionReceiver) {
|
else if (descriptor instanceof ExpressionReceiver) {
|
||||||
ExpressionReceiver expressionReceiver = (ExpressionReceiver) descriptor;
|
ExpressionReceiver expressionReceiver = (ExpressionReceiver) descriptor;
|
||||||
JetExpression expr = expressionReceiver.getExpression();
|
JetExpression expr = expressionReceiver.getExpression();
|
||||||
Type exprType = asmType(expressionReceiver.getType());
|
Type exprType = asmType(expressionReceiver.getType());
|
||||||
gen(expr, exprType);
|
gen(expr, exprType);
|
||||||
StackValue.onStack(exprType).put(type, v);
|
StackValue.onStack(exprType).put(type, v);
|
||||||
}
|
}
|
||||||
else if(descriptor instanceof AutoCastReceiver) {
|
else if (descriptor instanceof AutoCastReceiver) {
|
||||||
AutoCastReceiver autoCastReceiver = (AutoCastReceiver) descriptor;
|
AutoCastReceiver autoCastReceiver = (AutoCastReceiver) descriptor;
|
||||||
Type intermediateType = asmType(autoCastReceiver.getType());
|
Type intermediateType = asmType(autoCastReceiver.getType());
|
||||||
generateFromResolvedCall(autoCastReceiver.getOriginal(), intermediateType);
|
generateFromResolvedCall(autoCastReceiver.getOriginal(), intermediateType);
|
||||||
@@ -1532,7 +1532,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
cur = context;
|
cur = context;
|
||||||
StackValue result = StackValue.local(0, TYPE_OBJECT);
|
StackValue result = StackValue.local(0, TYPE_OBJECT);
|
||||||
while (cur != null) {
|
while (cur != null) {
|
||||||
if(cur instanceof CodegenContexts.MethodContext && !(cur instanceof CodegenContexts.ConstructorContext))
|
if (cur instanceof CodegenContexts.MethodContext && !(cur instanceof CodegenContexts.ConstructorContext))
|
||||||
cur = cur.getParentContext();
|
cur = cur.getParentContext();
|
||||||
|
|
||||||
if (cur instanceof CodegenContexts.ScriptContext) {
|
if (cur instanceof CodegenContexts.ScriptContext) {
|
||||||
@@ -1553,7 +1553,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
result = cur.getOuterExpression(result);
|
result = cur.getOuterExpression(result);
|
||||||
|
|
||||||
if(cur instanceof CodegenContexts.ConstructorContext) {
|
if (cur instanceof CodegenContexts.ConstructorContext) {
|
||||||
cur = cur.getParentContext();
|
cur = cur.getParentContext();
|
||||||
}
|
}
|
||||||
cur = cur.getParentContext();
|
cur = cur.getParentContext();
|
||||||
@@ -1570,12 +1570,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
cur = context;
|
cur = context;
|
||||||
StackValue result = StackValue.local(0, TYPE_OBJECT);
|
StackValue result = StackValue.local(0, TYPE_OBJECT);
|
||||||
while (cur != null) {
|
while (cur != null) {
|
||||||
if(cur instanceof CodegenContexts.MethodContext && !(cur instanceof CodegenContexts.ConstructorContext))
|
if (cur instanceof CodegenContexts.MethodContext && !(cur instanceof CodegenContexts.ConstructorContext))
|
||||||
cur = cur.getParentContext();
|
cur = cur.getParentContext();
|
||||||
|
|
||||||
if (DescriptorUtils.isSubclass(cur.getThisDescriptor(), calleeContainingClass)) {
|
if (DescriptorUtils.isSubclass(cur.getThisDescriptor(), calleeContainingClass)) {
|
||||||
Type type = asmType(calleeContainingClass.getDefaultType());
|
Type type = asmType(calleeContainingClass.getDefaultType());
|
||||||
if(!isObject || (cur.getThisDescriptor() == calleeContainingClass)) {
|
if (!isObject || (cur.getThisDescriptor() == calleeContainingClass)) {
|
||||||
result.put(TYPE_OBJECT, v);
|
result.put(TYPE_OBJECT, v);
|
||||||
return castToRequiredTypeOfInterfaceIfNeeded(StackValue.onStack(type), cur.getThisDescriptor(), calleeContainingClass);
|
return castToRequiredTypeOfInterfaceIfNeeded(StackValue.onStack(type), cur.getThisDescriptor(), calleeContainingClass);
|
||||||
}
|
}
|
||||||
@@ -1586,7 +1586,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
result = cur.getOuterExpression(result);
|
result = cur.getOuterExpression(result);
|
||||||
|
|
||||||
if(cur instanceof CodegenContexts.ConstructorContext) {
|
if (cur instanceof CodegenContexts.ConstructorContext) {
|
||||||
cur = cur.getParentContext();
|
cur = cur.getParentContext();
|
||||||
}
|
}
|
||||||
cur = cur.getParentContext();
|
cur = cur.getParentContext();
|
||||||
@@ -1618,21 +1618,21 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
for (ValueParameterDescriptor valueParameterDescriptor : fd.getValueParameters()) {
|
for (ValueParameterDescriptor valueParameterDescriptor : fd.getValueParameters()) {
|
||||||
ResolvedValueArgument resolvedValueArgument = valueArguments.get(valueParameterDescriptor.getIndex());
|
ResolvedValueArgument resolvedValueArgument = valueArguments.get(valueParameterDescriptor.getIndex());
|
||||||
if(resolvedValueArgument instanceof ExpressionValueArgument) {
|
if (resolvedValueArgument instanceof ExpressionValueArgument) {
|
||||||
ExpressionValueArgument valueArgument = (ExpressionValueArgument) resolvedValueArgument;
|
ExpressionValueArgument valueArgument = (ExpressionValueArgument) resolvedValueArgument;
|
||||||
gen(valueArgument.getValueArgument().getArgumentExpression(), valueParameterTypes.get(index));
|
gen(valueArgument.getValueArgument().getArgumentExpression(), valueParameterTypes.get(index));
|
||||||
}
|
}
|
||||||
else if(resolvedValueArgument instanceof DefaultValueArgument) {
|
else if (resolvedValueArgument instanceof DefaultValueArgument) {
|
||||||
Type type = valueParameterTypes.get(index);
|
Type type = valueParameterTypes.get(index);
|
||||||
if(type.getSort() == Type.OBJECT||type.getSort() == Type.ARRAY)
|
if (type.getSort() == Type.OBJECT||type.getSort() == Type.ARRAY)
|
||||||
v.aconst(null);
|
v.aconst(null);
|
||||||
else if(type.getSort() == Type.FLOAT) {
|
else if (type.getSort() == Type.FLOAT) {
|
||||||
v.aconst(0f);
|
v.aconst(0f);
|
||||||
}
|
}
|
||||||
else if(type.getSort() == Type.DOUBLE) {
|
else if (type.getSort() == Type.DOUBLE) {
|
||||||
v.aconst(0d);
|
v.aconst(0d);
|
||||||
}
|
}
|
||||||
else if(type.getSort() == Type.LONG) {
|
else if (type.getSort() == Type.LONG) {
|
||||||
v.aconst(0l);
|
v.aconst(0l);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1640,7 +1640,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
mask |= (1 << index);
|
mask |= (1 << index);
|
||||||
}
|
}
|
||||||
else if(resolvedValueArgument instanceof VarargValueArgument) {
|
else if (resolvedValueArgument instanceof VarargValueArgument) {
|
||||||
VarargValueArgument valueArgument = (VarargValueArgument) resolvedValueArgument;
|
VarargValueArgument valueArgument = (VarargValueArgument) resolvedValueArgument;
|
||||||
genVarargs(valueParameterDescriptor, valueArgument);
|
genVarargs(valueParameterDescriptor, valueArgument);
|
||||||
}
|
}
|
||||||
@@ -1663,14 +1663,14 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
boolean hasSpread = false;
|
boolean hasSpread = false;
|
||||||
for(int i = 0; i != size; ++i) {
|
for(int i = 0; i != size; ++i) {
|
||||||
if(arguments.get(i).getSpreadElement() != null) {
|
if (arguments.get(i).getSpreadElement() != null) {
|
||||||
hasSpread = true;
|
hasSpread = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasSpread) {
|
if (hasSpread) {
|
||||||
if(size == 1) {
|
if (size == 1) {
|
||||||
gen(arguments.get(0).getArgumentExpression(), type);
|
gen(arguments.get(0).getArgumentExpression(), type);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1681,7 +1681,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
for(int i = 0; i != size; ++i) {
|
for(int i = 0; i != size; ++i) {
|
||||||
v.dup();
|
v.dup();
|
||||||
ValueArgument argument = arguments.get(i);
|
ValueArgument argument = arguments.get(i);
|
||||||
if(argument.getSpreadElement() != null) {
|
if (argument.getSpreadElement() != null) {
|
||||||
gen(argument.getArgumentExpression(),JetTypeMapper.TYPE_OBJECT);
|
gen(argument.getArgumentExpression(),JetTypeMapper.TYPE_OBJECT);
|
||||||
v.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V");
|
v.invokevirtual(owner, "addSpread", "(Ljava/lang/Object;)V");
|
||||||
}
|
}
|
||||||
@@ -1712,7 +1712,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
public int pushMethodArguments(JetCallElement expression, List<Type> valueParameterTypes) {
|
public int pushMethodArguments(JetCallElement expression, List<Type> valueParameterTypes) {
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, expression.getCalleeExpression());
|
||||||
if(resolvedCall != null) {
|
if (resolvedCall != null) {
|
||||||
return pushMethodArguments(resolvedCall, valueParameterTypes);
|
return pushMethodArguments(resolvedCall, valueParameterTypes);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1750,11 +1750,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Type receiverType = asmType(receiverJetType);
|
Type receiverType = asmType(receiverJetType);
|
||||||
gen(expr, receiverType);
|
gen(expr, receiverType);
|
||||||
assert receiverJetType != null;
|
assert receiverJetType != null;
|
||||||
if(!receiverJetType.isNullable()) {
|
if (!receiverJetType.isNullable()) {
|
||||||
StackValue propValue = genQualified(StackValue.onStack(receiverType), expression.getSelectorExpression());
|
StackValue propValue = genQualified(StackValue.onStack(receiverType), expression.getSelectorExpression());
|
||||||
Type type = propValue.type;
|
Type type = propValue.type;
|
||||||
propValue.put(type, v);
|
propValue.put(type, v);
|
||||||
if(isPrimitive(type) && !type.equals(Type.VOID_TYPE)) {
|
if (isPrimitive(type) && !type.equals(Type.VOID_TYPE)) {
|
||||||
StackValue.valueOf(v, type);
|
StackValue.valueOf(v, type);
|
||||||
type = boxType(type);
|
type = boxType(type);
|
||||||
}
|
}
|
||||||
@@ -1769,7 +1769,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
StackValue propValue = genQualified(StackValue.onStack(receiverType), expression.getSelectorExpression());
|
StackValue propValue = genQualified(StackValue.onStack(receiverType), expression.getSelectorExpression());
|
||||||
Type type = propValue.type;
|
Type type = propValue.type;
|
||||||
propValue.put(type, v);
|
propValue.put(type, v);
|
||||||
if(isPrimitive(type) && !type.equals(Type.VOID_TYPE)) {
|
if (isPrimitive(type) && !type.equals(Type.VOID_TYPE)) {
|
||||||
StackValue.valueOf(v, type);
|
StackValue.valueOf(v, type);
|
||||||
type = boxType(type);
|
type = boxType(type);
|
||||||
}
|
}
|
||||||
@@ -1777,7 +1777,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
v.mark(ifnull);
|
v.mark(ifnull);
|
||||||
v.pop();
|
v.pop();
|
||||||
if(!propValue.type.equals(Type.VOID_TYPE)) {
|
if (!propValue.type.equals(Type.VOID_TYPE)) {
|
||||||
v.aconst(null);
|
v.aconst(null);
|
||||||
}
|
}
|
||||||
v.mark(end);
|
v.mark(end);
|
||||||
@@ -1812,7 +1812,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
else if (opToken == JetTokens.ELVIS) {
|
else if (opToken == JetTokens.ELVIS) {
|
||||||
return generateElvis(expression);
|
return generateElvis(expression);
|
||||||
}
|
}
|
||||||
else if(opToken == JetTokens.IN_KEYWORD || opToken == JetTokens.NOT_IN) {
|
else if (opToken == JetTokens.IN_KEYWORD || opToken == JetTokens.NOT_IN) {
|
||||||
return generateIn (expression);
|
return generateIn (expression);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1831,7 +1831,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
private StackValue generateIn(JetBinaryExpression expression) {
|
private StackValue generateIn(JetBinaryExpression expression) {
|
||||||
JetExpression expr = expression.getLeft();
|
JetExpression expr = expression.getLeft();
|
||||||
if(isIntRangeExpr(expression.getRight())) {
|
if (isIntRangeExpr(expression.getRight())) {
|
||||||
StackValue leftValue = StackValue.expression(Type.INT_TYPE, expression.getLeft(), this);
|
StackValue leftValue = StackValue.expression(Type.INT_TYPE, expression.getLeft(), this);
|
||||||
JetBinaryExpression rangeExpression = (JetBinaryExpression) expression.getRight();
|
JetBinaryExpression rangeExpression = (JetBinaryExpression) expression.getRight();
|
||||||
boolean inverted = expression.getOperationReference().getReferencedNameElementType() == JetTokens.NOT_IN;
|
boolean inverted = expression.getOperationReference().getReferencedNameElementType() == JetTokens.NOT_IN;
|
||||||
@@ -1883,7 +1883,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
// c c
|
// c c
|
||||||
|
|
||||||
v.and(Type.INT_TYPE);
|
v.and(Type.INT_TYPE);
|
||||||
if(inverted) {
|
if (inverted) {
|
||||||
v.iconst(1);
|
v.iconst(1);
|
||||||
v.xor(Type.INT_TYPE);
|
v.xor(Type.INT_TYPE);
|
||||||
}
|
}
|
||||||
@@ -1920,15 +1920,15 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Type leftType = asmType(leftJetType);
|
Type leftType = asmType(leftJetType);
|
||||||
JetType rightJetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, right);
|
JetType rightJetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, right);
|
||||||
Type rightType = asmType(rightJetType);
|
Type rightType = asmType(rightJetType);
|
||||||
if(leftType == TYPE_NOTHING) {
|
if (leftType == TYPE_NOTHING) {
|
||||||
return genCmpWithNull(right, rightType, opToken);
|
return genCmpWithNull(right, rightType, opToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rightType == TYPE_NOTHING) {
|
if (rightType == TYPE_NOTHING) {
|
||||||
return genCmpWithNull(left, leftType, opToken);
|
return genCmpWithNull(left, leftType, opToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPrimitive(leftType) != isPrimitive(rightType)) {
|
if (isPrimitive(leftType) != isPrimitive(rightType)) {
|
||||||
gen(left, leftType);
|
gen(left, leftType);
|
||||||
StackValue.valueOf(v, leftType);
|
StackValue.valueOf(v, leftType);
|
||||||
leftType = boxType(leftType);
|
leftType = boxType(leftType);
|
||||||
@@ -1941,7 +1941,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
gen(right, rightType);
|
gen(right, rightType);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPrimitive(leftType)) // both are primitive
|
if (isPrimitive(leftType)) // both are primitive
|
||||||
return generateEqualsForExpressionsOnStack(opToken, leftType, rightType, false, false);
|
return generateEqualsForExpressionsOnStack(opToken, leftType, rightType, false, false);
|
||||||
|
|
||||||
assert leftJetType != null;
|
assert leftJetType != null;
|
||||||
@@ -1953,7 +1953,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
v.iconst(1);
|
v.iconst(1);
|
||||||
gen(exp, boxType(expType));
|
gen(exp, boxType(expType));
|
||||||
Label ok = new Label();
|
Label ok = new Label();
|
||||||
if(JetTokens.EQEQ == opToken || JetTokens.EQEQEQ == opToken) {
|
if (JetTokens.EQEQ == opToken || JetTokens.EQEQEQ == opToken) {
|
||||||
v.ifnull(ok);
|
v.ifnull(ok);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1980,7 +1980,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private StackValue generateNullSafeEquals(IElementType opToken, boolean leftNullable, boolean rightNullable) {
|
private StackValue generateNullSafeEquals(IElementType opToken, boolean leftNullable, boolean rightNullable) {
|
||||||
if(!leftNullable) {
|
if (!leftNullable) {
|
||||||
v.invokevirtual("java/lang/Object", "equals", "(Ljava/lang/Object;)Z");
|
v.invokevirtual("java/lang/Object", "equals", "(Ljava/lang/Object;)Z");
|
||||||
if (opToken == JetTokens.EXCLEQ) {
|
if (opToken == JetTokens.EXCLEQ) {
|
||||||
v.iconst(1);
|
v.iconst(1);
|
||||||
@@ -1988,7 +1988,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(rightNullable) {
|
if (rightNullable) {
|
||||||
v.dup2(); // left right left right
|
v.dup2(); // left right left right
|
||||||
Label rightNull = new Label();
|
Label rightNull = new Label();
|
||||||
v.ifnull(rightNull);
|
v.ifnull(rightNull);
|
||||||
@@ -2042,7 +2042,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression.getLeft());
|
JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, expression.getLeft());
|
||||||
assert type != null;
|
assert type != null;
|
||||||
final Type leftType = asmType(type);
|
final Type leftType = asmType(type);
|
||||||
if(type.isNullable()) {
|
if (type.isNullable()) {
|
||||||
gen(expression.getLeft(), leftType);
|
gen(expression.getLeft(), leftType);
|
||||||
v.dup();
|
v.dup();
|
||||||
Label end = new Label();
|
Label end = new Label();
|
||||||
@@ -2111,9 +2111,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
final Callable callable = resolveToCallable((FunctionDescriptor) op, false);
|
final Callable callable = resolveToCallable((FunctionDescriptor) op, false);
|
||||||
final JetExpression lhs = expression.getLeft();
|
final JetExpression lhs = expression.getLeft();
|
||||||
|
|
||||||
// if(lhs instanceof JetArrayAccessExpression) {
|
// if (lhs instanceof JetArrayAccessExpression) {
|
||||||
// JetArrayAccessExpression arrayAccessExpression = (JetArrayAccessExpression) lhs;
|
// JetArrayAccessExpression arrayAccessExpression = (JetArrayAccessExpression) lhs;
|
||||||
// if(arrayAccessExpression.getIndexExpressions().size() != 1) {
|
// if (arrayAccessExpression.getIndexExpressions().size() != 1) {
|
||||||
// throw new UnsupportedOperationException("Augmented assignment with multi-index");
|
// throw new UnsupportedOperationException("Augmented assignment with multi-index");
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
@@ -2156,7 +2156,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
value.put(lhsType, v);
|
value.put(lhsType, v);
|
||||||
StackValue receiver = StackValue.onStack(lhsType);
|
StackValue receiver = StackValue.onStack(lhsType);
|
||||||
|
|
||||||
if(!(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor)) { // otherwise already
|
if (!(resolvedCall.getResultingDescriptor() instanceof ConstructorDescriptor)) { // otherwise already
|
||||||
receiver = StackValue.receiver(resolvedCall, receiver, this, callable, state);
|
receiver = StackValue.receiver(resolvedCall, receiver, this, callable, state);
|
||||||
receiver.put(receiver.type, v);
|
receiver.put(receiver.type, v);
|
||||||
}
|
}
|
||||||
@@ -2185,7 +2185,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Type leftType = expressionType(left);
|
Type leftType = expressionType(left);
|
||||||
Type rightType = expressionType(right);
|
Type rightType = expressionType(right);
|
||||||
|
|
||||||
if(leftType.equals(JetTypeMapper.JL_STRING_TYPE) && rightType.equals(JL_STRING_TYPE)) {
|
if (leftType.equals(JetTypeMapper.JL_STRING_TYPE) && rightType.equals(JL_STRING_TYPE)) {
|
||||||
invokeAppend(left);
|
invokeAppend(left);
|
||||||
invokeAppend(right);
|
invokeAppend(right);
|
||||||
return;
|
return;
|
||||||
@@ -2204,7 +2204,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JetSimpleNameExpression targetLabel(JetExpression expression) {
|
private JetSimpleNameExpression targetLabel(JetExpression expression) {
|
||||||
if(expression.getParent() instanceof JetPrefixExpression) {
|
if (expression.getParent() instanceof JetPrefixExpression) {
|
||||||
JetPrefixExpression parent = (JetPrefixExpression) expression.getParent();
|
JetPrefixExpression parent = (JetPrefixExpression) expression.getParent();
|
||||||
JetSimpleNameExpression operationSign = parent.getOperationReference();
|
JetSimpleNameExpression operationSign = parent.getOperationReference();
|
||||||
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
if (JetTokens.LABELS.contains(operationSign.getReferencedNameElementType())) {
|
||||||
@@ -2267,11 +2267,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver) {
|
public StackValue visitPostfixExpression(JetPostfixExpression expression, StackValue receiver) {
|
||||||
if(expression.getOperationReference().getReferencedNameElementType() == JetTokens.EXCLEXCL) {
|
if (expression.getOperationReference().getReferencedNameElementType() == JetTokens.EXCLEXCL) {
|
||||||
JetExpression baseExpression = expression.getBaseExpression();
|
JetExpression baseExpression = expression.getBaseExpression();
|
||||||
JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, baseExpression);
|
JetType type = bindingContext.get(BindingContext.EXPRESSION_TYPE, baseExpression);
|
||||||
StackValue base = genQualified(receiver, baseExpression);
|
StackValue base = genQualified(receiver, baseExpression);
|
||||||
if(type != null && type.isNullable()) {
|
if (type != null && type.isNullable()) {
|
||||||
base.put(base.type, v);
|
base.put(base.type, v);
|
||||||
v.dup();
|
v.dup();
|
||||||
Label ok = new Label();
|
Label ok = new Label();
|
||||||
@@ -2316,21 +2316,21 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
switch(value.receiverSize()) {
|
switch(value.receiverSize()) {
|
||||||
case 0:
|
case 0:
|
||||||
if(type.getSize() == 2)
|
if (type.getSize() == 2)
|
||||||
v.dup2();
|
v.dup2();
|
||||||
else
|
else
|
||||||
v.dup();
|
v.dup();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 1:
|
case 1:
|
||||||
if(type.getSize() == 2)
|
if (type.getSize() == 2)
|
||||||
v.dup2X1();
|
v.dup2X1();
|
||||||
else
|
else
|
||||||
v.dupX1();
|
v.dupX1();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 2:
|
case 2:
|
||||||
if(type.getSize() == 2)
|
if (type.getSize() == 2)
|
||||||
v.dup2X2();
|
v.dup2X2();
|
||||||
else
|
else
|
||||||
v.dupX2();
|
v.dupX2();
|
||||||
@@ -2459,7 +2459,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
// TODO typechecker must verify that we're the outer class of the instance being created
|
// TODO typechecker must verify that we're the outer class of the instance being created
|
||||||
//noinspection ConstantConditions
|
//noinspection ConstantConditions
|
||||||
if(!receiver.type.equals(Type.VOID_TYPE)) {
|
if (!receiver.type.equals(Type.VOID_TYPE)) {
|
||||||
receiver.put(receiver.type, v);
|
receiver.put(receiver.type, v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2476,7 +2476,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
private Type generateJavaConstructorCall(JetCallExpression expression) {
|
private Type generateJavaConstructorCall(JetCallExpression expression) {
|
||||||
JetExpression callee = expression.getCalleeExpression();
|
JetExpression callee = expression.getCalleeExpression();
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
||||||
if(resolvedCall == null) {
|
if (resolvedCall == null) {
|
||||||
assert callee != null;
|
assert callee != null;
|
||||||
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
||||||
}
|
}
|
||||||
@@ -2498,7 +2498,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
args.addAll(expression.getFunctionLiteralArguments());
|
args.addAll(expression.getFunctionLiteralArguments());
|
||||||
|
|
||||||
boolean isArray = state.getInjector().getJetStandardLibrary().getArray().equals(arrayType.getConstructor().getDeclarationDescriptor());
|
boolean isArray = state.getInjector().getJetStandardLibrary().getArray().equals(arrayType.getConstructor().getDeclarationDescriptor());
|
||||||
if(isArray) {
|
if (isArray) {
|
||||||
// if (args.size() != 2 && !arrayType.getArguments().get(0).getType().isNullable()) {
|
// if (args.size() != 2 && !arrayType.getArguments().get(0).getType().isNullable()) {
|
||||||
// throw new CompilationException("array constructor of non-nullable type requires two arguments");
|
// throw new CompilationException("array constructor of non-nullable type requires two arguments");
|
||||||
// }
|
// }
|
||||||
@@ -2509,12 +2509,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isArray) {
|
if (isArray) {
|
||||||
gen(args.get(0), Type.INT_TYPE);
|
gen(args.get(0), Type.INT_TYPE);
|
||||||
v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType())));
|
v.newarray(boxType(asmType(arrayType.getArguments().get(0).getType())));
|
||||||
/*
|
/*
|
||||||
JetType elementType = typeMapper.getGenericsElementType(arrayType);
|
JetType elementType = typeMapper.getGenericsElementType(arrayType);
|
||||||
if(elementType != null) {
|
if (elementType != null) {
|
||||||
generateTypeInfo(elementType, null);
|
generateTypeInfo(elementType, null);
|
||||||
gen(args.get(0), Type.INT_TYPE);
|
gen(args.get(0), Type.INT_TYPE);
|
||||||
v.invokevirtual("jet/TypeInfo", "newArray", "(I)[Ljava/lang/Object;");
|
v.invokevirtual("jet/TypeInfo", "newArray", "(I)[Ljava/lang/Object;");
|
||||||
@@ -2531,7 +2531,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
v.newarray(correctElementType(type));
|
v.newarray(correctElementType(type));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
int sizeIndex = myFrameMap.enterTemp(2);
|
int sizeIndex = myFrameMap.enterTemp(2);
|
||||||
int indexIndex = sizeIndex+1;
|
int indexIndex = sizeIndex+1;
|
||||||
|
|
||||||
@@ -2582,7 +2582,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
gen(index, Type.INT_TYPE);
|
gen(index, Type.INT_TYPE);
|
||||||
}
|
}
|
||||||
assert type != null;
|
assert type != null;
|
||||||
if(state.getInjector().getJetStandardLibrary().getArray().equals(type.getConstructor().getDeclarationDescriptor())) {
|
if (state.getInjector().getJetStandardLibrary().getArray().equals(type.getConstructor().getDeclarationDescriptor())) {
|
||||||
JetType elementType = type.getArguments().get(0).getType();
|
JetType elementType = type.getArguments().get(0).getType();
|
||||||
Type notBoxed = asmType(elementType);
|
Type notBoxed = asmType(elementType);
|
||||||
return StackValue.arrayElement(notBoxed, true);
|
return StackValue.arrayElement(notBoxed, true);
|
||||||
@@ -2605,9 +2605,9 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
Type asmType;
|
Type asmType;
|
||||||
Type[] argumentTypes = accessor.getSignature().getAsmMethod().getArgumentTypes();
|
Type[] argumentTypes = accessor.getSignature().getAsmMethod().getArgumentTypes();
|
||||||
int index = 0;
|
int index = 0;
|
||||||
if(isGetter) {
|
if (isGetter) {
|
||||||
Callable callable = resolveToCallable(getterDescriptor, false);
|
Callable callable = resolveToCallable(getterDescriptor, false);
|
||||||
if(callable instanceof CallableMethod)
|
if (callable instanceof CallableMethod)
|
||||||
genThisAndReceiverFromResolvedCall(receiver, resolvedGetCall, (CallableMethod) callable);
|
genThisAndReceiverFromResolvedCall(receiver, resolvedGetCall, (CallableMethod) callable);
|
||||||
else {
|
else {
|
||||||
assert getterDescriptor != null;
|
assert getterDescriptor != null;
|
||||||
@@ -2615,7 +2615,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assert getterDescriptor != null;
|
assert getterDescriptor != null;
|
||||||
if(getterDescriptor.getReceiverParameter().exists()) {
|
if (getterDescriptor.getReceiverParameter().exists()) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
asmType = accessor.getSignature().getAsmMethod().getReturnType();
|
asmType = accessor.getSignature().getAsmMethod().getReturnType();
|
||||||
@@ -2623,13 +2623,13 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
else {
|
else {
|
||||||
assert resolvedSetCall != null;
|
assert resolvedSetCall != null;
|
||||||
Callable callable = resolveToCallable(resolvedSetCall.getResultingDescriptor(), false);
|
Callable callable = resolveToCallable(resolvedSetCall.getResultingDescriptor(), false);
|
||||||
if(callable instanceof CallableMethod) {
|
if (callable instanceof CallableMethod) {
|
||||||
genThisAndReceiverFromResolvedCall(receiver, resolvedSetCall, (CallableMethod) callable);
|
genThisAndReceiverFromResolvedCall(receiver, resolvedSetCall, (CallableMethod) callable);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
gen(array, arrayType);
|
gen(array, arrayType);
|
||||||
|
|
||||||
if(setterDescriptor.getReceiverParameter().exists()) {
|
if (setterDescriptor.getReceiverParameter().exists()) {
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
asmType = argumentTypes[argumentTypes.length-1];
|
asmType = argumentTypes[argumentTypes.length-1];
|
||||||
@@ -2657,7 +2657,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
return generateThisOrOuter((ClassDescriptor) descriptor);
|
return generateThisOrOuter((ClassDescriptor) descriptor);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(descriptor instanceof FunctionDescriptor || descriptor instanceof PropertyDescriptor) {
|
if (descriptor instanceof FunctionDescriptor || descriptor instanceof PropertyDescriptor) {
|
||||||
return generateReceiver(descriptor);
|
return generateReceiver(descriptor);
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
@@ -2674,7 +2674,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
continueLabel = null;
|
continueLabel = null;
|
||||||
|
|
||||||
JetFinallySection finallyBlock = expression.getFinallyBlock();
|
JetFinallySection finallyBlock = expression.getFinallyBlock();
|
||||||
if(finallyBlock != null) {
|
if (finallyBlock != null) {
|
||||||
blockStackElements.push(new FinallyBlockStackElement(expression));
|
blockStackElements.push(new FinallyBlockStackElement(expression));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2728,7 +2728,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
v.mark(end);
|
v.mark(end);
|
||||||
v.nop();
|
v.nop();
|
||||||
|
|
||||||
if(finallyBlock != null) {
|
if (finallyBlock != null) {
|
||||||
blockStackElements.pop();
|
blockStackElements.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2758,7 +2758,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
assert leftType != null;
|
assert leftType != null;
|
||||||
|
|
||||||
if (opToken != JetTokens.AS_SAFE) {
|
if (opToken != JetTokens.AS_SAFE) {
|
||||||
if(leftType.isNullable()) {
|
if (leftType.isNullable()) {
|
||||||
if (!rightType.isNullable()) {
|
if (!rightType.isNullable()) {
|
||||||
v.dup();
|
v.dup();
|
||||||
Label nonnull = new Label();
|
Label nonnull = new Label();
|
||||||
@@ -2808,7 +2808,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
return generateTuplePatternMatch((JetTuplePattern) pattern, negated, expressionToMatch, nextEntry);
|
return generateTuplePatternMatch((JetTuplePattern) pattern, negated, expressionToMatch, nextEntry);
|
||||||
}
|
}
|
||||||
else if (pattern instanceof JetExpressionPattern) {
|
else if (pattern instanceof JetExpressionPattern) {
|
||||||
if(expressionToMatch != null) {
|
if (expressionToMatch != null) {
|
||||||
final Type subjectType = expressionToMatch.type;
|
final Type subjectType = expressionToMatch.type;
|
||||||
expressionToMatch.dupReceiver(v);
|
expressionToMatch.dupReceiver(v);
|
||||||
expressionToMatch.put(subjectType, v);
|
expressionToMatch.put(subjectType, v);
|
||||||
@@ -2902,7 +2902,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
v.dup();
|
v.dup();
|
||||||
}
|
}
|
||||||
Type type = boxType(asmType(jetType));
|
Type type = boxType(asmType(jetType));
|
||||||
if(jetType.isNullable()) {
|
if (jetType.isNullable()) {
|
||||||
Label nope = new Label();
|
Label nope = new Label();
|
||||||
Label end = new Label();
|
Label end = new Label();
|
||||||
|
|
||||||
@@ -2927,7 +2927,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
final Type subjectType = subjectJetType == null ? Type.VOID_TYPE : asmType(subjectJetType);
|
final Type subjectType = subjectJetType == null ? Type.VOID_TYPE : asmType(subjectJetType);
|
||||||
final Type resultType = expressionType(expression);
|
final Type resultType = expressionType(expression);
|
||||||
final int subjectLocal = expr != null ? myFrameMap.enterTemp(subjectType.getSize()) : -1;
|
final int subjectLocal = expr != null ? myFrameMap.enterTemp(subjectType.getSize()) : -1;
|
||||||
if(subjectLocal != -1) {
|
if (subjectLocal != -1) {
|
||||||
gen(expr, subjectType);
|
gen(expr, subjectType);
|
||||||
v.store(subjectLocal, subjectType);
|
v.store(subjectLocal, subjectType);
|
||||||
}
|
}
|
||||||
@@ -2935,7 +2935,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
Label end = new Label();
|
Label end = new Label();
|
||||||
boolean hasElse = false;
|
boolean hasElse = false;
|
||||||
for (JetWhenEntry whenEntry : expression.getEntries()) {
|
for (JetWhenEntry whenEntry : expression.getEntries()) {
|
||||||
if(whenEntry.isElse()) {
|
if (whenEntry.isElse()) {
|
||||||
hasElse = true;
|
hasElse = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -2989,7 +2989,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
while (rangeExpression instanceof JetParenthesizedExpression) {
|
while (rangeExpression instanceof JetParenthesizedExpression) {
|
||||||
rangeExpression = ((JetParenthesizedExpression)rangeExpression).getExpression();
|
rangeExpression = ((JetParenthesizedExpression)rangeExpression).getExpression();
|
||||||
}
|
}
|
||||||
if(isIntRangeExpr(rangeExpression)) {
|
if (isIntRangeExpr(rangeExpression)) {
|
||||||
getInIntRange(new StackValue.Local(subjectLocal, subjectType), (JetBinaryExpression) rangeExpression, conditionInRange.getOperationReference().getReferencedNameElementType() == JetTokens.NOT_IN);
|
getInIntRange(new StackValue.Local(subjectLocal, subjectType), (JetBinaryExpression) rangeExpression, conditionInRange.getOperationReference().getReferencedNameElementType() == JetTokens.NOT_IN);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -3020,7 +3020,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isIntRangeExpr(JetExpression rangeExpression) {
|
private boolean isIntRangeExpr(JetExpression rangeExpression) {
|
||||||
if(rangeExpression instanceof JetBinaryExpression) {
|
if (rangeExpression instanceof JetBinaryExpression) {
|
||||||
JetBinaryExpression binaryExpression = (JetBinaryExpression) rangeExpression;
|
JetBinaryExpression binaryExpression = (JetBinaryExpression) rangeExpression;
|
||||||
if (binaryExpression.getOperationReference().getReferencedNameElementType() == JetTokens.RANGE) {
|
if (binaryExpression.getOperationReference().getReferencedNameElementType() == JetTokens.RANGE) {
|
||||||
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, rangeExpression);
|
JetType jetType = bindingContext.get(BindingContext.EXPRESSION_TYPE, rangeExpression);
|
||||||
@@ -3044,7 +3044,7 @@ The "returned" value of try expression with no finally is either the last expres
|
|||||||
if (entries.size() > 22) {
|
if (entries.size() > 22) {
|
||||||
throw new UnsupportedOperationException("tuple too large");
|
throw new UnsupportedOperationException("tuple too large");
|
||||||
}
|
}
|
||||||
if(entries.size() == 0) {
|
if (entries.size() == 0) {
|
||||||
v.visitFieldInsn(Opcodes.GETSTATIC, "jet/Tuple0", "INSTANCE", "Ljet/Tuple0;");
|
v.visitFieldInsn(Opcodes.GETSTATIC, "jet/Tuple0", "INSTANCE", "Ljet/Tuple0;");
|
||||||
return StackValue.onStack(TUPLE0_TYPE);
|
return StackValue.onStack(TUPLE0_TYPE);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,7 +125,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
final MethodVisitor mv = v.newMethod(fun, flags, jvmSignature.getAsmMethod().getName(), jvmSignature.getAsmMethod().getDescriptor(), jvmSignature.getGenericsSignature(), null);
|
final MethodVisitor mv = v.newMethod(fun, flags, jvmSignature.getAsmMethod().getName(), jvmSignature.getAsmMethod().getDescriptor(), jvmSignature.getGenericsSignature(), null);
|
||||||
AnnotationCodegen.forMethod(mv, state.getInjector().getJetTypeMapper()).genAnnotations(functionDescriptor);
|
AnnotationCodegen.forMethod(mv, state.getInjector().getJetTypeMapper()).genAnnotations(functionDescriptor);
|
||||||
if(state.getClassBuilderMode() != ClassBuilderMode.SIGNATURES) {
|
if (state.getClassBuilderMode() != ClassBuilderMode.SIGNATURES) {
|
||||||
int start = 0;
|
int start = 0;
|
||||||
if (needJetAnnotations) {
|
if (needJetAnnotations) {
|
||||||
if (functionDescriptor instanceof PropertyAccessorDescriptor) {
|
if (functionDescriptor instanceof PropertyAccessorDescriptor) {
|
||||||
@@ -146,7 +146,7 @@ public class FunctionCodegen {
|
|||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(receiverParameter.exists()) {
|
if (receiverParameter.exists()) {
|
||||||
JetValueParameterAnnotationWriter av = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, start++);
|
JetValueParameterAnnotationWriter av = JetValueParameterAnnotationWriter.visitParameterAnnotation(mv, start++);
|
||||||
av.writeName("this$receiver");
|
av.writeName("this$receiver");
|
||||||
av.writeNullable(receiverParameter.getType().isNullable());
|
av.writeNullable(receiverParameter.getType().isNullable());
|
||||||
@@ -188,10 +188,10 @@ public class FunctionCodegen {
|
|||||||
Type[] argTypes = jvmSignature.getAsmMethod().getArgumentTypes();
|
Type[] argTypes = jvmSignature.getAsmMethod().getArgumentTypes();
|
||||||
int add = 0;
|
int add = 0;
|
||||||
|
|
||||||
if(kind == OwnerKind.TRAIT_IMPL)
|
if (kind == OwnerKind.TRAIT_IMPL)
|
||||||
add++;
|
add++;
|
||||||
|
|
||||||
if(receiverParameter.exists())
|
if (receiverParameter.exists())
|
||||||
add++;
|
add++;
|
||||||
|
|
||||||
for (int i = 0; i < paramDescrs.size(); i++) {
|
for (int i = 0; i < paramDescrs.size(); i++) {
|
||||||
@@ -263,7 +263,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
int k = 0;
|
int k = 0;
|
||||||
|
|
||||||
if(expectedThisObject.exists()) {
|
if (expectedThisObject.exists()) {
|
||||||
Type type = state.getInjector().getJetTypeMapper().mapType(expectedThisObject.getType(), MapTypeMode.VALUE);
|
Type type = state.getInjector().getJetTypeMapper().mapType(expectedThisObject.getType(), MapTypeMode.VALUE);
|
||||||
// TODO: specify signature
|
// TODO: specify signature
|
||||||
mv.visitLocalVariable("this", type.getDescriptor(), null, methodBegin, methodEnd, k++);
|
mv.visitLocalVariable("this", type.getDescriptor(), null, methodBegin, methodEnd, k++);
|
||||||
@@ -274,7 +274,7 @@ public class FunctionCodegen {
|
|||||||
mv.visitLocalVariable("this", type.getDescriptor(), null, methodBegin, methodEnd, k++);
|
mv.visitLocalVariable("this", type.getDescriptor(), null, methodBegin, methodEnd, k++);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(receiverParameter.exists()) {
|
if (receiverParameter.exists()) {
|
||||||
Type type = state.getInjector().getJetTypeMapper().mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
Type type = state.getInjector().getJetTypeMapper().mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||||
// TODO: specify signature
|
// TODO: specify signature
|
||||||
mv.visitLocalVariable("this$receiver", type.getDescriptor(), null, methodBegin, methodEnd, k);
|
mv.visitLocalVariable("this$receiver", type.getDescriptor(), null, methodBegin, methodEnd, k);
|
||||||
@@ -287,7 +287,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
Label divideLabel = mapLabelsToDivideLocalVarVisibilityForSharedVar.get(parameter.getName());
|
Label divideLabel = mapLabelsToDivideLocalVarVisibilityForSharedVar.get(parameter.getName());
|
||||||
String parameterName = parameter.getName().getName();
|
String parameterName = parameter.getName().getName();
|
||||||
if(divideLabel != null) {
|
if (divideLabel != null) {
|
||||||
Type sharedVarType = state.getInjector().getJetTypeMapper().getSharedVarType(parameter);
|
Type sharedVarType = state.getInjector().getJetTypeMapper().getSharedVarType(parameter);
|
||||||
mv.visitLocalVariable(parameterName, type.getDescriptor(), null, methodBegin, divideLabel, k);
|
mv.visitLocalVariable(parameterName, type.getDescriptor(), null, methodBegin, divideLabel, k);
|
||||||
|
|
||||||
@@ -329,7 +329,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
static void generateBridgeIfNeeded(CodegenContext owner, GenerationState state, ClassBuilder v, Method jvmSignature, FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
static void generateBridgeIfNeeded(CodegenContext owner, GenerationState state, ClassBuilder v, Method jvmSignature, FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
||||||
Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenDescriptors();
|
Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenDescriptors();
|
||||||
if(kind != OwnerKind.TRAIT_IMPL) {
|
if (kind != OwnerKind.TRAIT_IMPL) {
|
||||||
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
|
for (FunctionDescriptor overriddenFunction : overriddenFunctions) {
|
||||||
// TODO should we check params here as well?
|
// TODO should we check params here as well?
|
||||||
checkOverride(owner, state, v, jvmSignature, functionDescriptor, overriddenFunction.getOriginal());
|
checkOverride(owner, state, v, jvmSignature, functionDescriptor, overriddenFunction.getOriginal());
|
||||||
@@ -341,34 +341,34 @@ public class FunctionCodegen {
|
|||||||
static void generateDefaultIfNeeded(CodegenContexts.MethodContext owner, GenerationState state, ClassBuilder v, Method jvmSignature, @Nullable FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
static void generateDefaultIfNeeded(CodegenContexts.MethodContext owner, GenerationState state, ClassBuilder v, Method jvmSignature, @Nullable FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
||||||
DeclarationDescriptor contextClass = owner.getContextDescriptor().getContainingDeclaration();
|
DeclarationDescriptor contextClass = owner.getContextDescriptor().getContainingDeclaration();
|
||||||
|
|
||||||
if(kind != OwnerKind.TRAIT_IMPL) {
|
if (kind != OwnerKind.TRAIT_IMPL) {
|
||||||
// we don't generate defaults for traits but do for traitImpl
|
// we don't generate defaults for traits but do for traitImpl
|
||||||
if(contextClass instanceof ClassDescriptor) {
|
if (contextClass instanceof ClassDescriptor) {
|
||||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), contextClass);
|
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), contextClass);
|
||||||
if(psiElement instanceof JetClass) {
|
if (psiElement instanceof JetClass) {
|
||||||
JetClass element = (JetClass) psiElement;
|
JetClass element = (JetClass) psiElement;
|
||||||
if(element.isTrait())
|
if (element.isTrait())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean needed = false;
|
boolean needed = false;
|
||||||
if(functionDescriptor != null) {
|
if (functionDescriptor != null) {
|
||||||
for (ValueParameterDescriptor parameterDescriptor : functionDescriptor.getValueParameters()) {
|
for (ValueParameterDescriptor parameterDescriptor : functionDescriptor.getValueParameters()) {
|
||||||
if(parameterDescriptor.declaresDefaultValue()) {
|
if (parameterDescriptor.declaresDefaultValue()) {
|
||||||
needed = true;
|
needed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(needed) {
|
if (needed) {
|
||||||
ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
ReceiverDescriptor receiverParameter = functionDescriptor.getReceiverParameter();
|
||||||
boolean hasReceiver = receiverParameter.exists();
|
boolean hasReceiver = receiverParameter.exists();
|
||||||
boolean isStatic = kind == OwnerKind.NAMESPACE || kind instanceof OwnerKind.StaticDelegateKind;
|
boolean isStatic = kind == OwnerKind.NAMESPACE || kind instanceof OwnerKind.StaticDelegateKind;
|
||||||
|
|
||||||
if(kind == OwnerKind.TRAIT_IMPL) {
|
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||||
String correctedDescr = "(" + jvmSignature.getDescriptor().substring(jvmSignature.getDescriptor().indexOf(";") + 1);
|
String correctedDescr = "(" + jvmSignature.getDescriptor().substring(jvmSignature.getDescriptor().indexOf(";") + 1);
|
||||||
jvmSignature = new Method(jvmSignature.getName(), correctedDescr);
|
jvmSignature = new Method(jvmSignature.getName(), correctedDescr);
|
||||||
}
|
}
|
||||||
@@ -385,7 +385,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
String descriptor = jvmSignature.getDescriptor().replace(")","I)");
|
String descriptor = jvmSignature.getDescriptor().replace(")","I)");
|
||||||
boolean isConstructor = "<init>".equals(jvmSignature.getName());
|
boolean isConstructor = "<init>".equals(jvmSignature.getName());
|
||||||
if(!isStatic && !isConstructor)
|
if (!isStatic && !isConstructor)
|
||||||
descriptor = descriptor.replace("(", "(" + ownerInternalName.getDescriptor());
|
descriptor = descriptor.replace("(", "(" + ownerInternalName.getDescriptor());
|
||||||
final MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC), isConstructor ? "<init>" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, descriptor, null, null);
|
final MethodVisitor mv = v.newMethod(null, flags | (isConstructor ? 0 : ACC_STATIC), isConstructor ? "<init>" : jvmSignature.getName() + JvmAbi.DEFAULT_PARAMS_IMPL_SUFFIX, descriptor, null, null);
|
||||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||||
@@ -400,7 +400,7 @@ public class FunctionCodegen {
|
|||||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, jvmSignature.getReturnType(), owner, state);
|
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, jvmSignature.getReturnType(), owner, state);
|
||||||
|
|
||||||
int var = 0;
|
int var = 0;
|
||||||
if(!isStatic) {
|
if (!isStatic) {
|
||||||
var++;
|
var++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -411,7 +411,7 @@ public class FunctionCodegen {
|
|||||||
else {
|
else {
|
||||||
receiverType = Type.DOUBLE_TYPE;
|
receiverType = Type.DOUBLE_TYPE;
|
||||||
}
|
}
|
||||||
if(hasReceiver) {
|
if (hasReceiver) {
|
||||||
var += receiverType.getSize();
|
var += receiverType.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -425,11 +425,11 @@ public class FunctionCodegen {
|
|||||||
int maskIndex = var;
|
int maskIndex = var;
|
||||||
|
|
||||||
var = 0;
|
var = 0;
|
||||||
if(!isStatic) {
|
if (!isStatic) {
|
||||||
mv.visitVarInsn(ALOAD, var++);
|
mv.visitVarInsn(ALOAD, var++);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(hasReceiver) {
|
if (hasReceiver) {
|
||||||
iv.load(var, receiverType);
|
iv.load(var, receiverType);
|
||||||
var += receiverType.getSize();
|
var += receiverType.getSize();
|
||||||
}
|
}
|
||||||
@@ -467,12 +467,12 @@ public class FunctionCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!isStatic) {
|
if (!isStatic) {
|
||||||
if(kind == OwnerKind.TRAIT_IMPL) {
|
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||||
iv.invokeinterface(ownerInternalName.getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
iv.invokeinterface(ownerInternalName.getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!isConstructor)
|
if (!isConstructor)
|
||||||
iv.invokevirtual(ownerInternalName.getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
iv.invokevirtual(ownerInternalName.getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
||||||
else
|
else
|
||||||
iv.invokespecial(ownerInternalName.getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
iv.invokespecial(ownerInternalName.getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
||||||
@@ -491,14 +491,14 @@ public class FunctionCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static boolean differentMethods(Method method, Method overridden) {
|
private static boolean differentMethods(Method method, Method overridden) {
|
||||||
if(!method.getReturnType().equals(overridden.getReturnType()))
|
if (!method.getReturnType().equals(overridden.getReturnType()))
|
||||||
return true;
|
return true;
|
||||||
Type[] methodArgumentTypes = method.getArgumentTypes();
|
Type[] methodArgumentTypes = method.getArgumentTypes();
|
||||||
Type[] overriddenArgumentTypes = overridden.getArgumentTypes();
|
Type[] overriddenArgumentTypes = overridden.getArgumentTypes();
|
||||||
if(methodArgumentTypes.length != overriddenArgumentTypes.length)
|
if (methodArgumentTypes.length != overriddenArgumentTypes.length)
|
||||||
return true;
|
return true;
|
||||||
for(int i = 0; i != methodArgumentTypes.length; ++i)
|
for(int i = 0; i != methodArgumentTypes.length; ++i)
|
||||||
if(!methodArgumentTypes[i].equals(overriddenArgumentTypes[i]))
|
if (!methodArgumentTypes[i].equals(overriddenArgumentTypes[i]))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -507,14 +507,14 @@ public class FunctionCodegen {
|
|||||||
Method method = state.getInjector().getJetTypeMapper().mapSignature(functionDescriptor.getName(), functionDescriptor).getAsmMethod();
|
Method method = state.getInjector().getJetTypeMapper().mapSignature(functionDescriptor.getName(), functionDescriptor).getAsmMethod();
|
||||||
Method overridden = state.getInjector().getJetTypeMapper().mapSignature(overriddenFunction.getName(), overriddenFunction.getOriginal()).getAsmMethod();
|
Method overridden = state.getInjector().getJetTypeMapper().mapSignature(overriddenFunction.getName(), overriddenFunction.getOriginal()).getAsmMethod();
|
||||||
|
|
||||||
if(overriddenFunction.getModality() == Modality.ABSTRACT) {
|
if (overriddenFunction.getModality() == Modality.ABSTRACT) {
|
||||||
Set<? extends FunctionDescriptor> overriddenFunctions = overriddenFunction.getOverriddenDescriptors();
|
Set<? extends FunctionDescriptor> overriddenFunctions = overriddenFunction.getOverriddenDescriptors();
|
||||||
for (FunctionDescriptor of : overriddenFunctions) {
|
for (FunctionDescriptor of : overriddenFunctions) {
|
||||||
checkOverride(owner, state, v, jvmSignature, overriddenFunction, of.getOriginal());
|
checkOverride(owner, state, v, jvmSignature, overriddenFunction, of.getOriginal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(differentMethods(method, overridden)) {
|
if (differentMethods(method, overridden)) {
|
||||||
int flags = ACC_PUBLIC | ACC_BRIDGE; // TODO.
|
int flags = ACC_PUBLIC | ACC_BRIDGE; // TODO.
|
||||||
|
|
||||||
final MethodVisitor mv = v.newMethod(null, flags, jvmSignature.getName(), overridden.getDescriptor(), null, null);
|
final MethodVisitor mv = v.newMethod(null, flags, jvmSignature.getName(), overridden.getDescriptor(), null, null);
|
||||||
@@ -530,7 +530,7 @@ public class FunctionCodegen {
|
|||||||
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
||||||
Type argType = argTypes[i];
|
Type argType = argTypes[i];
|
||||||
iv.load(reg, argType);
|
iv.load(reg, argType);
|
||||||
if(argType.getSort() == Type.OBJECT) {
|
if (argType.getSort() == Type.OBJECT) {
|
||||||
StackValue.onStack(JetTypeMapper.TYPE_OBJECT).put(method.getArgumentTypes()[i], iv);
|
StackValue.onStack(JetTypeMapper.TYPE_OBJECT).put(method.getArgumentTypes()[i], iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -539,9 +539,9 @@ public class FunctionCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
iv.invokevirtual(state.getInjector().getJetTypeMapper().mapType(((ClassDescriptor) owner.getContextDescriptor()).getDefaultType(), MapTypeMode.VALUE).getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
iv.invokevirtual(state.getInjector().getJetTypeMapper().mapType(((ClassDescriptor) owner.getContextDescriptor()).getDefaultType(), MapTypeMode.VALUE).getInternalName(), jvmSignature.getName(), jvmSignature.getDescriptor());
|
||||||
if(JetTypeMapper.isPrimitive(jvmSignature.getReturnType()) && !JetTypeMapper.isPrimitive(overridden.getReturnType()))
|
if (JetTypeMapper.isPrimitive(jvmSignature.getReturnType()) && !JetTypeMapper.isPrimitive(overridden.getReturnType()))
|
||||||
StackValue.valueOf(iv, jvmSignature.getReturnType());
|
StackValue.valueOf(iv, jvmSignature.getReturnType());
|
||||||
if(jvmSignature.getReturnType() == Type.VOID_TYPE)
|
if (jvmSignature.getReturnType() == Type.VOID_TYPE)
|
||||||
iv.aconst(null);
|
iv.aconst(null);
|
||||||
iv.areturn(overridden.getReturnType());
|
iv.areturn(overridden.getReturnType());
|
||||||
endVisit(mv, "bridge method", BindingContextUtils.callableDescriptorToDeclaration(state.getBindingContext(), functionDescriptor));
|
endVisit(mv, "bridge method", BindingContextUtils.callableDescriptorToDeclaration(state.getBindingContext(), functionDescriptor));
|
||||||
@@ -571,7 +571,7 @@ public class FunctionCodegen {
|
|||||||
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
for (int i = 0, reg = 1; i < argTypes.length; i++) {
|
||||||
Type argType = argTypes[i];
|
Type argType = argTypes[i];
|
||||||
iv.load(reg, argType);
|
iv.load(reg, argType);
|
||||||
if(argType.getSort() == Type.OBJECT) {
|
if (argType.getSort() == Type.OBJECT) {
|
||||||
StackValue.onStack(JetTypeMapper.TYPE_OBJECT).put(method.getArgumentTypes()[i], iv);
|
StackValue.onStack(JetTypeMapper.TYPE_OBJECT).put(method.getArgumentTypes()[i], iv);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -583,7 +583,7 @@ public class FunctionCodegen {
|
|||||||
field.put(field.type, iv);
|
field.put(field.type, iv);
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) overriddenDescriptor.getContainingDeclaration();
|
ClassDescriptor classDescriptor = (ClassDescriptor) overriddenDescriptor.getContainingDeclaration();
|
||||||
String internalName = state.getInjector().getJetTypeMapper().mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName();
|
String internalName = state.getInjector().getJetTypeMapper().mapType(classDescriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName();
|
||||||
if(classDescriptor.getKind() == ClassKind.TRAIT)
|
if (classDescriptor.getKind() == ClassKind.TRAIT)
|
||||||
iv.invokeinterface(internalName, method.getName(), method.getDescriptor());
|
iv.invokeinterface(internalName, method.getName(), method.getDescriptor());
|
||||||
else
|
else
|
||||||
iv.invokevirtual(internalName, method.getName(), method.getDescriptor());
|
iv.invokevirtual(internalName, method.getName(), method.getDescriptor());
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
boolean isStatic = false;
|
boolean isStatic = false;
|
||||||
boolean isAnnotation = false;
|
boolean isAnnotation = false;
|
||||||
|
|
||||||
if(myClass instanceof JetClass) {
|
if (myClass instanceof JetClass) {
|
||||||
JetClass jetClass = (JetClass) myClass;
|
JetClass jetClass = (JetClass) myClass;
|
||||||
if (jetClass.hasModifier(JetTokens.ABSTRACT_KEYWORD))
|
if (jetClass.hasModifier(JetTokens.ABSTRACT_KEYWORD))
|
||||||
isAbstract = true;
|
isAbstract = true;
|
||||||
@@ -129,7 +129,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
v.visitSource(myClass.getContainingFile().getName(), null);
|
v.visitSource(myClass.getContainingFile().getName(), null);
|
||||||
|
|
||||||
ClassDescriptor container = getContainingClassDescriptor(descriptor);
|
ClassDescriptor container = getContainingClassDescriptor(descriptor);
|
||||||
if(container != null) {
|
if (container != null) {
|
||||||
v.visitOuterClass(typeMapper.mapType(container.getDefaultType(), MapTypeMode.IMPL).getInternalName(), null, null);
|
v.visitOuterClass(typeMapper.mapType(container.getDefaultType(), MapTypeMode.IMPL).getInternalName(), null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -244,7 +244,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
List<JetDelegationSpecifier> delegationSpecifiers = myClass.getDelegationSpecifiers();
|
List<JetDelegationSpecifier> delegationSpecifiers = myClass.getDelegationSpecifiers();
|
||||||
|
|
||||||
if(myClass instanceof JetClass && ((JetClass) myClass).isTrait())
|
if (myClass instanceof JetClass && ((JetClass) myClass).isTrait())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (kind != OwnerKind.IMPLEMENTATION) {
|
if (kind != OwnerKind.IMPLEMENTATION) {
|
||||||
@@ -256,7 +256,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
JetType superType = bindingContext.get(BindingContext.TYPE, specifier.getTypeReference());
|
||||||
assert superType != null;
|
assert superType != null;
|
||||||
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
ClassDescriptor superClassDescriptor = (ClassDescriptor) superType.getConstructor().getDeclarationDescriptor();
|
||||||
if(!CodegenUtil.isInterface(superClassDescriptor)) {
|
if (!CodegenUtil.isInterface(superClassDescriptor)) {
|
||||||
superClassType = superType;
|
superClassType = superType;
|
||||||
superClass = typeMapper.mapType(superClassDescriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
superClass = typeMapper.mapType(superClassDescriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||||
superCall = specifier;
|
superCall = specifier;
|
||||||
@@ -287,7 +287,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateAccessors() {
|
private void generateAccessors() {
|
||||||
if(context.accessors != null) {
|
if (context.accessors != null) {
|
||||||
for (Map.Entry<DeclarationDescriptor, DeclarationDescriptor> entry : context.accessors.entrySet()) {
|
for (Map.Entry<DeclarationDescriptor, DeclarationDescriptor> entry : context.accessors.entrySet()) {
|
||||||
genAccessor(entry);
|
genAccessor(entry);
|
||||||
}
|
}
|
||||||
@@ -295,7 +295,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void genAccessor(Map.Entry<DeclarationDescriptor, DeclarationDescriptor> entry) {
|
private void genAccessor(Map.Entry<DeclarationDescriptor, DeclarationDescriptor> entry) {
|
||||||
if(entry.getValue() instanceof FunctionDescriptor) {
|
if (entry.getValue() instanceof FunctionDescriptor) {
|
||||||
FunctionDescriptor bridge = (FunctionDescriptor) entry.getValue();
|
FunctionDescriptor bridge = (FunctionDescriptor) entry.getValue();
|
||||||
FunctionDescriptor original = (FunctionDescriptor) entry.getKey();
|
FunctionDescriptor original = (FunctionDescriptor) entry.getKey();
|
||||||
|
|
||||||
@@ -325,7 +325,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
FunctionCodegen.endVisit(iv, "accessor", null);
|
FunctionCodegen.endVisit(iv, "accessor", null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(entry.getValue() instanceof PropertyDescriptor) {
|
else if (entry.getValue() instanceof PropertyDescriptor) {
|
||||||
PropertyDescriptor bridge = (PropertyDescriptor) entry.getValue();
|
PropertyDescriptor bridge = (PropertyDescriptor) entry.getValue();
|
||||||
PropertyDescriptor original = (PropertyDescriptor) entry.getKey();
|
PropertyDescriptor original = (PropertyDescriptor) entry.getKey();
|
||||||
|
|
||||||
@@ -344,7 +344,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
InstructionAdapter iv = new InstructionAdapter(mv);
|
InstructionAdapter iv = new InstructionAdapter(mv);
|
||||||
|
|
||||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||||
if(original.getVisibility() == Visibilities.PRIVATE)
|
if (original.getVisibility() == Visibilities.PRIVATE)
|
||||||
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), original.getName().getName(), originalMethod.getReturnType().getDescriptor());
|
iv.getfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), original.getName().getName(), originalMethod.getReturnType().getDescriptor());
|
||||||
else
|
else
|
||||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), originalMethod.getName(), originalMethod.getDescriptor());
|
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), originalMethod.getName(), originalMethod.getDescriptor());
|
||||||
@@ -354,7 +354,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bridge.isVar())
|
if (bridge.isVar())
|
||||||
{
|
{
|
||||||
Method method = typeMapper.mapSetterSignature(bridge, OwnerKind.IMPLEMENTATION).getJvmMethodSignature().getAsmMethod();
|
Method method = typeMapper.mapSetterSignature(bridge, OwnerKind.IMPLEMENTATION).getJvmMethodSignature().getAsmMethod();
|
||||||
JvmPropertyAccessorSignature originalSignature2 = typeMapper.mapSetterSignature(original, OwnerKind.IMPLEMENTATION);
|
JvmPropertyAccessorSignature originalSignature2 = typeMapper.mapSetterSignature(original, OwnerKind.IMPLEMENTATION);
|
||||||
@@ -377,7 +377,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
//noinspection AssignmentToForLoopParameter
|
//noinspection AssignmentToForLoopParameter
|
||||||
reg += argType.getSize();
|
reg += argType.getSize();
|
||||||
}
|
}
|
||||||
if(original.getVisibility() == Visibilities.PRIVATE && original.getModality() == Modality.FINAL)
|
if (original.getVisibility() == Visibilities.PRIVATE && original.getModality() == Modality.FINAL)
|
||||||
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), original.getName().getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
iv.putfield(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), original.getName().getName(), originalMethod.getArgumentTypes()[0].getDescriptor());
|
||||||
else
|
else
|
||||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), originalMethod.getName(), originalMethod.getDescriptor());
|
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION).getInternalName(), originalMethod.getName(), originalMethod.getDescriptor());
|
||||||
@@ -435,11 +435,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void generatePrimaryConstructor() {
|
protected void generatePrimaryConstructor() {
|
||||||
if(myClass instanceof JetClass) {
|
if (myClass instanceof JetClass) {
|
||||||
JetClass aClass = (JetClass)myClass;
|
JetClass aClass = (JetClass)myClass;
|
||||||
if(aClass.isTrait())
|
if (aClass.isTrait())
|
||||||
return;
|
return;
|
||||||
if(aClass.isAnnotation()) {
|
if (aClass.isAnnotation()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -486,22 +486,22 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
final LinkedList<JvmMethodParameterSignature> consArgTypes = new LinkedList<JvmMethodParameterSignature>(constructorMethod.getKotlinParameterTypes());
|
final LinkedList<JvmMethodParameterSignature> consArgTypes = new LinkedList<JvmMethodParameterSignature>(constructorMethod.getKotlinParameterTypes());
|
||||||
|
|
||||||
int insert = 0;
|
int insert = 0;
|
||||||
if(closure != null) {
|
if (closure != null) {
|
||||||
if(closure.captureThis != null) {
|
if (closure.captureThis != null) {
|
||||||
if(!hasThis0)
|
if (!hasThis0)
|
||||||
consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName().getName()), "", JvmMethodParameterKind.THIS0));
|
consArgTypes.add(insert, new JvmMethodParameterSignature(Type.getObjectType(context.getThisDescriptor().getName().getName()), "", JvmMethodParameterKind.THIS0));
|
||||||
insert++;
|
insert++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(hasThis0)
|
if (hasThis0)
|
||||||
insert++;
|
insert++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(closure.captureReceiver != null)
|
if (closure.captureReceiver != null)
|
||||||
consArgTypes.add(insert++, new JvmMethodParameterSignature(closure.captureReceiver, "", JvmMethodParameterKind.RECEIVER));
|
consArgTypes.add(insert++, new JvmMethodParameterSignature(closure.captureReceiver, "", JvmMethodParameterKind.RECEIVER));
|
||||||
|
|
||||||
for (DeclarationDescriptor descriptor : closure.closure.keySet()) {
|
for (DeclarationDescriptor descriptor : closure.closure.keySet()) {
|
||||||
if(descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
|
if (descriptor instanceof VariableDescriptor && !(descriptor instanceof PropertyDescriptor)) {
|
||||||
final Type sharedVarType = typeMapper.getSharedVarType(descriptor);
|
final Type sharedVarType = typeMapper.getSharedVarType(descriptor);
|
||||||
final Type type;
|
final Type type;
|
||||||
if (sharedVarType != null) {
|
if (sharedVarType != null) {
|
||||||
@@ -512,18 +512,18 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
consArgTypes.add(insert++, new JvmMethodParameterSignature(type, "", JvmMethodParameterKind.SHARED_VAR));
|
consArgTypes.add(insert++, new JvmMethodParameterSignature(type, "", JvmMethodParameterKind.SHARED_VAR));
|
||||||
}
|
}
|
||||||
else if(descriptor instanceof FunctionDescriptor) {
|
else if (descriptor instanceof FunctionDescriptor) {
|
||||||
assert closure.captureReceiver != null;
|
assert closure.captureReceiver != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(myClass instanceof JetObjectDeclaration && ((JetObjectDeclaration) myClass).isObjectLiteral()) {
|
if (myClass instanceof JetObjectDeclaration && ((JetObjectDeclaration) myClass).isObjectLiteral()) {
|
||||||
if(superCall instanceof JetDelegatorToSuperCall) {
|
if (superCall instanceof JetDelegatorToSuperCall) {
|
||||||
if(closure != null)
|
if (closure != null)
|
||||||
closure.superCall = (JetDelegatorToSuperCall) superCall;
|
closure.superCall = (JetDelegatorToSuperCall) superCall;
|
||||||
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, ((JetDelegatorToSuperCall) superCall).getCalleeExpression().getConstructorReferenceExpression());
|
DeclarationDescriptor declarationDescriptor = bindingContext.get(BindingContext.REFERENCE_TARGET, ((JetDelegatorToSuperCall) superCall).getCalleeExpression().getConstructorReferenceExpression());
|
||||||
if(declarationDescriptor instanceof ClassDescriptor) {
|
if (declarationDescriptor instanceof ClassDescriptor) {
|
||||||
declarationDescriptor = ((ClassDescriptor)declarationDescriptor).getUnsubstitutedPrimaryConstructor();
|
declarationDescriptor = ((ClassDescriptor)declarationDescriptor).getUnsubstitutedPrimaryConstructor();
|
||||||
}
|
}
|
||||||
ConstructorDescriptor superConstructor = (ConstructorDescriptor) declarationDescriptor;
|
ConstructorDescriptor superConstructor = (ConstructorDescriptor) declarationDescriptor;
|
||||||
@@ -583,7 +583,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, constructorContext, state);
|
ExpressionCodegen codegen = new ExpressionCodegen(mv, frameMap, Type.VOID_TYPE, constructorContext, state);
|
||||||
|
|
||||||
// for(int slot = 0; slot != frameMap.getTypeParameterCount(); ++slot) {
|
// for(int slot = 0; slot != frameMap.getTypeParameterCount(); ++slot) {
|
||||||
// if(constructorDescriptor != null)
|
// if (constructorDescriptor != null)
|
||||||
// codegen.addTypeParameter(constructorDescriptor.getTypeParameters().get(slot), StackValue.local(frameMap.getFirstTypeParameter() + slot, JetTypeMapper.TYPE_TYPEINFO));
|
// codegen.addTypeParameter(constructorDescriptor.getTypeParameters().get(slot), StackValue.local(frameMap.getFirstTypeParameter() + slot, JetTypeMapper.TYPE_TYPEINFO));
|
||||||
// else
|
// else
|
||||||
// codegen.addTypeParameter(descriptor.getTypeConstructor().getParameters().get(slot), StackValue.local(frameMap.getFirstTypeParameter() + slot, JetTypeMapper.TYPE_TYPEINFO));
|
// codegen.addTypeParameter(descriptor.getTypeConstructor().getParameters().get(slot), StackValue.local(frameMap.getFirstTypeParameter() + slot, JetTypeMapper.TYPE_TYPEINFO));
|
||||||
@@ -625,7 +625,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
|
for (JetDelegationSpecifier specifier : myClass.getDelegationSpecifiers()) {
|
||||||
if(specifier == superCall)
|
if (specifier == superCall)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
|
if (specifier instanceof JetDelegatorByExpressionSpecifier) {
|
||||||
@@ -661,9 +661,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.putfield(classname.getInternalName(), fieldName, interfaceDesc);
|
iv.putfield(classname.getInternalName(), fieldName, interfaceDesc);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(closure != null) {
|
if (closure != null) {
|
||||||
int k = outerDescriptor != null && outerDescriptor.getKind() != ClassKind.OBJECT ? 2 : 1;
|
int k = outerDescriptor != null && outerDescriptor.getKind() != ClassKind.OBJECT ? 2 : 1;
|
||||||
if(closure.captureReceiver != null) {
|
if (closure.captureReceiver != null) {
|
||||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||||
iv.load(1, closure.captureReceiver);
|
iv.load(1, closure.captureReceiver);
|
||||||
iv.putfield(typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName(), "receiver$0", closure.captureReceiver.getDescriptor());
|
iv.putfield(typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.VALUE).getInternalName(), "receiver$0", closure.captureReceiver.getDescriptor());
|
||||||
@@ -672,9 +672,9 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
int l = 0;
|
int l = 0;
|
||||||
for (DeclarationDescriptor varDescr : closure.closure.keySet()) {
|
for (DeclarationDescriptor varDescr : closure.closure.keySet()) {
|
||||||
if(varDescr instanceof VariableDescriptor && !(varDescr instanceof PropertyDescriptor)) {
|
if (varDescr instanceof VariableDescriptor && !(varDescr instanceof PropertyDescriptor)) {
|
||||||
Type sharedVarType = typeMapper.getSharedVarType(varDescr);
|
Type sharedVarType = typeMapper.getSharedVarType(varDescr);
|
||||||
if(sharedVarType == null) {
|
if (sharedVarType == null) {
|
||||||
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getType(), MapTypeMode.VALUE);
|
sharedVarType = typeMapper.mapType(((VariableDescriptor) varDescr).getType(), MapTypeMode.VALUE);
|
||||||
}
|
}
|
||||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||||
@@ -710,7 +710,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void generateTraitMethods(ExpressionCodegen codegen) {
|
private void generateTraitMethods(ExpressionCodegen codegen) {
|
||||||
if(!(myClass instanceof JetClass) || ((JetClass)myClass).isTrait() || ((JetClass)myClass).hasModifier(JetTokens.ABSTRACT_KEYWORD))
|
if (!(myClass instanceof JetClass) || ((JetClass)myClass).isTrait() || ((JetClass)myClass).hasModifier(JetTokens.ABSTRACT_KEYWORD))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (Pair<CallableMemberDescriptor, CallableMemberDescriptor> needDelegates : getTraitImplementations(descriptor)) {
|
for (Pair<CallableMemberDescriptor, CallableMemberDescriptor> needDelegates : getTraitImplementations(descriptor)) {
|
||||||
@@ -729,12 +729,12 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
private void generateDelegationToTraitImpl(ExpressionCodegen codegen, FunctionDescriptor fun) {
|
private void generateDelegationToTraitImpl(ExpressionCodegen codegen, FunctionDescriptor fun) {
|
||||||
DeclarationDescriptor containingDeclaration = fun.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = fun.getContainingDeclaration();
|
||||||
if(containingDeclaration instanceof ClassDescriptor) {
|
if (containingDeclaration instanceof ClassDescriptor) {
|
||||||
ClassDescriptor declaration = (ClassDescriptor) containingDeclaration;
|
ClassDescriptor declaration = (ClassDescriptor) containingDeclaration;
|
||||||
PsiElement psiElement = BindingContextUtils.classDescriptorToDeclaration(bindingContext, declaration);
|
PsiElement psiElement = BindingContextUtils.classDescriptorToDeclaration(bindingContext, declaration);
|
||||||
if(psiElement instanceof JetClass) {
|
if (psiElement instanceof JetClass) {
|
||||||
JetClass jetClass = (JetClass) psiElement;
|
JetClass jetClass = (JetClass) psiElement;
|
||||||
if(jetClass.isTrait()) {
|
if (jetClass.isTrait()) {
|
||||||
int flags = ACC_PUBLIC; // TODO.
|
int flags = ACC_PUBLIC; // TODO.
|
||||||
|
|
||||||
Method function = typeMapper.mapSignature(fun.getName(), fun).getAsmMethod();
|
Method function = typeMapper.mapSignature(fun.getName(), fun).getAsmMethod();
|
||||||
@@ -795,7 +795,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
|
|
||||||
CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor, kind, typeMapper.hasThis0(constructorDescriptor.getContainingDeclaration()));
|
CallableMethod method = typeMapper.mapToCallableMethod(constructorDescriptor, kind, typeMapper.hasThis0(constructorDescriptor.getContainingDeclaration()));
|
||||||
|
|
||||||
if(myClass instanceof JetObjectDeclaration && superCall instanceof JetDelegatorToSuperCall && ((JetObjectDeclaration) myClass).isObjectLiteral()) {
|
if (myClass instanceof JetObjectDeclaration && superCall instanceof JetDelegatorToSuperCall && ((JetObjectDeclaration) myClass).isObjectLiteral()) {
|
||||||
ConstructorDescriptor superConstructor = (ConstructorDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, ((JetDelegatorToSuperCall) superCall).getCalleeExpression().getConstructorReferenceExpression());
|
ConstructorDescriptor superConstructor = (ConstructorDescriptor) bindingContext.get(BindingContext.REFERENCE_TARGET, ((JetDelegatorToSuperCall) superCall).getCalleeExpression().getConstructorReferenceExpression());
|
||||||
CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor, OwnerKind.IMPLEMENTATION, typeMapper.hasThis0(superConstructor.getContainingDeclaration()));
|
CallableMethod superCallable = typeMapper.mapToCallableMethod(superConstructor, OwnerKind.IMPLEMENTATION, typeMapper.hasThis0(superConstructor.getContainingDeclaration()));
|
||||||
int nextVar = firstSuperArgument+1;
|
int nextVar = firstSuperArgument+1;
|
||||||
@@ -924,38 +924,38 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
|
final JetExpression initializer = ((JetProperty) declaration).getInitializer();
|
||||||
if (initializer != null) {
|
if (initializer != null) {
|
||||||
CompileTimeConstant<?> compileTimeValue = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, initializer);
|
CompileTimeConstant<?> compileTimeValue = bindingContext.get(BindingContext.COMPILE_TIME_VALUE, initializer);
|
||||||
if(compileTimeValue != null) {
|
if (compileTimeValue != null) {
|
||||||
assert compileTimeValue != null;
|
assert compileTimeValue != null;
|
||||||
Object value = compileTimeValue.getValue();
|
Object value = compileTimeValue.getValue();
|
||||||
Type type = typeMapper.mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
Type type = typeMapper.mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||||
if(JetTypeMapper.isPrimitive(type)) {
|
if (JetTypeMapper.isPrimitive(type)) {
|
||||||
if( !propertyDescriptor.getType().isNullable() && value instanceof Number) {
|
if ( !propertyDescriptor.getType().isNullable() && value instanceof Number) {
|
||||||
if(type == Type.INT_TYPE && ((Number)value).intValue() == 0)
|
if (type == Type.INT_TYPE && ((Number)value).intValue() == 0)
|
||||||
continue;
|
continue;
|
||||||
if(type == Type.BYTE_TYPE && ((Number)value).byteValue() == 0)
|
if (type == Type.BYTE_TYPE && ((Number)value).byteValue() == 0)
|
||||||
continue;
|
continue;
|
||||||
if(type == Type.LONG_TYPE && ((Number)value).longValue() == 0L)
|
if (type == Type.LONG_TYPE && ((Number)value).longValue() == 0L)
|
||||||
continue;
|
continue;
|
||||||
if(type == Type.SHORT_TYPE && ((Number)value).shortValue() == 0)
|
if (type == Type.SHORT_TYPE && ((Number)value).shortValue() == 0)
|
||||||
continue;
|
continue;
|
||||||
if(type == Type.DOUBLE_TYPE && ((Number)value).doubleValue() == 0d)
|
if (type == Type.DOUBLE_TYPE && ((Number)value).doubleValue() == 0d)
|
||||||
continue;
|
continue;
|
||||||
if(type == Type.FLOAT_TYPE && ((Number)value).byteValue() == 0f)
|
if (type == Type.FLOAT_TYPE && ((Number)value).byteValue() == 0f)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(type == Type.BOOLEAN_TYPE && value instanceof Boolean && !((Boolean)value))
|
if (type == Type.BOOLEAN_TYPE && value instanceof Boolean && !((Boolean)value))
|
||||||
continue;
|
continue;
|
||||||
if(type == Type.CHAR_TYPE && value instanceof Character && ((Character)value) == 0)
|
if (type == Type.CHAR_TYPE && value instanceof Character && ((Character)value) == 0)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(value == null)
|
if (value == null)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||||
Type type = codegen.expressionType(initializer);
|
Type type = codegen.expressionType(initializer);
|
||||||
if(propertyDescriptor.getType().isNullable())
|
if (propertyDescriptor.getType().isNullable())
|
||||||
type = JetTypeMapper.boxType(type);
|
type = JetTypeMapper.boxType(type);
|
||||||
codegen.gen(initializer, type);
|
codegen.gen(initializer, type);
|
||||||
// @todo write directly to the field. Fix test excloset.jet::test6
|
// @todo write directly to the field. Fix test excloset.jet::test6
|
||||||
@@ -984,7 +984,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
if (callableMemberDescriptor.getKind() == CallableMemberDescriptor.Kind.DELEGATION) {
|
if (callableMemberDescriptor.getKind() == CallableMemberDescriptor.Kind.DELEGATION) {
|
||||||
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callableMemberDescriptor.getOverriddenDescriptors();
|
Set<? extends CallableMemberDescriptor> overriddenDescriptors = callableMemberDescriptor.getOverriddenDescriptors();
|
||||||
for (CallableMemberDescriptor overriddenDescriptor : overriddenDescriptors) {
|
for (CallableMemberDescriptor overriddenDescriptor : overriddenDescriptors) {
|
||||||
if(overriddenDescriptor.getContainingDeclaration() == classDescriptor) {
|
if (overriddenDescriptor.getContainingDeclaration() == classDescriptor) {
|
||||||
if (declaration instanceof PropertyDescriptor) {
|
if (declaration instanceof PropertyDescriptor) {
|
||||||
propertyCodegen.genDelegate((PropertyDescriptor) declaration, (PropertyDescriptor) overriddenDescriptor, field);
|
propertyCodegen.genDelegate((PropertyDescriptor) declaration, (PropertyDescriptor) overriddenDescriptor, field);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -551,7 +551,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CallableMethod mapToCallableMethod(FunctionDescriptor functionDescriptor, boolean superCall, OwnerKind kind) {
|
public CallableMethod mapToCallableMethod(FunctionDescriptor functionDescriptor, boolean superCall, OwnerKind kind) {
|
||||||
if(functionDescriptor == null)
|
if (functionDescriptor == null)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
final DeclarationDescriptor functionParent = functionDescriptor.getOriginal().getContainingDeclaration();
|
final DeclarationDescriptor functionParent = functionDescriptor.getOriginal().getContainingDeclaration();
|
||||||
@@ -615,7 +615,7 @@ public class JetTypeMapper {
|
|||||||
invokeOpcode = isInterface
|
invokeOpcode = isInterface
|
||||||
? (superCall ? Opcodes.INVOKESTATIC : Opcodes.INVOKEINTERFACE)
|
? (superCall ? Opcodes.INVOKESTATIC : Opcodes.INVOKEINTERFACE)
|
||||||
: (superCall ? Opcodes.INVOKESPECIAL : Opcodes.INVOKEVIRTUAL);
|
: (superCall ? Opcodes.INVOKESPECIAL : Opcodes.INVOKEVIRTUAL);
|
||||||
if(isInterface && superCall) {
|
if (isInterface && superCall) {
|
||||||
descriptor = mapSignature(functionDescriptor, false, OwnerKind.TRAIT_IMPL);
|
descriptor = mapSignature(functionDescriptor, false, OwnerKind.TRAIT_IMPL);
|
||||||
owner = JvmClassName.byInternalName(owner.getInternalName() + JvmAbi.TRAIT_IMPL_SUFFIX);
|
owner = JvmClassName.byInternalName(owner.getInternalName() + JvmAbi.TRAIT_IMPL_SUFFIX);
|
||||||
}
|
}
|
||||||
@@ -666,7 +666,7 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
signatureVisitor.writeParametersStart();
|
signatureVisitor.writeParametersStart();
|
||||||
|
|
||||||
if(kind == OwnerKind.TRAIT_IMPL) {
|
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) f.getContainingDeclaration();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) f.getContainingDeclaration();
|
||||||
JetType jetType = TraitImplBodyCodegen.getSuperClass(containingDeclaration, bindingContext);
|
JetType jetType = TraitImplBodyCodegen.getSuperClass(containingDeclaration, bindingContext);
|
||||||
Type type = mapType(jetType, MapTypeMode.VALUE);
|
Type type = mapType(jetType, MapTypeMode.VALUE);
|
||||||
@@ -801,7 +801,7 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
signatureWriter.writeParametersStart();
|
signatureWriter.writeParametersStart();
|
||||||
|
|
||||||
if(kind == OwnerKind.TRAIT_IMPL) {
|
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) descriptor.getContainingDeclaration();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) descriptor.getContainingDeclaration();
|
||||||
assert containingDeclaration != null;
|
assert containingDeclaration != null;
|
||||||
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
||||||
@@ -809,7 +809,7 @@ public class JetTypeMapper {
|
|||||||
signatureWriter.writeParameterTypeEnd();
|
signatureWriter.writeParameterTypeEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(descriptor.getReceiverParameter().exists()) {
|
if (descriptor.getReceiverParameter().exists()) {
|
||||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||||
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, MapTypeMode.VALUE);
|
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, MapTypeMode.VALUE);
|
||||||
signatureWriter.writeParameterTypeEnd();
|
signatureWriter.writeParameterTypeEnd();
|
||||||
@@ -842,7 +842,7 @@ public class JetTypeMapper {
|
|||||||
signatureWriter.writeParametersStart();
|
signatureWriter.writeParametersStart();
|
||||||
|
|
||||||
String name = PropertyCodegen.setterName(descriptor.getName());
|
String name = PropertyCodegen.setterName(descriptor.getName());
|
||||||
if(kind == OwnerKind.TRAIT_IMPL) {
|
if (kind == OwnerKind.TRAIT_IMPL) {
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) descriptor.getContainingDeclaration();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) descriptor.getContainingDeclaration();
|
||||||
assert containingDeclaration != null;
|
assert containingDeclaration != null;
|
||||||
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
signatureWriter.writeParameterType(JvmMethodParameterKind.THIS);
|
||||||
@@ -850,7 +850,7 @@ public class JetTypeMapper {
|
|||||||
signatureWriter.writeParameterTypeEnd();
|
signatureWriter.writeParameterTypeEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(descriptor.getReceiverParameter().exists()) {
|
if (descriptor.getReceiverParameter().exists()) {
|
||||||
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
signatureWriter.writeParameterType(JvmMethodParameterKind.RECEIVER);
|
||||||
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, MapTypeMode.VALUE);
|
mapType(descriptor.getReceiverParameter().getType(), signatureWriter, MapTypeMode.VALUE);
|
||||||
signatureWriter.writeParameterTypeEnd();
|
signatureWriter.writeParameterTypeEnd();
|
||||||
@@ -940,7 +940,7 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
public static int getAccessModifiers(MemberDescriptor p, int defaultFlags) {
|
public static int getAccessModifiers(MemberDescriptor p, int defaultFlags) {
|
||||||
DeclarationDescriptor declaration = p.getContainingDeclaration();
|
DeclarationDescriptor declaration = p.getContainingDeclaration();
|
||||||
if(CodegenUtil.isInterface(declaration)) {
|
if (CodegenUtil.isInterface(declaration)) {
|
||||||
return ACC_PUBLIC;
|
return ACC_PUBLIC;
|
||||||
}
|
}
|
||||||
if (p.getVisibility() == Visibilities.PUBLIC) {
|
if (p.getVisibility() == Visibilities.PUBLIC) {
|
||||||
@@ -950,7 +950,7 @@ public class JetTypeMapper {
|
|||||||
return ACC_PROTECTED;
|
return ACC_PROTECTED;
|
||||||
}
|
}
|
||||||
else if (p.getVisibility() == Visibilities.PRIVATE) {
|
else if (p.getVisibility() == Visibilities.PRIVATE) {
|
||||||
if(DescriptorUtils.isClassObject(declaration)) {
|
if (DescriptorUtils.isClassObject(declaration)) {
|
||||||
return defaultFlags;
|
return defaultFlags;
|
||||||
}
|
}
|
||||||
return ACC_PRIVATE;
|
return ACC_PRIVATE;
|
||||||
@@ -1021,10 +1021,10 @@ public class JetTypeMapper {
|
|||||||
|
|
||||||
public boolean isGenericsArray(JetType type) {
|
public boolean isGenericsArray(JetType type) {
|
||||||
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
DeclarationDescriptor declarationDescriptor = type.getConstructor().getDeclarationDescriptor();
|
||||||
if(declarationDescriptor instanceof TypeParameterDescriptor)
|
if (declarationDescriptor instanceof TypeParameterDescriptor)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(standardLibrary.getArray().equals(declarationDescriptor))
|
if (standardLibrary.getArray().equals(declarationDescriptor))
|
||||||
return isGenericsArray(type.getArguments().get(0).getType());
|
return isGenericsArray(type.getArguments().get(0).getType());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -1036,7 +1036,7 @@ public class JetTypeMapper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Type getSharedVarType(DeclarationDescriptor descriptor) {
|
public Type getSharedVarType(DeclarationDescriptor descriptor) {
|
||||||
if(descriptor instanceof PropertyDescriptor) {
|
if (descriptor instanceof PropertyDescriptor) {
|
||||||
return StackValue.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType(), MapTypeMode.VALUE));
|
return StackValue.sharedTypeForType(mapType(((PropertyDescriptor) descriptor).getReceiverParameter().getType(), MapTypeMode.VALUE));
|
||||||
}
|
}
|
||||||
else if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
else if (descriptor instanceof SimpleFunctionDescriptor && descriptor.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ public class NamespaceCodegen {
|
|||||||
fileFunctions.add(declaration);
|
fileFunctions.add(declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(fileFunctions.size() > 0)
|
if (fileFunctions.size() > 0)
|
||||||
byFile.add(new Pair<JetFile, Collection<JetDeclaration>>(file, fileFunctions));
|
byFile.add(new Pair<JetFile, Collection<JetDeclaration>>(file, fileFunctions));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,7 +133,7 @@ public class NamespaceCodegen {
|
|||||||
(JetTypeParameterListOwner) declaration, context, v.getClassBuilder());
|
(JetTypeParameterListOwner) declaration, context, v.getClassBuilder());
|
||||||
}
|
}
|
||||||
else if (declaration instanceof JetNamedFunction) {
|
else if (declaration instanceof JetNamedFunction) {
|
||||||
if(!multiFile) {
|
if (!multiFile) {
|
||||||
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, file);
|
NamespaceDescriptor descriptor = state.getBindingContext().get(BindingContext.FILE_TO_NAMESPACE, file);
|
||||||
final CodegenContext context = CodegenContexts.STATIC.intoNamespace(descriptor);
|
final CodegenContext context = CodegenContexts.STATIC.intoNamespace(descriptor);
|
||||||
state.getInjector().getMemberCodegen().generateFunctionOrProperty(
|
state.getInjector().getMemberCodegen().generateFunctionOrProperty(
|
||||||
@@ -150,7 +150,7 @@ public class NamespaceCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(multiFile) {
|
if (multiFile) {
|
||||||
int k = 0;
|
int k = 0;
|
||||||
for (JetDeclaration declaration : file.getDeclarations()) {
|
for (JetDeclaration declaration : file.getDeclarations()) {
|
||||||
if (declaration instanceof JetNamedFunction) {
|
if (declaration instanceof JetNamedFunction) {
|
||||||
@@ -158,7 +158,7 @@ public class NamespaceCodegen {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(k > 0) {
|
if (k > 0) {
|
||||||
PsiFile containingFile = file.getContainingFile();
|
PsiFile containingFile = file.getContainingFile();
|
||||||
String className = name.getFqName().replace('.','/') + "namespace$src$" + (nextMultiFile++);
|
String className = name.getFqName().replace('.','/') + "namespace$src$" + (nextMultiFile++);
|
||||||
ClassBuilder builder = state.forNamespacepart(className, file);
|
ClassBuilder builder = state.forNamespacepart(className, file);
|
||||||
@@ -212,7 +212,7 @@ public class NamespaceCodegen {
|
|||||||
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
|
if (initializer != null && !(initializer instanceof JetConstantExpression)) {
|
||||||
final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, declaration);
|
final PropertyDescriptor descriptor = (PropertyDescriptor) state.getBindingContext().get(BindingContext.VARIABLE, declaration);
|
||||||
assert descriptor != null;
|
assert descriptor != null;
|
||||||
if(descriptor.getReceiverParameter().exists()) {
|
if (descriptor.getReceiverParameter().exists()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
codegen.genToJVMStack(initializer);
|
codegen.genToJVMStack(initializer);
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class ObjectOrClosureCodegen {
|
|||||||
return innerValue;
|
return innerValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(CodegenUtil.isNamedFun(d, state.getBindingContext()) && d.getContainingDeclaration() instanceof FunctionDescriptor) {
|
if (CodegenUtil.isNamedFun(d, state.getBindingContext()) && d.getContainingDeclaration() instanceof FunctionDescriptor) {
|
||||||
FunctionDescriptor vd = (FunctionDescriptor) d;
|
FunctionDescriptor vd = (FunctionDescriptor) d;
|
||||||
|
|
||||||
final int idx = exprContext.lookupLocal(vd);
|
final int idx = exprContext.lookupLocal(vd);
|
||||||
@@ -101,7 +101,7 @@ public class ObjectOrClosureCodegen {
|
|||||||
return innerValue;
|
return innerValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d instanceof FunctionDescriptor) {
|
if (d instanceof FunctionDescriptor) {
|
||||||
// we are looking for receiver
|
// we are looking for receiver
|
||||||
FunctionDescriptor fd = (FunctionDescriptor) d;
|
FunctionDescriptor fd = (FunctionDescriptor) d;
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ public class ObjectOrClosureCodegen {
|
|||||||
|
|
||||||
CodegenContexts.ReceiverContext fcontext = (CodegenContexts.ReceiverContext) context;
|
CodegenContexts.ReceiverContext fcontext = (CodegenContexts.ReceiverContext) context;
|
||||||
|
|
||||||
if(fcontext.getReceiverDescriptor() != fd)
|
if (fcontext.getReceiverDescriptor() != fd)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
Type type = state.getInjector().getJetTypeMapper().mapType(fcontext.getReceiverDescriptor().getReceiverParameter().getType(), MapTypeMode.VALUE);
|
Type type = state.getInjector().getJetTypeMapper().mapType(fcontext.getReceiverDescriptor().getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ public class PropertyCodegen {
|
|||||||
}
|
}
|
||||||
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
final PropertyDescriptor propertyDescriptor = (PropertyDescriptor) descriptor;
|
||||||
if (kind == OwnerKind.NAMESPACE || kind == OwnerKind.IMPLEMENTATION || kind ==OwnerKind.TRAIT_IMPL ) {
|
if (kind == OwnerKind.NAMESPACE || kind == OwnerKind.IMPLEMENTATION || kind ==OwnerKind.TRAIT_IMPL ) {
|
||||||
if(kind != OwnerKind.TRAIT_IMPL)
|
if (kind != OwnerKind.TRAIT_IMPL)
|
||||||
generateBackingField(p, propertyDescriptor);
|
generateBackingField(p, propertyDescriptor);
|
||||||
generateGetter(p, propertyDescriptor);
|
generateGetter(p, propertyDescriptor);
|
||||||
generateSetter(p, propertyDescriptor);
|
generateSetter(p, propertyDescriptor);
|
||||||
@@ -75,7 +75,7 @@ public class PropertyCodegen {
|
|||||||
private void generateBackingField(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
private void generateBackingField(JetProperty p, PropertyDescriptor propertyDescriptor) {
|
||||||
if (state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
if (state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
|
||||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||||
if(CodegenUtil.isInterface(containingDeclaration))
|
if (CodegenUtil.isInterface(containingDeclaration))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Object value = null;
|
Object value = null;
|
||||||
@@ -97,7 +97,7 @@ public class PropertyCodegen {
|
|||||||
if (!propertyDescriptor.isVar()) {
|
if (!propertyDescriptor.isVar()) {
|
||||||
modifiers |= Opcodes.ACC_FINAL;
|
modifiers |= Opcodes.ACC_FINAL;
|
||||||
}
|
}
|
||||||
if(state.getInjector().getJetStandardLibrary().isVolatile(propertyDescriptor)) {
|
if (state.getInjector().getJetStandardLibrary().isVolatile(propertyDescriptor)) {
|
||||||
modifiers |= Opcodes.ACC_VOLATILE;
|
modifiers |= Opcodes.ACC_VOLATILE;
|
||||||
}
|
}
|
||||||
Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
Type type = state.getInjector().getJetTypeMapper().mapType(propertyDescriptor.getType(), MapTypeMode.VALUE);
|
||||||
@@ -165,7 +165,7 @@ public class PropertyCodegen {
|
|||||||
|
|
||||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
||||||
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
||||||
if(isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
if (isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
||||||
flags |= Opcodes.ACC_ABSTRACT;
|
flags |= Opcodes.ACC_ABSTRACT;
|
||||||
|
|
||||||
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
||||||
@@ -178,13 +178,13 @@ public class PropertyCodegen {
|
|||||||
MethodVisitor mv = v.newMethod(origin, flags, getterName, descriptor, null, null);
|
MethodVisitor mv = v.newMethod(origin, flags, getterName, descriptor, null, null);
|
||||||
generateJetPropertyAnnotation(mv, signature.getPropertyTypeKotlinSignature(), signature.getJvmMethodSignature().getKotlinTypeParameter());
|
generateJetPropertyAnnotation(mv, signature.getPropertyTypeKotlinSignature(), signature.getJvmMethodSignature().getKotlinTypeParameter());
|
||||||
|
|
||||||
if(propertyDescriptor.getGetter() != null) {
|
if (propertyDescriptor.getGetter() != null) {
|
||||||
assert !propertyDescriptor.getGetter().hasBody();
|
assert !propertyDescriptor.getGetter().hasBody();
|
||||||
AnnotationCodegen.forMethod(mv, state.getInjector().getJetTypeMapper()).genAnnotations(propertyDescriptor.getGetter());
|
AnnotationCodegen.forMethod(mv, state.getInjector().getJetTypeMapper()).genAnnotations(propertyDescriptor.getGetter());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.getClassBuilderMode() != ClassBuilderMode.SIGNATURES && (!isTrait || kind instanceof OwnerKind.DelegateKind)) {
|
if (state.getClassBuilderMode() != ClassBuilderMode.SIGNATURES && (!isTrait || kind instanceof OwnerKind.DelegateKind)) {
|
||||||
if(propertyDescriptor.getModality() != Modality.ABSTRACT) {
|
if (propertyDescriptor.getModality() != Modality.ABSTRACT) {
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
||||||
StubCodegen.generateStubThrow(mv);
|
StubCodegen.generateStubThrow(mv);
|
||||||
@@ -252,7 +252,7 @@ public class PropertyCodegen {
|
|||||||
|
|
||||||
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
PsiElement psiElement = BindingContextUtils.descriptorToDeclaration(state.getBindingContext(), propertyDescriptor.getContainingDeclaration());
|
||||||
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
boolean isTrait = psiElement instanceof JetClass && ((JetClass) psiElement).isTrait();
|
||||||
if(isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
if (isTrait && !(kind instanceof OwnerKind.DelegateKind))
|
||||||
flags |= Opcodes.ACC_ABSTRACT;
|
flags |= Opcodes.ACC_ABSTRACT;
|
||||||
|
|
||||||
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
if (propertyDescriptor.getModality() == Modality.FINAL) {
|
||||||
@@ -264,13 +264,13 @@ public class PropertyCodegen {
|
|||||||
MethodVisitor mv = v.newMethod(origin, flags, setterName(propertyDescriptor.getName()), descriptor, null, null);
|
MethodVisitor mv = v.newMethod(origin, flags, setterName(propertyDescriptor.getName()), descriptor, null, null);
|
||||||
generateJetPropertyAnnotation(mv, signature.getPropertyTypeKotlinSignature(), signature.getJvmMethodSignature().getKotlinTypeParameter());
|
generateJetPropertyAnnotation(mv, signature.getPropertyTypeKotlinSignature(), signature.getJvmMethodSignature().getKotlinTypeParameter());
|
||||||
|
|
||||||
if(propertyDescriptor.getSetter() != null) {
|
if (propertyDescriptor.getSetter() != null) {
|
||||||
assert !propertyDescriptor.getSetter().hasBody();
|
assert !propertyDescriptor.getSetter().hasBody();
|
||||||
AnnotationCodegen.forMethod(mv, state.getInjector().getJetTypeMapper()).genAnnotations(propertyDescriptor.getSetter());
|
AnnotationCodegen.forMethod(mv, state.getInjector().getJetTypeMapper()).genAnnotations(propertyDescriptor.getSetter());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state.getClassBuilderMode() != ClassBuilderMode.SIGNATURES && (!isTrait || kind instanceof OwnerKind.DelegateKind)) {
|
if (state.getClassBuilderMode() != ClassBuilderMode.SIGNATURES && (!isTrait || kind instanceof OwnerKind.DelegateKind)) {
|
||||||
if(propertyDescriptor.getModality() != Modality.ABSTRACT) {
|
if (propertyDescriptor.getModality() != Modality.ABSTRACT) {
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
if (state.getClassBuilderMode() == ClassBuilderMode.STUBS) {
|
||||||
StubCodegen.generateStubThrow(mv);
|
StubCodegen.generateStubThrow(mv);
|
||||||
@@ -322,7 +322,7 @@ public class PropertyCodegen {
|
|||||||
JvmPropertyAccessorSignature jvmPropertyAccessorSignature = state.getInjector().getJetTypeMapper().mapGetterSignature(declaration, OwnerKind.IMPLEMENTATION);
|
JvmPropertyAccessorSignature jvmPropertyAccessorSignature = state.getInjector().getJetTypeMapper().mapGetterSignature(declaration, OwnerKind.IMPLEMENTATION);
|
||||||
functionCodegen.genDelegate(declaration, overriddenDescriptor, field, jvmPropertyAccessorSignature.getJvmMethodSignature());
|
functionCodegen.genDelegate(declaration, overriddenDescriptor, field, jvmPropertyAccessorSignature.getJvmMethodSignature());
|
||||||
|
|
||||||
if(declaration.isVar()) {
|
if (declaration.isVar()) {
|
||||||
jvmPropertyAccessorSignature = state.getInjector().getJetTypeMapper().mapSetterSignature(declaration, OwnerKind.IMPLEMENTATION);
|
jvmPropertyAccessorSignature = state.getInjector().getJetTypeMapper().mapSetterSignature(declaration, OwnerKind.IMPLEMENTATION);
|
||||||
functionCodegen.genDelegate(declaration, overriddenDescriptor, field, jvmPropertyAccessorSignature.getJvmMethodSignature());
|
functionCodegen.genDelegate(declaration, overriddenDescriptor, field, jvmPropertyAccessorSignature.getJvmMethodSignature());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -220,20 +220,20 @@ public abstract class StackValue {
|
|||||||
if (toType.equals(fromType)) return;
|
if (toType.equals(fromType)) return;
|
||||||
|
|
||||||
if (toType.getSort() == Type.VOID && fromType.getSort() != Type.VOID) {
|
if (toType.getSort() == Type.VOID && fromType.getSort() != Type.VOID) {
|
||||||
if(fromType.getSize() == 1)
|
if (fromType.getSize() == 1)
|
||||||
v.pop();
|
v.pop();
|
||||||
else
|
else
|
||||||
v.pop2();
|
v.pop2();
|
||||||
}
|
}
|
||||||
else if (toType.getSort() != Type.VOID && fromType.getSort() == Type.VOID) {
|
else if (toType.getSort() != Type.VOID && fromType.getSort() == Type.VOID) {
|
||||||
if(toType.getSort() == Type.OBJECT) {
|
if (toType.getSort() == Type.OBJECT) {
|
||||||
putTuple0Instance(v);
|
putTuple0Instance(v);
|
||||||
}
|
}
|
||||||
else if(toType == Type.LONG_TYPE)
|
else if (toType == Type.LONG_TYPE)
|
||||||
v.lconst(0);
|
v.lconst(0);
|
||||||
else if(toType == Type.FLOAT_TYPE)
|
else if (toType == Type.FLOAT_TYPE)
|
||||||
v.fconst(0);
|
v.fconst(0);
|
||||||
else if(toType == Type.DOUBLE_TYPE)
|
else if (toType == Type.DOUBLE_TYPE)
|
||||||
v.dconst(0);
|
v.dconst(0);
|
||||||
else
|
else
|
||||||
v.iconst(0);
|
v.iconst(0);
|
||||||
@@ -242,7 +242,7 @@ public abstract class StackValue {
|
|||||||
v.checkcast(toType);
|
v.checkcast(toType);
|
||||||
}
|
}
|
||||||
else if (toType.getSort() == Type.OBJECT) {
|
else if (toType.getSort() == Type.OBJECT) {
|
||||||
if(fromType.getSort() == Type.OBJECT && !toType.equals(JetTypeMapper.TYPE_OBJECT)) {
|
if (fromType.getSort() == Type.OBJECT && !toType.equals(JetTypeMapper.TYPE_OBJECT)) {
|
||||||
v.checkcast(toType);
|
v.checkcast(toType);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -307,7 +307,7 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static StackValue receiver(ResolvedCall<? extends CallableDescriptor> resolvedCall, StackValue receiver, ExpressionCodegen codegen, @Nullable CallableMethod callableMethod, GenerationState state) {
|
public static StackValue receiver(ResolvedCall<? extends CallableDescriptor> resolvedCall, StackValue receiver, ExpressionCodegen codegen, @Nullable CallableMethod callableMethod, GenerationState state) {
|
||||||
if(resolvedCall.getThisObject().exists() || resolvedCall.getReceiverArgument().exists())
|
if (resolvedCall.getThisObject().exists() || resolvedCall.getReceiverArgument().exists())
|
||||||
return new CallReceiver(resolvedCall, receiver, codegen, state, callableMethod);
|
return new CallReceiver(resolvedCall, receiver, codegen, state, callableMethod);
|
||||||
return receiver;
|
return receiver;
|
||||||
}
|
}
|
||||||
@@ -398,16 +398,16 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(Type type, InstructionAdapter v) {
|
public void put(Type type, InstructionAdapter v) {
|
||||||
if(value instanceof Integer)
|
if (value instanceof Integer)
|
||||||
v.iconst((Integer) value);
|
v.iconst((Integer) value);
|
||||||
else
|
else
|
||||||
if(value instanceof Long)
|
if (value instanceof Long)
|
||||||
v.lconst((Long) value);
|
v.lconst((Long) value);
|
||||||
else
|
else
|
||||||
if(value instanceof Float)
|
if (value instanceof Float)
|
||||||
v.fconst((Float) value);
|
v.fconst((Float) value);
|
||||||
else
|
else
|
||||||
if(value instanceof Double)
|
if (value instanceof Double)
|
||||||
v.dconst((Double) value);
|
v.dconst((Double) value);
|
||||||
else
|
else
|
||||||
v.aconst(value);
|
v.aconst(value);
|
||||||
@@ -522,7 +522,7 @@ public abstract class StackValue {
|
|||||||
private Invert(StackValue operand) {
|
private Invert(StackValue operand) {
|
||||||
super(Type.BOOLEAN_TYPE);
|
super(Type.BOOLEAN_TYPE);
|
||||||
myOperand = operand;
|
myOperand = operand;
|
||||||
if(myOperand.type != Type.BOOLEAN_TYPE)
|
if (myOperand.type != Type.BOOLEAN_TYPE)
|
||||||
throw new UnsupportedOperationException("operand of ! must be boolean");
|
throw new UnsupportedOperationException("operand of ! must be boolean");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -603,7 +603,7 @@ public abstract class StackValue {
|
|||||||
if (getter == null) {
|
if (getter == null) {
|
||||||
throw new UnsupportedOperationException("no getter specified");
|
throw new UnsupportedOperationException("no getter specified");
|
||||||
}
|
}
|
||||||
if(getter instanceof CallableMethod)
|
if (getter instanceof CallableMethod)
|
||||||
((CallableMethod)getter).invoke(v);
|
((CallableMethod)getter).invoke(v);
|
||||||
else
|
else
|
||||||
((IntrinsicMethod)getter).generate(codegen, v, type, null, null, null, state);
|
((IntrinsicMethod)getter).generate(codegen, v, type, null, null, null, state);
|
||||||
@@ -615,15 +615,15 @@ public abstract class StackValue {
|
|||||||
if (setter == null) {
|
if (setter == null) {
|
||||||
throw new UnsupportedOperationException("no setter specified");
|
throw new UnsupportedOperationException("no setter specified");
|
||||||
}
|
}
|
||||||
if(setter instanceof CallableMethod) {
|
if (setter instanceof CallableMethod) {
|
||||||
CallableMethod method = (CallableMethod) setter;
|
CallableMethod method = (CallableMethod) setter;
|
||||||
Method asmMethod = method.getSignature().getAsmMethod();
|
Method asmMethod = method.getSignature().getAsmMethod();
|
||||||
Type[] argumentTypes = asmMethod.getArgumentTypes();
|
Type[] argumentTypes = asmMethod.getArgumentTypes();
|
||||||
coerce(topOfStackType, argumentTypes[argumentTypes.length-1], v);
|
coerce(topOfStackType, argumentTypes[argumentTypes.length-1], v);
|
||||||
method.invoke(v);
|
method.invoke(v);
|
||||||
Type returnType = asmMethod.getReturnType();
|
Type returnType = asmMethod.getReturnType();
|
||||||
if(returnType != Type.VOID_TYPE) {
|
if (returnType != Type.VOID_TYPE) {
|
||||||
if(returnType.getSize() == 2)
|
if (returnType.getSize() == 2)
|
||||||
v.pop2();
|
v.pop2();
|
||||||
else
|
else
|
||||||
v.pop();
|
v.pop();
|
||||||
@@ -634,7 +634,7 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int receiverSize() {
|
public int receiverSize() {
|
||||||
if(isStandardStack(resolvedGetCall, 1) && isStandardStack(resolvedSetCall, 2)) {
|
if (isStandardStack(resolvedGetCall, 1) && isStandardStack(resolvedSetCall, 2)) {
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -644,7 +644,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dupReceiver(InstructionAdapter v) {
|
public void dupReceiver(InstructionAdapter v) {
|
||||||
if(isStandardStack(resolvedGetCall, 1) && isStandardStack(resolvedSetCall, 2)) {
|
if (isStandardStack(resolvedGetCall, 1) && isStandardStack(resolvedSetCall, 2)) {
|
||||||
v.dup2(); // collection and index
|
v.dup2(); // collection and index
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -667,7 +667,7 @@ public abstract class StackValue {
|
|||||||
List<TypeParameterDescriptor> typeParameters = resolvedGetCall.getResultingDescriptor().getTypeParameters();
|
List<TypeParameterDescriptor> typeParameters = resolvedGetCall.getResultingDescriptor().getTypeParameters();
|
||||||
int firstTypeParamIndex = -1;
|
int firstTypeParamIndex = -1;
|
||||||
for(int i = typeParameters.size()-1; i >= 0; --i) {
|
for(int i = typeParameters.size()-1; i >= 0; --i) {
|
||||||
if(typeParameters.get(i).isReified()) {
|
if (typeParameters.get(i).isReified()) {
|
||||||
frame.enterTemp();
|
frame.enterTemp();
|
||||||
lastIndex++;
|
lastIndex++;
|
||||||
size++;
|
size++;
|
||||||
@@ -677,7 +677,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
ReceiverDescriptor receiverParameter = resolvedGetCall.getReceiverArgument();
|
ReceiverDescriptor receiverParameter = resolvedGetCall.getReceiverArgument();
|
||||||
int receiverIndex = -1;
|
int receiverIndex = -1;
|
||||||
if(receiverParameter.exists()) {
|
if (receiverParameter.exists()) {
|
||||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||||
int sz = type.getSize();
|
int sz = type.getSize();
|
||||||
frame.enterTemp(sz);
|
frame.enterTemp(sz);
|
||||||
@@ -688,7 +688,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
ReceiverDescriptor thisObject = resolvedGetCall.getThisObject();
|
ReceiverDescriptor thisObject = resolvedGetCall.getThisObject();
|
||||||
int thisIndex = -1;
|
int thisIndex = -1;
|
||||||
if(thisObject.exists()) {
|
if (thisObject.exists()) {
|
||||||
frame.enterTemp();
|
frame.enterTemp();
|
||||||
lastIndex++;
|
lastIndex++;
|
||||||
size++;
|
size++;
|
||||||
@@ -699,8 +699,8 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
int realReceiverIndex;
|
int realReceiverIndex;
|
||||||
Type realReceiverType;
|
Type realReceiverType;
|
||||||
if(thisIndex != -1) {
|
if (thisIndex != -1) {
|
||||||
if(receiverIndex != -1) {
|
if (receiverIndex != -1) {
|
||||||
realReceiverIndex = receiverIndex;
|
realReceiverIndex = receiverIndex;
|
||||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||||
}
|
}
|
||||||
@@ -710,7 +710,7 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(receiverIndex != -1) {
|
if (receiverIndex != -1) {
|
||||||
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
realReceiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||||
realReceiverIndex = receiverIndex;
|
realReceiverIndex = receiverIndex;
|
||||||
}
|
}
|
||||||
@@ -719,14 +719,14 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resolvedSetCall.getThisObject().exists()) {
|
if (resolvedSetCall.getThisObject().exists()) {
|
||||||
if(resolvedSetCall.getReceiverArgument().exists()) {
|
if (resolvedSetCall.getReceiverArgument().exists()) {
|
||||||
codegen.generateFromResolvedCall(resolvedSetCall.getThisObject(), JetTypeMapper.TYPE_OBJECT);
|
codegen.generateFromResolvedCall(resolvedSetCall.getThisObject(), JetTypeMapper.TYPE_OBJECT);
|
||||||
}
|
}
|
||||||
v.load(realReceiverIndex - realReceiverType.getSize(), realReceiverType);
|
v.load(realReceiverIndex - realReceiverType.getSize(), realReceiverType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(resolvedSetCall.getReceiverArgument().exists()) {
|
if (resolvedSetCall.getReceiverArgument().exists()) {
|
||||||
v.load(realReceiverIndex - realReceiverType.getSize(), realReceiverType);
|
v.load(realReceiverIndex - realReceiverType.getSize(), realReceiverType);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -743,19 +743,19 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// restoring original
|
// restoring original
|
||||||
if(thisIndex != -1) {
|
if (thisIndex != -1) {
|
||||||
v.load(thisIndex-1, JetTypeMapper.TYPE_OBJECT);
|
v.load(thisIndex-1, JetTypeMapper.TYPE_OBJECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(receiverIndex != -1) {
|
if (receiverIndex != -1) {
|
||||||
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
Type type = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||||
v.load(receiverIndex-type.getSize(), type);
|
v.load(receiverIndex-type.getSize(), type);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(firstTypeParamIndex != -1) {
|
if (firstTypeParamIndex != -1) {
|
||||||
index = firstTypeParamIndex;
|
index = firstTypeParamIndex;
|
||||||
for(int i = 0; i != typeParameters.size(); ++i) {
|
for(int i = 0; i != typeParameters.size(); ++i) {
|
||||||
if(typeParameters.get(i).isReified()) {
|
if (typeParameters.get(i).isReified()) {
|
||||||
v.load(index-1, JetTypeMapper.TYPE_OBJECT);
|
v.load(index-1, JetTypeMapper.TYPE_OBJECT);
|
||||||
index--;
|
index--;
|
||||||
}
|
}
|
||||||
@@ -775,16 +775,16 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean isStandardStack(ResolvedCall call, int valueParamsSize) {
|
private boolean isStandardStack(ResolvedCall call, int valueParamsSize) {
|
||||||
if(call == null)
|
if (call == null)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
for (TypeParameterDescriptor typeParameterDescriptor : call.getResultingDescriptor().getTypeParameters()) {
|
for (TypeParameterDescriptor typeParameterDescriptor : call.getResultingDescriptor().getTypeParameters()) {
|
||||||
if(typeParameterDescriptor.isReified())
|
if (typeParameterDescriptor.isReified())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<ValueParameterDescriptor> valueParameters = call.getResultingDescriptor().getValueParameters();
|
List<ValueParameterDescriptor> valueParameters = call.getResultingDescriptor().getValueParameters();
|
||||||
if(valueParameters.size() != valueParamsSize)
|
if (valueParameters.size() != valueParamsSize)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
for (ValueParameterDescriptor valueParameter : valueParameters) {
|
for (ValueParameterDescriptor valueParameter : valueParameters) {
|
||||||
@@ -792,12 +792,12 @@ public abstract class StackValue {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(call.getThisObject().exists()) {
|
if (call.getThisObject().exists()) {
|
||||||
if(call.getReceiverArgument().exists())
|
if (call.getReceiverArgument().exists())
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType(), MapTypeMode.VALUE).getSize() != 1)
|
if (codegen.typeMapper.mapType(call.getResultingDescriptor().getReceiverParameter().getType(), MapTypeMode.VALUE).getSize() != 1)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,7 +879,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(Type type, InstructionAdapter v) {
|
public void put(Type type, InstructionAdapter v) {
|
||||||
if(isSuper && isInterface) {
|
if (isSuper && isInterface) {
|
||||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), getter.getName(), getter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), getter.getName(), getter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -895,7 +895,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void store(Type topOfStackType, InstructionAdapter v) {
|
public void store(Type topOfStackType, InstructionAdapter v) {
|
||||||
if(isSuper && isInterface) {
|
if (isSuper && isInterface) {
|
||||||
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), setter.getName(), setter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
v.visitMethodInsn(Opcodes.INVOKESTATIC, methodOwner.getInternalName(), setter.getName(), setter.getDescriptor().replace("(", "(" + methodOwnerParam.getDescriptor()));
|
||||||
}
|
}
|
||||||
else if (setter == null) {
|
else if (setter == null) {
|
||||||
@@ -1011,7 +1011,7 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Type refType(Type type) {
|
public static Type refType(Type type) {
|
||||||
if(type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY)
|
if (type.getSort() == Type.OBJECT || type.getSort() == Type.ARRAY)
|
||||||
return JetTypeMapper.TYPE_OBJECT;
|
return JetTypeMapper.TYPE_OBJECT;
|
||||||
|
|
||||||
return type;
|
return type;
|
||||||
@@ -1103,7 +1103,7 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void put(Type type, InstructionAdapter v) {
|
public void put(Type type, InstructionAdapter v) {
|
||||||
if(!type.equals(Type.VOID_TYPE)) {
|
if (!type.equals(Type.VOID_TYPE)) {
|
||||||
v.load(index, Type.INT_TYPE);
|
v.load(index, Type.INT_TYPE);
|
||||||
coerce(type, v);
|
coerce(type, v);
|
||||||
}
|
}
|
||||||
@@ -1124,7 +1124,7 @@ public abstract class StackValue {
|
|||||||
@Override
|
@Override
|
||||||
public void put(Type type, InstructionAdapter v) {
|
public void put(Type type, InstructionAdapter v) {
|
||||||
v.iinc(index, increment);
|
v.iinc(index, increment);
|
||||||
if(!type.equals(Type.VOID_TYPE)) {
|
if (!type.equals(Type.VOID_TYPE)) {
|
||||||
v.load(index, Type.INT_TYPE);
|
v.load(index, Type.INT_TYPE);
|
||||||
coerce(type, v);
|
coerce(type, v);
|
||||||
}
|
}
|
||||||
@@ -1155,8 +1155,8 @@ public abstract class StackValue {
|
|||||||
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
CallableDescriptor descriptor = resolvedCall.getResultingDescriptor();
|
||||||
|
|
||||||
if (thisObject.exists()) {
|
if (thisObject.exists()) {
|
||||||
if(callableMethod != null) {
|
if (callableMethod != null) {
|
||||||
if(receiverArgument.exists()) {
|
if (receiverArgument.exists()) {
|
||||||
return callableMethod.getReceiverClass();
|
return callableMethod.getReceiverClass();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1164,7 +1164,7 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(receiverArgument.exists()) {
|
if (receiverArgument.exists()) {
|
||||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), MapTypeMode.VALUE);
|
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -1174,7 +1174,7 @@ public abstract class StackValue {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (receiverArgument.exists()) {
|
if (receiverArgument.exists()) {
|
||||||
if(callableMethod != null)
|
if (callableMethod != null)
|
||||||
return callableMethod.getReceiverClass();
|
return callableMethod.getReceiverClass();
|
||||||
else
|
else
|
||||||
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), MapTypeMode.VALUE);
|
return codegen.typeMapper.mapType(descriptor.getReceiverParameter().getType(), MapTypeMode.VALUE);
|
||||||
@@ -1192,7 +1192,7 @@ public abstract class StackValue {
|
|||||||
ReceiverDescriptor thisObject = resolvedCall.getThisObject();
|
ReceiverDescriptor thisObject = resolvedCall.getThisObject();
|
||||||
ReceiverDescriptor receiverArgument = resolvedCall.getReceiverArgument();
|
ReceiverDescriptor receiverArgument = resolvedCall.getReceiverArgument();
|
||||||
if (thisObject.exists()) {
|
if (thisObject.exists()) {
|
||||||
if(receiverArgument.exists()) {
|
if (receiverArgument.exists()) {
|
||||||
if (callableMethod != null) {
|
if (callableMethod != null) {
|
||||||
codegen.generateFromResolvedCall(thisObject, callableMethod.getOwner().getAsmType());
|
codegen.generateFromResolvedCall(thisObject, callableMethod.getOwner().getAsmType());
|
||||||
}
|
}
|
||||||
@@ -1214,8 +1214,8 @@ public abstract class StackValue {
|
|||||||
|
|
||||||
private void genReceiver(InstructionAdapter v, ReceiverDescriptor receiverArgument, Type type,
|
private void genReceiver(InstructionAdapter v, ReceiverDescriptor receiverArgument, Type type,
|
||||||
@Nullable ReceiverDescriptor receiverParameter, int depth) {
|
@Nullable ReceiverDescriptor receiverParameter, int depth) {
|
||||||
if(receiver == StackValue.none()) {
|
if (receiver == StackValue.none()) {
|
||||||
if(receiverParameter != null) {
|
if (receiverParameter != null) {
|
||||||
Type receiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
Type receiverType = codegen.typeMapper.mapType(receiverParameter.getType(), MapTypeMode.VALUE);
|
||||||
codegen.generateFromResolvedCall(receiverArgument, receiverType);
|
codegen.generateFromResolvedCall(receiverArgument, receiverType);
|
||||||
StackValue.onStack(receiverType).put(type, v);
|
StackValue.onStack(receiverType).put(type, v);
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
|||||||
//todo not needed when frontend will be able to calculate properly
|
//todo not needed when frontend will be able to calculate properly
|
||||||
static JetType getSuperClass(ClassDescriptor myClassDescr, BindingContext bindingContext) {
|
static JetType getSuperClass(ClassDescriptor myClassDescr, BindingContext bindingContext) {
|
||||||
JetClassOrObject myClass = (JetClassOrObject) BindingContextUtils.classDescriptorToDeclaration(bindingContext, myClassDescr);
|
JetClassOrObject myClass = (JetClassOrObject) BindingContextUtils.classDescriptorToDeclaration(bindingContext, myClassDescr);
|
||||||
if(myClass == null)
|
if (myClass == null)
|
||||||
return JetStandardClasses.getAnyType();
|
return JetStandardClasses.getAnyType();
|
||||||
List<JetDelegationSpecifier> delegationSpecifiers = myClass.getDelegationSpecifiers();
|
List<JetDelegationSpecifier> delegationSpecifiers = myClass.getDelegationSpecifiers();
|
||||||
|
|
||||||
@@ -51,8 +51,8 @@ public class TraitImplBodyCodegen extends ClassBodyCodegen {
|
|||||||
return superClassDescriptor.getDefaultType();
|
return superClassDescriptor.getDefaultType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(declaration instanceof JetClass) {
|
else if (declaration instanceof JetClass) {
|
||||||
if(!((JetClass) declaration).isTrait()) {
|
if (!((JetClass) declaration).isTrait()) {
|
||||||
return superClassDescriptor.getDefaultType();
|
return superClassDescriptor.getDefaultType();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ public class ArrayIterator implements IntrinsicMethod {
|
|||||||
FunctionDescriptor funDescriptor = (FunctionDescriptor) codegen.getBindingContext().get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
|
FunctionDescriptor funDescriptor = (FunctionDescriptor) codegen.getBindingContext().get(BindingContext.REFERENCE_TARGET, (JetSimpleNameExpression) call.getCalleeExpression());
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) funDescriptor.getContainingDeclaration().getOriginal();
|
||||||
JetStandardLibrary standardLibrary = codegen.getState().getInjector().getJetStandardLibrary();
|
JetStandardLibrary standardLibrary = codegen.getState().getInjector().getJetStandardLibrary();
|
||||||
if(containingDeclaration.equals(standardLibrary.getArray())) {
|
if (containingDeclaration.equals(standardLibrary.getArray())) {
|
||||||
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljet/Iterator;");
|
v.invokestatic("jet/runtime/ArrayIterator", "iterator", "([Ljava/lang/Object;)Ljet/Iterator;");
|
||||||
return StackValue.onStack(JetTypeMapper.TYPE_ITERATOR);
|
return StackValue.onStack(JetTypeMapper.TYPE_ITERATOR);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class BinaryOp implements IntrinsicMethod {
|
|||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
||||||
if(nullable) {
|
if (nullable) {
|
||||||
expectedType = JetTypeMapper.unboxType(expectedType);
|
expectedType = JetTypeMapper.unboxType(expectedType);
|
||||||
}
|
}
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
@@ -58,7 +58,7 @@ public class BinaryOp implements IntrinsicMethod {
|
|||||||
}
|
}
|
||||||
v.visitInsn(expectedType.getOpcode(opcode));
|
v.visitInsn(expectedType.getOpcode(opcode));
|
||||||
|
|
||||||
if(nullable) {
|
if (nullable) {
|
||||||
StackValue.onStack(expectedType).put(expectedType = JetTypeMapper.boxType(expectedType), v);
|
StackValue.onStack(expectedType).put(expectedType = JetTypeMapper.boxType(expectedType), v);
|
||||||
}
|
}
|
||||||
return StackValue.onStack(expectedType);
|
return StackValue.onStack(expectedType);
|
||||||
|
|||||||
@@ -37,21 +37,21 @@ public class CompareTo implements IntrinsicMethod {
|
|||||||
assert arguments != null;
|
assert arguments != null;
|
||||||
receiver.put(receiver.type, v);
|
receiver.put(receiver.type, v);
|
||||||
codegen.gen(arguments.get(0), receiver.type);
|
codegen.gen(arguments.get(0), receiver.type);
|
||||||
if(receiver.type == Type.BYTE_TYPE || receiver.type == Type.SHORT_TYPE || receiver.type == Type.CHAR_TYPE)
|
if (receiver.type == Type.BYTE_TYPE || receiver.type == Type.SHORT_TYPE || receiver.type == Type.CHAR_TYPE)
|
||||||
v.sub(Type.INT_TYPE);
|
v.sub(Type.INT_TYPE);
|
||||||
else if(receiver.type == Type.INT_TYPE) {
|
else if (receiver.type == Type.INT_TYPE) {
|
||||||
v.invokestatic("jet/runtime/Intrinsics", "compare", "(II)I");
|
v.invokestatic("jet/runtime/Intrinsics", "compare", "(II)I");
|
||||||
}
|
}
|
||||||
else if(receiver.type == Type.BOOLEAN_TYPE) {
|
else if (receiver.type == Type.BOOLEAN_TYPE) {
|
||||||
v.invokestatic("jet/runtime/Intrinsics", "compare", "(ZZ)I");
|
v.invokestatic("jet/runtime/Intrinsics", "compare", "(ZZ)I");
|
||||||
}
|
}
|
||||||
else if(receiver.type == Type.LONG_TYPE) {
|
else if (receiver.type == Type.LONG_TYPE) {
|
||||||
v.invokestatic("jet/runtime/Intrinsics", "compare", "(JJ)I");
|
v.invokestatic("jet/runtime/Intrinsics", "compare", "(JJ)I");
|
||||||
}
|
}
|
||||||
else if(receiver.type == Type.FLOAT_TYPE) {
|
else if (receiver.type == Type.FLOAT_TYPE) {
|
||||||
v.invokestatic("java/lang/Float", "compare", "(FF)I");
|
v.invokestatic("java/lang/Float", "compare", "(FF)I");
|
||||||
}
|
}
|
||||||
else if(receiver.type == Type.DOUBLE_TYPE) {
|
else if (receiver.type == Type.DOUBLE_TYPE) {
|
||||||
v.invokestatic("java/lang/Double", "compare", "(DD)I");
|
v.invokestatic("java/lang/Double", "compare", "(DD)I");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -41,13 +41,13 @@ public class Equals implements IntrinsicMethod {
|
|||||||
|
|
||||||
boolean leftNullable = true;
|
boolean leftNullable = true;
|
||||||
JetExpression rightExpr;
|
JetExpression rightExpr;
|
||||||
if(element instanceof JetCallExpression) {
|
if (element instanceof JetCallExpression) {
|
||||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||||
JetCallExpression jetCallExpression = (JetCallExpression) element;
|
JetCallExpression jetCallExpression = (JetCallExpression) element;
|
||||||
JetExpression calleeExpression = jetCallExpression.getCalleeExpression();
|
JetExpression calleeExpression = jetCallExpression.getCalleeExpression();
|
||||||
if(calleeExpression != null) {
|
if (calleeExpression != null) {
|
||||||
JetType leftType = codegen.getBindingContext().get(BindingContext.EXPRESSION_TYPE, calleeExpression);
|
JetType leftType = codegen.getBindingContext().get(BindingContext.EXPRESSION_TYPE, calleeExpression);
|
||||||
if(leftType != null)
|
if (leftType != null)
|
||||||
leftNullable = leftType.isNullable();
|
leftNullable = leftType.isNullable();
|
||||||
}
|
}
|
||||||
rightExpr = arguments.get(0);
|
rightExpr = arguments.get(0);
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ import java.util.List;
|
|||||||
public class IdentityEquals implements IntrinsicMethod {
|
public class IdentityEquals implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
if(element instanceof JetCallExpression) {
|
if (element instanceof JetCallExpression) {
|
||||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||||
codegen.gen(arguments.get(0)).put(JetTypeMapper.TYPE_OBJECT, v);
|
codegen.gen(arguments.get(0)).put(JetTypeMapper.TYPE_OBJECT, v);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,10 +43,10 @@ public class Increment implements IntrinsicMethod {
|
|||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
||||||
if(nullable) {
|
if (nullable) {
|
||||||
expectedType = JetTypeMapper.unboxType(expectedType);
|
expectedType = JetTypeMapper.unboxType(expectedType);
|
||||||
}
|
}
|
||||||
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();
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ public class IntrinsicMethods {
|
|||||||
|
|
||||||
public IntrinsicMethod getIntrinsic(DeclarationDescriptor descriptor) {
|
public IntrinsicMethod getIntrinsic(DeclarationDescriptor descriptor) {
|
||||||
IntrinsicMethod intrinsicMethod = myMethods.get(descriptor.getOriginal());
|
IntrinsicMethod intrinsicMethod = myMethods.get(descriptor.getOriginal());
|
||||||
if(intrinsicMethod == null) {
|
if (intrinsicMethod == null) {
|
||||||
List<AnnotationDescriptor> annotations = descriptor.getAnnotations();
|
List<AnnotationDescriptor> annotations = descriptor.getAnnotations();
|
||||||
if (annotations != null) {
|
if (annotations != null) {
|
||||||
for (AnnotationDescriptor annotation : annotations) {
|
for (AnnotationDescriptor annotation : annotations) {
|
||||||
|
|||||||
@@ -36,11 +36,11 @@ public class Inv implements IntrinsicMethod {
|
|||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
||||||
if(nullable) {
|
if (nullable) {
|
||||||
expectedType = JetTypeMapper.unboxType(expectedType);
|
expectedType = JetTypeMapper.unboxType(expectedType);
|
||||||
}
|
}
|
||||||
receiver.put(expectedType, v);
|
receiver.put(expectedType, v);
|
||||||
if(expectedType == Type.LONG_TYPE) {
|
if (expectedType == Type.LONG_TYPE) {
|
||||||
v.lconst(-1L);
|
v.lconst(-1L);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
@@ -35,21 +35,21 @@ public class IteratorNext implements IntrinsicMethod {
|
|||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
String name;
|
String name;
|
||||||
if(expectedType == Type.CHAR_TYPE)
|
if (expectedType == Type.CHAR_TYPE)
|
||||||
name = "Char";
|
name = "Char";
|
||||||
else if(expectedType == Type.BOOLEAN_TYPE)
|
else if (expectedType == Type.BOOLEAN_TYPE)
|
||||||
name = "Boolean";
|
name = "Boolean";
|
||||||
else if(expectedType == Type.BYTE_TYPE)
|
else if (expectedType == Type.BYTE_TYPE)
|
||||||
name = "Byte";
|
name = "Byte";
|
||||||
else if(expectedType == Type.SHORT_TYPE)
|
else if (expectedType == Type.SHORT_TYPE)
|
||||||
name = "Short";
|
name = "Short";
|
||||||
else if(expectedType == Type.INT_TYPE)
|
else if (expectedType == Type.INT_TYPE)
|
||||||
name = "Int";
|
name = "Int";
|
||||||
else if(expectedType == Type.LONG_TYPE)
|
else if (expectedType == Type.LONG_TYPE)
|
||||||
name = "Long";
|
name = "Long";
|
||||||
else if(expectedType == Type.FLOAT_TYPE)
|
else if (expectedType == Type.FLOAT_TYPE)
|
||||||
name = "Float";
|
name = "Float";
|
||||||
else if(expectedType == Type.DOUBLE_TYPE)
|
else if (expectedType == Type.DOUBLE_TYPE)
|
||||||
name = "Double";
|
name = "Double";
|
||||||
else
|
else
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
|
|||||||
@@ -34,9 +34,9 @@ import java.util.List;
|
|||||||
public class StringGetChar implements IntrinsicMethod {
|
public class StringGetChar implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
if(receiver != null)
|
if (receiver != null)
|
||||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||||
if(arguments != null)
|
if (arguments != null)
|
||||||
codegen.gen(arguments.get(0)).put(Type.INT_TYPE, v);
|
codegen.gen(arguments.get(0)).put(Type.INT_TYPE, v);
|
||||||
v.invokeinterface("java/lang/CharSequence", "charAt", "(I)C");
|
v.invokeinterface("java/lang/CharSequence", "charAt", "(I)C");
|
||||||
return StackValue.onStack(Type.CHAR_TYPE);
|
return StackValue.onStack(Type.CHAR_TYPE);
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import java.util.List;
|
|||||||
public class StringPlus implements IntrinsicMethod {
|
public class StringPlus implements IntrinsicMethod {
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
if(receiver == null || receiver == StackValue.none()) {
|
if (receiver == null || receiver == StackValue.none()) {
|
||||||
codegen.gen(arguments.get(0)).put(JetTypeMapper.JL_STRING_TYPE, v);
|
codegen.gen(arguments.get(0)).put(JetTypeMapper.JL_STRING_TYPE, v);
|
||||||
codegen.gen(arguments.get(1)).put(JetTypeMapper.TYPE_OBJECT, v);
|
codegen.gen(arguments.get(1)).put(JetTypeMapper.TYPE_OBJECT, v);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class Sure implements IntrinsicMethod {
|
|||||||
JetCallExpression call = (JetCallExpression) element;
|
JetCallExpression call = (JetCallExpression) element;
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, call.getCalleeExpression());
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = codegen.getBindingContext().get(BindingContext.RESOLVED_CALL, call.getCalleeExpression());
|
||||||
assert resolvedCall != null;
|
assert resolvedCall != null;
|
||||||
if(resolvedCall.getReceiverArgument().getType().isNullable()) {
|
if (resolvedCall.getReceiverArgument().getType().isNullable()) {
|
||||||
receiver.put(receiver.type, v);
|
receiver.put(receiver.type, v);
|
||||||
v.dup();
|
v.dup();
|
||||||
Label ok = new Label();
|
Label ok = new Label();
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class UnaryMinus implements IntrinsicMethod {
|
|||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
||||||
if(nullable) {
|
if (nullable) {
|
||||||
expectedType = JetTypeMapper.unboxType(expectedType);
|
expectedType = JetTypeMapper.unboxType(expectedType);
|
||||||
}
|
}
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ public class UnaryPlus implements IntrinsicMethod {
|
|||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, @Nullable PsiElement element, @Nullable List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, @Nullable PsiElement element, @Nullable List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
boolean nullable = expectedType.getSort() == Type.OBJECT;
|
||||||
if(nullable) {
|
if (nullable) {
|
||||||
expectedType = JetTypeMapper.unboxType(expectedType);
|
expectedType = JetTypeMapper.unboxType(expectedType);
|
||||||
}
|
}
|
||||||
if(receiver != null && receiver != StackValue.none())
|
if (receiver != null && receiver != StackValue.none())
|
||||||
receiver.put(expectedType, v);
|
receiver.put(expectedType, v);
|
||||||
else {
|
else {
|
||||||
assert arguments != null;
|
assert arguments != null;
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public class UpTo implements IntrinsicMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, @NotNull Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver, @NotNull GenerationState state) {
|
||||||
if(arguments.size()==1) {
|
if (arguments.size()==1) {
|
||||||
final Type leftType = receiver.type;
|
final Type leftType = receiver.type;
|
||||||
final Type rightType = codegen.expressionType(arguments.get(0));
|
final Type rightType = codegen.expressionType(arguments.get(0));
|
||||||
receiver.put(Type.INT_TYPE, v);
|
receiver.put(Type.INT_TYPE, v);
|
||||||
|
|||||||
+9
-9
@@ -1701,23 +1701,23 @@ public class JavaDescriptorResolver implements DependencyClassByQualifiedNameRes
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object literalValue = ((PsiLiteralExpression) value).getValue();
|
Object literalValue = ((PsiLiteralExpression) value).getValue();
|
||||||
if(literalValue instanceof String)
|
if (literalValue instanceof String)
|
||||||
valueArguments.add(new StringValue((String) literalValue));
|
valueArguments.add(new StringValue((String) literalValue));
|
||||||
else if(literalValue instanceof Byte)
|
else if (literalValue instanceof Byte)
|
||||||
valueArguments.add(new ByteValue((Byte) literalValue));
|
valueArguments.add(new ByteValue((Byte) literalValue));
|
||||||
else if(literalValue instanceof Short)
|
else if (literalValue instanceof Short)
|
||||||
valueArguments.add(new ShortValue((Short) literalValue));
|
valueArguments.add(new ShortValue((Short) literalValue));
|
||||||
else if(literalValue instanceof Character)
|
else if (literalValue instanceof Character)
|
||||||
valueArguments.add(new CharValue((Character) literalValue));
|
valueArguments.add(new CharValue((Character) literalValue));
|
||||||
else if(literalValue instanceof Integer)
|
else if (literalValue instanceof Integer)
|
||||||
valueArguments.add(new IntValue((Integer) literalValue));
|
valueArguments.add(new IntValue((Integer) literalValue));
|
||||||
else if(literalValue instanceof Long)
|
else if (literalValue instanceof Long)
|
||||||
valueArguments.add(new LongValue((Long) literalValue));
|
valueArguments.add(new LongValue((Long) literalValue));
|
||||||
else if(literalValue instanceof Float)
|
else if (literalValue instanceof Float)
|
||||||
valueArguments.add(new FloatValue((Float) literalValue));
|
valueArguments.add(new FloatValue((Float) literalValue));
|
||||||
else if(literalValue instanceof Double)
|
else if (literalValue instanceof Double)
|
||||||
valueArguments.add(new DoubleValue((Double) literalValue));
|
valueArguments.add(new DoubleValue((Double) literalValue));
|
||||||
else if(literalValue == null)
|
else if (literalValue == null)
|
||||||
valueArguments.add(NullValue.NULL);
|
valueArguments.add(NullValue.NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -216,9 +216,9 @@ public class JavaTypeTransformer {
|
|||||||
@Override
|
@Override
|
||||||
public JetType visitArrayType(PsiArrayType arrayType) {
|
public JetType visitArrayType(PsiArrayType arrayType) {
|
||||||
PsiType componentType = arrayType.getComponentType();
|
PsiType componentType = arrayType.getComponentType();
|
||||||
if(componentType instanceof PsiPrimitiveType) {
|
if (componentType instanceof PsiPrimitiveType) {
|
||||||
JetType jetType = getPrimitiveTypesMap().get("[" + componentType.getCanonicalText());
|
JetType jetType = getPrimitiveTypesMap().get("[" + componentType.getCanonicalText());
|
||||||
if(jetType != null)
|
if (jetType != null)
|
||||||
return TypeUtils.makeNullable(jetType);
|
return TypeUtils.makeNullable(jetType);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -296,12 +296,12 @@ public class DescriptorUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClassObject(@NotNull DeclarationDescriptor descriptor) {
|
public static boolean isClassObject(@NotNull DeclarationDescriptor descriptor) {
|
||||||
if(descriptor instanceof ClassDescriptor) {
|
if (descriptor instanceof ClassDescriptor) {
|
||||||
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
|
ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
|
||||||
if(classDescriptor.getKind() == ClassKind.OBJECT) {
|
if (classDescriptor.getKind() == ClassKind.OBJECT) {
|
||||||
if(classDescriptor.getContainingDeclaration() instanceof ClassDescriptor) {
|
if (classDescriptor.getContainingDeclaration() instanceof ClassDescriptor) {
|
||||||
ClassDescriptor containingDeclaration = (ClassDescriptor) classDescriptor.getContainingDeclaration();
|
ClassDescriptor containingDeclaration = (ClassDescriptor) classDescriptor.getContainingDeclaration();
|
||||||
if(classDescriptor.getDefaultType().equals(containingDeclaration.getClassObjectType())) {
|
if (classDescriptor.getDefaultType().equals(containingDeclaration.getClassObjectType())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class SubstitutionUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for(TypeProjection proj : type.getArguments()) {
|
for(TypeProjection proj : type.getArguments()) {
|
||||||
if(hasUnsubstitutedTypeParameters(proj.getType())) {
|
if (hasUnsubstitutedTypeParameters(proj.getType())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ public class JetStandardLibrary {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initStdClasses() {
|
private void initStdClasses() {
|
||||||
if(libraryScope == null) {
|
if (libraryScope == null) {
|
||||||
this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
|
this.libraryScope = JetStandardClasses.STANDARD_CLASSES_NAMESPACE.getMemberScope();
|
||||||
|
|
||||||
this.numberClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Number"));
|
this.numberClass = (ClassDescriptor) libraryScope.getClassifier(Name.identifier("Number"));
|
||||||
@@ -504,7 +504,7 @@ public class JetStandardLibrary {
|
|||||||
|
|
||||||
public final boolean isVolatile(PropertyDescriptor descriptor) {
|
public final boolean isVolatile(PropertyDescriptor descriptor) {
|
||||||
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
|
List<AnnotationDescriptor> annotations = descriptor.getOriginal().getAnnotations();
|
||||||
if(annotations != null) {
|
if (annotations != null) {
|
||||||
for(AnnotationDescriptor d: annotations) {
|
for(AnnotationDescriptor d: annotations) {
|
||||||
if (d.getType().equals(getVolatileType())) { return true; }
|
if (d.getType().equals(getVolatileType())) { return true; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class TestlibTest extends CodegenTestCase {
|
|||||||
try {
|
try {
|
||||||
for(JetFile jetFile : myEnvironment.getSourceFiles()) {
|
for(JetFile jetFile : myEnvironment.getSourceFiles()) {
|
||||||
for(JetDeclaration decl : jetFile.getDeclarations()) {
|
for(JetDeclaration decl : jetFile.getDeclarations()) {
|
||||||
if(decl instanceof JetClass) {
|
if (decl instanceof JetClass) {
|
||||||
JetClass jetClass = (JetClass) decl;
|
JetClass jetClass = (JetClass) decl;
|
||||||
|
|
||||||
ClassDescriptor descriptor = (ClassDescriptor) generationState.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
ClassDescriptor descriptor = (ClassDescriptor) generationState.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, jetClass);
|
||||||
@@ -116,11 +116,11 @@ public class TestlibTest extends CodegenTestCase {
|
|||||||
String name = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
String name = typeMapper.mapType(descriptor.getDefaultType(), MapTypeMode.IMPL).getInternalName();
|
||||||
System.out.println(name);
|
System.out.println(name);
|
||||||
Class<TestCase> aClass = (Class<TestCase>) loader.loadClass(name.replace('/', '.'));
|
Class<TestCase> aClass = (Class<TestCase>) loader.loadClass(name.replace('/', '.'));
|
||||||
if((aClass.getModifiers() & Modifier.ABSTRACT) == 0
|
if ((aClass.getModifiers() & Modifier.ABSTRACT) == 0
|
||||||
&& (aClass.getModifiers() & Modifier.PUBLIC) != 0) {
|
&& (aClass.getModifiers() & Modifier.PUBLIC) != 0) {
|
||||||
try {
|
try {
|
||||||
Constructor<TestCase> constructor = aClass.getConstructor();
|
Constructor<TestCase> constructor = aClass.getConstructor();
|
||||||
if(constructor != null && (constructor.getModifiers() & Modifier.PUBLIC) != 0) {
|
if (constructor != null && (constructor.getModifiers() & Modifier.PUBLIC) != 0) {
|
||||||
suite.addTestSuite(aClass);
|
suite.addTestSuite(aClass);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ public class JetPositionManager implements PositionManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(psiElement instanceof JetClassOrObject)
|
if (psiElement instanceof JetClassOrObject)
|
||||||
names.addAll(typeMapper.allJvmNames((JetClassOrObject) psiElement));
|
names.addAll(typeMapper.allJvmNames((JetClassOrObject) psiElement));
|
||||||
else {
|
else {
|
||||||
names.add(typeMapper.getClosureAnnotator().classNameForAnonymousClass((JetElement) psiElement).getInternalName());
|
names.add(typeMapper.getClosureAnnotator().classNameForAnonymousClass((JetElement) psiElement).getInternalName());
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public final class ByteRange implements Range<Byte>, ByteIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ByteIterator step(int step) {
|
public ByteIterator step(int step) {
|
||||||
if(step < 0)
|
if (step < 0)
|
||||||
return new MyIterator(getEnd(), -count, -step);
|
return new MyIterator(getEnd(), -count, -step);
|
||||||
else
|
else
|
||||||
return new MyIterator(start, count, step);
|
return new MyIterator(start, count, step);
|
||||||
@@ -89,7 +89,7 @@ public final class ByteRange implements Range<Byte>, ByteIterable {
|
|||||||
public MyIterator(byte startValue, int count, int step) {
|
public MyIterator(byte startValue, int count, int step) {
|
||||||
cur = startValue;
|
cur = startValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
if(count < 0) {
|
if (count < 0) {
|
||||||
reversed = true;
|
reversed = true;
|
||||||
count = -count;
|
count = -count;
|
||||||
startValue += count;
|
startValue += count;
|
||||||
@@ -108,7 +108,7 @@ public final class ByteRange implements Range<Byte>, ByteIterable {
|
|||||||
@Override
|
@Override
|
||||||
public byte nextByte() {
|
public byte nextByte() {
|
||||||
count -= step;
|
count -= step;
|
||||||
if(reversed) {
|
if (reversed) {
|
||||||
cur -= step;
|
cur -= step;
|
||||||
return (byte) (cur + step);
|
return (byte) (cur + step);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public final class CharRange implements Range<Character>, CharIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public CharIterator step(int step) {
|
public CharIterator step(int step) {
|
||||||
if(step < 0)
|
if (step < 0)
|
||||||
return new MyIterator(getEnd(), -count, -step);
|
return new MyIterator(getEnd(), -count, -step);
|
||||||
else
|
else
|
||||||
return new MyIterator(start, count, step);
|
return new MyIterator(start, count, step);
|
||||||
@@ -89,7 +89,7 @@ public final class CharRange implements Range<Character>, CharIterable {
|
|||||||
public MyIterator(char startValue, int count, int step) {
|
public MyIterator(char startValue, int count, int step) {
|
||||||
cur = startValue;
|
cur = startValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
if(count < 0) {
|
if (count < 0) {
|
||||||
reversed = true;
|
reversed = true;
|
||||||
count = -count;
|
count = -count;
|
||||||
startValue += count;
|
startValue += count;
|
||||||
@@ -108,7 +108,7 @@ public final class CharRange implements Range<Character>, CharIterable {
|
|||||||
@Override
|
@Override
|
||||||
public char nextChar() {
|
public char nextChar() {
|
||||||
count -= step;
|
count -= step;
|
||||||
if(reversed) {
|
if (reversed) {
|
||||||
cur -= step;
|
cur -= step;
|
||||||
return (char) (cur + step);
|
return (char) (cur + step);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public final class DoubleRange implements Range<Double> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DoubleIterator step(double step) {
|
public DoubleIterator step(double step) {
|
||||||
if(step < 0)
|
if (step < 0)
|
||||||
return new MyIterator(getEnd(), -size, -step);
|
return new MyIterator(getEnd(), -size, -step);
|
||||||
else
|
else
|
||||||
return new MyIterator(start, size, step);
|
return new MyIterator(start, size, step);
|
||||||
@@ -78,7 +78,7 @@ public final class DoubleRange implements Range<Double> {
|
|||||||
public MyIterator(double startValue, double size, double step) {
|
public MyIterator(double startValue, double size, double step) {
|
||||||
cur = startValue;
|
cur = startValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
if(size < 0) {
|
if (size < 0) {
|
||||||
reversed = true;
|
reversed = true;
|
||||||
end = startValue-size;
|
end = startValue-size;
|
||||||
startValue -= size;
|
startValue -= size;
|
||||||
@@ -91,7 +91,7 @@ public final class DoubleRange implements Range<Double> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getHasNext() {
|
public boolean getHasNext() {
|
||||||
if(reversed)
|
if (reversed)
|
||||||
return cur >= end;
|
return cur >= end;
|
||||||
else
|
else
|
||||||
return cur <= end;
|
return cur <= end;
|
||||||
@@ -99,7 +99,7 @@ public final class DoubleRange implements Range<Double> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double nextDouble() {
|
public double nextDouble() {
|
||||||
if(reversed) {
|
if (reversed) {
|
||||||
cur -= step;
|
cur -= step;
|
||||||
return cur + step;
|
return cur + step;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public final class FloatRange implements Range<Float> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public FloatIterator step(float step) {
|
public FloatIterator step(float step) {
|
||||||
if(step < 0)
|
if (step < 0)
|
||||||
return new MyIterator(getEnd(), -size, -step);
|
return new MyIterator(getEnd(), -size, -step);
|
||||||
else
|
else
|
||||||
return new MyIterator(start, size, step);
|
return new MyIterator(start, size, step);
|
||||||
@@ -78,7 +78,7 @@ public final class FloatRange implements Range<Float> {
|
|||||||
public MyIterator(float startValue, float size, float step) {
|
public MyIterator(float startValue, float size, float step) {
|
||||||
cur = startValue;
|
cur = startValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
if(size < 0) {
|
if (size < 0) {
|
||||||
reversed = true;
|
reversed = true;
|
||||||
end = startValue-size;
|
end = startValue-size;
|
||||||
startValue -= size;
|
startValue -= size;
|
||||||
@@ -91,7 +91,7 @@ public final class FloatRange implements Range<Float> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean getHasNext() {
|
public boolean getHasNext() {
|
||||||
if(reversed)
|
if (reversed)
|
||||||
return cur >= end;
|
return cur >= end;
|
||||||
else
|
else
|
||||||
return cur <= end;
|
return cur <= end;
|
||||||
@@ -99,7 +99,7 @@ public final class FloatRange implements Range<Float> {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float nextFloat() {
|
public float nextFloat() {
|
||||||
if(reversed) {
|
if (reversed) {
|
||||||
cur -= step;
|
cur -= step;
|
||||||
return cur + step;
|
return cur + step;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ public final class IntRange implements Range<Integer>, IntIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public IntIterator step(int step) {
|
public IntIterator step(int step) {
|
||||||
if(step < 0)
|
if (step < 0)
|
||||||
return new MyIterator(getEnd(), -count, -step);
|
return new MyIterator(getEnd(), -count, -step);
|
||||||
else
|
else
|
||||||
return new MyIterator(start, count, step);
|
return new MyIterator(start, count, step);
|
||||||
@@ -89,7 +89,7 @@ public final class IntRange implements Range<Integer>, IntIterable {
|
|||||||
public MyIterator(int startValue, int count, int step) {
|
public MyIterator(int startValue, int count, int step) {
|
||||||
cur = startValue;
|
cur = startValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
if(count < 0) {
|
if (count < 0) {
|
||||||
reversed = true;
|
reversed = true;
|
||||||
count = -count;
|
count = -count;
|
||||||
startValue += count;
|
startValue += count;
|
||||||
@@ -108,7 +108,7 @@ public final class IntRange implements Range<Integer>, IntIterable {
|
|||||||
@Override
|
@Override
|
||||||
public int nextInt() {
|
public int nextInt() {
|
||||||
count -= step;
|
count -= step;
|
||||||
if(reversed) {
|
if (reversed) {
|
||||||
cur -= step;
|
cur -= step;
|
||||||
return cur + step;
|
return cur + step;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public final class LongRange implements Range<Long>, LongIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public LongIterator step(long step) {
|
public LongIterator step(long step) {
|
||||||
if(step < 0)
|
if (step < 0)
|
||||||
return new MyIterator(getEnd(), -count, -step);
|
return new MyIterator(getEnd(), -count, -step);
|
||||||
else
|
else
|
||||||
return new MyIterator(start, count, step);
|
return new MyIterator(start, count, step);
|
||||||
@@ -89,7 +89,7 @@ public final class LongRange implements Range<Long>, LongIterable {
|
|||||||
public MyIterator(long startValue, long count, long step) {
|
public MyIterator(long startValue, long count, long step) {
|
||||||
cur = startValue;
|
cur = startValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
if(count < 0) {
|
if (count < 0) {
|
||||||
reversed = true;
|
reversed = true;
|
||||||
count = -count;
|
count = -count;
|
||||||
startValue += count;
|
startValue += count;
|
||||||
@@ -108,7 +108,7 @@ public final class LongRange implements Range<Long>, LongIterable {
|
|||||||
@Override
|
@Override
|
||||||
public long nextLong() {
|
public long nextLong() {
|
||||||
count -= step;
|
count -= step;
|
||||||
if(reversed) {
|
if (reversed) {
|
||||||
cur -= step;
|
cur -= step;
|
||||||
return (cur + step);
|
return (cur + step);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public final class ShortRange implements Range<Short>, ShortIterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ShortIterator step(int step) {
|
public ShortIterator step(int step) {
|
||||||
if(step < 0)
|
if (step < 0)
|
||||||
return new MyIterator(getEnd(), -count, -step);
|
return new MyIterator(getEnd(), -count, -step);
|
||||||
else
|
else
|
||||||
return new MyIterator(start, count, step);
|
return new MyIterator(start, count, step);
|
||||||
@@ -89,7 +89,7 @@ public final class ShortRange implements Range<Short>, ShortIterable {
|
|||||||
public MyIterator(short startValue, int count, int step) {
|
public MyIterator(short startValue, int count, int step) {
|
||||||
cur = startValue;
|
cur = startValue;
|
||||||
this.step = step;
|
this.step = step;
|
||||||
if(count < 0) {
|
if (count < 0) {
|
||||||
reversed = true;
|
reversed = true;
|
||||||
count = -count;
|
count = -count;
|
||||||
startValue += count;
|
startValue += count;
|
||||||
@@ -108,7 +108,7 @@ public final class ShortRange implements Range<Short>, ShortIterable {
|
|||||||
@Override
|
@Override
|
||||||
public short nextShort() {
|
public short nextShort() {
|
||||||
count -= step;
|
count -= step;
|
||||||
if(reversed) {
|
if (reversed) {
|
||||||
cur -= step;
|
cur -= step;
|
||||||
return (short) (cur + step);
|
return (short) (cur + step);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ public class Intrinsics {
|
|||||||
ArrayList<StackTraceElement> list = new ArrayList<StackTraceElement>();
|
ArrayList<StackTraceElement> list = new ArrayList<StackTraceElement>();
|
||||||
boolean skip = true;
|
boolean skip = true;
|
||||||
for(StackTraceElement ste : stackTrace) {
|
for(StackTraceElement ste : stackTrace) {
|
||||||
if(!skip) {
|
if (!skip) {
|
||||||
list.add(ste);
|
list.add(ste);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -87,25 +87,25 @@ public class Intrinsics {
|
|||||||
|
|
||||||
public static class SpreadBuilder extends ArrayList {
|
public static class SpreadBuilder extends ArrayList {
|
||||||
public void addSpread(Object array) {
|
public void addSpread(Object array) {
|
||||||
if(array != null) {
|
if (array != null) {
|
||||||
if(array instanceof Object[]) {
|
if (array instanceof Object[]) {
|
||||||
Object[] arr = (Object[]) array;
|
Object[] arr = (Object[]) array;
|
||||||
if(arr.length > 0) {
|
if (arr.length > 0) {
|
||||||
ensureCapacity(size() + arr.length);
|
ensureCapacity(size() + arr.length);
|
||||||
for (int i = 0; i < arr.length; i++) {
|
for (int i = 0; i < arr.length; i++) {
|
||||||
add(arr[i]);
|
add(arr[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(array instanceof Collection) {
|
else if (array instanceof Collection) {
|
||||||
addAll((Collection) array);
|
addAll((Collection) array);
|
||||||
}
|
}
|
||||||
else if(array instanceof Iterable) {
|
else if (array instanceof Iterable) {
|
||||||
for(Iterator iterator = ((Iterable) array).iterator(); iterator.hasNext(); ) {
|
for(Iterator iterator = ((Iterable) array).iterator(); iterator.hasNext(); ) {
|
||||||
add(iterator.next());
|
add(iterator.next());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(array instanceof Iterator) {
|
else if (array instanceof Iterator) {
|
||||||
for(Iterator iterator = ((Iterator) array); iterator.hasNext(); ) {
|
for(Iterator iterator = ((Iterator) array); iterator.hasNext(); ) {
|
||||||
add(iterator.next());
|
add(iterator.next());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ByteRange upTo(byte from, byte to) {
|
public static ByteRange upTo(byte from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return ByteRange.empty;
|
return ByteRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -38,7 +38,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ByteRange downTo(byte from, byte to) {
|
public static ByteRange downTo(byte from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new ByteRange(from, to-from-1);
|
return new ByteRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -47,7 +47,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange upTo(byte from, short to) {
|
public static ShortRange upTo(byte from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return ShortRange.empty;
|
return ShortRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -56,7 +56,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange downTo(byte from, short to) {
|
public static ShortRange downTo(byte from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new ShortRange(from, to-from-1);
|
return new ShortRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -65,7 +65,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange upTo(byte from, int to) {
|
public static IntRange upTo(byte from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return IntRange.empty;
|
return IntRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -74,7 +74,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange downTo(byte from, int to) {
|
public static IntRange downTo(byte from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new IntRange(from, to-from-1);
|
return new IntRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -83,7 +83,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(byte from, long to) {
|
public static LongRange upTo(byte from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -92,7 +92,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(byte from, long to) {
|
public static LongRange downTo(byte from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -117,7 +117,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange upTo(byte from, char to) {
|
public static CharRange upTo(byte from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return CharRange.empty;
|
return CharRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -126,7 +126,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange downTo(byte from, char to) {
|
public static CharRange downTo(byte from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new CharRange((char) from, to-from-1);
|
return new CharRange((char) from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -135,7 +135,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange upTo(short from, byte to) {
|
public static ShortRange upTo(short from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return ShortRange.empty;
|
return ShortRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -144,7 +144,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange downTo(short from, byte to) {
|
public static ShortRange downTo(short from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new ShortRange(from, to-from-1);
|
return new ShortRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -153,7 +153,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange upTo(short from, short to) {
|
public static ShortRange upTo(short from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return ShortRange.empty;
|
return ShortRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -162,7 +162,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange downTo(short from, short to) {
|
public static ShortRange downTo(short from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new ShortRange(from, to-from-1);
|
return new ShortRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -171,7 +171,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange upTo(short from, int to) {
|
public static IntRange upTo(short from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return IntRange.empty;
|
return IntRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -180,7 +180,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange downTo(short from, int to) {
|
public static IntRange downTo(short from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new IntRange(from, to-from-1);
|
return new IntRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -189,7 +189,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(short from, long to) {
|
public static LongRange upTo(short from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -198,7 +198,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(short from, long to) {
|
public static LongRange downTo(short from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -223,7 +223,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange upTo(short from, char to) {
|
public static ShortRange upTo(short from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return ShortRange.empty;
|
return ShortRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -232,7 +232,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange downTo(short from, char to) {
|
public static ShortRange downTo(short from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new ShortRange(from, to-from-1);
|
return new ShortRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -241,7 +241,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange upTo(int from, byte to) {
|
public static IntRange upTo(int from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return IntRange.empty;
|
return IntRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -250,7 +250,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange downTo(int from, byte to) {
|
public static IntRange downTo(int from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new IntRange(from, to-from-1);
|
return new IntRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -259,7 +259,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange upTo(int from, short to) {
|
public static IntRange upTo(int from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return IntRange.empty;
|
return IntRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -268,7 +268,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange downTo(int from, short to) {
|
public static IntRange downTo(int from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new IntRange(from, to-from-1);
|
return new IntRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -277,7 +277,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange upTo(int from, int to) {
|
public static IntRange upTo(int from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return IntRange.empty;
|
return IntRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -286,7 +286,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange downTo(int from, int to) {
|
public static IntRange downTo(int from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new IntRange(from, to-from-1);
|
return new IntRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -295,7 +295,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(int from, long to) {
|
public static LongRange upTo(int from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -304,7 +304,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(int from, long to) {
|
public static LongRange downTo(int from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -329,7 +329,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange upTo(int from, char to) {
|
public static IntRange upTo(int from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return IntRange.empty;
|
return IntRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -338,7 +338,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange downTo(int from, char to) {
|
public static IntRange downTo(int from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new IntRange(from, to-from-1);
|
return new IntRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -347,7 +347,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(long from, byte to) {
|
public static LongRange upTo(long from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -356,7 +356,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(long from, byte to) {
|
public static LongRange downTo(long from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -365,7 +365,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(long from, short to) {
|
public static LongRange upTo(long from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -374,7 +374,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(long from, short to) {
|
public static LongRange downTo(long from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -383,7 +383,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(long from, int to) {
|
public static LongRange upTo(long from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -392,7 +392,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(long from, int to) {
|
public static LongRange downTo(long from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -401,7 +401,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(long from, long to) {
|
public static LongRange upTo(long from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -410,7 +410,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(long from, long to) {
|
public static LongRange downTo(long from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -435,7 +435,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(long from, char to) {
|
public static LongRange upTo(long from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -444,7 +444,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(long from, char to) {
|
public static LongRange downTo(long from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -565,7 +565,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange upTo(char from, byte to) {
|
public static CharRange upTo(char from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return CharRange.empty;
|
return CharRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -574,7 +574,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange downTo(char from, byte to) {
|
public static CharRange downTo(char from, byte to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new CharRange(from, to-from-1);
|
return new CharRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -583,7 +583,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange upTo(char from, short to) {
|
public static ShortRange upTo(char from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return ShortRange.empty;
|
return ShortRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -592,7 +592,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static ShortRange downTo(char from, short to) {
|
public static ShortRange downTo(char from, short to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new ShortRange((short) from, to-from-1);
|
return new ShortRange((short) from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -601,7 +601,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange upTo(char from, int to) {
|
public static IntRange upTo(char from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return IntRange.empty;
|
return IntRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -610,7 +610,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static IntRange downTo(char from, int to) {
|
public static IntRange downTo(char from, int to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new IntRange(from, to-from-1);
|
return new IntRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -619,7 +619,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange upTo(char from, long to) {
|
public static LongRange upTo(char from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return LongRange.empty;
|
return LongRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -628,7 +628,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static LongRange downTo(char from, long to) {
|
public static LongRange downTo(char from, long to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new LongRange(from, to-from-1);
|
return new LongRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -653,7 +653,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange upTo(char from, char to) {
|
public static CharRange upTo(char from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return CharRange.empty;
|
return CharRange.empty;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -662,7 +662,7 @@ public class Ranges {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CharRange downTo(char from, char to) {
|
public static CharRange downTo(char from, char to) {
|
||||||
if(from > to) {
|
if (from > to) {
|
||||||
return new CharRange(from, to-from-1);
|
return new CharRange(from, to-from-1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
Reference in New Issue
Block a user