Created
August 18, 2020 21:24
-
-
Save FalseHonesty/c76cef82585b0f5f0052a01e54d520b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ElementaToolsAssignmentTransformer( | |
private val context: IrPluginContext | |
) : IrElementTransformerVoidWithContext(), FileLoweringPass { | |
private lateinit var file: IrFile | |
private lateinit var fileSource: String | |
override fun lower(irFile: IrFile) { | |
file = irFile | |
fileSource = File(irFile.path).readText() | |
irFile.transformChildrenVoid() | |
} | |
override fun visitSetField(expression: IrSetField): IrExpression { | |
val rhs = expression.value | |
if (rhs !is IrConstructorCall) | |
return super.visitSetField(expression) | |
val constructorType = rhs.symbol.owner | |
return super.visitSetField(expression) | |
} | |
override fun visitSetVariable(expression: IrSetVariable): IrExpression { | |
val rhs = expression.value | |
if (rhs !is IrConstructorCall) | |
return super.visitSetVariable(expression) | |
val constructorType = rhs.symbol.owner | |
return super.visitSetVariable(expression) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ElementaToolsIrGenerationExtension : IrGenerationExtension { | |
override fun generate(moduleFragment: IrModuleFragment, pluginContext: IrPluginContext) { | |
for (file in moduleFragment.files) { | |
ElementaToolsAssignmentTransformer(pluginContext).lower(file) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import club.sk1er.elementa.UIBlock | |
import kotlin.test.assertEquals | |
fun main() { | |
val myVarName = UIBlock() | |
assertEquals("myVarName", myVarName.name) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment