Skip to content

Instantly share code, notes, and snippets.

@tanishiking
Created March 7, 2024 09:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanishiking/fa52f5ed3d2fc7d3b3d10762ca011f58 to your computer and use it in GitHub Desktop.
Save tanishiking/fa52f5ed3d2fc7d3b3d10762ca011f58 to your computer and use it in GitHub Desktop.
/**
  * The `String` class represents character strings. All string literals in Kotlin programs, such as `"abc"`, are
  * implemented as instances of this class.
  */
 public class String internal @WasmPrimitiveConstructor constructor(
     private var leftIfInSum: String?,
     @kotlin.internal.IntrinsicConstEvaluation
     public override val length: Int,
     private var _chars: WasmCharArray,
 ) : Comparable<String>, CharSequence {
     public companion object {}

https://github.com/JetBrains/kotlin/blob/4d0454665214945f1a8d9d8e8acc6b8d7c6844e2/libraries/stdlib/wasm/builtins/kotlin/String.kt#L11-L21

that will compile to

(type $kotlin.String___type_86 (sub $kotlin.Any___type_32 (struct
	(field (ref $kotlin.String.vtable___type_60))
	(field (ref null struct))
	(field (mut i32))
	(field (mut i32))
	(field (mut (ref null $kotlin.String___type_86))) ;; left
	(field (mut i32)) ;; length
	(field (mut (ref null $kotlin.wasm.internal.WasmCharArray___type_34))))))  ;; chars
	
(type $kotlin.wasm.internal.WasmCharArray___type_34 (array (mut i16)))

https://seb.deleuze.fr/introducing-kotlin-wasm/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment