Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
硅谷海盗
kotlin
提交
c03fa59a
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,发现更多精彩内容 >>
提交
c03fa59a
编写于
11月 23, 2020
作者:
M
Mikhail Glukhikh
提交者:
Alexander Udalov
11月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce Fir2IrLazyPropertyAccessor
上级
71179326
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
225 addition
and
26 deletion
+225
-26
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt
.../jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt
+24
-15
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt
...r/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt
+44
-10
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt
...g/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt
+157
-0
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt
...org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt
+0
-1
未找到文件。
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/backend/Fir2IrDeclarationStorage.kt
浏览文件 @
c03fa59a
...
@@ -248,10 +248,21 @@ class Fir2IrDeclarationStorage(
...
@@ -248,10 +248,21 @@ class Fir2IrDeclarationStorage(
}
}
private
fun
<
T
:
IrFunction
>
T
.
declareDefaultSetterParameter
(
type
:
IrType
):
T
{
private
fun
<
T
:
IrFunction
>
T
.
declareDefaultSetterParameter
(
type
:
IrType
):
T
{
val
parent
=
this
val
descriptor
=
WrappedValueParameterDescriptor
()
valueParameters
=
listOf
(
valueParameters
=
listOf
(
symbolTable
.
declareValueParameter
(
createDefaultSetterParameter
(
startOffset
,
endOffset
,
origin
,
type
,
parent
=
this
)
)
return
this
}
internal
fun
createDefaultSetterParameter
(
startOffset
:
Int
,
endOffset
:
Int
,
origin
:
IrDeclarationOrigin
,
type
:
IrType
,
parent
:
IrFunction
):
IrValueParameter
{
val
descriptor
=
WrappedValueParameterDescriptor
()
return
symbolTable
.
declareValueParameter
(
startOffset
,
endOffset
,
origin
,
descriptor
,
type
startOffset
,
endOffset
,
origin
,
descriptor
,
type
)
{
symbol
->
)
{
symbol
->
irFactory
.
createValueParameter
(
irFactory
.
createValueParameter
(
...
@@ -264,8 +275,6 @@ class Fir2IrDeclarationStorage(
...
@@ -264,8 +275,6 @@ class Fir2IrDeclarationStorage(
descriptor
.
bind
(
this
)
descriptor
.
bind
(
this
)
}
}
}
}
)
return
this
}
}
private
fun
<
T
:
IrFunction
>
T
.
declareParameters
(
private
fun
<
T
:
IrFunction
>
T
.
declareParameters
(
...
...
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyProperty.kt
浏览文件 @
c03fa59a
...
@@ -24,6 +24,9 @@ import org.jetbrains.kotlin.ir.util.isInterface
...
@@ -24,6 +24,9 @@ import org.jetbrains.kotlin.ir.util.isInterface
import
org.jetbrains.kotlin.name.Name
import
org.jetbrains.kotlin.name.Name
import
org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
import
org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
import
org.jetbrains.kotlin.descriptors.DescriptorVisibility
import
org.jetbrains.kotlin.descriptors.DescriptorVisibility
import
org.jetbrains.kotlin.fir.backend.ConversionTypeContext
import
org.jetbrains.kotlin.fir.backend.ConversionTypeOrigin
import
org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol
class
Fir2IrLazyProperty
(
class
Fir2IrLazyProperty
(
components
:
Fir2IrComponents
,
components
:
Fir2IrComponents
,
...
@@ -110,7 +113,8 @@ class Fir2IrLazyProperty(
...
@@ -110,7 +113,8 @@ class Fir2IrLazyProperty(
with
(
declarationStorage
)
{
with
(
declarationStorage
)
{
createBackingField
(
createBackingField
(
fir
,
IrDeclarationOrigin
.
PROPERTY_DELEGATE
,
descriptor
,
fir
,
IrDeclarationOrigin
.
PROPERTY_DELEGATE
,
descriptor
,
components
.
visibilityConverter
.
convertToDescriptorVisibility
(
fir
.
visibility
),
Name
.
identifier
(
"${fir.name}\$delegate"
),
true
,
fir
.
delegate
components
.
visibilityConverter
.
convertToDescriptorVisibility
(
fir
.
visibility
),
Name
.
identifier
(
"${fir.name}\$delegate"
),
true
,
fir
.
delegate
)
)
}
}
}
}
...
@@ -123,29 +127,59 @@ class Fir2IrLazyProperty(
...
@@ -123,29 +127,59 @@ class Fir2IrLazyProperty(
}
}
override
var
getter
:
IrSimpleFunction
?
by
lazyVar
{
override
var
getter
:
IrSimpleFunction
?
by
lazyVar
{
declarationStorage
.
createIr
PropertyAccessor
(
Fir2IrLazy
PropertyAccessor
(
fir
.
getter
,
fir
,
this
,
type
,
parent
,
parent
as
?
IrClass
,
false
,
components
,
startOffset
,
endOffset
,
when
{
when
{
origin
==
IrDeclarationOrigin
.
IR_EXTERNAL_DECLARATION_STUB
->
origin
origin
==
IrDeclarationOrigin
.
IR_EXTERNAL_DECLARATION_STUB
->
origin
fir
.
delegate
!=
null
->
IrDeclarationOrigin
.
DELEGATED_PROPERTY_ACCESSOR
fir
.
delegate
!=
null
->
IrDeclarationOrigin
.
DELEGATED_PROPERTY_ACCESSOR
fir
.
getter
is
FirDefaultPropertyGetter
->
IrDeclarationOrigin
.
DEFAULT_PROPERTY_ACCESSOR
fir
.
getter
is
FirDefaultPropertyGetter
->
IrDeclarationOrigin
.
DEFAULT_PROPERTY_ACCESSOR
else
->
origin
else
->
origin
},
},
startOffset
,
endOffset
fir
.
getter
,
isSetter
=
false
,
fir
,
containingClass
,
Fir2IrSimpleFunctionSymbol
(
signatureComposer
.
composeAccessorSignature
(
fir
,
isSetter
=
false
,
containingClass
.
symbol
.
toLookupTag
())
!!
),
isFakeOverride
).
apply
{
parent
=
this
@Fir2IrLazyProperty
.
parent
correspondingPropertySymbol
=
this
@Fir2IrLazyProperty
.
symbol
with
(
classifierStorage
)
{
setTypeParameters
(
this
@Fir2IrLazyProperty
.
fir
,
ConversionTypeContext
(
definitelyNotNull
=
false
,
origin
=
ConversionTypeOrigin
.
DEFAULT
)
)
)
}
}
}
}
override
var
setter
:
IrSimpleFunction
?
by
lazyVar
{
override
var
setter
:
IrSimpleFunction
?
by
lazyVar
{
if
(!
fir
.
isVar
)
return
@lazyVar
null
if
(!
fir
.
isVar
)
null
else
Fir2IrLazyPropertyAccessor
(
declarationStorage
.
createIrPropertyAccessor
(
components
,
startOffset
,
endOffset
,
fir
.
setter
,
fir
,
this
,
type
,
parent
,
parent
as
?
IrClass
,
true
,
when
{
when
{
origin
==
IrDeclarationOrigin
.
IR_EXTERNAL_DECLARATION_STUB
->
origin
fir
.
delegate
!=
null
->
IrDeclarationOrigin
.
DELEGATED_PROPERTY_ACCESSOR
fir
.
delegate
!=
null
->
IrDeclarationOrigin
.
DELEGATED_PROPERTY_ACCESSOR
fir
.
setter
is
FirDefaultPropertySetter
->
IrDeclarationOrigin
.
DEFAULT_PROPERTY_ACCESSOR
fir
.
setter
is
FirDefaultPropertySetter
->
IrDeclarationOrigin
.
DEFAULT_PROPERTY_ACCESSOR
else
->
origin
else
->
origin
},
},
startOffset
,
endOffset
fir
.
setter
,
isSetter
=
true
,
fir
,
containingClass
,
Fir2IrSimpleFunctionSymbol
(
signatureComposer
.
composeAccessorSignature
(
fir
,
isSetter
=
true
,
containingClass
.
symbol
.
toLookupTag
())
!!
),
isFakeOverride
).
apply
{
parent
=
this
@Fir2IrLazyProperty
.
parent
correspondingPropertySymbol
=
this
@Fir2IrLazyProperty
.
symbol
with
(
classifierStorage
)
{
setTypeParameters
(
this
@Fir2IrLazyProperty
.
fir
,
ConversionTypeContext
(
definitelyNotNull
=
false
,
origin
=
ConversionTypeOrigin
.
SETTER
)
)
)
}
}
}
}
override
var
metadata
:
MetadataSource
?
override
var
metadata
:
MetadataSource
?
...
...
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazyPropertyAccessor.kt
0 → 100644
浏览文件 @
c03fa59a
/*
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
*/
package
org.jetbrains.kotlin.fir.lazy
import
org.jetbrains.kotlin.descriptors.DescriptorVisibility
import
org.jetbrains.kotlin.descriptors.FunctionDescriptor
import
org.jetbrains.kotlin.descriptors.Modality
import
org.jetbrains.kotlin.fir.backend.*
import
org.jetbrains.kotlin.fir.backend.declareThisReceiverParameter
import
org.jetbrains.kotlin.fir.backend.generateOverriddenAccessorSymbols
import
org.jetbrains.kotlin.fir.declarations.*
import
org.jetbrains.kotlin.fir.symbols.Fir2IrSimpleFunctionSymbol
import
org.jetbrains.kotlin.ir.ObsoleteDescriptorBasedAPI
import
org.jetbrains.kotlin.ir.declarations.*
import
org.jetbrains.kotlin.ir.declarations.lazy.lazyVar
import
org.jetbrains.kotlin.ir.expressions.IrBody
import
org.jetbrains.kotlin.ir.expressions.IrConstructorCall
import
org.jetbrains.kotlin.ir.symbols.IrPropertySymbol
import
org.jetbrains.kotlin.ir.symbols.IrSimpleFunctionSymbol
import
org.jetbrains.kotlin.ir.types.IrType
import
org.jetbrains.kotlin.ir.util.isNonCompanionObject
import
org.jetbrains.kotlin.name.ClassId
import
org.jetbrains.kotlin.name.Name
import
org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
import
org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource
class
Fir2IrLazyPropertyAccessor
(
components
:
Fir2IrComponents
,
override
val
startOffset
:
Int
,
override
val
endOffset
:
Int
,
override
var
origin
:
IrDeclarationOrigin
,
private
val
firAccessor
:
FirPropertyAccessor
?,
private
val
isSetter
:
Boolean
,
private
val
firParentProperty
:
FirProperty
,
firParentClass
:
FirRegularClass
,
override
val
symbol
:
Fir2IrSimpleFunctionSymbol
,
override
val
isFakeOverride
:
Boolean
)
:
IrSimpleFunction
(),
AbstractFir2IrLazyDeclaration
<
FirMemberDeclaration
,
IrSimpleFunction
>,
Fir2IrComponents
by
components
{
init
{
symbol
.
bind
(
this
)
}
override
val
fir
:
FirMemberDeclaration
get
()
=
firAccessor
?:
firParentProperty
override
var
annotations
:
List
<
IrConstructorCall
>
by
createLazyAnnotations
()
override
lateinit
var
typeParameters
:
List
<
IrTypeParameter
>
override
lateinit
var
parent
:
IrDeclarationParent
override
var
correspondingPropertySymbol
:
IrPropertySymbol
?
=
null
override
val
isTailrec
:
Boolean
get
()
=
fir
.
isTailRec
override
val
isSuspend
:
Boolean
get
()
=
fir
.
isSuspend
override
val
isOperator
:
Boolean
get
()
=
fir
.
isOperator
override
val
isInfix
:
Boolean
get
()
=
fir
.
isInfix
@ObsoleteDescriptorBasedAPI
override
val
descriptor
:
FunctionDescriptor
get
()
=
symbol
.
descriptor
override
val
isInline
:
Boolean
get
()
=
fir
.
isInline
override
val
isExternal
:
Boolean
get
()
=
fir
.
isExternal
override
val
isExpect
:
Boolean
get
()
=
fir
.
isExpect
override
var
body
:
IrBody
?
=
null
override
val
name
:
Name
get
()
=
Name
.
special
(
"<${if (isSetter) "
set
" else "
get
"}-${firParentProperty.name}>"
)
@Suppress
(
"SetterBackingFieldAssignment"
)
override
var
visibility
:
DescriptorVisibility
=
components
.
visibilityConverter
.
convertToDescriptorVisibility
(
fir
.
visibility
)
set
(
_
)
{
error
(
"Mutating Fir2Ir lazy elements is not possible"
)
}
override
val
modality
:
Modality
get
()
=
fir
.
modality
!!
override
var
attributeOwnerId
:
IrAttributeContainer
=
this
override
var
returnType
:
IrType
by
lazyVar
{
if
(
isSetter
)
irBuiltIns
.
unitType
else
firParentProperty
.
returnTypeRef
.
toIrType
(
typeConverter
)
}
override
var
dispatchReceiverParameter
:
IrValueParameter
?
by
lazyVar
{
val
containingClass
=
parent
as
?
IrClass
if
(
containingClass
!=
null
&&
!
firParentProperty
.
isStatic
&&
!(
containingClass
.
isNonCompanionObject
&&
firParentProperty
.
hasAnnotation
(
ClassId
.
topLevel
(
JVM_STATIC_ANNOTATION_FQ_NAME
)))
)
{
declarationStorage
.
enterScope
(
this
)
declareThisReceiverParameter
(
symbolTable
,
thisType
=
containingClass
.
thisReceiver
?.
type
?:
error
(
"No this receiver for containing class"
),
thisOrigin
=
origin
).
apply
{
declarationStorage
.
leaveScope
(
this
@Fir2IrLazyPropertyAccessor
)
}
}
else
null
}
override
var
extensionReceiverParameter
:
IrValueParameter
?
by
lazyVar
{
firParentProperty
.
receiverTypeRef
?.
let
{
declarationStorage
.
enterScope
(
this
)
declareThisReceiverParameter
(
symbolTable
,
thisType
=
it
.
toIrType
(
typeConverter
),
thisOrigin
=
origin
,
).
apply
{
declarationStorage
.
leaveScope
(
this
@Fir2IrLazyPropertyAccessor
)
}
}
}
override
var
valueParameters
:
List
<
IrValueParameter
>
by
lazyVar
{
if
(!
isSetter
)
emptyList
()
else
{
declarationStorage
.
enterScope
(
this
)
listOf
(
declarationStorage
.
createDefaultSetterParameter
(
startOffset
,
endOffset
,
origin
,
(
firAccessor
?.
valueParameters
?.
firstOrNull
()
?.
returnTypeRef
?:
firParentProperty
.
returnTypeRef
).
toIrType
(
typeConverter
,
ConversionTypeContext
.
DEFAULT
.
inSetter
()
),
this
@Fir2IrLazyPropertyAccessor
)
).
apply
{
declarationStorage
.
leaveScope
(
this
@Fir2IrLazyPropertyAccessor
)
}
}
}
override
var
overriddenSymbols
:
List
<
IrSimpleFunctionSymbol
>
by
lazyVar
{
firParentProperty
.
generateOverriddenAccessorSymbols
(
firParentClass
,
!
isSetter
,
session
,
scopeSession
,
declarationStorage
)
}
override
var
metadata
:
MetadataSource
?
get
()
=
null
set
(
_
)
=
error
(
"We should never need to store metadata of external declarations."
)
override
val
containerSource
:
DeserializedContainerSource
?
get
()
=
firParentProperty
.
containerSource
}
\ No newline at end of file
compiler/fir/fir2ir/src/org/jetbrains/kotlin/fir/lazy/Fir2IrLazySimpleFunction.kt
浏览文件 @
c03fa59a
...
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
...
@@ -23,7 +23,6 @@ import org.jetbrains.kotlin.serialization.deserialization.descriptors.Deserializ
import
org.jetbrains.kotlin.descriptors.DescriptorVisibility
import
org.jetbrains.kotlin.descriptors.DescriptorVisibility
import
org.jetbrains.kotlin.ir.util.hasAnnotation
import
org.jetbrains.kotlin.ir.util.hasAnnotation
import
org.jetbrains.kotlin.ir.util.isNonCompanionObject
import
org.jetbrains.kotlin.ir.util.isNonCompanionObject
import
org.jetbrains.kotlin.ir.util.isObject
import
org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
import
org.jetbrains.kotlin.resolve.annotations.JVM_STATIC_ANNOTATION_FQ_NAME
class
Fir2IrLazySimpleFunction
(
class
Fir2IrLazySimpleFunction
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录