Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
391da867
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,发现更多精彩内容 >>
提交
391da867
编写于
4月 15, 2011
作者:
M
Maxim Shafirov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
latest work on class codegen
上级
5d34c9ba
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
49 addition
and
28 deletion
+49
-28
idea/src/org/jetbrains/jet/codegen/ClassCodegen.java
idea/src/org/jetbrains/jet/codegen/ClassCodegen.java
+14
-16
idea/src/org/jetbrains/jet/codegen/Codegens.java
idea/src/org/jetbrains/jet/codegen/Codegens.java
+13
-0
idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java
idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java
+10
-2
idea/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
idea/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
+2
-6
idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java
idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java
+10
-4
未找到文件。
idea/src/org/jetbrains/jet/codegen/ClassCodegen.java
浏览文件 @
391da867
...
...
@@ -7,6 +7,7 @@ import org.jetbrains.jet.lang.types.ClassDescriptor;
import
org.jetbrains.jet.lang.types.JetStandardLibrary
;
import
org.jetbrains.jet.lang.types.JetType
;
import
org.objectweb.asm.ClassVisitor
;
import
org.objectweb.asm.Opcodes
;
import
java.util.List
;
...
...
@@ -15,25 +16,29 @@ import java.util.List;
*/
public
class
ClassCodegen
{
private
final
Project
project
;
private
final
ClassVisitor
v
;
private
final
BindingContext
bindingContext
;
private
final
Codegens
factory
;
public
ClassCodegen
(
Project
project
,
Codegens
v
,
JetClass
jetClass
,
BindingContext
bindingContext
)
{
public
ClassCodegen
(
Project
project
,
Codegens
factory
,
BindingContext
bindingContext
)
{
this
.
project
=
project
;
this
.
v
=
null
;
this
.
factory
=
factory
;
this
.
bindingContext
=
bindingContext
;
ClassDescriptor
descriptor
=
bindingContext
.
getClassDescriptor
(
jetClass
);
}
public
void
generate
(
JetClass
aClass
)
{
ClassDescriptor
descriptor
=
bindingContext
.
getClassDescriptor
(
aClass
);
String
fqName
=
CodeGenUtil
.
getInternalInterfaceName
(
descriptor
);
List
<
JetDelegationSpecifier
>
delegationSpecifiers
=
jet
Class
.
getDelegationSpecifiers
();
List
<
JetDelegationSpecifier
>
delegationSpecifiers
=
a
Class
.
getDelegationSpecifiers
();
for
(
JetDelegationSpecifier
specifier
:
delegationSpecifiers
)
{
JetType
superType
=
bindingContext
.
resolveTypeReference
(
specifier
.
getTypeReference
());
String
superClassFQN
=
CodeGenUtil
.
getInternalInterfaceName
((
ClassDescriptor
)
superType
.
getConstructor
().
getDeclarationDescriptor
());
}
//descriptor.
/*
ClassVisitor
v
=
factory
.
forClassImplementation
(
descriptor
);
v
.
visit
(
Opcodes
.
V1_6
,
Opcodes
.
ACC_PUBLIC
,
fqName
.
replace
(
'.'
,
'/'
),
...
...
@@ -42,24 +47,17 @@ public class ClassCodegen {
"java/lang/Object"
,
new
String
[
0
]
);
*/
}
public
void
generate
(
JetNamespace
namespace
)
{
final
PropertyCodegen
propertyCodegen
=
new
PropertyCodegen
(
v
);
final
FunctionCodegen
functionCodegen
=
new
FunctionCodegen
(
v
,
JetStandardLibrary
.
getJetStandardLibrary
(
project
),
bindingContext
);
for
(
JetDeclaration
declaration
:
namespace
.
getDeclarations
())
{
for
(
JetDeclaration
declaration
:
aClass
.
getDeclarations
())
{
if
(
declaration
instanceof
JetProperty
)
{
propertyCodegen
.
gen
((
JetProperty
)
declaration
,
namespace
);
propertyCodegen
.
gen
InInterface
((
JetProperty
)
declaration
);
}
else
if
(
declaration
instanceof
JetFunction
)
{
functionCodegen
.
gen
((
JetFunction
)
declaration
,
namespace
);
functionCodegen
.
gen
InInterface
((
JetFunction
)
declaration
);
}
}
}
public
ClassVisitor
getVisitor
()
{
return
v
;
}
}
idea/src/org/jetbrains/jet/codegen/Codegens.java
浏览文件 @
391da867
...
...
@@ -2,6 +2,7 @@ package org.jetbrains.jet.codegen;
import
com.intellij.openapi.project.Project
;
import
org.jetbrains.jet.lang.psi.JetNamespace
;
import
org.jetbrains.jet.lang.types.ClassDescriptor
;
import
org.objectweb.asm.ClassVisitor
;
import
org.objectweb.asm.ClassWriter
;
import
org.objectweb.asm.util.TraceClassVisitor
;
...
...
@@ -41,6 +42,18 @@ public class Codegens {
return
visitor
;
}
public
ClassVisitor
forClassInterface
(
ClassDescriptor
aClass
)
{
return
newVisitor
(
CodeGenUtil
.
getInternalInterfaceName
(
aClass
));
}
public
ClassVisitor
forClassImplementation
(
ClassDescriptor
aClass
)
{
return
newVisitor
(
CodeGenUtil
.
getInternalImplementationName
(
aClass
));
}
public
ClassVisitor
forClassDelegatingImplementation
(
ClassDescriptor
aClass
)
{
return
newVisitor
(
CodeGenUtil
.
getInternalDelegatingImplementationName
(
aClass
));
}
public
NamespaceCodegen
forNamespace
(
JetNamespace
namespace
)
{
assert
!
isDone
:
"Already done!"
;
String
fqName
=
namespace
.
getFQName
();
...
...
idea/src/org/jetbrains/jet/codegen/FunctionCodegen.java
浏览文件 @
391da867
...
...
@@ -27,11 +27,19 @@ public class FunctionCodegen {
typeMapper
=
new
JetTypeMapper
(
standardLibrary
,
bindingContext
);
}
public
void
gen
(
JetFunction
f
,
JetNamespace
owner
)
{
public
void
gen
InNamespace
(
JetFunction
f
)
{
gen
(
f
);
}
public
void
gen
(
JetFunction
f
,
JetClass
owner
)
{
public
void
genInInterface
(
JetFunction
f
)
{
}
public
void
genInImplementation
(
JetFunction
f
)
{
}
public
void
genInDelegatingImplementation
(
JetFunction
f
)
{
}
...
...
idea/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
浏览文件 @
391da867
...
...
@@ -41,10 +41,10 @@ public class NamespaceCodegen {
for
(
JetDeclaration
declaration
:
namespace
.
getDeclarations
())
{
if
(
declaration
instanceof
JetProperty
)
{
propertyCodegen
.
gen
((
JetProperty
)
declaration
,
namespace
);
propertyCodegen
.
gen
InNamespace
((
JetProperty
)
declaration
);
}
else
if
(
declaration
instanceof
JetFunction
)
{
functionCodegen
.
gen
((
JetFunction
)
declaration
,
namespace
);
functionCodegen
.
gen
InNamespace
((
JetFunction
)
declaration
);
}
}
}
...
...
@@ -59,8 +59,4 @@ public class NamespaceCodegen {
}
return
fqName
.
replace
(
'.'
,
'/'
)
+
"/namespace"
;
}
public
ClassVisitor
getVisitor
()
{
return
v
;
}
}
idea/src/org/jetbrains/jet/codegen/PropertyCodegen.java
浏览文件 @
391da867
package
org.jetbrains.jet.codegen
;
import
org.jetbrains.jet.lang.psi.JetClass
;
import
org.jetbrains.jet.lang.psi.JetNamespace
;
import
org.jetbrains.jet.lang.psi.JetProperty
;
import
org.objectweb.asm.ClassVisitor
;
...
...
@@ -15,11 +13,19 @@ public class PropertyCodegen {
this
.
v
=
v
;
}
public
void
gen
(
JetProperty
p
,
JetNamespace
owner
)
{
public
void
gen
InNamespace
(
JetProperty
p
)
{
}
public
void
gen
(
JetProperty
p
,
JetClass
owner
)
{
public
void
genInInterface
(
JetProperty
p
)
{
}
public
void
genInImplementation
(
JetProperty
p
)
{
}
public
void
genInDelegatingImplementation
(
JetProperty
p
)
{
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录