| |
| /pliant/appli/type_browser/internals.pli |
| |
| 1 |
module "/pliant/language/compiler.pli" | |
| 2 |
abstract | |
| 3 |
[Helper functions to get information about internals] | |
| 4 |
| |
| 5 |
constant access_mask 0FFFFFh | |
| 6 |
public | |
| 7 |
| |
| 8 |
doc | |
| 9 |
[Conversion from an access value to a Str] | |
| 10 |
| |
| 11 |
function access_to_string aa -> s | |
| 12 |
arg Int aa; arg Str s | |
| 13 |
var Int a:=aa .and. access_mask | |
| 14 |
if (a .and. access_object)<>0 | |
| 15 |
s:="O" | |
| 16 |
a := a .and. .not. access_object | |
| 17 |
else | |
| 18 |
s:="" | |
| 19 |
if (a .and. access_constant)<>0 | |
| 20 |
s:=s+"C" | |
| 21 |
a := a .and. .not. access_constant | |
| 22 |
else | |
| 23 |
s:=s+"A" | |
| 24 |
if (a .and. access_read)<>0 | |
| 25 |
s:=s+"r" | |
| 26 |
a:=a .and. .not. access_read | |
| 27 |
if (a .and. access_write)<>0 | |
| 28 |
s:=s+"w" | |
| 29 |
a:=a .and. .not. access_write | |
| 30 |
if (a .and. access_byvalue)<>0 | |
| 31 |
s:=s+"v" | |
| 32 |
a:=a .and. .not. access_byvalue | |
| 33 |
if (a .and. access_mapped)<>0 | |
| 34 |
s:=s+"m" | |
| 35 |
a:=a .and. .not. access_mapped | |
| 36 |
if (a .and. access_result_read)<>0 | |
| 37 |
s:=s+"R" | |
| 38 |
a:=a .and. .not. access_result_read | |
| 39 |
if (a .and. access_result_write)<>0 | |
| 40 |
s:=s+"W" | |
| 41 |
a:=a .and. .not. access_result_write | |
| 42 |
if (a .and. access_result_consistent)<>0 | |
| 43 |
s:=s+"C" | |
| 44 |
a:=a .and. .not. access_result_consistent | |
| 45 |
if a<>0 | |
| 46 |
s:=s+string:a | |
| 47 |
| |
| 48 |
type PairFunctionModule | |
| 49 |
field Pointer:Function f | |
| 50 |
field Pointer:Module m | |
| 51 |
| |
| 52 |
doc | |
| 53 |
[Find methods of a specified type] | |
| 54 |
| |
| 55 |
method t find_methods -> funlist | |
| 56 |
arg Type t; arg Link:(Index Str Arrow) funlist | |
| 57 |
funlist :> new (Index Str Arrow) | |
| 58 |
var Str k | |
| 59 |
each x pliant_general_dictionary type Function getkey k | |
| 60 |
if x:nb_args>0 and (x arg 0):type=t and (x:name 0 2)=". " | |
| 61 |
var Link:PairFunctionModule p :> new PairFunctionModule | |
| 62 |
p f :> x | |
| 63 |
p m :> ((addressof Link:Function x) translate Arrow 1) map Link:Module | |
| 64 |
var Arrow ar := addressof p | |
| 65 |
funlist insert k ar | |
| 66 |
| |
| 67 |
doc | |
| 68 |
[Finds cast functions to a specified type] | |
| 69 |
| |
| 70 |
method t find_castto -> funlist | |
| 71 |
arg Type t; arg Link:(Index Str Arrow) funlist | |
| 72 |
funlist :> new (Index Str Arrow) | |
| 73 |
var Str name :="cast "+t:name | |
| 74 |
var Pointer:Arrow c :> pliant_general_dictionary first name | |
| 75 |
while c<>null | |
| 76 |
if entry_type:c=Function and (c map Function):nb_args=1 | |
| 77 |
var Link:PairFunctionModule p :> new PairFunctionModule | |
| 78 |
p f :> c map Function | |
| 79 |
p m :> (addressof:c translate Arrow 1) map Link:Module | |
| 80 |
var Arrow ar := addressof:p | |
| 81 |
var Str k := ((c map Function) arg 0):type:name | |
| 82 |
funlist insert k ar | |
| 83 |
c :> pliant_general_dictionary next name c | |
| 84 |
| |
| 85 |
doc | |
| 86 |
[Finds cast functions from a specified type] | |
| 87 |
| |
| 88 |
method t find_castfrom -> funlist | |
| 89 |
arg Type t; arg Link:(Index Str Arrow) funlist | |
| 90 |
funlist :> new (Index Str Arrow) | |
| 91 |
var Str k | |
| 92 |
each x pliant_general_dictionary type Function getkey k | |
| 93 |
if x:nb_args=1 and x:nb_args_with_result=2 and (x arg 0):type=t and (k 0 5)="cast " | |
| 94 |
var Link:PairFunctionModule p :> new PairFunctionModule | |
| 95 |
p f :> x | |
| 96 |
p m :> ((addressof Link:Function x) translate Arrow 1) map Link:Module | |
| 97 |
var Arrow ar := addressof:p | |
| 98 |
funlist insert (x arg 1):type:name ar | |
| 99 |
| |
| 100 |
doc | |
| 101 |
[Get a type from its name] | |
| 102 |
| |
| 103 |
function get_type name -> t | |
| 104 |
arg Str name; arg_R Type t | |
| 105 |
var Pointer:Arrow c :> pliant_general_dictionary first name | |
| 106 |
while c<>null and entry_type:c<>Type | |
| 107 |
c :> pliant_general_dictionary next name c | |
| 108 |
t :> c map Type | |
| 109 |
| |
| 110 |
| |
| 111 |
| |
| 112 |
| |
| |