1 | | |
2 | | |
3 | | |
4 | | |
5 | | |
6 | | |
7 | | |
8 | | |
9 | | |
10 | | |
11 | | |
12 | | |
13 | | |
14 | | |
15 | | |
16 | | |
17 | | |
18 | | |
19 | | |
20 | | |
21 | | |
22 | | |
23 | | |
24 | | |
25 | | |
26 | | |
27 | | |
28 | | |
29 | | |
30 | | |
31 | | |
32 | | |
33 | | |
34 | | |
35 | | |
36 | | |
37 | | |
38 | | |
39 | | |
40 | | |
41 | | |
42 | | |
43 | | |
44 | | |
45 | | |
46 | | |
47 | | |
48 | | |
49 | | |
50 | | |
51 | | |
52 | | |
53 | | |
54 | | |
55 | | |
56 | | |
57 | | |
58 | | |
59 | | |
60 | | |
61 | | |
62 | | |
63 | | |
64 | | |
65 | | |
66 | | |
67 | | |
68 | | |
69 | | |
70 | | |
71 | | |
72 | | |
73 | | |
74 | | |
75 | | |
76 | | |
77 | | |
78 | | |
79 | | |
80 | | |
81 | | |
82 | | |
83 | | |
84 | | |
85 | | |
86 | | |
87 | | |
88 | | |
89 | | |
90 | | |
91 | | |
92 | | |
93 | | |
94 | | |
95 | | |
96 | | |
97 | | |
98 | | |
99 | | |
100 | | |
101 | | |
102 | | |
103 | | |
104 | | |
105 | | |
106 | | |
107 | | |
108 | | |
109 | | |
110 | | |
111 | | |
112 | | |
113 | | |
| | | | | | #include "global.h" | #include "constants.h" | #include "macros.h" | #include "program.h" | #include "pike_types.h" | #include "stralloc.h" | #include "memory.h" | #include "interpret.h" | #include "mapping.h" | | static INT32 num_callable=0; | static struct mapping *builtin_constants = 0; | | struct mapping *get_builtin_constants() | { | if(!builtin_constants) | builtin_constants=allocate_mapping(20); | | return builtin_constants; | } | | void low_add_efun(struct pike_string *name, struct svalue *fun) | { | struct svalue s; | | if(!builtin_constants) | builtin_constants=allocate_mapping(20); | | s.type=T_STRING; | s.subtype=0; | s.u.string=name; | | if(fun) | { | mapping_insert(builtin_constants, &s, fun); | }else{ | map_delete(builtin_constants, &s); | } | } | | struct callable *make_callable(c_fun fun, | char *name, | char *type, | INT16 flags, | optimize_fun optimize, | docode_fun docode) | { | struct callable *f; | f=ALLOC_STRUCT(callable); | num_callable++; | f->refs=1; | f->function=fun; | f->name=make_shared_string(name); | f->type=parse_type(type); | f->flags=flags; | f->docode=docode; | f->optimize=optimize; | return f; | } | | void really_free_callable(struct callable *fun) | { | free_string(fun->type); | free_string(fun->name); | free((char *)fun); | num_callable--; | } | | void add_efun2(char *name, | c_fun fun, | char *type, | INT16 flags, | optimize_fun optimize, | docode_fun docode) | { | struct svalue s; | struct pike_string *n; | | n=make_shared_string(name); | s.type=T_FUNCTION; | s.subtype=FUNCTION_BUILTIN; | s.u.efun=make_callable(fun, name, type, flags, optimize, docode); | low_add_efun(n, &s); | free_svalue(&s); | free_string(n); | } | | void add_efun(char *name, c_fun fun, char *type, INT16 flags) | { | add_efun2(name,fun,type,flags,0,0); | } | | void cleanup_added_efuns() | { | if(builtin_constants) | { | free_mapping(builtin_constants); | builtin_constants=0; | } | } | void count_memory_in_callables(INT32 *num_, INT32 *size_) | { | *num_=num_callable; | *size_=num_callable*sizeof(struct callable); | } | | | |
|