pushObject assembles a JSVM object wrapping a swappable stack and pushes it onto the VM stack.
(vm *duktape.Context)
| 159 | // pushObject assembles a JSVM object wrapping a swappable stack and pushes it |
| 160 | // onto the VM stack. |
| 161 | func (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. |
| 179 | type dbWrapper struct { |
nothing calls this directly
no test coverage detected