Skip to content

Commit

Permalink
github pages
Browse files Browse the repository at this point in the history
  • Loading branch information
andreypfau committed Feb 12, 2024
1 parent 47c5fb2 commit 22f4766
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 92 deletions.
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ <h1>TL-B -> FunC Generator (DEVELOPER PREVIEW)</h1>
<button id="compile" style="padding: 10px">Compile</button>
</div>
<label for="output"></label><textarea id="output" readonly style="width: 100%; height: 500px"></textarea>

<details>
<summary>TL-B Types Debug</summary>
<label for="debug"></label><textarea id="debug" readonly style="width: 100%; height: 200px"></textarea>
</details>

<script src="js/kotlin-kotlin-stdlib.js"></script>
<script src="js/kotlinx-io-kotlinx-io-core.js"></script>
Expand Down
76 changes: 19 additions & 57 deletions js/kotlin-kotlin-stdlib.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ if (typeof String.prototype.startsWith === 'undefined') {
setMetadataFor(KotlinNothingValueException, 'KotlinNothingValueException', classMeta, RuntimeException, VOID, KotlinNothingValueException_init_$Create$);
setMetadataFor(Annotation, 'Annotation', interfaceMeta);
setMetadataFor(ExperimentalJsFileName, 'ExperimentalJsFileName', classMeta, VOID, [Annotation]);
setMetadataFor(ExperimentalJsExport, 'ExperimentalJsExport', classMeta, VOID, [Annotation]);
setMetadataFor(IntrinsicConstEvaluation, 'IntrinsicConstEvaluation', classMeta, VOID, [Annotation]);
setMetadataFor(Companion, 'Companion', objectMeta);
setMetadataFor(Comparable, 'Comparable', interfaceMeta);
Expand Down Expand Up @@ -202,8 +201,6 @@ if (typeof String.prototype.startsWith === 'undefined') {
setMetadataFor(StringCompanionObject, 'StringCompanionObject', objectMeta);
setMetadataFor(BooleanCompanionObject, 'BooleanCompanionObject', objectMeta);
setMetadataFor(AutoCloseable, 'AutoCloseable', interfaceMeta);
setMetadataFor(Ignore, 'Ignore', classMeta, VOID, [Annotation]);
setMetadataFor(JsExport, 'JsExport', classMeta, VOID, [Annotation]);
setMetadataFor(JsName, 'JsName', classMeta, VOID, [Annotation]);
setMetadataFor(JsQualifier, 'JsQualifier', classMeta, VOID, [Annotation]);
setMetadataFor(JsFileName, 'JsFileName', classMeta, VOID, [Annotation]);
Expand Down Expand Up @@ -968,6 +965,10 @@ if (typeof String.prototype.startsWith === 'undefined') {
return new _no_name_provided__qut3iv(_this__u8e3s4);
}

function component2(_this__u8e3s4) {
return _this__u8e3s4.get_c1px32_k$(1);
}

function indexOfLast(_this__u8e3s4, predicate) {
var iterator = _this__u8e3s4.listIterator_70e65o_k$(_this__u8e3s4.get_size_woubt6_k$());
while (iterator.hasPrevious_qh0629_k$()) {
Expand Down Expand Up @@ -1031,6 +1032,10 @@ if (typeof String.prototype.startsWith === 'undefined') {
return false;
}

function component1(_this__u8e3s4) {
return _this__u8e3s4.get_c1px32_k$(0);
}

function mapIndexedNotNull(_this__u8e3s4, transform) {
// Inline function 'kotlin.collections.mapIndexedNotNullTo' call
var destination = ArrayList_init_$Create$();
Expand Down Expand Up @@ -2062,22 +2067,6 @@ if (typeof String.prototype.startsWith === 'undefined') {
return '@kotlin.js.ExperimentalJsFileName()';
};

function ExperimentalJsExport() {
}

protoOf(ExperimentalJsExport).equals = function (other) {
if (!(other instanceof ExperimentalJsExport))
return false;
other instanceof ExperimentalJsExport || THROW_CCE();
return true;
};
protoOf(ExperimentalJsExport).hashCode = function () {
return 0;
};
protoOf(ExperimentalJsExport).toString = function () {
return '@kotlin.js.ExperimentalJsExport()';
};

function IntrinsicConstEvaluation() {
}

Expand Down Expand Up @@ -6907,38 +6896,6 @@ if (typeof String.prototype.startsWith === 'undefined') {
return tmp;
}

function Ignore() {
}

protoOf(Ignore).equals = function (other) {
if (!(other instanceof Ignore))
return false;
other instanceof Ignore || THROW_CCE();
return true;
};
protoOf(Ignore).hashCode = function () {
return 0;
};
protoOf(Ignore).toString = function () {
return '@kotlin.js.JsExport.Ignore()';
};

function JsExport() {
}

protoOf(JsExport).equals = function (other) {
if (!(other instanceof JsExport))
return false;
other instanceof JsExport || THROW_CCE();
return true;
};
protoOf(JsExport).hashCode = function () {
return 0;
};
protoOf(JsExport).toString = function () {
return '@kotlin.js.JsExport()';
};

function JsName(name) {
this.name_1 = name;
}
Expand Down Expand Up @@ -13526,7 +13483,7 @@ if (typeof String.prototype.startsWith === 'undefined') {
return tmp;
}

function component1(_this__u8e3s4) {
function component1_0(_this__u8e3s4) {
return _this__u8e3s4.get_key_18j28a_k$();
}

Expand All @@ -13538,7 +13495,7 @@ if (typeof String.prototype.startsWith === 'undefined') {
return pairs.length > 0 ? toMap_0(pairs, LinkedHashMap_init_$Create$_0(mapCapacity(pairs.length))) : emptyMap();
}

function component2(_this__u8e3s4) {
function component2_0(_this__u8e3s4) {
return _this__u8e3s4.get_value_j01efc_k$();
}

Expand Down Expand Up @@ -17153,13 +17110,18 @@ if (typeof String.prototype.startsWith === 'undefined') {
return this_0.toString();
}

function appendLine_0(_this__u8e3s4, value) {
function appendLine_0(_this__u8e3s4) {
return _this__u8e3s4.append_am5a4z_k$(_Char___init__impl__6a9atx(10));
}

function appendLine_1(_this__u8e3s4, value) {
// Inline function 'kotlin.text.appendLine' call
return _this__u8e3s4.append_22ad7x_k$(value).append_am5a4z_k$(_Char___init__impl__6a9atx(10));
return _this__u8e3s4.append_t8pm91_k$(value).append_am5a4z_k$(_Char___init__impl__6a9atx(10));
}

function appendLine_1(_this__u8e3s4) {
return _this__u8e3s4.append_am5a4z_k$(_Char___init__impl__6a9atx(10));
function appendLine_2(_this__u8e3s4, value) {
// Inline function 'kotlin.text.appendLine' call
return _this__u8e3s4.append_22ad7x_k$(value).append_am5a4z_k$(_Char___init__impl__6a9atx(10));
}

function toIntOrNull(_this__u8e3s4) {
Expand Down
4 changes: 1 addition & 3 deletions js/tlb.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
type Nullable<T> = T | null | undefined
export declare namespace org.ton.tlb {
function funcCodeGen(src: string): string;
}

export as namespace tlb;
64 changes: 39 additions & 25 deletions js/tlb.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 9 additions & 6 deletions src/jsMain/kotlin/FuncCodeGen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ import org.ton.tlb.parser.TlbGrammar
fun main() {
document.getElementById("compile")?.addEventListener("click", {
val src = document.getElementById("src")?.asDynamic().value as String
val output = funcCodeGen(src)
val (output, debug) = funcCodeGen(src)
document.getElementById("output")?.textContent = output
document.getElementById("debug")?.textContent = debug
})
}

@OptIn(ExperimentalJsExport::class)
@JsExport
fun funcCodeGen(src: String): String {
fun funcCodeGen(src: String): List<String> {
try {
val ast = TlbGrammar().parseOrThrow(src)
val compiler = TlbCompiler()
Expand All @@ -31,8 +30,12 @@ fun funcCodeGen(src: String): String {
funcCodeGen.generate(this)
}
}
return output
return listOf(output, buildString {
compiler.types.values.forEach { type ->
appendLine(type)
}
})
} catch (e: Exception) {
return e.stackTraceToString()
return listOf(e.stackTraceToString(), "")
}
}

0 comments on commit 22f4766

Please sign in to comment.