Test
Test
Test
Test
Test
| (module | |
| (import "wasi_unstable" "fd_write" (func $fd_write (param i32 i32 i32 i32) (result i32))) | |
| (import "wasi_unstable" "fd_read" (func $fd_read (param i32 i32 i32 i32) (result i32))) | |
| (memory 10) | |
| (export "memory" (memory 0)) | |
| ;; prompt __wasi_ciovec_t struct | |
| (data (i32.const 0) "\08\00\00\00") ;; buf: pointer to prompt string | |
| (data (i32.const 4) "\02\00\00\00") ;; buf_len: 2 characters |
Test
Test
Test
Test
Test
| (module | |
| (type $t1 (func (param i32))) | |
| (type $t2 (func (param i32 i32 i32) (result i32))) | |
| (type $t3 (func (param i32) (result i32))) | |
| (type $t4 (func (param i32 i32) (result i32))) | |
| (func $putchar (import "env" "putchar") (type $t1)) | |
| (func $printf (import "env" "printf") (type $t4)) | |
| (func $sys_open (import "env" "sys_open") (type $t2)) | |
| (func $sys_read (import "env" "sys_read") (type $t2)) | |
| (func $sys_close (import "env" "sys_close") (type $t3)) |
| from ctypes import cdll, c_int, c_uint, c_void_p, CFUNCTYPE | |
| # Load library and get library | |
| lib = cdll.LoadLibrary('./libwasmer.so') | |
| # Get compile function | |
| compile = lib.compile | |
| compile.restype = c_void_p # vmctx_addr | |
| # NOTE: Ideally we will pass import objects |
| |=== <Program> ===| | |
| #__crystal_get_exception(Pointer(LibUnwind::Exception)) | |
| #__crystal_malloc(UInt32) | |
| #__crystal_malloc_atomic(UInt32) | |
| #__crystal_personality(Int32, LibUnwind::Action, UInt64, Pointer(LibUnwind::Exception), Pointer(Void)) | |
| #__crystal_raise(Pointer(LibUnwind::Exception)) | |
| #__crystal_raise_string(Pointer(UInt8)) | |
| #__crystal_realloc(Pointer(Void), UInt32) | |
| #__crystal_sigfault_handler(Int32, Pointer(Void)) |