Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
78a28456
K
kotlin
项目概览
硅谷海盗
/
kotlin
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
kotlin
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
78a28456
编写于
12月 20, 2011
作者:
A
Alex Tkachman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
better error reporting
上级
50400fd7
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
101 addition
and
60 deletion
+101
-60
.idea/modules.xml
.idea/modules.xml
+1
-0
compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
...ckend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
+1
-3
compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java
...backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java
+3
-6
compiler/backend/src/org/jetbrains/jet/codegen/CompilationException.java
...d/src/org/jetbrains/jet/codegen/CompilationException.java
+20
-0
compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
...kend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
+13
-14
compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
...ackend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
+13
-3
compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java
.../org/jetbrains/jet/codegen/ImplementationBodyCodegen.java
+10
-20
compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
...ckend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
+7
-5
compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
...ackend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
+2
-3
idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java
idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java
+30
-5
testlib/testlib.iml
testlib/testlib.iml
+1
-1
未找到文件。
.idea/modules.xml
浏览文件 @
78a28456
...
@@ -12,6 +12,7 @@
...
@@ -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>
...
...
compiler/backend/src/org/jetbrains/jet/codegen/ClassBodyCodegen.java
浏览文件 @
78a28456
...
@@ -126,9 +126,7 @@ public abstract class ClassBodyCodegen {
...
@@ -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
();
}
}
}
}
}
}
...
...
compiler/backend/src/org/jetbrains/jet/codegen/ClosureCodegen.java
浏览文件 @
78a28456
...
@@ -147,8 +147,7 @@ public class ClosureCodegen extends ObjectOrClosureCodegen {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
;
}
}
...
...
compiler/backend/src/org/jetbrains/jet/codegen/CompilationException.java
0 → 100644
浏览文件 @
78a28456
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
;
}
}
compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
浏览文件 @
78a28456
...
@@ -130,7 +130,15 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
...
@@ -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> {
...
@@ -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> {
...
@@ -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> {
...
@@ -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> {
...
@@ -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.
...
@@ -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
();
...
...
compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
浏览文件 @
78a28456
...
@@ -223,7 +223,7 @@ public class FunctionCodegen {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
();
}
}
}
}
...
...
compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java
浏览文件 @
78a28456
...
@@ -198,8 +198,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
();
}
}
}
}
...
...
compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
浏览文件 @
78a28456
...
@@ -62,8 +62,11 @@ public class NamespaceCodegen {
...
@@ -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 {
...
@@ -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 {
...
@@ -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
();
}
}
}
}
}
}
...
...
compiler/backend/src/org/jetbrains/jet/codegen/PropertyCodegen.java
浏览文件 @
78a28456
...
@@ -154,8 +154,7 @@ public class PropertyCodegen {
...
@@ -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 {
...
@@ -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
();
}
}
}
}
...
...
idea/src/org/jetbrains/jet/plugin/compiler/JetCompiler.java
浏览文件 @
78a28456
...
@@ -16,10 +16,7 @@ import com.intellij.psi.PsiFile;
...
@@ -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 {
...
@@ -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 {
...
@@ -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;
...
...
testlib/testlib.iml
浏览文件 @
78a28456
...
@@ -8,7 +8,6 @@
...
@@ -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 @@
...
@@ -18,6 +17,7 @@
<SOURCES
/>
<SOURCES
/>
</library>
</library>
</orderEntry>
</orderEntry>
<orderEntry
type=
"module"
module-name=
"stdlib"
exported=
""
/>
</component>
</component>
</module>
</module>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录