diff --git a/.ipynb_checkpoints/AstClasses-checkpoint.ipynb b/.ipynb_checkpoints/AstClasses-checkpoint.ipynb new file mode 100644 index 0000000..ffabdc4 --- /dev/null +++ b/.ipynb_checkpoints/AstClasses-checkpoint.ipynb @@ -0,0 +1,53 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "90d2708c-0aad-4b6d-aa16-3630ccc4d243", + "metadata": {}, + "source": [ + "# AST tree nodes\n", + "\n", + "**RValue** - something that can be assigned.\n", + "\n", + "**AstTypeLeaf** - string representation of variable/argument data type. Sample:\n", + "```\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + "\n", + "```\n", + "\n", + "**ArgumentNode** - represents variables that are passed to the functon." + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "ab11df09-20dc-4333-8967-a8210fa7f4ed", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Kotlin", + "language": "kotlin", + "name": "kotlin" + }, + "language_info": { + "codemirror_mode": "text/x-kotlin", + "file_extension": ".kt", + "mimetype": "text/x-kotlin", + "name": "kotlin", + "nbconvert_exporter": "", + "pygments_lexer": "kotlin", + "version": "1.9.23" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/.ipynb_checkpoints/AstTransformations-checkpoint.ipynb b/.ipynb_checkpoints/AstTransformations-checkpoint.ipynb new file mode 100644 index 0000000..d38c029 --- /dev/null +++ b/.ipynb_checkpoints/AstTransformations-checkpoint.ipynb @@ -0,0 +1,106 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "784cd44d-5255-44e1-be5f-1228a11c6abf", + "metadata": {}, + "source": [ + "Test kernel" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "id": "5e7b1719-385f-4e80-a810-78735d094f5d", + "metadata": {}, + "outputs": [], + "source": [ + "@file:Repository(\"https://jitpack.io\")\n", + "@file:DependsOn(\"com.github.vshcryabets:codegen:18c0114083\")" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "6ff5ce0c-0952-4b9b-8ba4-3883f03d5ca9", + "metadata": {}, + "outputs": [], + "source": [ + "import ce.defs.DataType\n", + "import ce.defs.DataValue\n", + "import generators.obj.abstractSyntaxTree.DataClass\n", + "import generators.obj.abstractSyntaxTree.DataField\n", + "import generators.kotlin.PrepareRightValueUseCase\n", + "\n", + "val dataClassDescriptor = DataClass(\"c\").apply {\n", + " field(\"A\", DataType.int32, 1)\n", + "}\n", + "\n", + "print(dataClassDescriptor)\n" + ] + }, + { + "cell_type": "markdown", + "id": "f3d7ec60-12d4-453e-be3d-20c6ca747810", + "metadata": {}, + "source": [ + "# Input tree to AST transformations\n", + "\n", + "**PrepareRightValueUseCase** - convert input DataValue node to AST RValue.\n", + "Sample of transformation, input:\n", + "```\n", + "DataField(\n", + " value = DataValue() {\n", + " NewInstance()\n", + " }\n", + ")\n", + "```" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "0b430479-4395-4b11-846d-f63537ffe4dc", + "metadata": {}, + "outputs": [], + "source": [ + "val dataField = DataField(\"varName\").apply {\n", + " generators.obj.abstractSyntaxTree.setType(DataType.int32)\n", + " generators.obj.abstractSyntaxTree.setValue(\"strValue\")\n", + " }\n", + "print(dataField)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "73167612-b597-4f99-a2bf-0948c082c5e1", + "metadata": {}, + "outputs": [], + "source": [ + "val prepareRightValueUseCase = PrepareRightValueUseCase()\n", + "val fileData = FileDataImpl(\"someFile.kt\")\n", + "val rValue = prepareRightValueUseCase.toRightValue(dataField, fileData)\n", + "print(rValue)" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Kotlin", + "language": "kotlin", + "name": "kotlin" + }, + "language_info": { + "codemirror_mode": "text/x-kotlin", + "file_extension": ".kt", + "mimetype": "text/x-kotlin", + "name": "kotlin", + "nbconvert_exporter": "", + "pygments_lexer": "kotlin", + "version": "1.9.23" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/.run/Uroborus.run.xml b/.run/Uroborus.run.xml index 140fdc7..9824ff4 100644 --- a/.run/Uroborus.run.xml +++ b/.run/Uroborus.run.xml @@ -1,6 +1,7 @@ -