mirror of
https://gitee.com/wa-lang/wa.git
synced 2025-12-06 09:18:53 +08:00
清理 wasi 相关代码
This commit is contained in:
15
.github/workflows/wa.yml
vendored
15
.github/workflows/wa.yml
vendored
@@ -30,8 +30,9 @@ jobs:
|
||||
- run: go install
|
||||
|
||||
- run: wa -h
|
||||
- run: cd waroot && wa run -target=wasi examples/prime
|
||||
- run: cd waroot && wa run -target=wasi hello.wa
|
||||
- run: cd waroot && wa run examples/prime
|
||||
- run: cd waroot && wa run hello.wa
|
||||
- run: cd waroot && wa run hello.wz
|
||||
- run: cd waroot && wa run -target=unknown hello.wa
|
||||
|
||||
build-and-test-windows:
|
||||
@@ -56,8 +57,9 @@ jobs:
|
||||
- run: go install
|
||||
|
||||
- run: wa -h
|
||||
- run: cd waroot && wa run -target=wasi examples/prime
|
||||
- run: cd waroot && wa run -target=wasi hello.wa
|
||||
- run: cd waroot && wa run examples/prime
|
||||
- run: cd waroot && wa run hello.wa
|
||||
- run: cd waroot && wa run hello.wz
|
||||
- run: cd waroot && wa run -target=unknown hello.wa
|
||||
|
||||
build-and-test-macos:
|
||||
@@ -81,6 +83,7 @@ jobs:
|
||||
- run: go install
|
||||
|
||||
- run: wa -h
|
||||
- run: cd waroot && wa run -target=wasi examples/prime
|
||||
- run: cd waroot && wa run -target=wasi hello.wa
|
||||
- run: cd waroot && wa run examples/prime
|
||||
- run: cd waroot && wa run hello.wa
|
||||
- run: cd waroot && wa run hello.wz
|
||||
- run: cd waroot && wa run -target=unknown hello.wa
|
||||
|
||||
@@ -193,7 +193,7 @@ func main {
|
||||
运行并输出结果:
|
||||
|
||||
```
|
||||
$ cd waroot && wa run -target=wasi examples/prime
|
||||
$ cd waroot && wa run examples/prime
|
||||
2
|
||||
3
|
||||
5
|
||||
|
||||
@@ -160,7 +160,7 @@ func main {
|
||||
Execute the program:
|
||||
|
||||
```
|
||||
$ cd waroot && wa run -target=wasi examples/prime
|
||||
$ cd waroot && wa run examples/prime
|
||||
2
|
||||
3
|
||||
5
|
||||
|
||||
@@ -37,7 +37,6 @@ const (
|
||||
WaOS_Default = config.WaOS_Default // 默认
|
||||
|
||||
WaOS_js = config.WaOS_js // 浏览器 js
|
||||
WaOS_wasi = config.WaOS_wasi // WASI 接口
|
||||
WaOS_wasm4 = config.WaOS_wasm4 // WASM4 接口
|
||||
WaOS_unknown = config.WaOS_unknown // Unknown
|
||||
)
|
||||
|
||||
@@ -77,8 +77,6 @@ func BuildOptions(c *cli.Context, waBackend ...string) *Option {
|
||||
// read from default or wa.mod
|
||||
case config.WaOS_js:
|
||||
opt.Target = config.WaOS_js
|
||||
case config.WaOS_wasi:
|
||||
opt.Target = config.WaOS_wasi
|
||||
case config.WaOS_wasm4:
|
||||
opt.Target = config.WaOS_wasm4
|
||||
case config.WaOS_arduino:
|
||||
|
||||
@@ -41,10 +41,6 @@ var CmdInit = &cli.Command{
|
||||
Name: "wasm4",
|
||||
Usage: "wasm4 game",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "wasi",
|
||||
Usage: "wasi example",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "arduino",
|
||||
Usage: "arduino nano 33 example",
|
||||
@@ -59,7 +55,7 @@ var CmdInit = &cli.Command{
|
||||
Action: func(c *cli.Context) error {
|
||||
err := InitApp(
|
||||
c.String("name"), c.String("pkgpath"),
|
||||
c.Bool("p5"), c.Bool("wasm4"), c.Bool("wasi"), c.Bool("arduino"),
|
||||
c.Bool("p5"), c.Bool("wasm4"), c.Bool("arduino"),
|
||||
c.Bool("update"),
|
||||
)
|
||||
if err != nil {
|
||||
@@ -70,7 +66,7 @@ var CmdInit = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func InitApp(name, pkgpath string, isP5App, isWasm4App, isWasiApp, isArduinoApp, update bool) error {
|
||||
func InitApp(name, pkgpath string, isP5App, isWasm4App, isArduinoApp, update bool) error {
|
||||
if name == "" {
|
||||
return fmt.Errorf("init failed: <%s> is empty", name)
|
||||
}
|
||||
@@ -89,7 +85,6 @@ func InitApp(name, pkgpath string, isP5App, isWasm4App, isWasiApp, isArduinoApp,
|
||||
}
|
||||
|
||||
if isP5App {
|
||||
isWasiApp = false
|
||||
isWasm4App = false
|
||||
}
|
||||
|
||||
@@ -106,7 +101,6 @@ func InitApp(name, pkgpath string, isP5App, isWasm4App, isWasiApp, isArduinoApp,
|
||||
Year int
|
||||
IsP5App bool
|
||||
IsWasm4App bool
|
||||
IsWasiApp bool
|
||||
IsArduinoApp bool
|
||||
}{
|
||||
Name: name,
|
||||
@@ -114,7 +108,6 @@ func InitApp(name, pkgpath string, isP5App, isWasm4App, isWasiApp, isArduinoApp,
|
||||
Year: time.Now().Year(),
|
||||
IsP5App: isP5App,
|
||||
IsWasm4App: isWasm4App,
|
||||
IsWasiApp: isWasiApp,
|
||||
IsArduinoApp: isArduinoApp,
|
||||
}
|
||||
|
||||
@@ -167,7 +160,7 @@ func InitApp(name, pkgpath string, isP5App, isWasm4App, isWasiApp, isArduinoApp,
|
||||
}
|
||||
|
||||
// 只有默认的 js 生成定制的 index.html
|
||||
if isP5App || isWasm4App || isWasiApp || isArduinoApp {
|
||||
if isP5App || isWasm4App || isArduinoApp {
|
||||
os.Remove(filepath.Join(name, "output", "index.html"))
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,6 @@ const (
|
||||
WaOS_Default = wasrc.WaOS_js // 默认
|
||||
|
||||
WaOS_js = wasrc.WaOS_js // 浏览器 JS
|
||||
WaOS_wasi = wasrc.WaOS_wasi // WASI 接口
|
||||
WaOS_wasm4 = wasrc.WaOS_wasm4 // WASM4 接口
|
||||
WaOS_arduino = wasrc.WaOS_arduino // Arduino
|
||||
WaOS_unknown = wasrc.WaOS_unknown // Unknown
|
||||
|
||||
@@ -69,7 +69,6 @@ var tokens = [...]elt{
|
||||
{token.FLOAT, "1e-100", literal},
|
||||
{token.FLOAT, "2.71828e-1000", literal},
|
||||
{token.CHAR, "'a'", literal},
|
||||
{token.STRING, `"wasi_snapshot_preview1"`, literal},
|
||||
//{token.STRING, `"abc\12\ab\CD\n\t\r"`, literal},
|
||||
|
||||
// Keywords
|
||||
|
||||
@@ -148,8 +148,6 @@ func ReadImportModuleName(wasmBytes []byte) (string, error) {
|
||||
switch moduleName {
|
||||
case "syscall_js":
|
||||
return config.WaOS_js, nil
|
||||
case "wasi_snapshot_preview1":
|
||||
return config.WaOS_wasi, nil
|
||||
case "arduino":
|
||||
return config.WaOS_arduino, nil
|
||||
case "env":
|
||||
@@ -179,7 +177,7 @@ func HasUnknownConsoleImportFunc(wasmBytes []byte) bool {
|
||||
}
|
||||
|
||||
switch moduleName {
|
||||
case "syscall_js", "wasi_snapshot_preview1", "arduino":
|
||||
case "syscall_js", "arduino":
|
||||
default: // wasm4, unknown, ...
|
||||
return true
|
||||
}
|
||||
@@ -244,11 +242,6 @@ func (p *Module) buildModule() error {
|
||||
break
|
||||
}
|
||||
|
||||
if moduleName == "wasi_snapshot_preview1" {
|
||||
waOS = config.WaOS_wasi
|
||||
break
|
||||
}
|
||||
|
||||
if moduleName == "arduino" {
|
||||
waOS = config.WaOS_arduino
|
||||
break
|
||||
@@ -266,11 +259,6 @@ func (p *Module) buildModule() error {
|
||||
p.wazeroInitErr = err
|
||||
return err
|
||||
}
|
||||
case config.WaOS_wasi:
|
||||
if _, err = WasiInstantiate(p.wazeroCtx, p.wazeroRuntime); err != nil {
|
||||
p.wazeroInitErr = err
|
||||
return err
|
||||
}
|
||||
case config.WaOS_wasm4:
|
||||
panic("wasm4: TODO") // 浏览器执行
|
||||
case config.WaOS_js:
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
// 版权 @2022 凹语言 作者。保留所有权利。
|
||||
|
||||
package wazero
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io"
|
||||
"os"
|
||||
|
||||
"wa-lang.org/wa/internal/3rdparty/wazero"
|
||||
"wa-lang.org/wa/internal/3rdparty/wazero/api"
|
||||
wasi "wa-lang.org/wa/internal/3rdparty/wazero/imports/wasi_snapshot_preview1"
|
||||
)
|
||||
|
||||
// https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md
|
||||
|
||||
const wasiModuleName = "wasi_snapshot_preview1"
|
||||
|
||||
func WasiInstantiate(ctx context.Context, rt wazero.Runtime) (api.Closer, error) {
|
||||
return wasi.Instantiate(ctx, rt)
|
||||
}
|
||||
|
||||
func wasi_fdWriteFn(ctx context.Context, mod api.Module, fd, iovs, iovsCount, resultSize uint32) wasi.Errno {
|
||||
var err error
|
||||
var nwritten uint32
|
||||
var writer = os.Stdout
|
||||
|
||||
for i := uint32(0); i < iovsCount; i++ {
|
||||
iov := iovs + i*8
|
||||
offset, ok := mod.Memory().ReadUint32Le(ctx, iov)
|
||||
if !ok {
|
||||
return wasi.ErrnoFault
|
||||
}
|
||||
// Note: emscripten has been known to write zero length iovec. However,
|
||||
// it is not common in other compilers, so we don't optimize for it.
|
||||
l, ok := mod.Memory().ReadUint32Le(ctx, iov+4)
|
||||
if !ok {
|
||||
return wasi.ErrnoFault
|
||||
}
|
||||
|
||||
var n int
|
||||
if writer == io.Discard { // special-case default
|
||||
n = int(l)
|
||||
} else {
|
||||
b, ok := mod.Memory().Read(ctx, offset, l)
|
||||
if !ok {
|
||||
return wasi.ErrnoFault
|
||||
}
|
||||
n, err = writer.Write(b)
|
||||
if err != nil {
|
||||
return wasi.ErrnoIo
|
||||
}
|
||||
}
|
||||
nwritten += uint32(n)
|
||||
}
|
||||
if !mod.Memory().WriteUint32Le(ctx, resultSize, nwritten) {
|
||||
return wasi.ErrnoFault
|
||||
}
|
||||
return wasi.ErrnoSuccess
|
||||
}
|
||||
@@ -5,7 +5,7 @@ default:
|
||||
go version
|
||||
wasmer -V
|
||||
|
||||
wa build -optimize -target=wasi -output=fib_wa.wasm fib_wa.wa
|
||||
wa build -optimize -output=fib_wa.wasm fib_wa.wa
|
||||
GOOS=wasip1 GOARCH=wasm go build -o fib_go.wasm
|
||||
|
||||
du -sh fib_*.wasm
|
||||
@@ -15,7 +15,7 @@ default:
|
||||
|
||||
tinygo:
|
||||
time tinygo build --target wasm -o fib_tinygo.wasm -scheduler none --no-debug fib_go.go
|
||||
time wa build -optimize -target=wasi -output=fib_wa.wasm fib_wa.wa
|
||||
time wa build -optimize -output=fib_wa.wasm fib_wa.wa
|
||||
|
||||
wasm2wat fib_tinygo.wasm -o fib_tinygo.wat
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ go version go1.21.0 darwin/amd64
|
||||
wasmer -V
|
||||
wasmer 4.3.7
|
||||
|
||||
wa build -optimize -target=wasi -output=fib_wa.wasm fib_wa.wa
|
||||
wa build -optimize -output=fib_wa.wasm fib_wa.wa
|
||||
GOOS=wasip1 GOARCH=wasm go build -o fib_go.wasm
|
||||
|
||||
du -sh fib_*.wasm
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
- `unsafe` 包增加 `SliceData` 函数获取切片的数据地址
|
||||
- `os` 包增加 `StdinData` 函数一次性获取标准输入数据
|
||||
- 增加 CSP-J 2025 算法的例子
|
||||
- 移除 WASI 规范的支持
|
||||
- v1.3.0 (2025-11-01)
|
||||
- 凹语言中文版正式上线
|
||||
- 解除 `unsafe.Pointer` 封印
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// 版权 @2022 凹语言™ 作者。保留所有权利。
|
||||
|
||||
import "examples/prime/benpkg"
|
||||
import "prime/benpkg"
|
||||
import "joypkg"
|
||||
|
||||
func main {
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
# 版权 @2023 prime 作者。保留所有权利。
|
||||
|
||||
name = "prime"
|
||||
pkgpath = "examples/prime"
|
||||
version = "0.0.1"
|
||||
authors = ["author", "author2"]
|
||||
description = "module description"
|
||||
readme = "README.md"
|
||||
homepage = ""
|
||||
repository = ""
|
||||
license = ""
|
||||
license_file = "LICENSE"
|
||||
keywords = []
|
||||
categories = []
|
||||
pkgpath = "prime"
|
||||
target = "js"
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 random_get
|
||||
func wasi_random_get(buf: i32, bufLen: i32) => (errno: i32)
|
||||
|
||||
func getRandomData(r: []byte) => error {
|
||||
if wasi_random_get(runtime.WaBytesToPtr(r), i32(len(r))) != 0 {
|
||||
return errors.New("wasi_random_get failed")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
;; Copyright 2023 The Wa Authors. All rights reserved.
|
||||
|
||||
;; 打印字符串
|
||||
(func $$runtime.waPuts (param $str i32) (param $len i32)
|
||||
;; {{$$runtime.waPuts/body/begin}}
|
||||
|
||||
(local $sp i32)
|
||||
(local $p_iov i32)
|
||||
(local $p_nwritten i32)
|
||||
(local $stdout i32)
|
||||
|
||||
;; 保存栈指针状态
|
||||
global.get $__stack_ptr
|
||||
local.set $sp
|
||||
|
||||
;; 分配 iov 结构体
|
||||
i32.const 8
|
||||
call $runtime.stackAlloc
|
||||
local.set $p_iov
|
||||
|
||||
;; 返回地址
|
||||
i32.const 4
|
||||
call $runtime.stackAlloc
|
||||
local.set $p_nwritten
|
||||
|
||||
;; 设置字符串指针和长度
|
||||
local.get $p_iov
|
||||
local.get $str
|
||||
i32.store offset=0 align=1
|
||||
|
||||
local.get $p_iov
|
||||
local.get $len
|
||||
i32.store offset=4 align=1
|
||||
|
||||
;; 标准输出
|
||||
i32.const 1
|
||||
local.set $stdout
|
||||
|
||||
;; 输出字符串
|
||||
local.get $stdout
|
||||
local.get $p_iov
|
||||
i32.const 1
|
||||
local.get $p_nwritten
|
||||
call $$runtime.fdWrite
|
||||
|
||||
;; 重置栈指针
|
||||
local.get $sp
|
||||
global.set $__stack_ptr
|
||||
drop
|
||||
|
||||
;; {{$$runtime.waPuts/body/end}}
|
||||
)
|
||||
@@ -1,132 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
import "syscall/wasi"
|
||||
|
||||
const WAOS = "wasi"
|
||||
|
||||
const 内力 = "瓦斯门"
|
||||
|
||||
#wa:linkname $runtime.argsSizesGet
|
||||
func argsSizesGet(result_argc: i32, result_argv_len: i32) => (errno: i32) {
|
||||
return wasi.ArgsSizesGet(result_argc, result_argv_len)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.argsGet
|
||||
func argsGet(result_argv: i32, result_argv_buf: i32) => (errno: i32) {
|
||||
return wasi.ArgsGet(result_argv, result_argv_buf)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.environGet
|
||||
func environGet(result_environv: i32, result_environv_buf: i32) => (errno: i32) {
|
||||
return wasi.EnvironGet(result_environv, result_environv_buf)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.environSizesGet
|
||||
func environSizesGet(result_environc: i32, result_environv_len: i32) => (errno: i32) {
|
||||
return wasi.EnvironSizesGet(result_environc, result_environv_len)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.fdWrite
|
||||
func fdWrite(fd: i32, io: i32, iovs_len: i32, nwritten: i32) => (errno: i32) {
|
||||
return wasi.FdWrite(fd, io, iovs_len, nwritten)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.procExit
|
||||
func procExit(code: int) {
|
||||
wasi.ProcExit(code)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.panic_
|
||||
func panic_(msg_ptr: i32, msg_len: i32, pos_msg_ptr: i32, pos_msg_len: i32) {
|
||||
waPrintString("panic: ")
|
||||
waPuts(msg_ptr, msg_len)
|
||||
waPrintString(" (")
|
||||
waPuts(pos_msg_ptr, pos_msg_len)
|
||||
waPrintRune(')')
|
||||
waPrintRune('\n')
|
||||
procExit(1)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.assert
|
||||
func assert(ok: i32, pos_msg_ptr: i32, pos_msg_len: i32) {
|
||||
if ok == 0 {
|
||||
waPrintString("assert failed (")
|
||||
waPuts(pos_msg_ptr, pos_msg_len)
|
||||
waPrintRune(')')
|
||||
waPrintRune('\n')
|
||||
procExit(1)
|
||||
}
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.assertWithMessage
|
||||
func assertWithMessage(ok: i32, msg_ptr: i32, msg_len: i32, pos_msg_ptr: i32, pos_msg_len: i32) {
|
||||
if ok == 0 {
|
||||
waPrintString("assert failed: ")
|
||||
waPuts(msg_ptr, msg_len)
|
||||
waPrintString(" (")
|
||||
waPuts(pos_msg_ptr, pos_msg_len)
|
||||
waPrintRune(')')
|
||||
waPrintRune('\n')
|
||||
procExit(1)
|
||||
}
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintBool
|
||||
func waPrintBool(i: bool) {
|
||||
printBool(i)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintI32
|
||||
func waPrintI32(i: i32) {
|
||||
printI64(i64(i))
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintU32Ptr
|
||||
func waPrintU32Ptr(i: u32) {
|
||||
printHex(u64(i))
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintU32
|
||||
func waPrintU32(i: u32) {
|
||||
printU64(u64(i))
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintI64
|
||||
func waPrintI64(i: i64) {
|
||||
printI64(i)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintU64
|
||||
func waPrintU64(i: u64) {
|
||||
printU64(i)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintF32
|
||||
func waPrintF32(i: f32) {
|
||||
printF64(f64(i))
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintF64
|
||||
func waPrintF64(i: f64) {
|
||||
printF64(f64(i))
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintString
|
||||
func waPrintString(s: string) {
|
||||
printString(s)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintRune
|
||||
func waPrintRune(r: i32) {
|
||||
printString(stringFromRune(r))
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPrintChar
|
||||
func waPrintChar(ch: i32) {
|
||||
d := []byte{byte(ch)}
|
||||
waPuts(U8_slice_to_ptr(d), 1)
|
||||
}
|
||||
|
||||
#wa:linkname $runtime.waPuts
|
||||
func waPuts(ptr: i32, len: i32)
|
||||
@@ -71,8 +71,6 @@ func GetBaseImportCode(waos string) string {
|
||||
return baseImportFile_js
|
||||
case WaOS_unknown:
|
||||
return ""
|
||||
case WaOS_wasi:
|
||||
return ""
|
||||
case WaOS_wasm4:
|
||||
return ""
|
||||
}
|
||||
@@ -180,7 +178,6 @@ var stdPkgs = []string{
|
||||
"strings", // API 完整, wat2wasm ok
|
||||
"syscall", // API 完整
|
||||
"syscall/js", //
|
||||
"syscall/wasi", //
|
||||
"syscall/wasm4", // WASM4 游戏
|
||||
"syscall/unknown", //
|
||||
"text/template", // 无
|
||||
@@ -199,6 +196,5 @@ var wzStdPkgs = []string{
|
||||
"假死门/画布", // js/canvas
|
||||
"门阀/阿多一诺门", // syscall/arduino
|
||||
"门阀/假死门", // syscall/js
|
||||
"门阀/瓦力四像门", // syscall/wasi
|
||||
"门阀/瓦斯门", // syscall/wasm4
|
||||
"门阀/瓦力四像门", // syscall/wasm4
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
func ArgsGet(result_argv: i32, result_argv_buf: i32) => (errno: i32) {
|
||||
return __import__args_get(result_argv, result_argv_buf)
|
||||
}
|
||||
|
||||
func ArgsSizesGet(result_argc: i32, result_argv_len: i32) => (errno: i32) {
|
||||
return __import__args_sizes_get(result_argc, result_argv_len)
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
func ClockResGet(id: i32, result_resolution: i32) => (errno: i32) {
|
||||
return __import__clock_res_get(id, result_resolution)
|
||||
}
|
||||
|
||||
func ClockTimeGet(id: i32, precision: i64, result_timestamp: i32) => (errno: i32) {
|
||||
return __import__clock_time_get(id, precision, result_timestamp)
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#wa:import wasi_snapshot_preview1 environ_get
|
||||
func EnvironGet(result_environv: i32, result_environv_buf: i32) => (errno: i32) {
|
||||
return __import__environ_get(result_environv, result_environv_buf)
|
||||
}
|
||||
|
||||
#wa:import wasi_snapshot_preview1 environ_sizes_get
|
||||
func EnvironSizesGet(result_environc: i32, result_environv_len: i32) => (errno: i32) {
|
||||
return __import__environ_sizes_get(result_environc, result_environv_len)
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_advise
|
||||
func FdAdvise(fd: i32, offset: i64, len: i64, result_advice: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_allocate
|
||||
func FdAllocate(fd: i32, offset: i64, len: i64) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_close
|
||||
func FdClose(fd: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_datasync
|
||||
func FdDatasync(fd: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_fdstat_get
|
||||
func FdFdstatGet(fd: i32, result_stat: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_fdstat_set_flags
|
||||
func FdFdstatSetFlags(fd: i32, flags: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_fdstat_set_rights
|
||||
func FdFdstatSetRights(fd: i32, fs_rights_base: i64, fs_rights_inheriting: i64) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_filestat_get
|
||||
func FdFilestatGet(fd: i32, result_buf: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_filestat_set_size
|
||||
func FdFilestatSetSize(fd: i32, size: i64) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_filestat_set_times
|
||||
func FdFilestatSetTimes(fd: i32, atim: i64, mtim: i64, fst_flags: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_pread
|
||||
func FdPread(fd: i32, iovs: i32, iovs_len: i32, offset: i64, result_size: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_prestat_get
|
||||
func FdPrestatGet(fd: i32, result_prestat: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_prestat_dir_name
|
||||
func FdPrestatDirName(fd: i32, path: i32, path_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_pwrite
|
||||
func FdPwrite(fd: i32, iovs: i32, iovs_len: i32, offset: i64, result_nwritten: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_read
|
||||
func FdRead(fd: i32, iovs: i32, iovs_len: i32, result_size: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_readdir
|
||||
func FdReaddir(fd: i32, buf: i32, buf_len: i32, cookie: i64, result_bufused: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_renumber
|
||||
func FdRenumber(fd: i32, to: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_seek
|
||||
func FdSeek(fd: i32, offset: i64, whence: i32, result_newoffset: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_sync
|
||||
func FdSync(fd: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_tell
|
||||
func FdTell(fd: i32, result_offset: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 fd_write
|
||||
func FdWrite(fd: i32, io: i32, iovs_len: i32, nwritten: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_create_directory
|
||||
func PathCreateDirectory(fd: i32, path: i32, path_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_filestat_get
|
||||
func PathFilestatGet(fd: i32, flags: i32, path: i32, path_len: i32, result_buf: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_filestat_set_times
|
||||
func PathFilestatSetTimes(fd: i32, flags: i32, path: i32, path_len: i32, atim: i64, mtim: i64, fst_flags: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_link
|
||||
func PathLink(old_fd, old_flags, old_path, old_path_len, new_fd, new_path, new_path_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_open
|
||||
func PathOpen(fd, dirflags, path, path_len, oflags: i32, fs_rights_base: i64, fs_rights_inheriting: i64, fdflags, result_opened_fd: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_readlink
|
||||
func PathReadlink(fd, path, path_len, buf, buf_len, result_bufused: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_remove_directory
|
||||
func PathRemoveDirectory(fd, path, path_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_rename
|
||||
func PathRename(fd, old_path, old_path_len, new_fd, new_path, new_path_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_symlink
|
||||
func PathSymlink(old_path, old_path_len, fd, new_path, new_path_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 path_unlink_file
|
||||
func PathUnlinkFile(fd, path, path_len: i32) => (errno: i32)
|
||||
@@ -1,6 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
func ProcExit(code: int) {
|
||||
__import__proc_exit(i32(code))
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
func RandomGet(d: []byte) => (errno: int) {
|
||||
return int(__import__random_get(
|
||||
__linkname__slice_data_ptr(d),
|
||||
i32(len(d)),
|
||||
))
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
// Copyright (C) 2024 武汉凹语言科技有限公司
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
// https://github.com/WebAssembly/WASI/blob/snapshot-01/phases/snapshot/docs.md#functions
|
||||
|
||||
#wa:import wasi_snapshot_preview1 args_get
|
||||
func __import__args_get(result_argv: i32, result_argv_buf: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 args_sizes_get
|
||||
func __import__args_sizes_get(result_argc: i32, result_argv_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 clock_res_get
|
||||
func __import__clock_res_get(id: i32, result_resolution: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 clock_time_get
|
||||
func __import__clock_time_get(id: i32, precision: i64, result_timestamp: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 environ_get
|
||||
func __import__environ_get(result_environv: i32, result_environv_buf: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 environ_sizes_get
|
||||
func __import__environ_sizes_get(result_environc: i32, result_environv_len: i32) => (errno: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 proc_exit
|
||||
func __import__proc_exit(code: i32)
|
||||
|
||||
#wa:import wasi_snapshot_preview1 random_get
|
||||
func __import__random_get(buf: i32, buf_len: i32) => (errno: i32)
|
||||
|
||||
#wa:linkname $syscall/wasi.__linkname__slice_data_ptr
|
||||
func __linkname__slice_data_ptr(s: []byte) => i32
|
||||
|
||||
#wa:linkname $syscall/wasi.__linkname__string_data_ptr
|
||||
func __linkname__string_data_ptr(s: string) => i32
|
||||
|
||||
#wa:linkname $syscall/wasi.__linkname__make_slice
|
||||
func __linkname__makeByteSlice(blk, ptr, len, cap: i32) => []byte
|
||||
|
||||
#wa:linkname $syscall/wasi.__linkname__make_slice
|
||||
func __linkname__makeU8Slice(blk, ptr, len, cap: i32) => []u8
|
||||
|
||||
#wa:linkname $syscall/wasi.__linkname__make_slice
|
||||
func __linkname__makeU16Slice(blk, ptr, len, cap: i32) => []u16
|
||||
|
||||
#wa:linkname $syscall/wasi.__linkname__make_slice
|
||||
func __linkname__makeU32Slice(blk, ptr, len, cap: i32) => []u32
|
||||
@@ -1,17 +0,0 @@
|
||||
;; Copyright 2024 The Wa Authors. All rights reserved.
|
||||
|
||||
(func $$syscall/wasi.__linkname__string_data_ptr (param $b i32) (param $d i32) (param $l i32) (result i32) ;;result = ptr
|
||||
local.get $d
|
||||
)
|
||||
|
||||
(func $$syscall/wasi.__linkname__slice_data_ptr (param $b i32) (param $d i32) (param $l i32) (param $c i32) (result i32) ;;result = ptr
|
||||
local.get $d
|
||||
)
|
||||
|
||||
(func $$syscall/wasi.__linkname__make_slice (param $blk i32) (param $ptr i32) (param $len i32) (param $cap i32) (result i32 i32 i32 i32)
|
||||
local.get $blk
|
||||
local.get $ptr
|
||||
local.get $len
|
||||
local.get $cap
|
||||
return
|
||||
)
|
||||
@@ -32,7 +32,6 @@ const (
|
||||
WaOS_Default = WaOS_js // 默认
|
||||
|
||||
WaOS_js = "js" // 浏览器 JS
|
||||
WaOS_wasi = "wasi" // WASI 接口
|
||||
WaOS_wasm4 = "wasm4" // WASM4 游戏
|
||||
WaOS_arduino = "arduino" // Arduino 平台
|
||||
WaOS_unknown = "unknown" // Unknown
|
||||
@@ -52,7 +51,6 @@ var WaBackend_List = []string{
|
||||
// OS 列表
|
||||
var WaOS_List = []string{
|
||||
WaOS_js,
|
||||
WaOS_wasi,
|
||||
WaOS_wasm4,
|
||||
WaOS_arduino,
|
||||
WaOS_unknown,
|
||||
|
||||
Reference in New Issue
Block a user