September Morn Update
This commit is contained in:
parent
4e2d22a71d
commit
aac6731f2c
6856 changed files with 141342 additions and 21127 deletions
|
|
@ -1,4 +1,4 @@
|
|||
-- check existance of bloop in local scope
|
||||
-- check existence of bloop in local scope
|
||||
bloopExists = not voidP(value("bloop"))
|
||||
-- or for global scope:
|
||||
-- bloopExists = not voidP(_global.bloop)
|
||||
|
|
|
|||
2
Task/Introspection/Phix/introspection-1.phix
Normal file
2
Task/Introspection/Phix/introspection-1.phix
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
?version()
|
||||
?scanf(version(),"%d.%d.%d")[1]
|
||||
7
Task/Introspection/Phix/introspection-2.phix
Normal file
7
Task/Introspection/Phix/introspection-2.phix
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
include pmaths.e -- (needed pre-0.8.1 to work around a compiler bug [oops])
|
||||
--include complex.e -- (not an auto-include, needed in all versions)
|
||||
integer r_abs = routine_id("abs")
|
||||
--integer r_abs = routine_id("complex_abs")
|
||||
if r_abs!=-1 then
|
||||
?call_func(r_abs,{-42})
|
||||
end if
|
||||
113
Task/Introspection/Phix/introspection-3.phix
Normal file
113
Task/Introspection/Phix/introspection-3.phix
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
include builtins/VM/pStack.e -- :%opGetST
|
||||
-- copies from pglobals.e:
|
||||
constant S_Name = 1, -- const/var/rtn name
|
||||
S_NTyp = 2, -- Const/GVar/TVar/Nspc/Type/Func/Proc
|
||||
S_FPno = 3, -- File and Path number
|
||||
S_Slink = 6, -- scope/secondary chain (see below)
|
||||
S_vtype = 7, -- variable type or namespace fileno
|
||||
S_GVar2 = 2, -- global or static variable
|
||||
T_int = 1,
|
||||
T_EBP = 22, -- compiled/listing=0, interpreted={ebp4,esp4,sym4} (set at last possible moment)
|
||||
T_ds4 = 23 -- compiled = start of data section, same but /4 when interpreted ([T_EBP]!=0)
|
||||
|
||||
function var_id(object s)
|
||||
-- hacked copy of routine_id(), for local file-level integers only
|
||||
integer res, -- symidx for string s, else sum(local gvar integers)
|
||||
rtn, -- routine number of callee, from callstack
|
||||
cFno, -- calling fileno.
|
||||
tidx,
|
||||
ds4
|
||||
object symtab,
|
||||
si, -- copy of symtab[i], speedwise
|
||||
si_name -- copy of symtab[i][S_name], speedwise/thread-sfaety
|
||||
|
||||
-- get copy of symtab. NB read only! may contain nuts! (unassigned vars)
|
||||
enter_cs()
|
||||
#ilASM{
|
||||
[32]
|
||||
lea edi,[symtab]
|
||||
call :%opGetST -- [edi]=symtab (ie our local:=the real symtab)
|
||||
mov edi,[ebp+20] -- prev_ebp
|
||||
mov edi,[edi+8] -- calling routine no
|
||||
mov [rtn],edi
|
||||
[64]
|
||||
lea rdi,[symtab]
|
||||
call :%opGetST -- [rdi]=symtab (ie our local:=the real symtab)
|
||||
mov rdi,[rbp+40] -- prev_ebp
|
||||
mov rdi,[rdi+16] -- calling routine no
|
||||
mov [rtn],rdi
|
||||
[]
|
||||
}
|
||||
if symtab[T_EBP]=0 then -- compiled
|
||||
ds4 = floor(symtab[T_ds4]/4)
|
||||
else -- interpreted
|
||||
ds4 = symtab[T_ds4]
|
||||
end if
|
||||
cFno = symtab[rtn][S_FPno] -- fileno of callee (whether routine or toplevel)
|
||||
res = iff(s=0?0:-1)
|
||||
for i=1 to length(symtab) do
|
||||
si = symtab[i]
|
||||
if sequence(si)
|
||||
and si[S_NTyp]=S_GVar2
|
||||
and si[S_FPno]=cFno
|
||||
and si[S_vtype]=T_int then
|
||||
si_name = si[S_Name]
|
||||
if s=0 then
|
||||
-- cut-down version of pDiagN.e/getGvarValue():
|
||||
integer gidx = si[S_Slink], novalue, o
|
||||
#ilASM{
|
||||
mov [novalue],0
|
||||
[32]
|
||||
mov esi,[ds4]
|
||||
mov edx,[gidx]
|
||||
shl esi,2
|
||||
mov esi,[esi+edx*4+16] -- ([ds+(gidx+4)*4] == gvar[gidx])
|
||||
cmp esi,h4
|
||||
jl @f
|
||||
mov [novalue],1
|
||||
xor esi,esi
|
||||
@@:
|
||||
mov [o],esi
|
||||
[64]
|
||||
mov rsi,[ds4]
|
||||
mov rdx,[gidx]
|
||||
shl rsi,2
|
||||
mov rsi,[rsi+rdx*8+24] -- ([ds+(gidx+3)*8] == gvar[gidx])
|
||||
mov r15,h4
|
||||
cmp rsi,r15
|
||||
jl @f
|
||||
mov [novalue],1
|
||||
xor rsi,rsi
|
||||
@@:
|
||||
mov [o],rsi
|
||||
[]
|
||||
}
|
||||
if novalue then
|
||||
?{si_name,"no_value"}
|
||||
else
|
||||
res += o
|
||||
end if
|
||||
elsif s=si_name then
|
||||
res = i
|
||||
exit
|
||||
end if
|
||||
end if
|
||||
end for
|
||||
si_name = 0
|
||||
si = 0
|
||||
symtab = 0
|
||||
leave_cs()
|
||||
return res
|
||||
end function
|
||||
|
||||
{} = routine_id("blurgzmp") -- force symtab name population..
|
||||
-- (alt: see rbldrqd in pDiagN.e)
|
||||
integer bloop = 5,
|
||||
-- barf, -- triggers {"barf","no_value"}
|
||||
burp = 35
|
||||
bloop = 6
|
||||
burp += 1
|
||||
?var_id("bloop") -- >0 === exists
|
||||
?var_id("blooop") -- -1 === does not exist
|
||||
?var_id(0) -- bloop+burp = 42
|
||||
?bloop+burp -- "", doh
|
||||
9
Task/Introspection/Phix/introspection-4.phix
Normal file
9
Task/Introspection/Phix/introspection-4.phix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
?platform() -- WINDOWS=2, LINUX=3
|
||||
?machine_bits() -- 32 or 64
|
||||
?machine_word() -- 4 or 8
|
||||
?include_paths() -- eg {"C:\\Program Files (x86)\\Phix\\builtins\\",
|
||||
-- "C:\\Program Files (x86)\\Phix\\builtins\\VM\\",
|
||||
-- "C:\\Program Files (x86)\\Phix\\"}
|
||||
-- (plus other application-specific directories)
|
||||
?get_interpreter() -- eg "C:\Program Files (x86)\Phix\p.exe"
|
||||
-- or perhaps "/home/pete/phix/p" on Linux
|
||||
|
|
@ -1 +1 @@
|
|||
version ^strings'splitAtChar: . drop toNumber 3 < &bye ifTrue
|
||||
@Version #201906 lt+ &bye if
|
||||
|
|
|
|||
|
|
@ -1 +1,9 @@
|
|||
build toNumber 1309798464 < &bye ifTrue
|
||||
Checks for existence of "bloop" and "n:abs"
|
||||
|
||||
~~~
|
||||
: executeByName (s-)
|
||||
d:lookup [ d:xt fetch ] [ d:class fetch ] bi call ;
|
||||
|
||||
'bloop 'n:abs [ find nip ] bi@ and
|
||||
[ 'bloop executeByName 'n:abs executeByName ] if
|
||||
~~~
|
||||
|
|
|
|||
|
|
@ -1,6 +1 @@
|
|||
( Checks for existance of "bloop" and "abs" )
|
||||
: executeByName ( $- )
|
||||
find drop [ @d->xt ] [ @d->class ] bi withClass ;
|
||||
|
||||
"bloop" "abs" [ find nip ] bi@ and
|
||||
[ "bloop" executeByName "abs" executeByName ] ifTrue
|
||||
#0 #0 [ dup d:class fetch &class:integer eq? [ d:xt fetch + [ n:inc ] dip ] [ drop ] choose ] d:for-each
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue