mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-30 23:23:07 +00:00 
			
		
		
		
	Begin implementing module system.
This commit is contained in:
		| @@ -20,14 +20,14 @@ struct GstCompiler { | ||||
| /* Initialize the Compiler */ | ||||
| void gst_compiler(GstCompiler *c, Gst *vm); | ||||
|  | ||||
| /* Register an environment for compilation */ | ||||
| void gst_compiler_env(GstCompiler *c, GstValue env); | ||||
| /* Add many globals */ | ||||
| void gst_compiler_globals(GstCompiler *c, GstObject *env); | ||||
|  | ||||
| /* Register a global for the compilation environment. */ | ||||
| void gst_compiler_add_global(GstCompiler *c, const char *name, GstValue x); | ||||
| void gst_compiler_global(GstCompiler *c, const char *name, GstValue x); | ||||
|  | ||||
| /* Register a global c function for the compilation environment. */ | ||||
| void gst_compiler_add_global_cfunction(GstCompiler *c, const char *name, GstCFunction f); | ||||
| /* Use a module */ | ||||
| void gst_compiler_usemodule(GstCompiler *c, const char *modulename); | ||||
|  | ||||
| /* Compile a function that evaluates the given form. */ | ||||
| GstFunction *gst_compiler_compile(GstCompiler *c, GstValue form); | ||||
|   | ||||
| @@ -131,6 +131,15 @@ typedef union GstValueUnion GstValueUnion; | ||||
| /* Definitely implementation details */ | ||||
| typedef struct GstBucket GstBucket; | ||||
|  | ||||
| /* API Types */ | ||||
| typedef struct GstModuleItem GstModuleItem; | ||||
|  | ||||
| /* C Api data types */ | ||||
| struct GstModuleItem { | ||||
|     const char *name; | ||||
|     GstCFunction data; | ||||
| }; | ||||
|  | ||||
| /* Union datatype */ | ||||
| union GstValueUnion { | ||||
|     GstBoolean boolean; | ||||
| @@ -174,7 +183,7 @@ struct GstThread { | ||||
|     } status; | ||||
| }; | ||||
|  | ||||
| /* A dynamic array type. Useful for implementing a stack. */ | ||||
| /* A dynamic array type. */ | ||||
| struct GstArray { | ||||
|     uint32_t count; | ||||
|     uint32_t capacity; | ||||
| @@ -257,7 +266,7 @@ struct Gst { | ||||
|     /* Thread */ | ||||
|     GstThread *thread; | ||||
|     /* A GC root */ | ||||
|     GstValue rootenv; | ||||
|     GstObject *rootenv; | ||||
|     /* Return state */ | ||||
|     const char *crash; | ||||
|     GstValue ret; /* Returned value from gst_start. Also holds errors. */ | ||||
| @@ -462,4 +471,11 @@ GstValue gst_arg(Gst *vm, uint16_t index); | ||||
| void gst_set_arg(Gst *vm, uint16_t index, GstValue x); | ||||
| uint16_t gst_count_args(Gst *vm); | ||||
|  | ||||
| /***/ | ||||
| /* C Api */ | ||||
| /***/ | ||||
|  | ||||
| GstObject *gst_c_module(Gst *vm, const GstModuleItem *mod); | ||||
| void gst_c_register(Gst *vm, const char *packagename, GstObject *mod); | ||||
|  | ||||
| #endif // GST_H_defined | ||||
|   | ||||
| @@ -2,10 +2,9 @@ | ||||
| #define stl_h_INCLUDED | ||||
|  | ||||
| #include <gst/gst.h> | ||||
| #include <gst/compile.h> | ||||
|  | ||||
| /* Load the standard library */ | ||||
| void gst_stl_load(GstCompiler *c); | ||||
| void gst_stl_load(Gst *vm); | ||||
|  | ||||
| #endif // stl_h_INCLUDED | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose