Tracey Yoshima
12/16/2022, 12:50 AMRAW_FILE
phase when I call #process(List<FirFile)
and does not change even though the transform
runs.
I’d like to know what I am doing wrong since I am still learning about the Kotlin compiler.
Questions:
• Is there a recommended example of what I may look at to see how to progress a FirFile through the compilation phases?
• Would it be possible to schedule a zoom to provide context about how we’re using the Kotlin compiler to construct a type-aware, whitespace-preserving AST?
• Or could anyone take a look at what I have so far?Tracey Yoshima
12/16/2022, 12:51 AMdmitriy.novozhilov
12/16/2022, 8:29 AMrunResolution
function on session
(like here)dmitriy.novozhilov
12/16/2022, 8:30 AMrunResolution
does exact same thing as you do (run total resolve processor)dmitriy.novozhilov
12/16/2022, 8:31 AMresolvePhase
has not changed, that it's ok. This field can be changed only in lazy mode in IDE. Regular CLI compiler does not take care about this phase and does not update itTracey Yoshima
12/16/2022, 5:01 PMrunResolution
, but wasn’t sure if I should use it. I’ve replaced it locally; thank you so much!
• Would you happen to have any recommended examples related to session configuration?
• In the Java compiler, each type contains a symbol that provides information like superclasses, fields, methods, etc. I’d like to use that information to connect to AST elements. Is or where is that represented in Kotlin?
◦ I’m not currently seeing anything like that, and I am under the impression that it exists, but it is missing due to a lack of configurations. Is my understanding correct?
Example of `java.io.Serializable`:Tracey Yoshima
12/16/2022, 5:04 PMdmitriy.novozhilov
12/16/2022, 5:20 PMWould you happen to have any recommended examples related to session configuration?FirFrontendFacade (from tests) or FirKotlinToJvmBytecodeCompiler (from CLI compiler)
I’d like to use that information to connect to AST elementsI'm not fully understand what do you want. You mean that you are trying to create mapping between FIR elements and PSI nodes (which represent C(oncrete)ST from parser)? Or smth else?
dmitriy.novozhilov
12/16/2022, 5:20 PMFirElement.source
Tracey Yoshima
12/16/2022, 5:42 PMFirKotlinToJvmBytecodeCompiler (from CLI compiler)This is precisely what I am looking for; thank you!
I’m not fully understand what do you want. You mean that you are trying to create mapping between FIR elements and PSI nodes (which represent C(oncrete)ST from parser)? Or smth else?I may find what I need using the
KotlinToJVMBytecodeCompiler
to correctly configure the FirSession. (I’ve skipped a few steps.)
The missing configuration may be causing the issue that I am experiencing. So, I’ll try that first — Thanks again!Tracey Yoshima
12/17/2022, 1:38 AMList,
to its methods, fields, super types, etc.?dmitriy.novozhilov
12/18/2022, 6:29 PMCould you provide a TLDR on the backend part of the compilation process or point me to documentation? Meaning what happens to the IR and how is the IR used to generate byte code?TLDR: backend consist with two parts: lowerings and codegen Lowering is a pass which somehow transfroms the IR tree to something more similar to real code in bytecode/js/llvm. Examples of lowerings: • transformation of
for (x in 1..n)
loop into for (int x = 1; x <= n; x++)
• transformation of extension receivers into parameters
// before
fun String.foo(x: Int) {}
s.foo(10)
// after
fun foo(reciever: String, x: Int)
foo(s, 10)
• inlining of inline functions
• transformation of suspend
functions into state machine with continuation
• etc (AFAIR there are several tens of lowering)
Codegen is the part which takes lowered IR at input and produces bytecode/js/llvm bitcode from it
For more information/articles/talks it's better to ask someone else in this channel. All materials I have are in Russiandmitriy.novozhilov
12/18/2022, 6:30 PMIs there a utility that links the IR information, like a List, to its methods, fields, super types, etc.?Could you elaborate question, please? All IR declarations contain all it's content right inside the tree
dmitriy.novozhilov
12/18/2022, 6:31 PMTracey Yoshima
12/19/2022, 7:06 PMCould you elaborate question, please?
All IR declarations contain all it’s content right inside the treeI misunderstood the output when I was debugging — it looks like I have access to everything I need. Thank you for all your help
dmitriy.novozhilov
01/09/2023, 8:37 AMMerlinTHS
03/10/2023, 12:13 PMFor more information/articles/talks it's better to ask someone else in this channel. All materials I have are in Russian.@dmitriy.novozhilov I would like to take a look at these russian materials. Are they public?
dmitriy.novozhilov
03/10/2023, 12:18 PMdmitriy.novozhilov
03/10/2023, 12:20 PMMerlinTHS
03/10/2023, 1:12 PMdmitriy.novozhilov
03/10/2023, 3:27 PMMerlinTHS
03/10/2023, 8:01 PM