MCPcopy Create free account
hub / github.com/CPChain/chain / opSignExtend

Function opSignExtend

core/vm/instructions.go:134–152  ·  view source on GitHub ↗
(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack)

Source from the content-addressed store, hash-verified

132}
133
134func opSignExtend(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
135 back := stack.pop()
136 if back.Cmp(big.NewInt(31)) < 0 {
137 bit := uint(back.Uint64()*8 + 7)
138 num := stack.pop()
139 mask := back.Lsh(common.Big1, bit)
140 mask.Sub(mask, common.Big1)
141 if num.Bit(int(bit)) > 0 {
142 num.Or(num, mask.Not(mask))
143 } else {
144 num.And(num, mask)
145 }
146
147 stack.push(math.U256(num))
148 }
149
150 evm.interpreter.intPool.put(back)
151 return nil, nil
152}
153
154func opNot(pc *uint64, evm *EVM, contract *Contract, memory *Memory, stack *Stack) ([]byte, error) {
155 x := stack.peek()

Callers

nothing calls this directly

Calls 5

popMethod · 0.80
CmpMethod · 0.80
Uint64Method · 0.80
pushMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected