Skip to content
This repository was archived by the owner on May 11, 2020. It is now read-only.

WIP: Go Module with JS Runtime Environment #70

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions exec/vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,20 @@ func (proc *Process) WriteAt(p []byte, off int64) (int, error) {
return length, err
}

// ErrOutOfBounds is returned when you attempt to buffer memory out of the bounds of process memory
var ErrOutOfBounds = errors.New("offset and length out of memory bounds")

// BufferAt returns a slice pointing at the process memory at offset "off" for length "len"
func (proc *Process) BufferAt(offset, length int64) ([]byte, error) {
mem := proc.vm.Memory()

if len(mem) < int(offset+length) {
return nil, ErrOutOfBounds
}

return mem[offset : offset+length], nil
}

// Terminate stops the execution of the current module.
func (proc *Process) Terminate() {
proc.vm.abort = true
Expand Down
Loading