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

Method pushObject

protocols/cpc/tracers/tracer.go:161–176  ·  view source on GitHub ↗

pushObject assembles a JSVM object wrapping a swappable stack and pushes it onto the VM stack.

(vm *duktape.Context)

Source from the content-addressed store, hash-verified

159// pushObject assembles a JSVM object wrapping a swappable stack and pushes it
160// onto the VM stack.
161func (sw *stackWrapper) pushObject(vm *duktape.Context) {
162 obj := vm.PushObject()
163
164 vm.PushGoFunction(func(ctx *duktape.Context) int { ctx.PushInt(len(sw.stack.Data())); return 1 })
165 vm.PutPropString(obj, "length")
166
167 // Generate the `peek` method which takes an int and returns a bigint
168 vm.PushGoFunction(func(ctx *duktape.Context) int {
169 offset := ctx.GetInt(-1)
170 ctx.Pop()
171
172 pushBigInt(sw.peek(offset), ctx)
173 return 1
174 })
175 vm.PutPropString(obj, "peek")
176}
177
178// dbWrapper provides a JavaScript wrapper around vm.Database.
179type dbWrapper struct {

Callers

nothing calls this directly

Calls 4

peekMethod · 0.95
pushBigIntFunction · 0.85
DataMethod · 0.65
PopMethod · 0.45

Tested by

no test coverage detected