summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--include/ucode/lib.h1
-rw-r--r--lib.c12
2 files changed, 13 insertions, 0 deletions
diff --git a/include/ucode/lib.h b/include/ucode/lib.h
index 095956a..a80844d 100644
--- a/include/ucode/lib.h
+++ b/include/ucode/lib.h
@@ -29,6 +29,7 @@ typedef struct {
extern const uc_function_list_t uc_stdlib_functions[];
void uc_stdlib_load(uc_value_t *scope);
+uc_cfn_ptr_t uc_stdlib_function(const char *name);
bool uc_source_context_format(uc_stringbuf_t *buf, uc_source_t *src, size_t off, bool compact);
bool uc_error_context_format(uc_stringbuf_t *buf, uc_source_t *src, uc_value_t *stacktrace, size_t off);
diff --git a/lib.c b/lib.c
index 8fdf2ec..5f8a053 100644
--- a/lib.c
+++ b/lib.c
@@ -3194,3 +3194,15 @@ uc_stdlib_load(uc_value_t *scope)
{
uc_function_list_register(scope, uc_stdlib_functions);
}
+
+uc_cfn_ptr_t
+uc_stdlib_function(const char *name)
+{
+ size_t i;
+
+ for (i = 0; i < ARRAY_SIZE(uc_stdlib_functions); i++)
+ if (!strcmp(uc_stdlib_functions[i].name, name))
+ return uc_stdlib_functions[i].func;
+
+ return NULL;
+}