Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
1
Task/Stack-traces/Groovy/stack-traces-1.groovy
Normal file
1
Task/Stack-traces/Groovy/stack-traces-1.groovy
Normal file
|
|
@ -0,0 +1 @@
|
|||
def rawTrace = { Thread.currentThread().stackTrace }
|
||||
14
Task/Stack-traces/Groovy/stack-traces-2.groovy
Normal file
14
Task/Stack-traces/Groovy/stack-traces-2.groovy
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
def trace = rawTrace().collect {
|
||||
def props = it.properties
|
||||
def keys = (it.properties.keySet() - (new Object().properties.keySet()))
|
||||
props.findAll{ k, v -> k in keys }
|
||||
}
|
||||
|
||||
def propNames = trace[0].keySet().sort()
|
||||
def propWidths = propNames.collect { name -> [name, trace.collect{ it[name].toString() }].flatten()*.size().max() }
|
||||
|
||||
propNames.eachWithIndex{ name, i -> printf("%-${propWidths[i]}s ", name) }; println ''
|
||||
propWidths.each{ width -> print('-' * width + ' ') }; println ''
|
||||
trace.each {
|
||||
propNames.eachWithIndex{ name, i -> printf("%-${propWidths[i]}s ", it[name].toString()) }; println ''
|
||||
}
|
||||
16
Task/Stack-traces/Groovy/stack-traces-3.groovy
Normal file
16
Task/Stack-traces/Groovy/stack-traces-3.groovy
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
import Utils # for buildStackTrace
|
||||
|
||||
procedure main()
|
||||
g()
|
||||
write()
|
||||
f()
|
||||
end
|
||||
|
||||
procedure f()
|
||||
g()
|
||||
end
|
||||
|
||||
procedure g()
|
||||
# Using 1 as argument omits the trace of buildStackTrace itself
|
||||
every write("\t",!buildStackTrace(1))
|
||||
end
|
||||
22
Task/Stack-traces/Groovy/stack-traces-4.groovy
Normal file
22
Task/Stack-traces/Groovy/stack-traces-4.groovy
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
#<p>
|
||||
# Compute the current stack trace. Starting at level <i>n</i> above
|
||||
# the current procedure. Here, <i>n</i> defaults to 0, which will
|
||||
# include this procedure in the stack trace.
|
||||
# <i>ce</i> defaults to ¤t.
|
||||
# <i>This only works with newer versions of Unicon!</i>
|
||||
# <[generates the stacktrace from current call back to first
|
||||
# in the co-expression]>
|
||||
#</p>
|
||||
procedure buildStackTrace(n:0, # starting distance from this call
|
||||
ce # co-expr to trace stack in [¤t]
|
||||
)
|
||||
local L
|
||||
/ce := ¤t
|
||||
L := []; n -:= 1
|
||||
while pName := image(proc(ce, n+:=1)) do {
|
||||
fName := keyword("&file",ce,n) | "no file name"
|
||||
fLine := keyword("&line",ce,n) | "no line number"
|
||||
put(L, pName||" ["||fName||":"||fLine||"]" )
|
||||
}
|
||||
return L
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue