RPA Toolkit
Added support for script args.
[rpatk.git] / rjs / rjs.h
1 #ifndef _RJS_H_
2 #define _RJS_H_
3
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9 #include <stdarg.h>
10 #include "rtypes.h"
11 #include "rvmcpu.h"
12 #include "rjsparser.h"
13 #include "rjscompiler.h"
14 #include "rjserror.h"
15
16
17 typedef struct rjs_engine_s {
18         rjs_parser_t *pa;
19         rjs_compiler_t *co;
20         rarray_t *cgs;
21         rarray_t *errors;
22         rvmcpu_t *cpu;
23         rlong debugcompile:1;
24         rlong debugexec:1;
25 } rjs_engine_t;
26
27
28 #define RJS_VERSION_MAJOR 0
29 #define RJS_VERSION_MINOR 51
30 #define RJS_VERSION_MICRO 1
31 #define RJS_VERSION_STRING "0.51.1"
32 #define RJS_SWI_PARAM(__cpu__, __n__) RVM_STACK_ADDR((__cpu__)->stack, RVM_CPUREG_GETU(__cpu__, FP) + (__n__))
33 #define RJS_SWI_PARAMS(__cpu__) (RVM_CPUREG_GETU((__cpu__), SP) - RVM_CPUREG_GETU((__cpu__), FP))
34 #define RJS_SWI_ABORT(__j__, __e__) do { rjs_engine_abort((__j__), (__e__)); return; } while (0)
35
36
37 const rchar *rjs_version();
38
39 rjs_engine_t *rjs_engine_create();
40 void rjs_engine_destroy(rjs_engine_t *jse);
41 rint rjs_engine_open(rjs_engine_t *jse);
42 rint rjs_engine_compile(rjs_engine_t *jse, const rchar *script, rsize_t size);
43 rint rjs_engine_compile_s(rjs_engine_t *jse, const rchar *script);
44 rint rjs_engine_close(rjs_engine_t *jse);
45 rint rjs_engine_run(rjs_engine_t *jse);
46 rint rjs_engine_addswitable(rjs_engine_t *jse, const rchar *tabname, rvm_switable_t *switalbe);
47 rint rjs_engine_dumpast(rjs_engine_t *jse, const rchar *script, rsize_t size);
48 rvmreg_t *rjs_engine_exec(rjs_engine_t *jse, const rchar *script, rsize_t size);
49 rvmreg_t *rjs_engine_vexec(rjs_engine_t *jse, const rchar *script, rsize_t size, rsize_t nargs, va_list args);
50 rvmreg_t *rjs_engine_args_exec(rjs_engine_t *jse, const rchar *script, rsize_t size, rsize_t nargs, ...);
51 rvmreg_t *rjs_engine_args_exec_s(rjs_engine_t *jse, const rchar *script, rsize_t nargs, ...);
52 rvmreg_t *rjs_engine_exec_s(rjs_engine_t *jse, const rchar *script);
53 void rjs_engine_abort(rjs_engine_t *jse, rjs_error_t *error);
54 rjs_engine_t *rjs_engine_get(rvmcpu_t *cpu);
55
56 #ifdef __cplusplus
57 }
58 #endif
59
60 #endif