version 1.2, 2000/08/21 08:31:45 |
version 1.9, 2018/03/29 01:32:54 |
|
|
* shall be made on your publication or presentation in any form of the |
* shall be made on your publication or presentation in any form of the |
* results obtained by use of the SOFTWARE. |
* results obtained by use of the SOFTWARE. |
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
* (4) In the event that you modify the SOFTWARE, you shall notify FLL by |
* e-mail at risa-admin@flab.fujitsu.co.jp of the detailed specification |
* e-mail at risa-admin@sec.flab.fujitsu.co.jp of the detailed specification |
* for such modification or the source code of the modified part of the |
* for such modification or the source code of the modified part of the |
* SOFTWARE. |
* SOFTWARE. |
* |
* |
|
|
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* DEVELOPER SHALL HAVE NO LIABILITY IN CONNECTION WITH THE USE, |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* PERFORMANCE OR NON-PERFORMANCE OF THE SOFTWARE. |
* |
* |
* $OpenXM: OpenXM_contrib2/asir2000/parse/asir_sm.c,v 1.1.1.1 1999/12/03 07:39:11 noro Exp $ |
* $OpenXM: OpenXM_contrib2/asir2000/parse/asir_sm.c,v 1.8 2012/12/17 07:20:45 noro Exp $ |
*/ |
*/ |
#include "ca.h" |
#include "ca.h" |
#include "parse.h" |
#include "parse.h" |
|
|
#include <console.h> |
#include <console.h> |
#endif |
#endif |
|
|
#if PARI |
#if defined(PARI) |
#include "genpari.h" |
#include "genpari.h" |
|
# if !(PARI_VERSION_CODE > 131588) |
extern jmp_buf environnement; |
extern jmp_buf environnement; |
|
# endif |
#endif |
#endif |
|
|
extern jmp_buf env; |
extern jmp_buf env; |
extern int *StackBottom; |
|
extern int ox_do_copy, ox_do_count, ox_count_length; |
extern int ox_do_copy, ox_do_count, ox_count_length; |
extern char *ox_copy_bptr; |
extern char *ox_copy_bptr; |
|
|
Line 71 int Asir_DebugStackPtr; |
|
Line 71 int Asir_DebugStackPtr; |
|
|
|
Asir_Start() |
Asir_Start() |
{ |
{ |
int tmp; |
int tmp; |
FILE *ifp; |
FILE *ifp; |
char ifname[BUFSIZ]; |
char ifname[BUFSIZ]; |
extern int GC_dont_gc; |
extern int GC_dont_gc; |
extern int read_exec_file; |
extern int read_exec_file; |
extern int do_asirrc; |
extern int do_asirrc; |
char *getenv(); |
char *getenv(); |
static ox_asir_initialized = 0; |
static ox_asir_initialized = 0; |
|
|
asir_save_handler(); |
asir_save_handler(); |
if ( ox_asir_initialized ) |
if ( ox_asir_initialized ) |
return; |
return; |
ox_asir_initialized = 1; |
GC_init(); |
ox_do_copy = 1; |
ox_asir_initialized = 1; |
|
ox_do_copy = 1; |
#if defined(THINK_C) |
#if defined(THINK_C) |
param_init(); |
param_init(); |
#endif |
#endif |
StackBottom = &tmp + 1; /* XXX */ |
rtime_init(); |
rtime_init(); |
env_init(); |
env_init(); |
endian_init(); |
endian_init(); |
|
#if !defined(TOWNS) && !defined(THINK_C) |
#if !defined(TOWNS) && !defined(THINK_C) |
/* check_key(); */ |
/* check_key(); */ |
#endif |
#endif |
#if defined(TOWNS) && !defined(GO32) && !defined(__WIN32__) |
#if defined(TOWNS) && !defined(GO32) && !defined(__WIN32__) |
disable_ctrl_c(); |
disable_ctrl_c(); |
#endif |
#endif |
GC_init(); |
/* process_args(argc,argv); */ |
/* process_args(argc,argv); */ |
|
#if 0 |
#if 0 |
copyright(); |
copyright(); |
#endif |
#endif |
output_init(); |
output_init(); |
arf_init(); |
arf_init(); |
nglob_init(); |
nglob_init(); |
glob_init(); |
glob_init(); |
sig_init(); |
sig_init(); |
tty_init(); |
tty_init(); |
debug_init(); |
debug_init(); |
pf_init(); |
pf_init(); |
sysf_init(); |
sysf_init(); |
parif_init(); |
parif_init(); |
#if defined(UINIT) |
#if defined(UINIT) |
reg_sysf(); |
reg_sysf(); |
#endif |
#endif |
#if defined(THINK_C) || defined(TOWNS) |
#if defined(THINK_C) || defined(TOWNS) |
sprintf(ifname,"asirrc"); |
sprintf(ifname,"asirrc"); |
#else |
#else |
sprintf(ifname,"%s/.asirrc",getenv("HOME")); |
sprintf(ifname,"%s/.asirrc",getenv("HOME")); |
#endif |
#endif |
asir_set_handler(); |
asir_set_handler(); |
if ( do_asirrc && (ifp = fopen(ifname,"r")) ) { |
if ( do_asirrc && (ifp = fopen(ifname,"r")) ) { |
input_init(ifp,ifname); |
input_init(ifp,ifname); |
if ( !setjmp(env) ) { |
if ( !setjmp(env) ) { |
read_exec_file = 1; |
read_exec_file = 1; |
read_eval_loop(); |
read_eval_loop(); |
} |
} |
fclose(ifp); |
fclose(ifp); |
} |
} |
asir_reset_handler(); |
asir_reset_handler(); |
input_init(0,"string"); |
input_init(0,"string"); |
Asir_OperandStackPtr = Asir_DebugStackPtr = -1; |
Asir_OperandStackPtr = Asir_DebugStackPtr = -1; |
} |
} |
|
|
char *Asir_PopBinary(); |
char *Asir_PopBinary(); |
Line 145 extern int ox_do_copy; |
|
Line 144 extern int ox_do_copy; |
|
int Asir_ExecuteString(s) |
int Asir_ExecuteString(s) |
char *s; |
char *s; |
{ |
{ |
SNODE snode; |
SNODE snode; |
pointer val; |
pointer val; |
#if PARI |
#if defined(PARI) |
static long tloc,listloc; |
static long tloc,listloc; |
extern long avloc; |
extern long avloc; |
|
|
Asir_Start(); |
Asir_Start(); |
asir_set_handler(); |
asir_set_handler(); |
avloc = avma; tloc = tglobal; listloc = marklist(); |
avloc = avma; tloc = tglobal; listloc = marklist(); |
if ( setjmp(environnement) ) { |
# if !(PARI_VERSION_CODE > 131588) |
avma = avloc; tglobal = tloc; recover(listloc); |
if ( setjmp(environnement) ) { |
resetenv(""); |
avma = avloc; tglobal = tloc; recover(listloc); |
} |
resetenv(""); |
|
} |
|
# endif |
#endif |
#endif |
if ( setjmp(env) ) { |
if ( setjmp(env) ) { |
asir_reset_handler(); |
asir_reset_handler(); |
return -1; |
return -1; |
} |
} |
parse_strp = s; |
parse_strp = s; |
if ( mainparse(&snode) ) { |
if ( mainparse(&snode) ) { |
asir_reset_handler(); |
asir_reset_handler(); |
return -1; |
return -1; |
} |
} |
val = evalstat(snode); |
val = evalstat(snode); |
if ( NEXT(asir_infile) ) { |
if ( NEXT(asir_infile) ) { |
while ( NEXT(asir_infile) ) { |
while ( NEXT(asir_infile) ) { |
if ( mainparse(&snode) ) { |
if ( mainparse(&snode) ) { |
asir_push_obj(val); |
asir_push_obj(val); |
asir_reset_handler(); |
asir_reset_handler(); |
return -1; |
return -1; |
} |
} |
nextbp = 0; |
nextbp = 0; |
val = evalstat(snode); |
val = evalstat(snode); |
} |
} |
} |
} |
asir_push_obj(val); |
asir_push_obj(val); |
asir_reset_handler(); |
asir_reset_handler(); |
return 0; |
return 0; |
} |
} |
|
|
char *Asir_PopString() |
char *Asir_PopString() |
{ |
{ |
Obj val; |
Obj val; |
char *buf,*obuf; |
char *buf,*obuf; |
int l; |
int l; |
|
|
Asir_Start(); |
Asir_Start(); |
val = asir_pop_obj(); |
val = asir_pop_obj(); |
if ( !val ) |
if ( !val ) |
return 0; |
return 0; |
else { |
else { |
l = estimate_length(CO,val); |
l = estimate_length(CO,val); |
buf = (char *)ALLOCA(l+1); |
buf = (char *)ALLOCA(l+1); |
soutput_init(buf); |
soutput_init(buf); |
sprintexpr(CO,val); |
sprintexpr(CO,val); |
l = strlen(buf); |
l = strlen(buf); |
obuf = (char *)GC_malloc(l+1); |
obuf = (char *)MALLOC(l+1); |
strcpy(obuf,buf); |
strcpy(obuf,buf); |
return obuf; |
return obuf; |
} |
} |
} |
} |
|
|
int Asir_Set(name) |
int Asir_Set(name) |
char *name; |
char *name; |
{ |
{ |
int l,n; |
int l,n; |
char *dummy = "=0;"; |
char *dummy = "=0;"; |
SNODE snode; |
SNODE snode; |
|
|
Asir_Start(); |
Asir_Start(); |
l = strlen(name); |
l = strlen(name); |
n = l+strlen(dummy)+1; |
n = l+strlen(dummy)+1; |
parse_strp = (char *)ALLOCA(n); |
parse_strp = (char *)ALLOCA(n); |
sprintf(parse_strp,"%s%s",name,dummy); |
sprintf(parse_strp,"%s%s",name,dummy); |
if ( mainparse(&snode) ) |
if ( mainparse(&snode) ) |
return -1; |
return -1; |
FA1((FNODE)FA0(snode)) = (pointer)mkfnode(1,I_FORMULA,asir_pop_obj()); |
FA1((FNODE)FA0(snode)) = (pointer)mkfnode(1,I_FORMULA,asir_pop_obj()); |
evalstat(snode); |
evalstat(snode); |
return 0; |
return 0; |
} |
} |
|
|
int Asir_PushBinary(size,data) |
int Asir_PushBinary(size,data) |
int size; |
int size; |
char *data; |
char *data; |
{ |
{ |
Obj val; |
Obj val; |
|
|
Asir_Start(); |
Asir_Start(); |
ox_copy_bptr = data; |
ox_copy_bptr = data; |
loadvl(0); |
loadvl(0); |
loadobj(0,&val); |
loadobj(0,&val); |
asir_push_obj(val); |
asir_push_obj(val); |
ox_copy_bptr = 0; |
ox_copy_bptr = 0; |
} |
} |
|
|
char *Asir_PopBinary(size) |
char *Asir_PopBinary(size) |
int *size; |
int *size; |
{ |
{ |
Obj val; |
Obj val; |
char *buf; |
char *buf; |
VL vl,t; |
VL vl,t; |
|
|
Asir_Start(); |
Asir_Start(); |
val = asir_pop_obj(); |
val = asir_pop_obj(); |
get_vars(val,&vl); |
get_vars(val,&vl); |
for ( t = vl; t; t = NEXT(t) ) |
for ( t = vl; t; t = NEXT(t) ) |
if ( t->v->attr == (pointer)V_UC || t->v->attr == (pointer)V_PF ) |
if ( t->v->attr == (pointer)V_UC || t->v->attr == (pointer)V_PF ) |
error("bsave : not implemented"); |
error("bsave : not implemented"); |
ox_count_length = 0; ox_do_count = 1; |
ox_count_length = 0; ox_do_count = 1; |
savevl(0,vl); |
savevl(0,vl); |
saveobj(0,val); |
saveobj(0,val); |
*size = ox_count_length; |
*size = ox_count_length; |
ox_count_length = 0; ox_do_count = 0; |
ox_count_length = 0; ox_do_count = 0; |
ox_copy_bptr = buf = (char *)GC_malloc(*size); |
ox_copy_bptr = buf = (char *)MALLOC(*size); |
savevl(0,vl); |
savevl(0,vl); |
saveobj(0,val); |
saveobj(0,val); |
ox_copy_bptr = 0; |
ox_copy_bptr = 0; |
return buf; |
return buf; |
} |
} |
|
|
asir_push_obj(obj) |
asir_push_obj(obj) |
Obj obj; |
Obj obj; |
{ |
{ |
Asir_OperandStack[++Asir_OperandStackPtr] = obj; |
Asir_OperandStack[++Asir_OperandStackPtr] = obj; |
} |
} |
|
|
Obj asir_pop_obj() { |
Obj asir_pop_obj() { |
if ( Asir_OperandStackPtr < 0 ) |
if ( Asir_OperandStackPtr < 0 ) |
return 0; |
return 0; |
else |
else |
return Asir_OperandStack[Asir_OperandStackPtr--]; |
return Asir_OperandStack[Asir_OperandStackPtr--]; |
} |
} |