Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
af522320
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,发现更多精彩内容 >>
提交
af522320
编写于
11月 11, 2020
作者:
M
Mikhail Glukhikh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[FIR2IR] Use proper lookup tags in data class member generator
上级
7905bc86
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
21 addition
and
17 deletion
+21
-17
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt
...ins/kotlin/fir/backend/generators/ClassMemberGenerator.kt
+3
-3
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DataClassMembersGenerator.kt
...otlin/fir/backend/generators/DataClassMembersGenerator.kt
+18
-14
未找到文件。
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/ClassMemberGenerator.kt
浏览文件 @
af522320
...
...
@@ -125,14 +125,14 @@ internal class ClassMemberGenerator(
irFunction
.
body
=
IrSyntheticBodyImpl
(
startOffset
,
endOffset
,
kind
)
}
irFunction
.
parent
is
IrClass
&&
irFunction
.
parentAsClass
.
isData
->
{
val
classId
=
firFunction
?.
symbol
?.
dispatchReceiverClassOrNull
()
?.
classId
val
lookupTag
=
firFunction
?.
symbol
?.
dispatchReceiverClassOrNull
()
when
{
DataClassMembersGenerator
.
isComponentN
(
irFunction
)
->
firFunction
?.
body
?.
let
{
irFunction
.
body
=
visitor
.
convertToIrBlockBody
(
it
)
}
?:
DataClassMembersGenerator
(
components
).
generateDataClassComponentBody
(
irFunction
,
classId
!!
)
?:
DataClassMembersGenerator
(
components
).
generateDataClassComponentBody
(
irFunction
,
lookupTag
!!
)
DataClassMembersGenerator
.
isCopy
(
irFunction
)
->
firFunction
?.
body
?.
let
{
irFunction
.
body
=
visitor
.
convertToIrBlockBody
(
it
)
}
?:
DataClassMembersGenerator
(
components
).
generateDataClassCopyBody
(
irFunction
,
classId
!!
)
?:
DataClassMembersGenerator
(
components
).
generateDataClassCopyBody
(
irFunction
,
lookupTag
!!
)
else
->
irFunction
.
body
=
firFunction
?.
body
?.
let
{
visitor
.
convertToIrBlockBody
(
it
)
}
}
...
...
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/generators/DataClassMembersGenerator.kt
浏览文件 @
af522320
...
...
@@ -16,7 +16,9 @@ import org.jetbrains.kotlin.fir.declarations.builder.buildValueParameter
import
org.jetbrains.kotlin.fir.declarations.impl.FirDeclarationStatusImpl
import
org.jetbrains.kotlin.fir.scopes.unsubstitutedScope
import
org.jetbrains.kotlin.fir.symbols.CallableId
import
org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
import
org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
import
org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirNamedFunctionSymbol
import
org.jetbrains.kotlin.fir.symbols.impl.FirVariableSymbol
import
org.jetbrains.kotlin.fir.types.ConeStarProjection
...
...
@@ -50,20 +52,24 @@ import org.jetbrains.kotlin.name.Name
class
DataClassMembersGenerator
(
val
components
:
Fir2IrComponents
)
{
fun
generateInlineClassMembers
(
klass
:
FirClass
<
*
>,
irClass
:
IrClass
):
List
<
FirDeclaration
>
=
MyDataClassMethodsGenerator
(
irClass
,
klass
.
symbol
.
classId
,
IrDeclarationOrigin
.
GENERATED_INLINE_CLASS_MEMBER
).
generate
(
klass
)
MyDataClassMethodsGenerator
(
irClass
,
klass
.
symbol
.
toLookupTag
()
,
IrDeclarationOrigin
.
GENERATED_INLINE_CLASS_MEMBER
).
generate
(
klass
)
fun
generateDataClassMembers
(
klass
:
FirClass
<
*
>,
irClass
:
IrClass
):
List
<
FirDeclaration
>
=
MyDataClassMethodsGenerator
(
irClass
,
klass
.
symbol
.
classId
,
IrDeclarationOrigin
.
GENERATED_DATA_CLASS_MEMBER
).
generate
(
klass
)
MyDataClassMethodsGenerator
(
irClass
,
klass
.
symbol
.
toLookupTag
()
,
IrDeclarationOrigin
.
GENERATED_DATA_CLASS_MEMBER
).
generate
(
klass
)
fun
generateDataClassComponentBody
(
irFunction
:
IrFunction
,
classId
:
ClassId
)
=
MyDataClassMethodsGenerator
(
irFunction
.
parentAsClass
,
classId
,
IrDeclarationOrigin
.
GENERATED_DATA_CLASS_MEMBER
)
fun
generateDataClassComponentBody
(
irFunction
:
IrFunction
,
lookupTag
:
ConeClassLikeLookupTag
)
=
MyDataClassMethodsGenerator
(
irFunction
.
parentAsClass
,
lookupTag
,
IrDeclarationOrigin
.
GENERATED_DATA_CLASS_MEMBER
)
.
generateComponentBody
(
irFunction
)
fun
generateDataClassCopyBody
(
irFunction
:
IrFunction
,
classId
:
ClassId
)
=
MyDataClassMethodsGenerator
(
irFunction
.
parentAsClass
,
classId
,
IrDeclarationOrigin
.
GENERATED_DATA_CLASS_MEMBER
)
fun
generateDataClassCopyBody
(
irFunction
:
IrFunction
,
lookupTag
:
ConeClassLikeLookupTag
)
=
MyDataClassMethodsGenerator
(
irFunction
.
parentAsClass
,
lookupTag
,
IrDeclarationOrigin
.
GENERATED_DATA_CLASS_MEMBER
)
.
generateCopyBody
(
irFunction
)
private
inner
class
MyDataClassMethodsGenerator
(
val
irClass
:
IrClass
,
val
classId
:
ClassId
,
val
origin
:
IrDeclarationOrigin
)
{
private
inner
class
MyDataClassMethodsGenerator
(
val
irClass
:
IrClass
,
val
lookupTag
:
ConeClassLikeLookupTag
,
val
origin
:
IrDeclarationOrigin
)
{
private
val
irDataClassMembersGenerator
=
object
:
DataClassMembersGenerator
(
IrGeneratorContextBase
(
components
.
irBuiltIns
),
components
.
symbolTable
,
...
...
@@ -226,7 +232,7 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
val
firFunction
=
buildSimpleFunction
{
origin
=
FirDeclarationOrigin
.
Synthetic
this
.
name
=
name
this
.
symbol
=
FirNamedFunctionSymbol
(
CallableId
(
classId
,
name
))
this
.
symbol
=
FirNamedFunctionSymbol
(
CallableId
(
lookupTag
.
classId
,
name
))
this
.
status
=
FirDeclarationStatusImpl
(
Visibilities
.
Public
,
Modality
.
FINAL
)
this
.
session
=
components
.
session
this
.
returnTypeRef
=
when
(
returnType
)
{
...
...
@@ -249,13 +255,11 @@ class DataClassMembersGenerator(val components: Fir2IrComponents) {
}
)
}
dispatchReceiverType
=
ConeClassLikeLookupTagImpl
(
classId
)
.
constructType
(
(
1
..
irClass
.
typeParameters
.
size
).
map
{
ConeStarProjection
}.
toTypedArray
(),
isNullable
=
false
)
dispatchReceiverType
=
lookupTag
.
constructType
(
(
1
..
irClass
.
typeParameters
.
size
).
map
{
ConeStarProjection
}.
toTypedArray
(),
isNullable
=
false
)
}
val
signature
=
if
(
classId
.
isLocal
)
null
else
components
.
signatureComposer
.
composeSignature
(
firFunction
)
val
signature
=
if
(
lookupTag
.
classId
.
isLocal
)
null
else
components
.
signatureComposer
.
composeSignature
(
firFunction
)
return
components
.
declarationStorage
.
declareIrSimpleFunction
(
signature
,
null
)
{
symbol
->
components
.
irFactory
.
createFunction
(
UNDEFINED_OFFSET
,
UNDEFINED_OFFSET
,
origin
,
symbol
,
name
,
DescriptorVisibilities
.
PUBLIC
,
Modality
.
OPEN
,
returnType
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录