better error reporting
This commit is contained in:
Generated
+1
@@ -12,6 +12,7 @@
|
|||||||
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" />
|
<module fileurl="file://$PROJECT_DIR$/grammar/grammar.iml" filepath="$PROJECT_DIR$/grammar/grammar.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" />
|
<module fileurl="file://$PROJECT_DIR$/idea/idea.iml" filepath="$PROJECT_DIR$/idea/idea.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/stdlib/stdlib.iml" />
|
<module fileurl="file://$PROJECT_DIR$/stdlib/stdlib.iml" filepath="$PROJECT_DIR$/stdlib/stdlib.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/testlib/testlib.iml" filepath="$PROJECT_DIR$/testlib/testlib.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -126,9 +126,7 @@ public abstract class ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mv.visitInsn(Opcodes.RETURN);
|
mv.visitInsn(Opcodes.RETURN);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(v, "static initializer", myClass);
|
||||||
|
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,8 +147,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
|
|
||||||
mv.visitLabel(ret);
|
mv.visitLabel(ret);
|
||||||
mv.visitInsn(ARETURN);
|
mv.visitInsn(ARETURN);
|
||||||
mv.visitMaxs(0,0);
|
FunctionCodegen.endVisit(mv, "$getInstance", fun);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,8 +204,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
|
|
||||||
iv.areturn(JetTypeMapper.TYPE_OBJECT);
|
iv.areturn(JetTypeMapper.TYPE_OBJECT);
|
||||||
|
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(mv, "bridge", fun);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,8 +284,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
|
|||||||
|
|
||||||
iv.visitInsn(RETURN);
|
iv.visitInsn(RETURN);
|
||||||
|
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(iv, "constructor", fun);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
return constructor;
|
return constructor;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
package org.jetbrains.jet.codegen;
|
||||||
|
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetElement;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author alex.tkachman
|
||||||
|
*/
|
||||||
|
public class CompilationException extends RuntimeException {
|
||||||
|
private PsiElement element;
|
||||||
|
|
||||||
|
CompilationException(String message, Throwable cause, PsiElement element) {
|
||||||
|
super(message, cause);
|
||||||
|
this.element = element;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PsiElement getElement() {
|
||||||
|
return element;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -130,7 +130,15 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
public StackValue genQualified(StackValue receiver, JetElement selector) {
|
public StackValue genQualified(StackValue receiver, JetElement selector) {
|
||||||
markLineNumber(selector);
|
markLineNumber(selector);
|
||||||
return selector.accept(this, receiver);
|
try {
|
||||||
|
return selector.accept(this, receiver);
|
||||||
|
}
|
||||||
|
catch(CompilationException e) {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
catch (Throwable error) {
|
||||||
|
throw new CompilationException(error.getMessage(), error, selector);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StackValue gen(JetElement expr) {
|
public StackValue gen(JetElement expr) {
|
||||||
@@ -204,7 +212,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
JetExpression elseExpression = expression.getElse();
|
JetExpression elseExpression = expression.getElse();
|
||||||
|
|
||||||
if (thenExpression == null && elseExpression == null) {
|
if (thenExpression == null && elseExpression == null) {
|
||||||
throw new CompilationException();
|
throw new CompilationException("Both brunches of if/else are null", null, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isEmptyExpression(thenExpression)) {
|
if (isEmptyExpression(thenExpression)) {
|
||||||
@@ -1126,7 +1134,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
|
|
||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
||||||
if(resolvedCall == null) {
|
if(resolvedCall == null) {
|
||||||
throw new CompilationException("Cannot resolve: " + callee.getText());
|
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
||||||
}
|
}
|
||||||
receiver = StackValue.receiver(resolvedCall, receiver, this, null);
|
receiver = StackValue.receiver(resolvedCall, receiver, this, null);
|
||||||
|
|
||||||
@@ -2074,7 +2082,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
ResolvedCall<? extends CallableDescriptor> resolvedCall = bindingContext.get(BindingContext.RESOLVED_CALL, callee);
|
||||||
if(resolvedCall == null) {
|
if(resolvedCall == null) {
|
||||||
assert callee != null;
|
assert callee != null;
|
||||||
throw new CompilationException("Cannot resolve: " + callee.getText());
|
throw new CompilationException("Cannot resolve: " + callee.getText(), null, expression);
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionDescriptor descriptor = (FunctionDescriptor) resolvedCall.getResultingDescriptor();
|
FunctionDescriptor descriptor = (FunctionDescriptor) resolvedCall.getResultingDescriptor();
|
||||||
@@ -2098,7 +2106,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (args.size() != 1) {
|
if (args.size() != 1) {
|
||||||
throw new CompilationException("primitive array constructor requires one argument");
|
throw new CompilationException("primitive array constructor requires one argument", null, expression);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2784,15 +2792,6 @@ If finally block is present, its last expression is the value of try expression.
|
|||||||
v.athrow();
|
v.athrow();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CompilationException extends RuntimeException {
|
|
||||||
private CompilationException() {
|
|
||||||
}
|
|
||||||
|
|
||||||
private CompilationException(String message) {
|
|
||||||
super(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return context.getContextDescriptor().toString();
|
return context.getContextDescriptor().toString();
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ public class FunctionCodegen {
|
|||||||
k += type.getSize();
|
k += type.getSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
mv.visitMaxs(0, 0);
|
endVisit(mv, null, fun);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
|
|
||||||
generateBridgeIfNeeded(owner, state, v, jvmSignature.getAsmMethod(), functionDescriptor, kind);
|
generateBridgeIfNeeded(owner, state, v, jvmSignature.getAsmMethod(), functionDescriptor, kind);
|
||||||
@@ -233,6 +233,16 @@ public class FunctionCodegen {
|
|||||||
generateDefaultIfNeeded(context, state, v, jvmSignature.getAsmMethod(), functionDescriptor, kind);
|
generateDefaultIfNeeded(context, state, v, jvmSignature.getAsmMethod(), functionDescriptor, kind);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void endVisit(MethodVisitor mv, String description, PsiElement method) {
|
||||||
|
try {
|
||||||
|
mv.visitMaxs(0, 0);
|
||||||
|
}
|
||||||
|
catch (Throwable t) {
|
||||||
|
throw new CompilationException("wrong code generated" + (description != null ? " for " + description : "") + t.getClass().getName() + " " + t.getMessage(), t, method);
|
||||||
|
}
|
||||||
|
mv.visitEnd();
|
||||||
|
}
|
||||||
|
|
||||||
static void generateBridgeIfNeeded(CodegenContext owner, GenerationState state, ClassBuilder v, Method jvmSignature, FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
static void generateBridgeIfNeeded(CodegenContext owner, GenerationState state, ClassBuilder v, Method jvmSignature, FunctionDescriptor functionDescriptor, OwnerKind kind) {
|
||||||
Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenDescriptors();
|
Set<? extends FunctionDescriptor> overriddenFunctions = functionDescriptor.getOverriddenDescriptors();
|
||||||
if(kind != OwnerKind.TRAIT_IMPL) {
|
if(kind != OwnerKind.TRAIT_IMPL) {
|
||||||
@@ -390,7 +400,7 @@ public class FunctionCodegen {
|
|||||||
|
|
||||||
iv.areturn(jvmSignature.getReturnType());
|
iv.areturn(jvmSignature.getReturnType());
|
||||||
|
|
||||||
mv.visitMaxs(0, 0);
|
endVisit(mv, "default method", state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, functionDescriptor));
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,7 +436,7 @@ public class FunctionCodegen {
|
|||||||
if(jvmSignature.getReturnType() == Type.VOID_TYPE)
|
if(jvmSignature.getReturnType() == Type.VOID_TYPE)
|
||||||
iv.aconst(null);
|
iv.aconst(null);
|
||||||
iv.areturn(overriden.getReturnType());
|
iv.areturn(overriden.getReturnType());
|
||||||
mv.visitMaxs(0, 0);
|
endVisit(mv, "bridge method", state.getBindingContext().get(BindingContext.DESCRIPTOR_TO_DECLARATION, functionDescriptor));
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,8 +198,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||||
|
|
||||||
iv.areturn(method.getReturnType());
|
iv.areturn(method.getReturnType());
|
||||||
mv.visitMaxs(0,0);
|
FunctionCodegen.endVisit(iv, "accessor", null);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(entry.getValue() instanceof PropertyDescriptor) {
|
else if(entry.getValue() instanceof PropertyDescriptor) {
|
||||||
@@ -222,8 +221,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||||
|
|
||||||
iv.areturn(method.getReturnType());
|
iv.areturn(method.getReturnType());
|
||||||
mv.visitMaxs(0,0);
|
FunctionCodegen.endVisit(iv, "accessor", null);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
method = typeMapper.mapSetterSignature(bridge, OwnerKind.IMPLEMENTATION).getAsmMethod();
|
method = typeMapper.mapSetterSignature(bridge, OwnerKind.IMPLEMENTATION).getAsmMethod();
|
||||||
@@ -248,8 +246,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
iv.invokespecial(typeMapper.getOwner(original, OwnerKind.IMPLEMENTATION), originalMethod.getName(), originalMethod.getDescriptor());
|
||||||
|
|
||||||
iv.areturn(method.getReturnType());
|
iv.areturn(method.getReturnType());
|
||||||
mv.visitMaxs(0,0);
|
FunctionCodegen.endVisit(iv, "accessor", null);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -465,8 +462,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
outer.visitVarInsn(Opcodes.ALOAD, 0);
|
outer.visitVarInsn(Opcodes.ALOAD, 0);
|
||||||
outer.visitFieldInsn(Opcodes.GETFIELD, classname, "this$0", outerType.getDescriptor());
|
outer.visitFieldInsn(Opcodes.GETFIELD, classname, "this$0", outerType.getDescriptor());
|
||||||
outer.visitInsn(Opcodes.ARETURN);
|
outer.visitInsn(Opcodes.ARETURN);
|
||||||
outer.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(outer, "getOuterObject", myClass);
|
||||||
outer.visitEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType()) && kind == OwnerKind.IMPLEMENTATION) {
|
if (CodegenUtil.requireTypeInfoConstructorArg(descriptor.getDefaultType()) && kind == OwnerKind.IMPLEMENTATION) {
|
||||||
@@ -518,8 +514,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
generateTraitMethods(codegen);
|
generateTraitMethods(codegen);
|
||||||
|
|
||||||
mv.visitInsn(Opcodes.RETURN);
|
mv.visitInsn(Opcodes.RETURN);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(mv, "constructor", myClass);
|
||||||
mv.visitEnd();
|
|
||||||
|
|
||||||
FunctionCodegen.generateDefaultIfNeeded(constructorContext, state, v, constructorMethod, constructorDescriptor, OwnerKind.IMPLEMENTATION);
|
FunctionCodegen.generateDefaultIfNeeded(constructorContext, state, v, constructorMethod, constructorDescriptor, OwnerKind.IMPLEMENTATION);
|
||||||
}
|
}
|
||||||
@@ -572,8 +567,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.checkcast(function.getReturnType());
|
iv.checkcast(function.getReturnType());
|
||||||
}
|
}
|
||||||
iv.areturn(function.getReturnType());
|
iv.areturn(function.getReturnType());
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(iv, "trait method", bindingContext.get(BindingContext.DESCRIPTOR_TO_DECLARATION, fun));
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FunctionCodegen.generateBridgeIfNeeded(context, state, v, function, fun, kind);
|
FunctionCodegen.generateBridgeIfNeeded(context, state, v, function, fun, kind);
|
||||||
@@ -708,8 +702,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mv.visitInsn(Opcodes.RETURN);
|
mv.visitInsn(Opcodes.RETURN);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(mv, "constructor", null);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -821,8 +814,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
iv.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||||
iv.getfield(owner, "$typeInfo", "Ljet/typeinfo/TypeInfo;");
|
iv.getfield(owner, "$typeInfo", "Ljet/typeinfo/TypeInfo;");
|
||||||
iv.areturn(JetTypeMapper.TYPE_TYPEINFO);
|
iv.areturn(JetTypeMapper.TYPE_TYPEINFO);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(iv, "getTypeInfo", myClass);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mv = v.newMethod(myClass, Opcodes.ACC_PROTECTED | Opcodes.ACC_FINAL, "$setTypeInfo", "(Ljet/typeinfo/TypeInfo;)V", null, null);
|
mv = v.newMethod(myClass, Opcodes.ACC_PROTECTED | Opcodes.ACC_FINAL, "$setTypeInfo", "(Ljet/typeinfo/TypeInfo;)V", null, null);
|
||||||
@@ -834,8 +826,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
iv.load(1, JetTypeMapper.TYPE_OBJECT);
|
iv.load(1, JetTypeMapper.TYPE_OBJECT);
|
||||||
iv.putfield(owner, "$typeInfo", "Ljet/typeinfo/TypeInfo;");
|
iv.putfield(owner, "$typeInfo", "Ljet/typeinfo/TypeInfo;");
|
||||||
mv.visitInsn(Opcodes.RETURN);
|
mv.visitInsn(Opcodes.RETURN);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(iv, "$setTypeInfo", myClass);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -853,8 +844,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
|||||||
String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName();
|
String owner = typeMapper.mapType(descriptor.getDefaultType(), OwnerKind.IMPLEMENTATION).getInternalName();
|
||||||
v.getstatic(owner, "$staticTypeInfo", "Ljet/typeinfo/TypeInfo;");
|
v.getstatic(owner, "$staticTypeInfo", "Ljet/typeinfo/TypeInfo;");
|
||||||
v.areturn(JetTypeMapper.TYPE_TYPEINFO);
|
v.areturn(JetTypeMapper.TYPE_TYPEINFO);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(v, "getTypeInfo", myClass);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -62,8 +62,11 @@ public class NamespaceCodegen {
|
|||||||
else if (declaration instanceof JetNamedFunction) {
|
else if (declaration instanceof JetNamedFunction) {
|
||||||
try {
|
try {
|
||||||
functionCodegen.gen((JetNamedFunction) declaration);
|
functionCodegen.gen((JetNamedFunction) declaration);
|
||||||
} catch (Exception e) {
|
} catch (CompilationException e) {
|
||||||
throw new RuntimeException("Failed to generate function " + declaration.getName(), e);
|
throw e;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
throw new CompilationException("Failed to generate function " + declaration.getName(), e, declaration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (declaration instanceof JetClassOrObject) {
|
else if (declaration instanceof JetClassOrObject) {
|
||||||
@@ -107,7 +110,7 @@ public class NamespaceCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mv.visitInsn(RETURN);
|
mv.visitInsn(RETURN);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(mv, "static initializer for namespace", namespace);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,8 +137,7 @@ public class NamespaceCodegen {
|
|||||||
v.visitFieldInsn(PUTSTATIC, jvmClassName, fieldName, "Ljet/typeinfo/TypeInfo;");
|
v.visitFieldInsn(PUTSTATIC, jvmClassName, fieldName, "Ljet/typeinfo/TypeInfo;");
|
||||||
v.visitLabel(end);
|
v.visitLabel(end);
|
||||||
v.visitInsn(ARETURN);
|
v.visitInsn(ARETURN);
|
||||||
v.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(v, "type info method", namespace);
|
||||||
v.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -154,8 +154,7 @@ public class PropertyCodegen {
|
|||||||
type.getDescriptor());
|
type.getDescriptor());
|
||||||
}
|
}
|
||||||
iv.areturn(type);
|
iv.areturn(type);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(mv, "getter", origin);
|
||||||
mv.visitEnd();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,7 +206,7 @@ public class PropertyCodegen {
|
|||||||
}
|
}
|
||||||
|
|
||||||
iv.visitInsn(Opcodes.RETURN);
|
iv.visitInsn(Opcodes.RETURN);
|
||||||
mv.visitMaxs(0, 0);
|
FunctionCodegen.endVisit(mv, "setter", origin);
|
||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ import com.intellij.psi.PsiFile;
|
|||||||
import com.intellij.psi.PsiManager;
|
import com.intellij.psi.PsiManager;
|
||||||
import com.intellij.util.Chunk;
|
import com.intellij.util.Chunk;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.jet.codegen.ClassBuilderFactory;
|
import org.jetbrains.jet.codegen.*;
|
||||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
|
||||||
import org.jetbrains.jet.codegen.CompilationErrorHandler;
|
|
||||||
import org.jetbrains.jet.codegen.GenerationState;
|
|
||||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||||
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
@@ -102,7 +99,12 @@ public class JetCompiler implements TranslatingCompiler {
|
|||||||
generationState.compileCorrectNamespaces(bindingContext, namespaces, new CompilationErrorHandler() {
|
generationState.compileCorrectNamespaces(bindingContext, namespaces, new CompilationErrorHandler() {
|
||||||
@Override
|
@Override
|
||||||
public void reportException(Throwable exception, String fileUrl) {
|
public void reportException(Throwable exception, String fileUrl) {
|
||||||
compileContext.addMessage(CompilerMessageCategory.WARNING, exception.getClass().getCanonicalName() + ": " + exception.getMessage(), fileUrl, 0, 0);
|
if(exception instanceof CompilationException) {
|
||||||
|
report((CompilationException) exception, compileContext);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
compileContext.addMessage(CompilerMessageCategory.ERROR, exception.getClass().getCanonicalName() + ": " + exception.getMessage(), fileUrl, 0, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
///////////
|
///////////
|
||||||
@@ -175,6 +177,29 @@ public class JetCompiler implements TranslatingCompiler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void report(CompilationException diagnostic, CompileContext compileContext) {
|
||||||
|
PsiFile psiFile = diagnostic.getElement().getContainingFile();
|
||||||
|
TextRange textRange = diagnostic.getElement().getTextRange();
|
||||||
|
Document document = psiFile.getViewProvider().getDocument();
|
||||||
|
int line;
|
||||||
|
int col;
|
||||||
|
if (document != null) {
|
||||||
|
line = document.getLineNumber(textRange.getStartOffset());
|
||||||
|
col = textRange.getStartOffset() - document.getLineStartOffset(line) + 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
line = -1;
|
||||||
|
col = -1;
|
||||||
|
}
|
||||||
|
VirtualFile virtualFile = psiFile.getVirtualFile();
|
||||||
|
if (virtualFile == null) {
|
||||||
|
compileContext.addMessage(ERROR, "[Internal Error] No virtual file for PsiFile. Diagnostic: " + diagnostic.getMessage(), "", -1, -1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
compileContext.addMessage(ERROR, diagnostic.getMessage(), virtualFile.getUrl(), line + 1, col);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// private static class ModuleCompileState {
|
// private static class ModuleCompileState {
|
||||||
// private final GenerationState state;
|
// private final GenerationState state;
|
||||||
// private final CompileContext compileContext;
|
// private final CompileContext compileContext;
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,6 @@
|
|||||||
</content>
|
</content>
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module" module-name="Stdlib" exported="" />
|
|
||||||
<orderEntry type="module-library" exported="">
|
<orderEntry type="module-library" exported="">
|
||||||
<library>
|
<library>
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
@@ -18,6 +17,7 @@
|
|||||||
<SOURCES />
|
<SOURCES />
|
||||||
</library>
|
</library>
|
||||||
</orderEntry>
|
</orderEntry>
|
||||||
|
<orderEntry type="module" module-name="stdlib" exported="" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user