language

some fools attempt at an interpreted language
Log | Files | Refs | README

rt.h (1061B)


      1 /* `rt.h` handles runtime management
      2  */
      3 
      4 #ifndef RT_H
      5 #define RT_H
      6 
      7 #include <stdlib.h>
      8 #include <stdio.h>
      9 
     10 #include "bc.h"
     11 #include "stk.h"
     12 #include "var.h"
     13 #include "object.h"
     14 #include "ns.h"
     15 #include "pc.h"
     16 #include "helper.h"
     17 
     18 /* Runtime context structure
     19  *  db    -  Debug flag
     20  *  pc    - `pc.h` program counter instance
     21  *  stack - `stk.h` stack instance[0]
     22  *  argstk- `stk.h` stack instance[1]
     23  *  vars  - `ns.h` namespace instance
     24  *  varctx- `ns.h` namespace context instance
     25  *  names - `ns.h` namespace instance
     26  *
     27  *  [0] This is the stack register used at runtime to push/pop variable
     28  *      containers.
     29  *  [1] Function calls implement this stack to load variables as arguements.
     30  */
     31 typedef struct rt_t {
     32 	int     db;
     33 	pc_t*   pc;
     34 	stk_t*  stack;
     35 	stk_t*  argstk;
     36 	ns_t*   vars;
     37 	ns_t*   names;
     38 	ns_ctx* varctx;
     39 } rt_t;
     40 
     41 /* Creates new runtime context.
     42  *  char*   - Filename
     43  *  stk_t*  - Arguement stack
     44  */
     45 rt_t* rt_ctx_new(char*, stk_t*);
     46 
     47 void rt_ns_del(void*);
     48 
     49 /* Destroys runtime context.
     50  */
     51 void rt_ctx_del(rt_t*);
     52 
     53 #endif // RT_H