os-envs primitive to get current environment
parent
8cd8a10c47
commit
a81a3387bf
|
@ -272,6 +272,7 @@ H{ } clone update-map set
|
|||
{ "set-innermost-frame-quot" "kernel.private" }
|
||||
{ "call-clear" "kernel" }
|
||||
{ "strip-compiled-quotations" "quotations" }
|
||||
{ "(os-envs)" "system" }
|
||||
}
|
||||
dup length [ >r first2 r> make-primitive ] 2each
|
||||
|
||||
|
|
|
@ -577,3 +577,5 @@ t over set-effect-terminated?
|
|||
\ innermost-frame-scan { callstack } { fixnum } <effect> "inferred-effect" set-word-prop
|
||||
|
||||
\ set-innermost-frame-quot { quotation callstack } { } <effect> "inferred-effect" set-word-prop
|
||||
|
||||
\ (os-envs) { } { array } <effect> "inferred-effect" set-word-prop
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
! Copyright (C) 2007 Slava Pestov.
|
||||
! See http://factorcode.org/license.txt for BSD license.
|
||||
IN: system
|
||||
USING: kernel kernel.private sequences math namespaces ;
|
||||
USING: kernel kernel.private sequences math namespaces
|
||||
splitting assocs ;
|
||||
|
||||
: cell ( -- n ) 7 getenv ; foldable
|
||||
|
||||
|
@ -55,3 +56,6 @@ USING: kernel kernel.private sequences math namespaces ;
|
|||
: bootstrap-cells bootstrap-cell * ; inline
|
||||
|
||||
: bootstrap-cell-bits 8 bootstrap-cells ; inline
|
||||
|
||||
: os-envs ( -- assoc )
|
||||
(os-envs) [ "=" split1 ] H{ } map>assoc ;
|
||||
|
|
|
@ -11,3 +11,8 @@ const char *vm_executable_path(void);
|
|||
const char *default_image_path(void);
|
||||
|
||||
DLLEXPORT void c_to_factor_toplevel(CELL quot);
|
||||
|
||||
#ifndef environ
|
||||
extern char ***_NSGetEnviron(void);
|
||||
#define environ (*_NSGetEnviron())
|
||||
#endif
|
18
vm/os-unix.c
18
vm/os-unix.c
|
@ -128,6 +128,24 @@ DEFINE_PRIMITIVE(cd)
|
|||
chdir(unbox_char_string());
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(os_envs)
|
||||
{
|
||||
GROWABLE_ARRAY(result);
|
||||
char **env = environ;
|
||||
|
||||
while(*env)
|
||||
{
|
||||
REGISTER_UNTAGGED(result);
|
||||
CELL string = tag_object(from_char_string(*env));
|
||||
UNREGISTER_UNTAGGED(result);
|
||||
GROWABLE_ADD(result,string);
|
||||
env++;
|
||||
}
|
||||
|
||||
GROWABLE_TRIM(result);
|
||||
dpush(tag_object(result));
|
||||
}
|
||||
|
||||
F_SEGMENT *alloc_segment(CELL size)
|
||||
{
|
||||
int pagesize = getpagesize();
|
||||
|
|
|
@ -207,3 +207,8 @@ void sleep_millis(DWORD msec)
|
|||
{
|
||||
Sleep(msec);
|
||||
}
|
||||
|
||||
DEFINE_PRIMITIVE(os_envs)
|
||||
{
|
||||
not_implemented_error();
|
||||
}
|
||||
|
|
|
@ -195,4 +195,5 @@ void *primitives[] = {
|
|||
primitive_set_innermost_stack_frame_quot,
|
||||
primitive_call_clear,
|
||||
primitive_strip_compiled_quotations,
|
||||
primitive_os_envs,
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue