diff --git a/.idea/ant.xml b/.idea/ant.xml
index 82d39650097..544e1256edb 100644
--- a/.idea/ant.xml
+++ b/.idea/ant.xml
@@ -2,14 +2,6 @@
-
-
-
-
-
-
-
-
@@ -26,6 +18,14 @@
+
+
+
+
+
+
+
+
diff --git a/.idea/libraries/annotations.xml b/.idea/libraries/annotations.xml
new file mode 100644
index 00000000000..5183e286398
--- /dev/null
+++ b/.idea/libraries/annotations.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 8958a9581db..2df90c07743 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,7 +3,10 @@
+
+
+
diff --git a/.idea/projectCodeStyle.xml b/.idea/projectCodeStyle.xml
index 4169b3f2f33..25b91e81484 100644
--- a/.idea/projectCodeStyle.xml
+++ b/.idea/projectCodeStyle.xml
@@ -51,16 +51,6 @@
-
-
-
-
-
-
-
-
-
-
@@ -151,6 +141,17 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/.idea/runConfigurations/All_Tests.xml b/.idea/runConfigurations/All_Tests.xml
index 6ebba66deda..85e2275839b 100644
--- a/.idea/runConfigurations/All_Tests.xml
+++ b/.idea/runConfigurations/All_Tests.xml
@@ -23,10 +23,16 @@
+
+
+
+
+
+
diff --git a/compiler/backend/backend.iml b/compiler/backend/backend.iml
new file mode 100644
index 00000000000..c2cb311107b
--- /dev/null
+++ b/compiler/backend/backend.iml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/idea/src/org/jetbrains/jet/codegen/Callable.java b/compiler/backend/src/org/jetbrains/jet/codegen/Callable.java
similarity index 100%
rename from idea/src/org/jetbrains/jet/codegen/Callable.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/Callable.java
diff --git a/idea/src/org/jetbrains/jet/codegen/CallableMethod.java b/compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java
similarity index 100%
rename from idea/src/org/jetbrains/jet/codegen/CallableMethod.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/CallableMethod.java
diff --git a/idea/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
similarity index 92%
rename from idea/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
index 6c2079241e9..6ffc688431f 100644
--- a/idea/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
@@ -71,13 +71,17 @@ public abstract class ClassBodyCodegen {
}
else if (declaration instanceof JetNamedFunction) {
try {
- functionCodegen.gen((JetNamedFunction) declaration);
+ genNamedFunction((JetNamedFunction) declaration, functionCodegen);
} catch (RuntimeException e) {
throw new RuntimeException("Error generating method " + myClass.getName() + "." + declaration.getName() + " in " + context, e);
}
}
}
+ protected void genNamedFunction(JetNamedFunction declaration, FunctionCodegen functionCodegen) {
+ functionCodegen.gen(declaration);
+ }
+
private void generatePrimaryConstructorProperties(PropertyCodegen propertyCodegen) {
OwnerKind kind = context.getContextKind();
for (JetParameter p : getPrimaryConstructorParameters()) {
@@ -89,7 +93,8 @@ public abstract class ClassBodyCodegen {
propertyCodegen.generateDefaultSetter(propertyDescriptor, Opcodes.ACC_PUBLIC);
}
- if (!(kind instanceof OwnerKind.DelegateKind) && kind != OwnerKind.INTERFACE && state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
+ //noinspection ConstantConditions
+ if (!(kind instanceof OwnerKind.DelegateKind) && state.getBindingContext().get(BindingContext.BACKING_FIELD_REQUIRED, propertyDescriptor)) {
v.visitField(Opcodes.ACC_PRIVATE, p.getName(), state.getTypeMapper().mapType(propertyDescriptor.getOutType()).getDescriptor(), null, null);
}
}
diff --git a/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassCodegen.java
similarity index 51%
rename from idea/src/org/jetbrains/jet/codegen/ClassCodegen.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/ClassCodegen.java
index c7d6d88809f..60dc3bc46f0 100644
--- a/idea/src/org/jetbrains/jet/codegen/ClassCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassCodegen.java
@@ -9,6 +9,7 @@ import org.objectweb.asm.commons.InstructionAdapter;
/**
* @author max
+ * @author alex.tkachman
*/
public class ClassCodegen {
private final GenerationState state;
@@ -20,18 +21,10 @@ public class ClassCodegen {
public void generate(ClassContext parentContext, JetClassOrObject aClass) {
GenerationState.prepareAnonymousClasses((JetElement) aClass, state.getTypeMapper());
- if (aClass instanceof JetObjectDeclaration) {
- generateImplementation(parentContext, aClass, OwnerKind.IMPLEMENTATION);
- }
- else {
- generateInterface(parentContext, aClass);
- generateImplementation(parentContext, aClass, OwnerKind.IMPLEMENTATION);
- if (!ImplementationBodyCodegen.isEnum(aClass)) {
- generateImplementation(parentContext, aClass, OwnerKind.DELEGATING_IMPLEMENTATION);
- }
- }
-
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
+
+ generateImplementation(parentContext, aClass, OwnerKind.IMPLEMENTATION);
+
final ClassContext contextForInners = parentContext.intoClass(descriptor, OwnerKind.IMPLEMENTATION);
for (JetDeclaration declaration : aClass.getDeclarations()) {
if (declaration instanceof JetClass && !(declaration instanceof JetEnumEntry)) {
@@ -40,26 +33,16 @@ public class ClassCodegen {
}
}
- private void generateInterface(ClassContext parentContext, JetClassOrObject aClass) {
- ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
- final ClassVisitor visitor = state.forClassInterface(descriptor);
- new InterfaceBodyCodegen(aClass, parentContext.intoClass(descriptor, OwnerKind.INTERFACE), visitor, state).generate();
- }
-
private void generateImplementation(ClassContext parentContext, JetClassOrObject aClass, OwnerKind kind) {
ClassDescriptor descriptor = state.getBindingContext().get(BindingContext.CLASS, aClass);
- ClassVisitor v = kind == OwnerKind.IMPLEMENTATION
- ? state.forClassImplementation(descriptor)
- : state.forClassDelegatingImplementation(descriptor);
+ ClassVisitor v = state.forClassImplementation(descriptor);
new ImplementationBodyCodegen(aClass, parentContext.intoClass(descriptor, kind), v, state).generate();
+
+ if(aClass instanceof JetClass && ((JetClass)aClass).isTrait()) {
+ v = state.forTraitImplementation(descriptor);
+ new TraitImplBodyCodegen(aClass, parentContext.intoClass(descriptor, OwnerKind.TRAIT_IMPL), v, state).generate();
+ }
}
- public static void newTypeInfo(InstructionAdapter v, boolean isNullable, Type asmType) {
- v.anew(JetTypeMapper.TYPE_TYPEINFO);
- v.dup();
- v.aconst(asmType);
- v.aconst(isNullable);
- v.invokespecial("jet/typeinfo/TypeInfo", "", "(Ljava/lang/Class;Z)V");
- }
}
diff --git a/idea/src/org/jetbrains/jet/codegen/ClassContext.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassContext.java
similarity index 80%
rename from idea/src/org/jetbrains/jet/codegen/ClassContext.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/ClassContext.java
index 87e92d070f7..81d06bf4ea8 100644
--- a/idea/src/org/jetbrains/jet/codegen/ClassContext.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClassContext.java
@@ -7,10 +7,13 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
+import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.objectweb.asm.Type;
import org.objectweb.asm.commons.InstructionAdapter;
+import java.util.HashMap;
+
public class ClassContext {
public static final ClassContext STATIC = new ClassContext(null, OwnerKind.NAMESPACE, null, null, null);
private final DeclarationDescriptor contextType;
@@ -19,6 +22,8 @@ public class ClassContext {
private final ClassContext parentContext;
private final ClosureCodegen closure;
private boolean thisWasUsed = false;
+
+ HashMap typeInfoConstants;
public ClassContext(DeclarationDescriptor contextType, OwnerKind contextKind, StackValue thisExpression, ClassContext parentContext, ClosureCodegen closureCodegen) {
this.contextType = contextType;
@@ -32,12 +37,19 @@ public class ClassContext {
return contextType;
}
+ public String getNamespaceClassName() {
+ if(parentContext != STATIC)
+ return parentContext.getNamespaceClassName();
+
+ return NamespaceCodegen.getJVMClassName(contextType.getName());
+ }
+
public OwnerKind getContextKind() {
return contextKind;
}
public StackValue getThisExpression() {
- if (parentContext == null) return null;
+ if (parentContext == null) return StackValue.none();
thisWasUsed = true;
if (thisExpression != null) return thisExpression;
@@ -50,14 +62,7 @@ public class ClassContext {
public ClassContext intoClass(ClassDescriptor descriptor, OwnerKind kind) {
final StackValue thisValue;
- if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
- thisValue = StackValue.instanceField(JetTypeMapper.jetInterfaceType(descriptor),
- JetTypeMapper.jetDelegatingImplementationType(descriptor).getInternalName(),
- "$this");
- }
- else {
- thisValue = StackValue.local(0, JetTypeMapper.TYPE_OBJECT);
- }
+ thisValue = StackValue.local(0, JetTypeMapper.TYPE_OBJECT);
return new ClassContext(descriptor, kind, thisValue, this, null);
}
@@ -68,7 +73,7 @@ public class ClassContext {
thisIdx++;
}
- final boolean hasReceiver = descriptor.getReceiverType() != null;
+ final boolean hasReceiver = descriptor.getReceiver().exists();
if (hasReceiver) {
thisIdx++;
}
@@ -98,12 +103,12 @@ public class ClassContext {
return frameMap;
}
- private JetType receiverType() {
- return contextType instanceof FunctionDescriptor ? ((FunctionDescriptor) contextType).getReceiverType() : null;
+ private ReceiverDescriptor receiver() {
+ return contextType instanceof FunctionDescriptor ? ((FunctionDescriptor) contextType).getReceiver() : ReceiverDescriptor.NO_RECEIVER;
}
private boolean hasReceiver() {
- return receiverType() != null;
+ return receiver().exists();
}
public ClassContext getParentContext() {
@@ -150,7 +155,7 @@ public class ClassContext {
public Type enclosingClassType(JetTypeMapper mapper) {
DeclarationDescriptor descriptor = getContextDescriptor();
if (descriptor instanceof ClassDescriptor) {
- return Type.getObjectType(mapper.jvmName((ClassDescriptor) descriptor, OwnerKind.INTERFACE));
+ return Type.getObjectType(mapper.jvmName((ClassDescriptor) descriptor, OwnerKind.IMPLEMENTATION));
}
if (descriptor instanceof NamespaceDescriptor) {
@@ -164,4 +169,19 @@ public class ClassContext {
final ClassContext parent = getParentContext();
return parent != null ? parent.enclosingClassType(mapper) : null;
}
+
+ public int getTypeInfoConstantIndex(JetType type) {
+ if(parentContext != STATIC)
+ return parentContext.getTypeInfoConstantIndex(type);
+
+ if(typeInfoConstants == null)
+ typeInfoConstants = new HashMap();
+
+ Integer index = typeInfoConstants.get(type);
+ if(index == null) {
+ index = typeInfoConstants.size();
+ typeInfoConstants.put(type, index);
+ }
+ return index;
+ }
}
diff --git a/idea/src/org/jetbrains/jet/codegen/ClassFileFactory.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClassFileFactory.java
similarity index 100%
rename from idea/src/org/jetbrains/jet/codegen/ClassFileFactory.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/ClassFileFactory.java
diff --git a/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java
similarity index 96%
rename from idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java
index 4de5e2ff34a..864111bee96 100644
--- a/idea/src/org/jetbrains/jet/codegen/ClosureCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java
@@ -11,6 +11,7 @@ import org.jetbrains.jet.lang.descriptors.VariableDescriptor;
import org.jetbrains.jet.lang.psi.JetFunctionLiteral;
import org.jetbrains.jet.lang.psi.JetFunctionLiteralExpression;
import org.jetbrains.jet.lang.resolve.BindingContext;
+import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
import org.jetbrains.jet.lang.types.JetType;
import org.objectweb.asm.ClassVisitor;
import org.objectweb.asm.MethodVisitor;
@@ -41,7 +42,7 @@ public class ClosureCodegen {
}
public static Method erasedInvokeSignature(FunctionDescriptor fd) {
- boolean isExtensionFunction = fd.getReceiverType() != null;
+ boolean isExtensionFunction = fd.getReceiver().exists();
int paramCount = fd.getValueParameters().size();
if (isExtensionFunction) {
paramCount++;
@@ -150,11 +151,11 @@ public class ClosureCodegen {
iv.load(0, Type.getObjectType(className));
- final JetType receiverType = funDescriptor.getReceiverType();
+ final ReceiverDescriptor receiver = funDescriptor.getReceiver();
int count = 1;
- if (receiverType != null) {
+ if (receiver.exists()) {
StackValue.local(count, JetTypeMapper.TYPE_OBJECT).put(JetTypeMapper.TYPE_OBJECT, iv);
- StackValue.onStack(JetTypeMapper.TYPE_OBJECT).upcast(state.getTypeMapper().mapType(receiverType), iv);
+ StackValue.onStack(JetTypeMapper.TYPE_OBJECT).upcast(state.getTypeMapper().mapType(receiver.getType()), iv);
count++;
}
@@ -228,7 +229,7 @@ public class ClosureCodegen {
public static String getInternalClassName(FunctionDescriptor descriptor) {
final int paramCount = descriptor.getValueParameters().size();
- if (descriptor.getReceiverType() != null) {
+ if (descriptor.getReceiver().exists()) {
return "jet/ExtensionFunction" + paramCount;
}
else {
@@ -249,7 +250,7 @@ public class ClosureCodegen {
Method descriptor = erasedInvokeSignature(fd);
String owner = getInternalClassName(fd);
final CallableMethod result = new CallableMethod(owner, descriptor, Opcodes.INVOKEVIRTUAL, Arrays.asList(descriptor.getArgumentTypes()));
- if (fd.getReceiverType() != null) {
+ if (fd.getReceiver().exists()) {
result.setNeedsReceiver(null);
}
result.requestGenerateCallee(Type.getObjectType(getInternalClassName(fd)));
diff --git a/idea/src/org/jetbrains/jet/codegen/CodeChunk.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodeChunk.java
similarity index 100%
rename from idea/src/org/jetbrains/jet/codegen/CodeChunk.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/CodeChunk.java
diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java
new file mode 100644
index 00000000000..3e3fe413c90
--- /dev/null
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/CodegenUtil.java
@@ -0,0 +1,105 @@
+package org.jetbrains.jet.codegen;
+
+import com.intellij.psi.PsiClass;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
+import org.jetbrains.jet.lang.descriptors.ClassKind;
+import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
+import org.jetbrains.jet.lang.psi.JetClass;
+import org.jetbrains.jet.lang.resolve.BindingContext;
+import org.jetbrains.jet.lang.types.JetType;
+import org.jetbrains.jet.lang.types.TypeProjection;
+import org.objectweb.asm.Type;
+
+/**
+ * @author abreslav
+ * @author alex.tkachman
+ */
+public class CodegenUtil {
+ private CodegenUtil() {
+ }
+
+ public static boolean isInterface(DeclarationDescriptor descriptor) {
+ return descriptor instanceof ClassDescriptor && ((ClassDescriptor)descriptor).getKind() == ClassKind.TRAIT;
+ }
+
+ public static boolean isInterface(JetType type) {
+ return isInterface(type.getConstructor().getDeclarationDescriptor());
+ }
+
+ public static boolean isClassObject(DeclarationDescriptor descriptor) {
+ if(descriptor instanceof ClassDescriptor) {
+ ClassDescriptor classDescriptor = (ClassDescriptor) descriptor;
+ if(classDescriptor.getKind() == ClassKind.OBJECT) {
+ if(classDescriptor.getContainingDeclaration() instanceof ClassDescriptor) {
+ ClassDescriptor containingDeclaration = (ClassDescriptor) classDescriptor.getContainingDeclaration();
+ if(classDescriptor.getDefaultType().equals(containingDeclaration.getClassObjectType())) {
+ return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ public static boolean hasThis0(ClassDescriptor classDescriptor) {
+ return getOuterClassDescriptor(classDescriptor) != null && !isClassObject(classDescriptor);
+ }
+
+ public static ClassDescriptor getOuterClassDescriptor(DeclarationDescriptor descriptor) {
+ DeclarationDescriptor outerDescriptor = descriptor.getContainingDeclaration();
+ while(outerDescriptor != null) {
+ if(outerDescriptor instanceof ClassDescriptor)
+ break;
+
+ outerDescriptor = outerDescriptor.getContainingDeclaration();
+ }
+ return (ClassDescriptor) outerDescriptor;
+ }
+
+ public static boolean hasOuterTypeInfo(ClassDescriptor descriptor) {
+ ClassDescriptor outerClassDescriptor = getOuterClassDescriptor(descriptor);
+ if(outerClassDescriptor == null)
+ return false;
+
+ if(outerClassDescriptor.getTypeConstructor().getParameters().size() > 0)
+ return true;
+
+ return hasOuterTypeInfo(outerClassDescriptor);
+ }
+
+ public static boolean hasTypeInfoField(JetType type) {
+ if(type.getConstructor().getParameters().size() > 0)
+ return true;
+
+ for (JetType jetType : type.getConstructor().getSupertypes()) {
+ if(hasTypeInfoField(jetType))
+ return true;
+ }
+
+ ClassDescriptor outerClassDescriptor = getOuterClassDescriptor(type.getConstructor().getDeclarationDescriptor());
+ if(outerClassDescriptor == null)
+ return false;
+
+ return hasTypeInfoField(outerClassDescriptor.getDefaultType());
+ }
+
+ public static boolean hasDerivedTypeInfoField(JetType type, boolean exceptOwn) {
+ if(!exceptOwn) {
+ if(!isInterface(type))
+ if(hasTypeInfoField(type))
+ return true;
+ }
+
+ for (JetType jetType : type.getConstructor().getSupertypes()) {
+ if(hasDerivedTypeInfoField(jetType, false))
+ return true;
+ }
+
+ return false;
+ }
+
+ public static Type arrayElementType(Type type) {
+ return Type.getType(type.getDescriptor().substring(1));
+ }
+}
diff --git a/idea/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java b/compiler/backend/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java
similarity index 79%
rename from idea/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java
index 4ae7b71fd88..17a134befac 100644
--- a/idea/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ConstructorFrameMap.java
@@ -14,22 +14,16 @@ import java.util.List;
*/
public class ConstructorFrameMap extends FrameMap {
private int myOuterThisIndex = -1;
- private int myDelegateThisIndex = -1;
private int myFirstTypeParameter = -1;
private int myTypeParameterCount = 0;
- public ConstructorFrameMap(CallableMethod callableMethod, @Nullable ConstructorDescriptor descriptor, OwnerKind kind) {
+ public ConstructorFrameMap(CallableMethod callableMethod, @Nullable ConstructorDescriptor descriptor, ClassDescriptor classDescriptor, OwnerKind kind) {
enterTemp(); // this
- ClassDescriptor classDescriptor = null;
if (descriptor != null) {
- classDescriptor = descriptor.getContainingDeclaration();
- if (classDescriptor.getContainingDeclaration() instanceof ClassDescriptor) {
+ if (CodegenUtil.hasThis0(classDescriptor)) {
myOuterThisIndex = enterTemp(); // outer class instance
}
}
- if (kind == OwnerKind.DELEGATING_IMPLEMENTATION) {
- myDelegateThisIndex = enterTemp(); // $this
- }
List explicitArgTypes = callableMethod.getValueParameterTypes();
@@ -41,7 +35,6 @@ public class ConstructorFrameMap extends FrameMap {
enter(parameter, explicitArgTypes.get(i).getSize());
}
-
if (classDescriptor != null) {
myTypeParameterCount = classDescriptor.getTypeConstructor().getParameters().size();
if (kind == OwnerKind.IMPLEMENTATION) {
@@ -59,10 +52,6 @@ public class ConstructorFrameMap extends FrameMap {
return myOuterThisIndex;
}
- public int getDelegateThisIndex() {
- return myDelegateThisIndex;
- }
-
public int getFirstTypeParameter() {
return myFirstTypeParameter;
}
diff --git a/idea/src/org/jetbrains/jet/codegen/EnclosedValueDescriptor.java b/compiler/backend/src/org/jetbrains/jet/codegen/EnclosedValueDescriptor.java
similarity index 100%
rename from idea/src/org/jetbrains/jet/codegen/EnclosedValueDescriptor.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/EnclosedValueDescriptor.java
diff --git a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
similarity index 57%
rename from idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
rename to compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
index 99783414912..91c126fd77d 100644
--- a/idea/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
+++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
@@ -1,24 +1,21 @@
package org.jetbrains.jet.codegen;
import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.project.Project;
import com.intellij.psi.*;
-import com.intellij.psi.search.ProjectScope;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiTreeUtil;
import gnu.trove.THashSet;
-import jet.Range;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethod;
import org.jetbrains.jet.codegen.intrinsics.IntrinsicMethods;
import org.jetbrains.jet.lang.descriptors.*;
+import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.resolve.BindingContextUtils;
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
-import org.jetbrains.jet.lang.types.JetStandardClasses;
-import org.jetbrains.jet.lang.types.JetType;
-import org.jetbrains.jet.lang.types.TypeProjection;
+import org.jetbrains.jet.lang.resolve.java.JavaClassDescriptor;
+import org.jetbrains.jet.lang.types.*;
import org.jetbrains.jet.lexer.JetTokens;
import org.objectweb.asm.Label;
import org.objectweb.asm.MethodVisitor;
@@ -32,49 +29,26 @@ import java.util.*;
/**
* @author max
* @author yole
+ * @author alex.tkachman
*/
-public class ExpressionCodegen extends JetVisitorVoid {
+public class ExpressionCodegen extends JetVisitor {
private static final String CLASS_OBJECT = "java/lang/Object";
private static final String CLASS_STRING = "java/lang/String";
public static final String CLASS_STRING_BUILDER = "java/lang/StringBuilder";
private static final String CLASS_COMPARABLE = "java/lang/Comparable";
- private static final String CLASS_ITERABLE = "java/lang/Iterable";
- private static final String CLASS_ITERATOR = "java/util/Iterator";
- private static final String CLASS_RANGE = "jet/Range";
private static final String CLASS_NO_PATTERN_MATCHED_EXCEPTION = "jet/NoPatternMatchedException";
private static final String CLASS_TYPE_CAST_EXCEPTION = "jet/TypeCastException";
- private static final String ITERABLE_ITERATOR_DESCRIPTOR = "()Ljava/util/Iterator;";
- private static final String ITERATOR_HASNEXT_DESCRIPTOR = "()Z";
- private static final String ITERATOR_NEXT_DESCRIPTOR = "()Ljava/lang/Object;";
-
private static final Type OBJECT_TYPE = Type.getType(Object.class);
- private static final Type INTEGER_TYPE = Type.getType(Integer.class);
- private static final Type ITERATOR_TYPE = Type.getType(Iterator.class);
private static final Type THROWABLE_TYPE = Type.getType(Throwable.class);
private static final Type STRING_TYPE = Type.getObjectType(CLASS_STRING);
- private static final Type RANGE_TYPE = Type.getType(Range.class);
-
private final Stack