September 2017 Update

This commit is contained in:
Ingy döt Net 2017-09-23 10:01:46 +02:00
parent bba7bfd280
commit ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions

View file

@ -0,0 +1,25 @@
import extensions.
program =
{
inner
[
console printLine(CallStack new).
]
middle
[
$self inner.
]
outer
[
$self middle.
]
// program entry point
eval
[
$self outer.
]
}.

View file

@ -0,0 +1,10 @@
// version 1.1.2 (stacktrace.kt which compiles to StacktraceKt.class)
fun myFunc() {
println(Throwable().stackTrace.joinToString("\n"))
}
fun main(args:Array<String>) {
myFunc()
println("\nContinuing ... ")
}

View file

@ -0,0 +1,56 @@
constant W = machine_word(),
{RTN,PREVEBP} = iff(W=4?{8,20}:{16,40})
procedure show_stack()
sequence symtab, symtabN
integer rtn
atom prev_ebp
#ilASM{
[32]
lea edi,[symtab]
call :%opGetST -- [edi]=symtab (ie our local:=the real symtab)
mov edi,[ebp+20] -- prev_ebp
mov eax,[edi+8] -- calling routine no
mov [rtn],eax
mov eax,edi
lea edi,[prev_ebp]
call :%pStoreMint
[64]
lea rdi,[symtab]
call :%opGetST -- [rdi]=symtab (ie our local:=the real symtab)
mov rdi,[rbp+40] -- prev_ebp
mov rax,[rdi+16] -- calling routine no
mov [rtn],rax
mov rax,rdi
lea rdi,[prev_ebp]
call :%pStoreMint
[]
}
while rtn!=21 do -- (T_maintls, main top level routine, always present)
symtabN = symtab[rtn]
?symtabN[1]
prev_ebp = peekNS(prev_ebp+PREVEBP,W,0)
rtn = peekNS(prev_ebp+RTN,W,0)
end while
end procedure
procedure three(bool die)
if die then
?9/0
else
show_stack()
end if
end procedure
procedure two(bool die)
three(die)
end procedure
procedure one(bool die)
two(die)
end procedure
one(0)
?routine_id("dummy") -- see note below
one(1)

View file

@ -0,0 +1 @@
trace(1)

View file

@ -0,0 +1,30 @@
/* call stack */
say 'Call A'
call A '123'
say result
exit 0
A:
say 'Call B'
call B '456'
say result
return ARG(1)
B:
say 'Call C'
call C '789'
say result
return ARG(1)
C:
call callstack
return ARG(1)
callstack: procedure
getcallstack(cs.)
say 'Dump call stack with' cs.0 'items'
do i = 1 to cs.0
parse var cs.i line func
say format(line, 3) ':' left(func, 9) ': source "' || sourceline(line) || '"'
end
return cs.0

View file

@ -0,0 +1,4 @@
C:
signal noname
call callstack
return ARG(1)

View file

@ -0,0 +1,2 @@
fcn f{println("F");vm.stackTrace().println()} fcn g{println("G")}
f();g();