 |
My Project
debian-1:4.1.2-p1+ds-2
|
#include "kernel/mod2.h"
#include "Singular/tok.h"
#include "misc/options.h"
#include "Singular/ipid.h"
#include "polys/monomials/ring.h"
#include "Singular/subexpr.h"
#include "Singular/ipshell.h"
#include "Singular/fevoices.h"
#include "Singular/lists.h"
#include <ctype.h>
#include "libparse.h"
#include "Singular/mod_lib.h"
#include <map>
#include <string>
#include <pthread.h>
Go to the source code of this file.
|
BOOLEAN | load_modules (const char *newlib, char *fullname, BOOLEAN autoexport) |
|
int | iiArithAddCmd (const char *szName, short nAlias, short nTokval, short nToktype, short nPos) |
|
void | yylprestart (FILE *input_file) |
|
int | current_pos (int i=0) |
|
void | print_init () |
|
char | mytolower (char c) |
|
BOOLEAN | iiGetLibStatus (const char *lib) |
|
char * | iiProcName (char *buf, char &ct, char *&e) |
|
char * | iiProcArgs (char *e, BOOLEAN withParenth) |
|
char * | iiGetLibProcBuffer (procinfo *pi, int part) |
|
BOOLEAN | iiAllStart (procinfov pi, char *p, feBufferTypes t, int l) |
|
BOOLEAN | iiPStart (idhdl pn, leftv v) |
|
static void | iiShowLevRings () |
|
static void | iiCheckNest () |
|
BOOLEAN | iiMake_proc (idhdl pn, package pack, leftv sl) |
|
static void | iiCallLibProcBegin () |
|
static void | iiCallLibProcEnd (idhdl save_ringhdl, ring save_ring) |
|
void * | iiCallLibProc1 (const char *n, void *arg, int arg_type, BOOLEAN &err) |
|
void * | iiCallLibProcM (const char *n, void **args, int *arg_types, BOOLEAN &err) |
| args: NULL terminated arry of arguments arg_types: 0 terminated array of corresponding types More...
|
|
BOOLEAN | iiEStart (char *example, procinfo *pi) |
|
| SI_FOREACH_BUILTIN (SI_GET_BUILTIN_MOD_INIT0) } |
|
SModulFunc_t | iiGetBuiltinModInit (const char *libname) |
|
BOOLEAN | iiTryLoadLib (leftv v, const char *id) |
|
BOOLEAN | iiLocateLib (const char *lib, char *where) |
|
BOOLEAN | iiLibCmd (char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force) |
|
static void | iiCleanProcs (idhdl &root) |
|
static void | iiRunInit (package p) |
|
BOOLEAN | iiLoadLIB (FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror) |
|
procinfo * | iiInitSingularProcinfo (procinfov pi, const char *libname, const char *procname, int, long pos, BOOLEAN pstatic) |
|
int | iiAddCproc (const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v)) |
|
int | iiAddCprocTop (const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v)) |
|
bool | registered_dyn_module (char *fullname) |
|
void | register_dyn_module (char *fullname, void *handle) |
|
void | close_all_dyn_modules () |
|
BOOLEAN | load_modules_aux (const char *newlib, char *fullname, BOOLEAN autoexport) |
|
BOOLEAN | load_builtin (const char *newlib, BOOLEAN autoexport, SModulFunc_t init) |
|
void | module_help_main (const char *newlib, const char *help) |
|
void | module_help_proc (const char *newlib, const char *p, const char *help) |
|
void * | binary_module_function (const char *newlib, const char *funcname) |
|
char | mytoupper (char c) |
|
char * | iiConvName (const char *libname) |
|
◆ MODULE_SUFFIX
◆ MODULE_SUFFIX_STRING
◆ SI_GET_BUILTIN_MOD_INIT
◆ SI_GET_BUILTIN_MOD_INIT0
◆ SI_MAX_NEST
◆ binary_module_function()
void* binary_module_function |
( |
const char * |
newlib, |
|
|
const char * |
funcname |
|
) |
| |
◆ close_all_dyn_modules()
void close_all_dyn_modules |
( |
| ) |
|
Definition at line 1113 of file iplib.cc.
1115 for (std::map<std::string, void *>::iterator it =
dyn_modules->begin();
◆ current_pos()
int current_pos |
( |
int |
i = 0 | ) |
|
◆ iiAddCproc()
Definition at line 1005 of file iplib.cc.
1014 if (
IsCmd(procname,dummy))
1016 Werror(
">>%s< is a reserved name",procname);
1029 Warn(
"extend `%s`",procname);
1048 pi->is_static = pstatic;
1049 pi->data.o.function = func;
1053 if(
pi->data.o.function == func)
1065 pi->is_static = pstatic;
1066 pi->data.o.function = func;
1070 Warn(
"internal error: unknown procedure type %d",
pi->language);
1076 WarnS(
"iiAddCproc: failed.");
◆ iiAddCprocTop()
◆ iiAllStart()
Definition at line 293 of file iplib.cc.
311 (
pi->libname!=
NULL) && (
pi->libname[0]!=
'\0'))
313 if ((
pi->libname!=
NULL) && (
pi->libname[0]!=
'\0'))
314 Warn(
"option changed in proc %s from %s",
pi->procname,
pi->libname);
316 Warn(
"option changed in proc %s",
pi->procname);
◆ iiArithAddCmd()
int iiArithAddCmd |
( |
const char * |
szName, |
|
|
short |
nAlias, |
|
|
short |
nTokval, |
|
|
short |
nToktype, |
|
|
short |
nPos |
|
) |
| |
Definition at line 9352 of file iparith.cc.
9376 if(szName==
NULL)
return -1;
9380 Print(
"'%s' already exists at %d\n", szName, nIndex);
◆ iiCallLibProc1()
void* iiCallLibProc1 |
( |
const char * |
n, |
|
|
void * |
arg, |
|
|
int |
arg_type, |
|
|
BOOLEAN & |
err |
|
) |
| |
◆ iiCallLibProcBegin()
static void iiCallLibProcBegin |
( |
| ) |
|
|
static |
◆ iiCallLibProcEnd()
static void iiCallLibProcEnd |
( |
idhdl |
save_ringhdl, |
|
|
ring |
save_ring |
|
) |
| |
|
static |
Definition at line 588 of file iplib.cc.
607 WarnS(
"internal: lost ring in iiCallLib");
◆ iiCallLibProcM()
void* iiCallLibProcM |
( |
const char * |
n, |
|
|
void ** |
args, |
|
|
int * |
arg_types, |
|
|
BOOLEAN & |
err |
|
) |
| |
args: NULL terminated arry of arguments arg_types: 0 terminated array of corresponding types
Definition at line 647 of file iplib.cc.
669 tmp.
rtyp=arg_types[0];
670 while(arg_types[
i]!=0)
674 tt->
rtyp=arg_types[
i];
◆ iiCheckNest()
static void iiCheckNest |
( |
| ) |
|
|
static |
◆ iiCleanProcs()
static void iiCleanProcs |
( |
idhdl & |
root | ) |
|
|
static |
Definition at line 870 of file iplib.cc.
876 if (root==
NULL)
return;
881 && (
pi->data.s.body_start == 0L))
◆ iiConvName()
char* iiConvName |
( |
const char * |
libname | ) |
|
Definition at line 1373 of file iplib.cc.
1377 char *
p = strrchr(tmpname,
DIR_SEP);
1379 if(
p==
NULL)
p = tmpname;
else p++;
1382 while(isalnum(*r)||(*r==
'_')) r++;
◆ iiEStart()
Definition at line 699 of file iplib.cc.
711 printf(
"entering example (level %d)\n",
myynest);
723 printf(
"leaving -example- (level %d)\n",
myynest);
◆ iiGetBuiltinModInit()
Definition at line 751 of file iplib.cc.
754 # define SI_GET_BUILTIN_MOD_INIT(name) if (strcmp(libname, #name ".so") == 0){ return SI_MOD_INIT0(name); }
756 # undef SI_GET_BUILTIN_MOD_INIT
◆ iiGetLibProcBuffer()
char* iiGetLibProcBuffer |
( |
procinfo * |
pi, |
|
|
int |
part |
|
) |
| |
Definition at line 192 of file iplib.cc.
208 long head =
pi->data.s.def_end -
pi->data.s.proc_start;
209 procbuflen =
pi->data.s.help_end -
pi->data.s.help_start;
223 s[procbuflen+
head+1] =
'\n';
224 s[procbuflen+
head+2] =
'\0';
226 for(
i=0;
i<=procbuflen+
head+2;
i++)
229 (
s[
i+1]==
'"' ||
s[
i+1]==
'{' ||
s[
i+1]==
'}' ||
s[
i+1]==
'\\'))
240 procbuflen =
pi->data.s.def_end -
pi->data.s.proc_start;
241 char *ss=(
char *)
omAlloc(procbuflen+2);
251 assume(
pi->data.s.body_end >
pi->data.s.body_start);
253 procbuflen =
pi->data.s.body_end -
pi->data.s.body_start;
254 pi->data.s.body = (
char *)
omAlloc( strlen(argstr)+procbuflen+15+
255 strlen(
pi->libname) );
260 strcpy(
pi->data.s.body,argstr);
261 myfread(
pi->data.s.body+strlen(argstr), procbuflen, 1,
fp);
263 procbuflen+=strlen(argstr);
266 pi->data.s.body[procbuflen] =
'\0';
267 strcat(
pi->data.s.body+procbuflen,
"\n;return();\n\n" );
268 strcat(
pi->data.s.body+procbuflen+13,
pi->libname);
269 s=(
char *)strchr(
pi->data.s.body,
'{');
275 if (
pi->data.s.example_lineno == 0)
280 procbuflen =
pi->data.s.proc_end -
pi->data.s.example_start - strlen(
buf);
285 s[procbuflen] =
'\0';
286 strcat(
s+procbuflen-3,
"\n;return();\n\n" );
287 p=(
char *)strchr(
s,
'{');
◆ iiGetLibStatus()
◆ iiInitSingularProcinfo()
Definition at line 991 of file iplib.cc.
995 memset(
pi,0,
sizeof(*
pi));
1000 pi->is_static = pstatic;
1001 pi->data.s.proc_start = pos;
◆ iiLibCmd()
Definition at line 826 of file iplib.cc.
856 WarnS(
"not of type package.");
860 if (!force)
return FALSE;
◆ iiLoadLIB()
Definition at line 915 of file iplib.cc.
945 WerrorS(
"Cannot load library,... aborting.");
955 Warn(
"library %s has old format. This format is still accepted,", newlib);
956 WarnS(
"but for functionality you may wish to change to the new");
957 WarnS(
"format. Please refer to the manual for further information.");
972 ls = ls->
pop(newlib);
976 PrintS(
"--------------------\n");
979 Print(
"%s: LIB-stack:(%d), %s %s\n", newlib, ls->
cnt, ls->
get(),
982 PrintS(
"--------------------\n");
◆ iiLocateLib()
◆ iiMake_proc()
Definition at line 485 of file iplib.cc.
492 Werror(
"'%s::%s()' is a local procedure and cannot be accessed by an user.",
493 pi->libname,
pi->procname);
510 switch (
pi->language)
537 err = (
pi->data.o.function)(
res, sl);
561 if (!err)
Warn(
"too many arguments for %s",
IDID(pn));
◆ iiProcArgs()
char* iiProcArgs |
( |
char * |
e, |
|
|
BOOLEAN |
withParenth |
|
) |
| |
Definition at line 109 of file iplib.cc.
112 while ((*e==
' ') || (*e==
'\t') || (*e==
'(')) e++;
118 return omStrDup(
"parameter list #;");
129 char *argstr=(
char *)
omAlloc(127);
141 if ((*
s==
' ')||(*
s==
'\t'))
143 else if ((*
s==
'\n')&&(*(
s+1)==
' '))
150 &&((par!=0) || (*e!=
')'))
154 else if (*e==
')') par--;
155 args_found=args_found || (*e>
' ');
163 if ((
int)strlen(argstr)+12 +(int)strlen(
s)>= argstrlen)
166 char *a=(
char *)
omAlloc( argstrlen);
172 if(strncmp(
s,
"alias ",6)!=0)
174 strcat(argstr,
"parameter ");
◆ iiProcName()
char* iiProcName |
( |
char * |
buf, |
|
|
char & |
ct, |
|
|
char *& |
e |
|
) |
| |
Definition at line 95 of file iplib.cc.
101 while ((*e>
' ') && (*e!=
'(')) e++;
◆ iiPStart()
Definition at line 353 of file iplib.cc.
368 save_flags=
pi->trace_flag;
369 if(
pi->data.s.body==
NULL )
415 if (oh!=
NULL) o=oh->id;
421 Werror(
"ring change during procedure call %s: %s -> %s (level %d)",
pi->procname,o,n,
myynest);
448 pi->trace_flag=save_flags;
◆ iiRunInit()
◆ iiShowLevRings()
static void iiShowLevRings |
( |
| ) |
|
|
static |
◆ iiTryLoadLib()
Definition at line 764 of file iplib.cc.
769 char *libname = (
char *)
omAlloc(strlen(
id)+5);
770 const char *suffix[] = {
"",
".lib",
".so",
".sl",
NULL };
776 for(
i=0; suffix[
i] !=
NULL;
i++)
778 sprintf(libname,
"%s%s",
id, suffix[
i]);
783 #ifdef HAVE_DYNAMIC_LOADING
789 #ifdef HAVE_DYNAMIC_LOADING
◆ load_builtin()
Definition at line 1239 of file iplib.cc.
1255 pl =
basePack->idroot->get(plib,0);
1283 (*init)(&sModulFunctions);
◆ load_modules()
Definition at line 1230 of file iplib.cc.
1232 GLOBAL_VAR static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
1233 pthread_mutex_lock(&mutex);
1235 pthread_mutex_unlock(&mutex);
◆ load_modules_aux()
Definition at line 1123 of file iplib.cc.
1127 WerrorS(
"mod_init: static version can not load modules");
1142 memset(FullName,0,256);
1144 if( *fullname !=
'/' && *fullname !=
'.' )
1145 sprintf(FullName,
"./%s", newlib);
1146 else strncpy(FullName, fullname,255);
1149 if(
IsCmd(plib, token))
1151 Werror(
"'%s' is resered identifier\n", plib);
1152 goto load_modules_end;
1154 pl =
basePack->idroot->get(plib,0);
1187 Werror(
"%s not found", newlib);
1189 goto load_modules_end;
1203 int ver=(*fktn)(&sModulFunctions);
1210 Warn(
"loaded %s for a different version of Singular(expected MAX_TOK: %d, got %d)",fullname,
MAX_TOK,ver);
1219 Werror(
"mod_init not found:: %s\nThis is probably not a dynamic module for Singular!\n",
dynl_error());
◆ module_help_main()
void module_help_main |
( |
const char * |
newlib, |
|
|
const char * |
help |
|
) |
| |
Definition at line 1291 of file iplib.cc.
1297 Werror(
">>%s<< is not a package (trying to add package help)",plib);
◆ module_help_proc()
void module_help_proc |
( |
const char * |
newlib, |
|
|
const char * |
p, |
|
|
const char * |
help |
|
) |
| |
Definition at line 1306 of file iplib.cc.
1312 Werror(
">>%s<< is not a package(trying to add help for %s)",plib,
p);
1319 strncpy(buff,
p,255);
1320 strncat(buff,
"_help",255-strlen(
p));
◆ mytolower()
Definition at line 1360 of file iplib.cc.
1363 if(c>=65 && c<=(65+26)) c+=32;
◆ mytoupper()
Definition at line 1354 of file iplib.cc.
1357 if(c>=97 && c<=(97+26)) c-=32;
◆ print_init()
◆ register_dyn_module()
void register_dyn_module |
( |
char * |
fullname, |
|
|
void * |
handle |
|
) |
| |
Definition at line 1106 of file iplib.cc.
1110 dyn_modules =
new std::map<std::string, void *>();
1111 dyn_modules->insert(std::pair<std::string, void *>(fname, handle));
◆ registered_dyn_module()
bool registered_dyn_module |
( |
char * |
fullname | ) |
|
◆ SI_FOREACH_BUILTIN()
◆ yylprestart()
void yylprestart |
( |
FILE * |
input_file | ) |
|
◆ dyn_modules
◆ iiLocalRing
◆ iiRETURNEXPR
◆ iiRETURNEXPR_len
VAR int iiRETURNEXPR_len =0 |
◆ library_stack
◆ yylp_errlist
const char* yylp_errlist[] |
◆ yylp_errno
◆ yylplineno
int dynl_close(void *handle)
int iiArithFindCmd(const char *szName)
void iiCheckPack(package &p)
char * iiProcName(char *buf, char &ct, char *&e)
BOOLEAN load_modules_aux(const char *newlib, char *fullname, BOOLEAN autoexport)
int(* iiArithAddCmd)(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
FILE * feFopen(const char *path, const char *mode, char *where, short useWerror, short path_only)
static void iiCallLibProcBegin()
#define MODULE_SUFFIX_STRING
void register_dyn_module(char *fullname, void *handle)
SI_FOREACH_BUILTIN(SI_GET_BUILTIN_MOD_INIT0) }
VAR libstackv library_stack
BOOLEAN iiMake_proc(idhdl pn, package pack, leftv sl)
idhdl enterid(const char *s, int lev, int t, idhdl *root, BOOLEAN init, BOOLEAN search)
int yylplex(const char *libname, const char *libfile, lib_style_types *lib_style, idhdl pl, BOOLEAN autoexport=FALSE, lp_modes=LOAD_LIB)
BOOLEAN iiAllStart(procinfov pi, char *p, feBufferTypes t, int l)
EXTERN_VAR int yylp_errno
const struct soptionStruct verboseStruct[]
Class used for (list of) interpreter objects.
const char * dynl_error()
SModulFunc_t iiGetBuiltinModInit(const char *libname)
static void iiCleanProcs(idhdl &root)
STATIC_VAR SArithBase sArithBase
Base entry for arithmetic.
#define omRealloc(addr, size)
int iiAddCproc(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
idhdl packFindHdl(package r)
EXTERN_VAR omBin sleftv_bin
THREAD_VAR std::map< std::string, void * > * dyn_modules
BOOLEAN iiLoadLIB(FILE *fp, const char *libnamebuf, const char *newlib, idhdl pl, BOOLEAN autoexport, BOOLEAN tellerror)
int status int void * buf
void PrintS(const char *s)
void killhdl2(idhdl h, idhdl *ih, ring r)
char * iiProcArgs(char *e, BOOLEAN withParenth)
#define TRACE_SHOW_LINENO
char * iiGetLibProcBuffer(procinfo *pi, int part)
char * iiConvName(const char *libname)
BOOLEAN load_modules(const char *newlib, char *fullname, BOOLEAN autoexport)
BOOLEAN load_builtin(const char *newlib, BOOLEAN autoexport, SModulFunc_t init)
int(* SModulFunc_t)(SModulFunctions *)
VAR char * yylp_buffer_start
unsigned nLastIdentifier
valid indentifieres are slot 1..nLastIdentifier
int iiArithAddCmd(const char *szName, short nAlias, short nTokval, short nToktype, short nPos)
void killhdl(idhdl h, package proot)
int iiAddCprocTop(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
lib_types type_of_LIB(const char *newlib, char *libnamebuf)
void CleanUp(ring r=currRing)
libstackv pop(const char *p)
#define SI_GET_BUILTIN_MOD_INIT(name)
INST_VAR sleftv iiRETURNEXPR
cmdnames * sCmds
array of existing commands
const char * yylp_errlist[]
static void iiCallLibProcEnd(idhdl save_ringhdl, ring save_ring)
void * dynl_open(char *filename)
idhdl rFindHdl(ring r, idhdl n)
VAR proclevel * procstack
static void iiShowLevRings()
int IsCmd(const char *n, int &tok)
static void iiRunInit(package p)
EXTERN_VAR int yylplineno
void Werror(const char *fmt,...)
#define omreallocSize(addr, o_size, size)
char name(const Variable &v)
void * dynl_sym(void *handle, const char *symbol)
void WerrorS(const char *s)
unsigned nCmdAllocated
number of commands-slots allocated
char * feGetResource(const char id, int warn)
BOOLEAN iiPStart(idhdl pn, leftv v)
const Variable & v
< [in] a sqrfree bivariate poly
unsigned nCmdUsed
number of commands used
VAR ring currRing
Widely used global variable which specifies the current polynomial ring for Singular interpreter and ...
idhdl ggetid(const char *n)
const CanonicalForm int s
const struct soptionStruct optionStruct[]
int(* iiAddCproc)(const char *libname, const char *procname, BOOLEAN pstatic, BOOLEAN(*func)(leftv res, leftv v))
static int _gentable_sort_cmds(const void *a, const void *b)
compares to entry of cmdsname-list
int dynl_check_opened(char *filename)
static void iiCheckNest()
BOOLEAN iiLibCmd(char *newlib, BOOLEAN autoexport, BOOLEAN tellerror, BOOLEAN force)
#define omFreeBin(addr, bin)
INST_VAR sleftv sLastPrinted
void newBuffer(char *s, feBufferTypes t, procinfo *pi, int lineno)
VAR char libnamebuf[1024]
size_t myfread(void *ptr, size_t size, size_t nmemb, FILE *stream)