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

Function PrintDisassembled

core/asm/asm.go:103–118  ·  view source on GitHub ↗

Pretty-print all disassembled EVM instructions to stdout.

(code string)

Source from the content-addressed store, hash-verified

101
102// Pretty-print all disassembled EVM instructions to stdout.
103func PrintDisassembled(code string) error {
104 script, err := hex.DecodeString(code)
105 if err != nil {
106 return err
107 }
108
109 it := NewInstructionIterator(script)
110 for it.Next() {
111 if it.Arg() != nil && 0 < len(it.Arg()) {
112 fmt.Printf("%06v: %v 0x%x\n", it.PC(), it.Op(), it.Arg())
113 } else {
114 fmt.Printf("%06v: %v\n", it.PC(), it.Op())
115 }
116 }
117 return it.Error()
118}
119
120// Return all disassembled EVM instructions in human-readable format.
121func Disassemble(script []byte) ([]string, error) {

Callers

nothing calls this directly

Calls 6

NewInstructionIteratorFunction · 0.85
ArgMethod · 0.80
PCMethod · 0.80
OpMethod · 0.80
ErrorMethod · 0.65
NextMethod · 0.45

Tested by

no test coverage detected