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