v0.1.1 Latest Latest

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2019 License: MIT Imports: 12 Imported by: 1


Common WebAssembly API Compliance

This ABI complies to the spec outlined in the GitHub repo CommonWA/cwa-spec. The vendored copy of the CWA spec will reflect what Olin implements.

There are no tests for CWA compliance, so some will be developed as part of this.



Package cwa contains the ABI for CommonWA1 applications.



View Source
const (
	LogLevelError   = 1
	LogLevelWarning = 3
	LogLevelInfo    = 6

Log levels

View Source
const (
	SpecMajor   = 0
	SpecMinor   = 0
	RuntimeName = "olin"



This section is empty.


func ErrorCode

func ErrorCode(err error) int

ErrorCode extracts the code from an error.


type Error

type Error int

Error is an individual error as defined by the CommonWA spec.

const (
	ErrNone Error = (iota * -1)

CommonWA errors as defined by the spec at

func (Error) Error

func (e Error) Error() string

func (Error) String

func (i Error) String() string

type Process

type Process struct {
	Logger *log.Logger

	FileHandles    map[int32]abi.File
	Stdin          io.Reader
	Stdout, Stderr io.Writer
	// contains filtered or unexported fields

Process is an individual CommonWA process. It is the collection of resources and other macguffins that the child module ends up requiring.

func NewProcess

func NewProcess(name string, argv []string, env map[string]string) *Process

NewProcess creates a new process with the given name, arguments and environment.

func (*Process) ArgAt

func (p *Process) ArgAt(i int32, outPtr, outLen uint32) (int32, error)

func (*Process) ArgLen

func (p *Process) ArgLen() int32

func (*Process) EnvGet

func (p *Process) EnvGet(keyPtr, keyLen, valPtr, valLen uint32) (int32, error)

func (*Process) Files

func (p *Process) Files() []abi.File

Files returns the set of open files in use by this process.

func (*Process) IOGetStderr

func (p *Process) IOGetStderr() int32

func (*Process) IOGetStdin

func (p *Process) IOGetStdin() int32

func (*Process) IOGetStdout

func (p *Process) IOGetStdout() int32

func (*Process) LogWrite

func (p *Process) LogWrite(level int32, msgPtr, msgLen uint32)

func (*Process) Name

func (p *Process) Name() string

Name returns this process' name.

func (Process) Open

func (Process) Open(abi.File)

Open does nothing

func (*Process) RandI32

func (p *Process) RandI32() int32

func (*Process) RandI64

func (p *Process) RandI64() int64

func (*Process) ResolveFunc

func (p *Process) ResolveFunc(module, field string) exec.FunctionImport

ResolveFunc resolves the CommonWA ABI and importable functions.

func (*Process) ResolveGlobal

func (p *Process) ResolveGlobal(module, field string) int64

ResolveGlobal does nothing, currently.

func (*Process) ResourceClose

func (p *Process) ResourceClose(fid int32) error

func (*Process) ResourceFlush

func (p *Process) ResourceFlush(fid int32) error

func (*Process) ResourceOpen

func (p *Process) ResourceOpen(urlPtr, urlLen uint32) (int32, error)

func (*Process) ResourceRead

func (p *Process) ResourceRead(fid int32, dataPtr, dataLen uint32) (int32, error)

func (*Process) ResourceWrite

func (p *Process) ResourceWrite(fid int32, dataPtr, dataLen uint32) (int32, error)

func (*Process) RuntimeName

func (p *Process) RuntimeName(namePtr, nameLen uint32) int32

func (*Process) SetVM

func (p *Process) SetVM(vm *exec.VirtualMachine)

SetVM sets the VM associated with this process.

func (*Process) Setenv

func (p *Process) Setenv(m map[string]string)

Setenv updates a process' environment. This does not inform the process. It is up to the running process to detect these values have changed.

func (Process) SyscallCount

func (p Process) SyscallCount() int64

func (*Process) TimeNow

func (p *Process) TimeNow() int64

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL