Ver Fonte

added sys_hl_file

Nicolas Cannasse há 8 anos atrás
pai
commit
37193cbf8c
4 ficheiros alterados com 13 adições e 4 exclusões
  1. 1 1
      src/hl.h
  2. 1 1
      src/hlc_main.c
  3. 1 1
      src/main.c
  4. 10 1
      src/std/sys.c

+ 1 - 1
src/hl.h

@@ -631,7 +631,7 @@ typedef struct {
 #define hl_fatal4(msg,p0,p1,p2,p3)	hl_fatal_fmt(__FILE__,__LINE__,msg,p0,p1,p2,p3)
 HL_API void *hl_fatal_error( const char *msg, const char *file, int line );
 HL_API void hl_fatal_fmt( const char *file, int line, const char *fmt, ...);
-HL_API void hl_sys_init(void **args, int nargs);
+HL_API void hl_sys_init(void **args, int nargs, void *hlfile);
 HL_API void hl_setup_callbacks(void *sc, void *gw);
 
 #include <setjmp.h>

+ 1 - 1
src/hlc_main.c

@@ -93,7 +93,7 @@ int main(int argc, char *argv[]) {
 	hl_global_init(&ctx);
 	hl_setup_exception(hlc_resolve_symbol,hlc_capture_stack);
 	hl_setup_callbacks(hlc_static_call, hlc_get_wrapper);
-	hl_sys_init((void**)(argv + 1),argc - 1);
+	hl_sys_init((void**)(argv + 1),argc - 1,NULL);
 	hl_trap(ctx, exc, on_exception);
 #	ifdef HL_VCC
 	__try {

+ 1 - 1
src/main.c

@@ -125,7 +125,7 @@ int main(int argc, pchar *argv[]) {
 	exit(1);
 #	endif
 	hl_global_init(&ctx);
-	hl_sys_init((void**)argv,argc);
+	hl_sys_init((void**)argv,argc,file);
 	ctx.code = load_code(file);
 	if( ctx.code == NULL )
 		return 1;

+ 10 - 1
src/std/sys.c

@@ -527,11 +527,20 @@ HL_PRIM varray *hl_sys_args() {
 	return a;
 }
 
-HL_PRIM void hl_sys_init(void **args, int nargs) {
+static void *hl_file = NULL;
+
+HL_PRIM void hl_sys_init(void **args, int nargs, void *hlfile) {
 	sys_args = (pchar**)args;
 	sys_nargs = nargs;
+	hl_file = hlfile;
+}
+
+HL_PRIM vbyte *hl_sys_hl_file() {
+	return hl_file;
 }
 
+
+DEFINE_PRIM(_BYTES, sys_hl_file, _NO_ARG);
 DEFINE_PRIM(_BOOL, sys_utf8_path, _NO_ARG);
 DEFINE_PRIM(_BYTES, sys_string, _NO_ARG);
 DEFINE_PRIM(_VOID, sys_print, _BYTES);