formatting

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