MCPcopy Create free account
hub / github.com/chain/txvm / bitOp

Function bitOp

protocol/txvm/bitwise.go:26–38  ·  view source on GitHub ↗
(vm *VM, f func(a, b byte) byte)

Source from the content-addressed store, hash-verified

24func opBitXor(vm *VM) { bitOp(vm, xor) }
25
26func bitOp(vm *VM, f func(a, b byte) byte) {
27 b := vm.popBytes()
28 a := vm.popBytes()
29 if len(a) != len(b) {
30 panic(errors.Wrap(errors.WithData(ErrBitLen, "len(a)", len(a), "len(b)", len(b)), op.Name(vm.opcode)))
31 }
32 c := make([]byte, len(a))
33 for i := 0; i < len(a); i++ {
34 c[i] = f(a[i], b[i])
35 }
36 vm.chargeCreate(Bytes(c))
37 vm.push(Bytes(c))
38}
39
40func and(a, b byte) byte { return a & b }
41func or(a, b byte) byte { return a | b }

Callers 3

opBitAndFunction · 0.85
opBitOrFunction · 0.85
opBitXorFunction · 0.85

Calls 7

WrapFunction · 0.92
WithDataFunction · 0.92
NameFunction · 0.92
BytesTypeAlias · 0.85
popBytesMethod · 0.80
chargeCreateMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected