We originally exported WASI errno as we originally supported invoking host functions directly (e.g. without a guest). This was an invalid call pattern, and we removed that. However, we left the errnos exported even though the caller of a guest won't ever see them. This prevented us from re-using them cleanly in features such as logging. This moves all constants including function names and flag enums internal so that there is less duplication between logging and implementation of wasi functions. This also helps in reference searches, as we can analyze uses of a particular function name. The only constant left exported is the module name, as there's a use case for that (overriding implementations via FunctionBuilder). Signed-off-by: Adrian Cole <adrian@tetrate.io>
28 lines
581 B
Go
28 lines
581 B
Go
// Package wasi_snapshot_preview1 is a helper to remove package cycles re-using
|
|
// constants.
|
|
package wasi_snapshot_preview1
|
|
|
|
import (
|
|
"strings"
|
|
)
|
|
|
|
// InternalModuleName is not named ModuleName, to avoid a clash on dot imports.
|
|
const InternalModuleName = "wasi_snapshot_preview1"
|
|
|
|
func flagsString(names []string, f int) string {
|
|
var builder strings.Builder
|
|
first := true
|
|
for i, sf := range names {
|
|
target := 1 << i
|
|
if target&f != 0 {
|
|
if !first {
|
|
builder.WriteByte('|')
|
|
} else {
|
|
first = false
|
|
}
|
|
builder.WriteString(sf)
|
|
}
|
|
}
|
|
return builder.String()
|
|
}
|