| // Copyright 2009 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // The execution frame of this function. This remains the |
| // same throughout a function invocation. |
| type code []func(*Thread) |
| func (i code) exec(t *Thread) { |
| func newCodeBuf() *codeBuf { |
| return &codeBuf{make(code, 0, 16)}; |
| func (b *codeBuf) push(instr func(*Thread)) { |
| for i := range b.instrs { |
| b.instrs = b.instrs[0 : n+1]; |
| func (b *codeBuf) nextPC() uint { |
| return uint(len(b.instrs)); |
| func (b *codeBuf) get() code { |
| // Freeze this buffer into an array of exactly the right size |
| a := make(code, len(b.instrs)); |
| for i := range b.instrs { |
| func (f *evalFunc) NewFrame() *Frame { |
| return f.outer.child(f.frameSize); |
| func (f *evalFunc) Call(t *Thread) { |