-
Henrik (Grubba) Grubbström authored
Rev: src/acconfig.h:1.9 Rev: src/array.c:1.12 Rev: src/array.h:1.4 Rev: src/backend.c:1.15 Rev: src/backend.h:1.3 Rev: src/builtin_functions.c:1.41 Rev: src/builtin_functions.h:1.4 Rev: src/callback.c:1.9 Rev: src/callback.h:1.4 Rev: src/constants.c:1.12 Rev: src/constants.h:1.5 Rev: src/docode.c:1.20 Rev: src/docode.h:1.3 Rev: src/dynamic_load.c:1.19 Rev: src/dynamic_load.h:1.2 Rev: src/error.c:1.8 Rev: src/error.h:1.6 Rev: src/gc.c:1.12 Rev: src/gc.h:1.10 Rev: src/hashtable.c:1.3 Rev: src/hashtable.h:1.4 Rev: src/interpret.c:1.45 Rev: src/interpret.h:1.12 Rev: src/language.yacc:1.46 Rev: src/las.c:1.36 Rev: src/las.h:1.8 Rev: src/lex.c:1.26 Rev: src/lex.h:1.5 Rev: src/main.c:1.23 Rev: src/mapping.c:1.21 Rev: src/mapping.h:1.4 Rev: src/modules/Gdbm/gdbmmod.c:1.4 Rev: src/modules/Gmp/mpz_glue.c:1.20 Rev: src/modules/Image/image.c:1.36 Rev: src/modules/Image/polyfill.c:1.5 Rev: src/modules/Mysql/mysql.c:1.6 Rev: src/modules/Pipe/pipe.c:1.11 Rev: src/modules/Regexp/glue.c:1.7 Rev: src/modules/Regexp/pike_regexp.c:1.5 Rev: src/modules/Ssleay/ssleay.c:1.7 Rev: src/modules/Yp/yp.c:1.8 Rev: src/modules/_Crypto/lib/desQuick.c:1.3 Rev: src/modules/call_out/call_out.c:1.13 Rev: src/modules/files/efuns.c:1.33 Rev: src/modules/files/file.c:1.51 Rev: src/modules/files/file.h:1.5 Rev: src/modules/files/socket.c:1.14 Rev: src/modules/math/math.c:1.5 Rev: src/modules/spider/accesseddb.c:1.10 Rev: src/modules/spider/dumudp.c:1.14 Rev: src/modules/spider/spider.c:1.39 Rev: src/modules/spider/streamed_parser.c:1.7 Rev: src/modules/spider/streamed_parser.h:1.2 Rev: src/multiset.c:1.7 Rev: src/multiset.h:1.3 Rev: src/object.c:1.21 Rev: src/object.h:1.11 Rev: src/opcodes.c:1.8 Rev: src/opcodes.h:1.3 Rev: src/operators.c:1.16 Rev: src/operators.h:1.3 Rev: src/peep.c:1.15 Rev: src/peep.h:1.3 Rev: src/pike_types.c:1.25 Rev: src/pike_types.h:1.5 Rev: src/program.c:1.37 Rev: src/program.h:1.18 Rev: src/rusage.c:1.8 Rev: src/rusage.h:1.2 Rev: src/signal_handler.c:1.14 Rev: src/signal_handler.h:1.3 Rev: src/stralloc.c:1.17 Rev: src/stralloc.h:1.9 Rev: src/svalue.c:1.14 Rev: src/threads.c:1.24 Rev: src/threads.h:1.12
Henrik (Grubba) Grubbström authoredRev: src/acconfig.h:1.9 Rev: src/array.c:1.12 Rev: src/array.h:1.4 Rev: src/backend.c:1.15 Rev: src/backend.h:1.3 Rev: src/builtin_functions.c:1.41 Rev: src/builtin_functions.h:1.4 Rev: src/callback.c:1.9 Rev: src/callback.h:1.4 Rev: src/constants.c:1.12 Rev: src/constants.h:1.5 Rev: src/docode.c:1.20 Rev: src/docode.h:1.3 Rev: src/dynamic_load.c:1.19 Rev: src/dynamic_load.h:1.2 Rev: src/error.c:1.8 Rev: src/error.h:1.6 Rev: src/gc.c:1.12 Rev: src/gc.h:1.10 Rev: src/hashtable.c:1.3 Rev: src/hashtable.h:1.4 Rev: src/interpret.c:1.45 Rev: src/interpret.h:1.12 Rev: src/language.yacc:1.46 Rev: src/las.c:1.36 Rev: src/las.h:1.8 Rev: src/lex.c:1.26 Rev: src/lex.h:1.5 Rev: src/main.c:1.23 Rev: src/mapping.c:1.21 Rev: src/mapping.h:1.4 Rev: src/modules/Gdbm/gdbmmod.c:1.4 Rev: src/modules/Gmp/mpz_glue.c:1.20 Rev: src/modules/Image/image.c:1.36 Rev: src/modules/Image/polyfill.c:1.5 Rev: src/modules/Mysql/mysql.c:1.6 Rev: src/modules/Pipe/pipe.c:1.11 Rev: src/modules/Regexp/glue.c:1.7 Rev: src/modules/Regexp/pike_regexp.c:1.5 Rev: src/modules/Ssleay/ssleay.c:1.7 Rev: src/modules/Yp/yp.c:1.8 Rev: src/modules/_Crypto/lib/desQuick.c:1.3 Rev: src/modules/call_out/call_out.c:1.13 Rev: src/modules/files/efuns.c:1.33 Rev: src/modules/files/file.c:1.51 Rev: src/modules/files/file.h:1.5 Rev: src/modules/files/socket.c:1.14 Rev: src/modules/math/math.c:1.5 Rev: src/modules/spider/accesseddb.c:1.10 Rev: src/modules/spider/dumudp.c:1.14 Rev: src/modules/spider/spider.c:1.39 Rev: src/modules/spider/streamed_parser.c:1.7 Rev: src/modules/spider/streamed_parser.h:1.2 Rev: src/multiset.c:1.7 Rev: src/multiset.h:1.3 Rev: src/object.c:1.21 Rev: src/object.h:1.11 Rev: src/opcodes.c:1.8 Rev: src/opcodes.h:1.3 Rev: src/operators.c:1.16 Rev: src/operators.h:1.3 Rev: src/peep.c:1.15 Rev: src/peep.h:1.3 Rev: src/pike_types.c:1.25 Rev: src/pike_types.h:1.5 Rev: src/program.c:1.37 Rev: src/program.h:1.18 Rev: src/rusage.c:1.8 Rev: src/rusage.h:1.2 Rev: src/signal_handler.c:1.14 Rev: src/signal_handler.h:1.3 Rev: src/stralloc.c:1.17 Rev: src/stralloc.h:1.9 Rev: src/svalue.c:1.14 Rev: src/threads.c:1.24 Rev: src/threads.h:1.12
constants.c 2.55 KiB
/*\
||| This file a part of Pike, and is copyright by Fredrik Hubinette
||| Pike is distributed as GPL (General Public License)
||| See the files COPYING and DISCLAIMER for more information.
\*/
#include "global.h"
#include "constants.h"
#include "pike_macros.h"
#include "program.h"
#include "pike_types.h"
#include "stralloc.h"
#include "pike_memory.h"
#include "interpret.h"
#include "mapping.h"
#include "error.h"
static INT32 num_callable=0;
static struct mapping *builtin_constants = 0;
struct mapping *get_builtin_constants(void)
{
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);
}
}
void low_add_constant(char *name, struct svalue *fun)
{
struct pike_string *p;
p=make_shared_string(name);
low_add_efun(p, fun);
free_string(p);
}
void add_global_program(char *name, struct program *p)
{
struct svalue s;
s.type=T_PROGRAM;
s.subtype=0;
s.u.program=p;
low_add_constant(name, &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(void)
{
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);
}