diff options
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 29 |
1 files changed, 28 insertions, 1 deletions
@@ -2579,7 +2579,34 @@ static const uc_cfunction_list functions[] = { void -uc_lib_init(uc_value_t *scope) +uc_load_stdlib(uc_value_t *scope) { uc_add_proto_functions(scope, functions); } + +uc_value_t * +uc_alloc_global(uc_vm *vm) +{ + const char *path[] = { LIB_SEARCH_PATH }; + uc_value_t *global, *arr; + size_t i; + + global = ucv_object_new(vm); + + /* build default require() search path */ + arr = ucv_array_new(vm); + + for (i = 0; i < ARRAY_SIZE(path); i++) + ucv_array_push(arr, ucv_string_new(path[i])); + + ucv_object_add(global, "REQUIRE_SEARCH_PATH", arr); + + /* register global math constants */ + ucv_object_add(global, "NaN", ucv_double_new(NAN)); + ucv_object_add(global, "Infinity", ucv_double_new(INFINITY)); + + /* register global property */ + ucv_object_add(global, "global", ucv_get(global)); + + return global; +} |