Skip to content

Instantly share code, notes, and snippets.

#include "sdk/allocator.h"
#include "sdk/logger.h"
#include <stdlib.h>
#include <string.h>
#define __MODULE_IMPORT(module_name, function_name) \
__attribute__((__import_module__(#module_name), __import_name__(#function_name)))
void store_extern(char *ptr, char byte) __MODULE_IMPORT(sqlite, store);
(mainModule, sideModules) <- Traverse[List]
.foldLeftM[EitherT[F, ApplyError, ?], Compiled, (Option[MainModule], List[WasmModule])](
scriptCxt.getModules.toList,
(None, Nil)
) {
// the main module almost always has non set module name
case (acc, moduleDescription) if Option(moduleDescription.getName) == config.mainModuleConfig.name ⇒
for {
mainModule ← MainModule(
moduleDescription,
#include "quickjs-libc.h"
const uint32_t pi_size = 1120;
const uint8_t pi[1120] = {
0x01, 0x27, 0x0e, 0x63, 0x61, 0x6c, 0x63, 0x5f,
0x70, 0x69, 0x14, 0x75, 0x73, 0x65, 0x20, 0x73,
0x74, 0x72, 0x69, 0x63, 0x74, 0x14, 0x75, 0x73,
0x65, 0x20, 0x62, 0x69, 0x67, 0x69, 0x6e, 0x74,
0x0a, 0x70, 0x69, 0x2e, 0x6a, 0x73, 0x08, 0x70,
(func $__DOUBLE_BITS_ (type 28) (param f64) (result i64)
get_local 0
i64.reinterpret/f64)
...
(func $__DOUBLE_BITS_.1 (type 28) (param f64) (result i64)
get_local 0
i64.reinterpret/f64)
...
(func $__DOUBLE_BITS_.2 (type 28) (param f64) (result i64)
get_local 0
(func $hincrbyCommand (type 0) (param i32)
(local i32 i32 i32 i64 i64 i32)
get_global 0
i32.const 32
i32.sub
tee_local 1
set_global 0
block ;; label = @1
get_local 0
get_local 0
(func $hincrbyCommand (type 0) (param i32)
(local i32 i32 i32 i64 i64 i32)
get_global 0
i32.const 32
i32.sub
tee_local 1
set_global 0
block ;; label = @1
get_local 0
get_local 0
(func $hincrbyCommand (type 0) (param i32)
(local i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i64 i64 i64 i64 i64 i64 i32 i32 i32 i64 i64 i64 i64 i32 i32 i32 i64 i64 i64 i64 i64 i64 i32 i32 i32 i64 i64 i64 i64 i32 i32 i32 i64 i64 i64 i64 i32 i32 i32 i64 i64 i64 i64 i64 i64 i32 i32 i32 i32 i32 i32 i32 i32 i64 i64 i64 i64 i32 i32 i32 i32 i32 i32 i32 i32 i64 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i32 i64 i64 i64 i32 i32 i32)
get_global 0
set_local 1
i32.const 48
set_local 2
get_local 1
get_local 2
i32.sub
set_local 3
block ;; label = @4
block ;; label = @5
get_local 63
i32.eqz
br_if 0 (;@5;)
i32.const 2139095040
set_local 64
get_local 3
f64.load offset=5200
set_local 65
call $__extenddftf2
i32.const 8
set_local 124
get_local 3
get_local 124
i32.add
set_local 125
get_local 125
i64.load align=1
set_local 126
@mikevoronov
mikevoronov / main.c
Created April 12, 2019 13:53
main.c
#include "sdk/allocator.h"
#include "sdk/logger.h"
...
char *invoke(const char *str, int length) {
const size_t greeting_length = strlen(greeting);
char *response = (char *)allocate(response_length);
wasm_log(str, length);
for(int i = 0; i < RESPONSE_SIZE_BYTES; ++i) {
response[i] = (response_length >> 8*i) & 0xFF;