Skip to content

Commit

Permalink
Update wypes
Browse files Browse the repository at this point in the history
  • Loading branch information
orsinium authored and deadprogram committed Mar 6, 2024
1 parent 4530e84 commit 16a0741
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 25 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ replace github.com/tetratelabs/wazero => github.com/orsinium-forks/wazero v0.0.0

require (
github.com/hybridgroup/wasman v0.0.0-20240304140329-ce1ea6b61834
github.com/orsinium-labs/wypes v0.1.1
github.com/orsinium-labs/wypes v0.1.2
github.com/tetratelabs/wazero v1.6.0
github.com/urfave/cli/v2 v2.27.1
tinygo.org/x/tinyfs v0.3.1-0.20231212053859-32ae3f6bbad9
Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ github.com/orsinium-forks/wazero v0.0.0-20240217173836-b12c024bcbe4 h1:MUh9e2izc
github.com/orsinium-forks/wazero v0.0.0-20240217173836-b12c024bcbe4/go.mod h1:0U0G41+ochRKoPKCJlh0jMg1CHkyfK8kDqiirMmKY8A=
github.com/orsinium-labs/tinytest v1.0.0 h1:YiGm/whlGm3mn/ynx9CCFuvEa3Q6yEGrzrKXEqJOkdc=
github.com/orsinium-labs/tinytest v1.0.0/go.mod h1:GwcYBp0aKi6zujzBXFpCnqw6RSLSp9JSedDyu/V1DF4=
github.com/orsinium-labs/wypes v0.1.0 h1:WSw47er3Dz2nHzw1D20mt57W2i+Rm0sI6c4uSm1XdKM=
github.com/orsinium-labs/wypes v0.1.0/go.mod h1:FSNWGo8I6/D5RYXMkCxyu71TXJAlwJGQUxgs4i6MAwo=
github.com/orsinium-labs/wypes v0.1.1 h1:i8J8wDnoJERQoK5JXQomlAYER8MyySgZQPE8hRDvRiM=
github.com/orsinium-labs/wypes v0.1.1/go.mod h1:FSNWGo8I6/D5RYXMkCxyu71TXJAlwJGQUxgs4i6MAwo=
github.com/orsinium-labs/wypes v0.1.2 h1:xa+d83u6jkGENM2I63KY1dxTC9S/D2At/rB7EsvU5QY=
github.com/orsinium-labs/wypes v0.1.2/go.mod h1:FSNWGo8I6/D5RYXMkCxyu71TXJAlwJGQUxgs4i6MAwo=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/urfave/cli/v2 v2.27.1 h1:8xSQ6szndafKVRmfyeUMxkNUJQMjL1F2zmsZ+qHpfho=
Expand Down
22 changes: 2 additions & 20 deletions interp/wasman/interp.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ func (i *Interpreter) defineModule(modName string, m wypes.Module, refs wypes.Re
func (i *Interpreter) adaptHostFunc(hf wypes.HostFunc, refs wypes.Refs) wasm.RawHostFunc {
return func(stack []uint64) []uint64 {
adaptedStack := wypes.SliceStack(stack)
adaptedMemory := wypes.SliceMemory(i.Memory)
store := wypes.Store{
Memory: &memoryReaderWriter{data: i.Memory},
Memory: &adaptedMemory,
Stack: &adaptedStack,
Refs: refs,
Context: nil,
Expand Down Expand Up @@ -179,22 +180,3 @@ func wrapValueTypes(ins []wypes.ValueType) []types.ValueType {
}
return outs
}

type memoryReaderWriter struct {
data []byte
}

func (m *memoryReaderWriter) Read(offset, count uint32) ([]byte, bool) {
if offset+count > uint32(len(m.data)) {
return nil, false
}
return m.data[offset : offset+count], true
}

func (m *memoryReaderWriter) Write(offset uint32, v []byte) bool {
if offset+uint32(len(v)) > uint32(len(m.data)) {
return false
}
copy(m.data[offset:], v)
return true
}

0 comments on commit 16a0741

Please sign in to comment.