4 * Revision 1.1 2001/04/04 05:43:39 wang
5 * First commit: compiles on Linux, Amiga, Windows, Windows CE, generic gcc
7 * Revision 1.3 1999/11/26 13:13:47 bnv
8 * *** empty log message ***
10 * Revision 1.2 1999/05/14 12:31:22 bnv
13 * Revision 1.1 1998/07/02 17:34:50 bnv
25 /* ----------- MyFunc -------- */
35 /* ----------- RxFork ---------- *
42 /* ----------- RxIndirectCall ---------- */
43 TBltFunc
*C_isBuiltin( PLstr
);
49 TBltFunc
*bltfunc
; // Is a builtin function?
52 Lerror(ERR_INCORRECT_CALL
,0);
57 /* ---- Search for the label ---- */
58 leaf
= BinFind(&_labels
,ARG1
);
59 if (leaf
==NULL
|| ((RxFunc
*)(leaf
->value
))->label
==UNKNOWN_LABEL
) {
60 /* ---- Last chance, trye a builtin ----- */
61 if ((bltfunc
=C_isBuiltin(ARG1
))!=NULL
) {
65 for (i
=0; i
<ARGN
; i
++)
66 Rxarg
.a
[i
] = Rxarg
.a
[i
+1];
68 (bltfunc
->func
)(bltfunc
->opt
);
70 Lerror(ERR_UNEXISTENT_LABEL
,1,ARG1
);
74 // -- Label found, prepare the arguments and do the function call --
75 printf("Label FOUND\n");
76 // func = (RxFunc*)(leaf->value);
77 // RxSetSpecialVar(SIGLVAR,TraceCurline(NULL,FALSE));
78 // Rxcip = (CIPTYPE*)((byte huge *)Rxcodestart + (size_t)(func->label));
79 } /* RxIndirectCall */
81 PBinLeaf leaf
,litleaf
;
83 int ct
,nargs
,realarg
,st
;
91 /* --- read the arguments here --- */
92 PLEAF(leaf
); /* function number */
93 nargs
= *(Rxcip
++); /* number of args */
94 realarg
= *(Rxcip
++); /* real arguments */
95 existarg
= *(CWORD
*)Rxcip
; /* existing arguments */
97 line
= *(CWORD
*)Rxcip
; /* SIGL line */
99 ct
= *(Rxcip
++); /* call type */
100 func
= (RxFunc
*)(leaf
->value
);
104 RxSetSpecialVar(SIGLVAR
,line
);
105 I_MakeArgs(ct
,nargs
,existarg
);
106 Rxcip
= (CIPTYPE
*)((byte huge
*)Rxcodestart
+func
->label
);
107 Rxcip
++; /* skip the newclause_mn */
108 if (_trace
) TraceClause();
110 /* handle proc_mn code */
111 if (*Rxcip
== proc_mn
) {
114 /* give a unique program id */
115 /* we might have a problem after 2*32 routine calls!! */
117 _Proc
[_rx_proc
].id
= _procidcnt
;
121 inst_ip
= (size_t)((byte huge
*)Rxcip
- (byte huge
*)Rxcodestart
);
123 DEBUGDISPLAY0nl("PROC ");
125 _Proc
[_rx_proc
].scope
= RxScopeMalloc();
126 VarScope
= _Proc
[_rx_proc
].scope
;
128 /* handle exposed variables */
129 exposed
= *(Rxcip
++);
131 if (__debug__
&& exposed
>0)
134 for (;exposed
>0;exposed
--) {
135 PLEAF(litleaf
); /* Get pointer to variable */
139 Lprint(STDOUT
,&(litleaf
->key
));
142 RxVarExpose(VarScope
,litleaf
);
152 } /* RxIndirectCall */
154 /* --------------------- main ---------------------- */
156 main(int ac
, char *av
[])
158 Lstr args
, tracestr
, file
;
167 puts("\nsyntax: rexx [-[trace]] <filename> <args>...\nrexx - (to use stdin)\n");
169 puts("Author: "AUTHOR
);
170 puts("Please report any bugs, fatal errors or comments to the");
171 puts("above address, or to <bnv@nisyros.physics.auth.gr>\n");
178 /* --- Initialise --- */
181 /* --- User registered functions --- */
182 RxRegFunction("BINGO", MyFunc
, 0);
183 RxRegFunction("BANANA", MyFunc
, 1);
184 //RxRegFunction("FORK", RxFork, 0);
186 RxRegFunction("THE", RxIndirectCall
, 0);
188 /* --- scan arguments --- */
190 if (av
[ia
][0]=='-') {
194 Lscpy(&tracestr
,av
[ia
]+1);
197 if (av
[ia
][0]=='?' || av
[ia
][0]=='!') {
198 Lscpy(&tracestr
,av
[ia
]);
202 /* --- let's read a normal file --- */
203 if (!input
&& ia
<ac
) {
204 /* prepare arguments for program */
205 for (ir
=ia
+1; ir
<ac
; ir
++) {
207 if (ir
<ac
-1) Lcat(&args
," ");
209 RxRun(av
[ia
],NULL
,&args
,&tracestr
,NULL
);
212 Lread(STDIN
,&file
,LREADFILE
);
216 if (ia
<ac
-1) Lcat(&file
," ");
218 RxRun(NULL
,&file
,&args
,&tracestr
,NULL
);
221 /* --- Free everything --- */
228 if (mem_allocated()!=0) {
229 fprintf(STDERR
,"\nMemory left allocated: %ld\n",mem_allocated());