+
+`{
+ #include <emscripten.h>
+ #include <gc.h>
+`}
+
+redef class String
+ fun run_js do run_js_native(self.escape_to_js.to_cstring)
+ private fun run_js_native(script: NativeString) `{ emscripten_run_script(script); `}
+
+ fun escape_to_js: String do return self.replace('\n', "\\n")
+
+ fun alert do "alert('{self.escape_to_js}')".run_js
+end
+
+redef class Sys
+ redef fun force_garbage_collection `{ GC_FORCE_COLLECT(); `}
+
+ # The emscripten GC *must* be manually invoked, it will not act by itself
+ fun suggest_garbage_collection `{ GC_MAYBE_COLLECT(); `}
+end