bunch of changes
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
"unicode"
|
||||
)
|
||||
|
||||
@@ -201,22 +202,16 @@ func (vm *VM) LastPoppedStackElem() object.Object {
|
||||
}
|
||||
|
||||
func (vm *VM) Run() error {
|
||||
var n int
|
||||
var ip int
|
||||
var ins code.Instructions
|
||||
var op code.Opcode
|
||||
|
||||
if vm.Debug {
|
||||
log.Printf(
|
||||
"%-25s %-20s\n",
|
||||
fmt.Sprintf(
|
||||
"%04d %s", ip,
|
||||
strings.Split(ins[ip:].String(), "\n")[0][4:],
|
||||
),
|
||||
fmt.Sprintf(
|
||||
"[ip=%02d fp=%02d, sp=%02d]",
|
||||
ip, vm.fp-1, vm.sp,
|
||||
),
|
||||
)
|
||||
start := time.Now()
|
||||
defer func() {
|
||||
log.Printf("%d instructions executed in %s", n, time.Now().Sub(start))
|
||||
}()
|
||||
}
|
||||
|
||||
for vm.frame.ip < len(vm.frame.Instructions())-1 {
|
||||
@@ -487,6 +482,7 @@ func (vm *VM) Run() error {
|
||||
}
|
||||
|
||||
if vm.Debug {
|
||||
n++
|
||||
log.Printf(
|
||||
"%-25s [ip=%02d fp=%02d, sp=%02d]",
|
||||
"", ip, vm.fp-1, vm.sp,
|
||||
|
||||
Reference in New Issue
Block a user