mirror of
https://github.com/fluencelabs/wasmer
synced 2024-12-05 02:20:19 +00:00
Remove old emscripten examples
This commit is contained in:
parent
2486ac96a3
commit
d351ac0136
@ -1,31 +0,0 @@
|
||||
(module
|
||||
(type $t1 (func (param i32 i32) (result i32)))
|
||||
(type $t2 (func (param i32)))
|
||||
(type $t3 (func ))
|
||||
(func $printf (import "env" "printf") (type $t1))
|
||||
(func $abort (import "env" "abort") (type $t2))
|
||||
(func $_abort (import "env" "_abort") (type $t3))
|
||||
(func $abort_on_cannot_grow_memory (import "env" "abortOnCannotGrowMemory") (type $t3))
|
||||
(memory 1)
|
||||
(data (i32.const 0) ">>> First\00")
|
||||
(data (i32.const 24) ">>> Second\00")
|
||||
(data (i32.const 48) "Aborting abruptly!\00")
|
||||
(func $main (export "main")
|
||||
;; print ">>> First"
|
||||
(call $printf (i32.const 0) (i32.const 0))
|
||||
(drop)
|
||||
|
||||
;; aborts
|
||||
(call $_abort) ;; ()
|
||||
|
||||
;; aborts
|
||||
(call $abort_on_cannot_grow_memory) ;; ()
|
||||
|
||||
;; aborts
|
||||
(call $abort (i32.const 48)) ;; (message: u32)
|
||||
|
||||
;; print ">>> Second"
|
||||
(call $printf (i32.const 24) (i32.const 0))
|
||||
(drop)
|
||||
)
|
||||
)
|
@ -1,27 +0,0 @@
|
||||
(module
|
||||
(type $t1 (func (param i32)))
|
||||
(func $putchar (import "env" "putchar") (type $t1))
|
||||
(func $sys_exit (import "env" "___syscall1") (type $t1))
|
||||
(memory 1)
|
||||
(func $main (export "main")
|
||||
;; print "Hello"
|
||||
(call $putchar (i32.const 72))
|
||||
(call $putchar (i32.const 101))
|
||||
(call $putchar (i32.const 108))
|
||||
(call $putchar (i32.const 108))
|
||||
(call $putchar (i32.const 111))
|
||||
(call $putchar (i32.const 32))
|
||||
|
||||
;; exit abruptly
|
||||
(call $sys_exit (i32.const 255)) ;; (status: c_int) -> c_int
|
||||
|
||||
;; print " World!"
|
||||
(call $putchar (i32.const 87))
|
||||
(call $putchar (i32.const 111))
|
||||
(call $putchar (i32.const 114))
|
||||
(call $putchar (i32.const 108))
|
||||
(call $putchar (i32.const 100))
|
||||
(call $putchar (i32.const 33))
|
||||
(call $putchar (i32.const 10))
|
||||
)
|
||||
)
|
@ -1,43 +0,0 @@
|
||||
(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" "___syscall5") (type $t2))
|
||||
(func $sys_read (import "env" "___syscall3") (type $t2))
|
||||
(func $sys_close (import "env" "___syscall6") (type $t3))
|
||||
(memory 1)
|
||||
(data $filename (i32.const 0) "/Users/xxxx/Desktop/hello.txt\00")
|
||||
(func $main (export "main")
|
||||
;; declare variables
|
||||
(local $string_buf_addr i32)
|
||||
(local $string_buf_len i32)
|
||||
(local $file_access_flag i32)
|
||||
(local $file_permission_flag i32)
|
||||
(local $file_descriptor i32)
|
||||
|
||||
;; set variables
|
||||
(set_local $string_buf_addr (i32.const 72)) ;; string_buf_addr at offset 72
|
||||
(set_local $string_buf_len (i32.const 10)) ;; string_buf_len is 5
|
||||
(set_local $file_access_flag (i32.const 02)) ;; file_access_flag has O_RDWR permission
|
||||
(set_local $file_permission_flag (i32.const 700)) ;; file_permission_flag has S_IRWXU permission
|
||||
|
||||
;; open file
|
||||
(call $sys_open (i32.const 0) (get_local $file_access_flag) (get_local $file_permission_flag)) ;; (path: u32, flags: c_int, mode: c_int) -> c_int
|
||||
(set_local $file_descriptor) ;; set file_descriptor to the value returned by sys_open
|
||||
|
||||
;; read file content
|
||||
(call $sys_read (get_local $file_descriptor) (get_local $string_buf_addr) (get_local $string_buf_len)) ;; (fd: c_int, buf: u32, count: size_t) -> ssize_t
|
||||
(drop) ;; ignoring errors
|
||||
|
||||
;; close file
|
||||
(call $sys_close (get_local $file_descriptor)) ;; (fd: c_int) -> c_int
|
||||
(drop) ;; ignoring errors
|
||||
|
||||
;; print file content
|
||||
(call $printf (get_local $string_buf_addr) (i32.const 0))
|
||||
(drop) ;; ignoring errors
|
||||
)
|
||||
)
|
Loading…
Reference in New Issue
Block a user