Piotr Krzemiński
08/09/2021, 10:09 AMproperties_initialized_someFileName_kt
is checked inside the init functions (we base our Python backend on the JS one, so this also happens in JS/IR backend). The problem in Python is that variables need to be initialized before they are read, so for each IrFile I need to produce a top-level assignment properties_initialized_someFileName_kt = False
.
Something along these lines (forgive the imprecise arguments, the returned type is the real problem):
JsIrBuilder.buildSetField(
symbol = ...Name.identifier("properties initialized $fileName")...,
receiver = null,
value = JsIrBuilder.buildBoolean(context.irBuiltIns.booleanType, false)
)
I tried adapting existing lowerings to emit such IR entity, but I don't know how to put IrSetFieldImpl
in the IR output because lowerings produce a list of IrDeclaration
and the types just don't match. I sort of understand lowerings that transform some existing IR node to something else, but here I need to produce something new (not map from A to B). It would be cool if you could guide me how to write such lowering, and maybe also refer me to some docs about internal compiler API.Piotr Krzemiński
08/09/2021, 10:13 AMbashor
08/09/2021, 10:20 AMbashor
08/09/2021, 10:21 AMIrAnonymousInitializer
on file level.Piotr Krzemiński
08/09/2021, 10:25 AMPiotr Krzemiński
08/10/2021, 10:40 AMinitializedField.initializer = irFactory.createExpressionBody(JsIrBuilder.buildBoolean(context.irBuiltIns.booleanType, false))
I got this Python thing working 🎉bashor
08/10/2021, 3:20 PM