func _loop(thread *rtda.Thread) { defer _catchErr(thread) // todo for { frame := thread.CurrentFrame() pc := frame.NextPC() thread.SetPC(pc) // fetch instruction method := frame.Method() if method.Instructions == nil { method.Instructions = decodeMethod(method.Code()) } insts := method.Instructions.([]base.Instruction) inst := insts[pc] instCount := len(insts) // update nextPC for { pc++ if pc >= instCount || insts[pc] != nil { break } } frame.SetNextPC(pc) // execute instruction //_logInstruction(frame, inst) inst.Execute(frame) if thread.IsStackEmpty() { break } } }
func _logFrames(thread *rtda.Thread) { for !thread.IsStackEmpty() { frame := thread.PopFrame() method := frame.Method() className := method.Class().Name() lineNum := method.GetLineNumber(frame.NextPC()) fmt.Printf(">> line:%4d pc:%4d %v.%v%v \n", lineNum, frame.NextPC(), className, method.Name(), method.Descriptor()) } }