From: Tim Vaughan Date: Sat, 23 Apr 2016 12:37:58 +0000 (+1200) Subject: Debugging DOCOL X-Git-Url: https://thelambdalab.xyz/gitweb/index.cgi?a=commitdiff_plain;h=03de266dbc3975cfa2f3b07de2d58ff642f4bf76;p=forth.jl.git Debugging DOCOL --- diff --git a/src/forth.jl b/src/forth.jl index 0c9cf4f..4b625bc 100644 --- a/src/forth.jl +++ b/src/forth.jl @@ -31,6 +31,7 @@ size_TIB = 1096 # Terminal input buffer size mem = Array{Int64,1}(size_mem) primitives = Array{Function,1}() +primNames = Array{ASCIIString,1}() # Built-in variables @@ -127,6 +128,8 @@ function defPrim(name::AbstractString, f::Function; flags::Int64=0) mem[codeWordAddr] = -length(primitives) mem[HERE] += 1 + push!(primNames, name) + return codeWordAddr end @@ -878,7 +881,7 @@ function runVM() # Everyting else is simply a consequence of this loop! jmp = mem[NEXT] while (jmp = callPrim(jmp)) != 0 - println("Evaluating prim $jmp") + println("Evaluating prim $jmp [$(primNames[-jmp])]") end end