language

Some fools attempt at an interpreted language
Log | Files | Refs

commit 2f6b3dcc27da01129eb8a513ed84aa218f3ebbf6
parent a423398e4539de453b50d5a9084b3f07ddb91a9a
Author: Paul Longtine <paullongtine@gmail.com>
Date:   Thu Feb  4 10:41:47 2016

Started to outline runtime/thread management

Diffstat:
 src/vm/inc/bc.h      |  2 +-
 src/vm/inc/rt.h      | 39 +++++++++++++++++++++++++++++++++++++++
 src/vm/inc/threads.h |  7 +++++++
 src/vm/src/bc.c      |  2 +-
 src/vm/src/rt.c      | 28 ++++++++++++++++++++++++++++
 5 files changed, 76 insertions(+), 2 deletions(-)

diff --git a/src/vm/inc/bc.h b/src/vm/inc/bc.h @@ -44,6 +44,6 @@ byte_t* get_dync_arg(FILE*); /* Initiates the first pass to take a raw binary file and translate it into a * basic datastructure */ -bc_cont* bc_read(char* fname); +bc_cont* bc_read(char*); #endif // BC_H diff --git a/src/vm/inc/rt.h b/src/vm/inc/rt.h @@ -0,0 +1,39 @@ +/* `rt.h` handles runtime management + */ + +#include <stdlib.h> +#include <stdio.h> + +#include "bc.h" +#include "stk.h" +#include "var.h" +#include "threads.h" +#include "helper.h" + +typedef struct rt_info { + int thread_count; + rt_worker** threads; + bc_cont* code; + ns_t* vars; +} rt_info; + +typedef struct rt_worker { + thrd_state state; + stk_t* stack; + ns_t* vars; + ns_addr func; + thread_t* thread_ctx; +} rt_worker + +/* Initializes runtime environment, spawns main thread and + * + */ +rt_info* rt_init(char); + +ns_t* rt_init_ns(bc_cont*); + +rt_worker* rt_spawnthread(rt_info*, ns_addr); + +void rt_runthread(rt_info*, rt_worker*); + +void* rt_workerfun(void*); diff --git a/src/vm/inc/threads.h b/src/vm/inc/threads.h @@ -0,0 +1,7 @@ +/* `threads.h` handles threading implementation, provides wrapper for + * cross-platform threading implementation + * + * Currently, this header will support a context for win32 threads and pthreads + */ + +#include <pthreads.h> diff --git a/src/vm/src/bc.c b/src/vm/src/bc.c @@ -1,5 +1,5 @@ -#include <stdio.h> #include <stdlib.h> +#include <stdio.h> #include "bc.h" #include "is.h" diff --git a/src/vm/src/rt.c b/src/vm/src/rt.c @@ -0,0 +1,28 @@ +#include <stdlib.h> + +#include "rt.h" +#include "bc.h" +#include "stk.h" +#include "var.h" +#include "threads.h" +#include "helper.h" + +rt_info* rt_init(char* fname) +{ + +} + +ns_t* rt_init_ns(bc_cont* bytecode) +{ + +} + +void rt_runthread(rt_info* ctx, ns_addr func) +{ + +} + +void* rt_worker(void* arg) +{ + +}