Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
7214993d
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,发现更多精彩内容 >>
提交
7214993d
编写于
9月 10, 2011
作者:
A
Alex Tkachman
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
removing unnneded InstructionAdapterEx
上级
76df19c2
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
50 addition
and
108 deletion
+50
-108
compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
...kend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
+6
-6
compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
...ackend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
+3
-2
compiler/backend/src/org/jetbrains/jet/codegen/InstructionAdapterEx.java
...d/src/org/jetbrains/jet/codegen/InstructionAdapterEx.java
+0
-92
compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java
.../backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java
+22
-0
compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
...ckend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
+7
-8
compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java
...ler/backend/src/org/jetbrains/jet/codegen/StackValue.java
+12
-0
未找到文件。
compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java
浏览文件 @
7214993d
...
...
@@ -49,7 +49,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
private
int
myLastLineNumber
=
-
1
;
private
final
InstructionAdapter
Ex
v
;
private
final
InstructionAdapter
v
;
private
final
FrameMap
myMap
;
private
final
JetTypeMapper
typeMapper
;
private
final
GenerationState
state
;
...
...
@@ -68,7 +68,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
this
.
typeMapper
=
state
.
getTypeMapper
();
this
.
returnType
=
returnType
;
this
.
state
=
state
;
this
.
v
=
new
InstructionAdapter
Ex
(
v
);
this
.
v
=
new
InstructionAdapter
(
v
);
this
.
bindingContext
=
state
.
getBindingContext
();
this
.
context
=
context
;
this
.
intrinsics
=
state
.
getIntrinsics
();
...
...
@@ -773,7 +773,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
return
myMap
.
getIndex
(
descriptor
);
}
public
void
invokeFunctionNoParams
(
FunctionDescriptor
functionDescriptor
,
Type
type
,
InstructionAdapter
Ex
v
)
{
public
void
invokeFunctionNoParams
(
FunctionDescriptor
functionDescriptor
,
Type
type
,
InstructionAdapter
v
)
{
DeclarationDescriptor
containingDeclaration
=
functionDescriptor
.
getContainingDeclaration
();
boolean
isStatic
=
containingDeclaration
instanceof
NamespaceDescriptorImpl
;
functionDescriptor
=
functionDescriptor
.
getOriginal
();
...
...
@@ -1085,7 +1085,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
Type
type
=
propValue
.
type
;
propValue
.
put
(
type
,
v
);
if
(
JetTypeMapper
.
isPrimitive
(
type
)
&&
!
type
.
equals
(
Type
.
VOID_TYPE
))
{
v
.
valueOf
(
type
);
StackValue
.
valueOf
(
v
,
type
);
type
=
JetTypeMapper
.
boxType
(
type
);
}
v
.
goTo
(
end
);
...
...
@@ -1265,10 +1265,10 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
if
(
JetTypeMapper
.
isPrimitive
(
leftType
)
!=
JetTypeMapper
.
isPrimitive
(
rightType
))
{
gen
(
left
,
leftType
);
v
.
valueOf
(
leftType
);
StackValue
.
valueOf
(
v
,
leftType
);
leftType
=
JetTypeMapper
.
boxType
(
leftType
);
gen
(
right
,
rightType
);
v
.
valueOf
(
rightType
);
StackValue
.
valueOf
(
v
,
rightType
);
rightType
=
JetTypeMapper
.
boxType
(
rightType
);
}
else
{
...
...
compiler/backend/src/org/jetbrains/jet/codegen/FunctionCodegen.java
浏览文件 @
7214993d
...
...
@@ -55,17 +55,18 @@ public class FunctionCodegen {
mv
.
visitCode
();
Type
[]
argTypes
=
function
.
getArgumentTypes
();
InstructionAdapter
Ex
iv
=
new
InstructionAdapterEx
(
mv
);
InstructionAdapter
iv
=
new
InstructionAdapter
(
mv
);
iv
.
load
(
0
,
JetTypeMapper
.
TYPE_OBJECT
);
for
(
int
i
=
0
,
reg
=
1
;
i
<
argTypes
.
length
;
i
++)
{
Type
argType
=
argTypes
[
i
];
iv
.
load
(
reg
,
argType
);
//noinspection AssignmentToForLoopParameter
reg
+=
argType
.
getSize
();
}
iv
.
invokevirtual
(
state
.
getTypeMapper
().
jvmName
((
ClassDescriptor
)
owner
.
getContextDescriptor
(),
OwnerKind
.
IMPLEMENTATION
),
function
.
getName
(),
function
.
getDescriptor
());
if
(
JetTypeMapper
.
isPrimitive
(
function
.
getReturnType
())
&&
!
JetTypeMapper
.
isPrimitive
(
overriden
.
getReturnType
()))
iv
.
valueOf
(
function
.
getReturnType
());
StackValue
.
valueOf
(
iv
,
function
.
getReturnType
());
if
(
function
.
getReturnType
()
==
Type
.
VOID_TYPE
)
iv
.
aconst
(
null
);
iv
.
areturn
(
overriden
.
getReturnType
());
...
...
compiler/backend/src/org/jetbrains/jet/codegen/InstructionAdapterEx.java
已删除
100644 → 0
浏览文件 @
76df19c2
package
org.jetbrains.jet.codegen
;
import
org.objectweb.asm.MethodVisitor
;
import
org.objectweb.asm.Opcodes
;
import
org.objectweb.asm.Type
;
import
org.objectweb.asm.commons.InstructionAdapter
;
import
org.objectweb.asm.commons.Method
;
public
class
InstructionAdapterEx
extends
InstructionAdapter
{
private
static
final
Method
BOOLEAN_VALUE
=
Method
.
getMethod
(
"boolean booleanValue()"
);
private
static
final
Method
CHAR_VALUE
=
Method
.
getMethod
(
"char charValue()"
);
private
static
final
Method
INT_VALUE
=
Method
.
getMethod
(
"int intValue()"
);
private
static
final
Method
FLOAT_VALUE
=
Method
.
getMethod
(
"float floatValue()"
);
private
static
final
Method
LONG_VALUE
=
Method
.
getMethod
(
"long longValue()"
);
private
static
final
Method
DOUBLE_VALUE
=
Method
.
getMethod
(
"double doubleValue()"
);
public
InstructionAdapterEx
(
MethodVisitor
methodVisitor
)
{
super
(
methodVisitor
);
}
private
static
Type
getBoxedType
(
final
Type
type
)
{
switch
(
type
.
getSort
())
{
case
Type
.
BYTE
:
return
JetTypeMapper
.
JL_BYTE_TYPE
;
case
Type
.
BOOLEAN
:
return
JetTypeMapper
.
JL_BOOLEAN_TYPE
;
case
Type
.
SHORT
:
return
JetTypeMapper
.
JL_SHORT_TYPE
;
case
Type
.
CHAR
:
return
JetTypeMapper
.
JL_CHAR_TYPE
;
case
Type
.
INT
:
return
JetTypeMapper
.
JL_INTEGER_TYPE
;
case
Type
.
FLOAT
:
return
JetTypeMapper
.
JL_FLOAT_TYPE
;
case
Type
.
LONG
:
return
JetTypeMapper
.
JL_LONG_TYPE
;
case
Type
.
DOUBLE
:
return
JetTypeMapper
.
JL_DOUBLE_TYPE
;
}
return
type
;
}
public
void
valueOf
(
final
Type
type
)
{
if
(
type
.
getSort
()
==
Type
.
OBJECT
||
type
.
getSort
()
==
Type
.
ARRAY
)
{
return
;
}
if
(
type
==
Type
.
VOID_TYPE
)
{
aconst
(
null
);
}
else
{
Type
boxed
=
getBoxedType
(
type
);
invokestatic
(
boxed
.
getInternalName
(),
"valueOf"
,
"("
+
type
.
getDescriptor
()
+
")"
+
boxed
.
getDescriptor
());
}
}
public
void
unbox
(
final
Type
type
)
{
Type
t
=
JetTypeMapper
.
JL_NUMBER_TYPE
;
Method
sig
=
null
;
switch
(
type
.
getSort
())
{
case
Type
.
VOID
:
return
;
case
Type
.
CHAR
:
t
=
JetTypeMapper
.
JL_CHAR_TYPE
;
sig
=
CHAR_VALUE
;
break
;
case
Type
.
BOOLEAN
:
t
=
JetTypeMapper
.
JL_BOOLEAN_TYPE
;
sig
=
BOOLEAN_VALUE
;
break
;
case
Type
.
DOUBLE
:
sig
=
DOUBLE_VALUE
;
break
;
case
Type
.
FLOAT
:
sig
=
FLOAT_VALUE
;
break
;
case
Type
.
LONG
:
sig
=
LONG_VALUE
;
break
;
case
Type
.
INT
:
case
Type
.
SHORT
:
case
Type
.
BYTE
:
sig
=
INT_VALUE
;
}
checkcast
(
t
);
invokevirtual
(
t
.
getInternalName
(),
sig
.
getName
(),
sig
.
getDescriptor
());
}
}
compiler/backend/src/org/jetbrains/jet/codegen/JetTypeMapper.java
浏览文件 @
7214993d
...
...
@@ -173,6 +173,28 @@ public class JetTypeMapper {
return
result
;
}
public
static
Type
getBoxedType
(
final
Type
type
)
{
switch
(
type
.
getSort
())
{
case
Type
.
BYTE
:
return
JL_BYTE_TYPE
;
case
Type
.
BOOLEAN
:
return
JL_BOOLEAN_TYPE
;
case
Type
.
SHORT
:
return
JL_SHORT_TYPE
;
case
Type
.
CHAR
:
return
JL_CHAR_TYPE
;
case
Type
.
INT
:
return
JL_INTEGER_TYPE
;
case
Type
.
FLOAT
:
return
JL_FLOAT_TYPE
;
case
Type
.
LONG
:
return
JL_LONG_TYPE
;
case
Type
.
DOUBLE
:
return
JL_DOUBLE_TYPE
;
}
return
type
;
}
public
String
jvmName
(
ClassDescriptor
jetClass
,
OwnerKind
kind
)
{
PsiElement
declaration
=
bindingContext
.
get
(
BindingContext
.
DESCRIPTOR_TO_DECLARATION
,
jetClass
);
if
(
declaration
instanceof
PsiClass
)
{
...
...
compiler/backend/src/org/jetbrains/jet/codegen/NamespaceCodegen.java
浏览文件 @
7214993d
...
...
@@ -3,7 +3,6 @@ package org.jetbrains.jet.codegen;
import
com.intellij.psi.PsiFile
;
import
org.jetbrains.jet.lang.descriptors.DeclarationDescriptor
;
import
org.jetbrains.jet.lang.descriptors.PropertyDescriptor
;
import
org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor
;
import
org.jetbrains.jet.lang.psi.*
;
import
org.jetbrains.jet.lang.resolve.BindingContext
;
import
org.jetbrains.jet.lang.resolve.java.JavaClassDescriptor
;
...
...
@@ -69,14 +68,14 @@ public class NamespaceCodegen {
}
}
if
(
hasNonConstantPropertyInitializers
(
namespace
,
context
))
{
generateStaticInitializers
(
namespace
,
context
);
if
(
hasNonConstantPropertyInitializers
(
namespace
))
{
generateStaticInitializers
(
namespace
);
}
generateTypeInfoFields
(
namespace
,
context
);
}
private
void
generateStaticInitializers
(
JetNamespace
namespace
,
ClassContext
context
)
{
private
void
generateStaticInitializers
(
JetNamespace
namespace
)
{
MethodVisitor
mv
=
v
.
visitMethod
(
ACC_PUBLIC
|
ACC_STATIC
,
"<clinit>"
,
"()V"
,
null
,
null
);
mv
.
visitCode
();
...
...
@@ -88,7 +87,7 @@ public class NamespaceCodegen {
if
(
declaration
instanceof
JetProperty
)
{
final
JetExpression
initializer
=
((
JetProperty
)
declaration
).
getInitializer
();
if
(
initializer
!=
null
&&
!(
initializer
instanceof
JetConstantExpression
))
{
final
PropertyDescriptor
descriptor
=
(
PropertyDescriptor
)
state
.
getBindingContext
().
get
(
BindingContext
.
VARIABLE
,
(
JetProperty
)
declaration
);
final
PropertyDescriptor
descriptor
=
(
PropertyDescriptor
)
state
.
getBindingContext
().
get
(
BindingContext
.
VARIABLE
,
declaration
);
codegen
.
genToJVMStack
(
initializer
);
codegen
.
intermediateValueForProperty
(
descriptor
,
true
,
false
).
store
(
new
InstructionAdapter
(
mv
));
}
...
...
@@ -108,7 +107,7 @@ public class NamespaceCodegen {
v
.
visitField
(
ACC_PRIVATE
|
ACC_STATIC
|
ACC_SYNTHETIC
,
fieldName
,
"Ljet/typeinfo/TypeInfo;"
,
null
,
null
);
MethodVisitor
mmv
=
v
.
visitMethod
(
ACC_PUBLIC
|
ACC_STATIC
|
ACC_SYNTHETIC
,
"$getCachedTypeInfo$"
+
e
.
getValue
(),
"()Ljet/typeinfo/TypeInfo;"
,
null
,
null
);
InstructionAdapter
Ex
v
=
new
InstructionAdapterEx
(
mmv
);
InstructionAdapter
v
=
new
InstructionAdapter
(
mmv
);
v
.
visitFieldInsn
(
GETSTATIC
,
jvmClassName
,
fieldName
,
"Ljet/typeinfo/TypeInfo;"
);
v
.
visitInsn
(
DUP
);
Label
end
=
new
Label
();
...
...
@@ -127,7 +126,7 @@ public class NamespaceCodegen {
}
}
private
void
generateTypeInfo
(
ClassContext
context
,
InstructionAdapterEx
v
,
JetType
jetType
,
JetTypeMapper
typeMapper
,
JetType
root
)
{
private
static
void
generateTypeInfo
(
ClassContext
context
,
InstructionAdapter
v
,
JetType
jetType
,
JetTypeMapper
typeMapper
,
JetType
root
)
{
String
knownTypeInfo
=
typeMapper
.
isKnownTypeInfo
(
jetType
);
if
(
knownTypeInfo
!=
null
)
{
v
.
getstatic
(
"jet/typeinfo/TypeInfo"
,
knownTypeInfo
,
"Ljet/typeinfo/TypeInfo;"
);
...
...
@@ -172,7 +171,7 @@ public class NamespaceCodegen {
}
}
private
static
boolean
hasNonConstantPropertyInitializers
(
JetNamespace
namespace
,
ClassContext
context
)
{
private
static
boolean
hasNonConstantPropertyInitializers
(
JetNamespace
namespace
)
{
for
(
JetDeclaration
declaration
:
namespace
.
getDeclarations
())
{
if
(
declaration
instanceof
JetProperty
)
{
final
JetExpression
initializer
=
((
JetProperty
)
declaration
).
getInitializer
();
...
...
compiler/backend/src/org/jetbrains/jet/codegen/StackValue.java
浏览文件 @
7214993d
...
...
@@ -19,6 +19,18 @@ public abstract class StackValue {
this
.
type
=
type
;
}
public
static
void
valueOf
(
InstructionAdapter
instructionAdapter
,
final
Type
type
)
{
if
(
type
.
getSort
()
==
Type
.
OBJECT
||
type
.
getSort
()
==
Type
.
ARRAY
)
{
return
;
}
if
(
type
==
Type
.
VOID_TYPE
)
{
instructionAdapter
.
aconst
(
null
);
}
else
{
Type
boxed
=
JetTypeMapper
.
getBoxedType
(
type
);
instructionAdapter
.
invokestatic
(
boxed
.
getInternalName
(),
"valueOf"
,
"("
+
type
.
getDescriptor
()
+
")"
+
boxed
.
getDescriptor
());
}
}
public
abstract
void
put
(
Type
type
,
InstructionAdapter
v
);
public
void
store
(
InstructionAdapter
v
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录