Skip to content

Commit d221f35

Browse files
committed
feat: Add stdlib_core.c to centralize standard library module registration and define core native functions like len, list_push, list_pop, and substr.
1 parent 57abd3a commit d221f35

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

src/stdlib/stdlib_core.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ extern Value native_clock(int argCount, Value* args);
3232

3333
static Value native_len(int argCount, Value* args) {
3434
if (argCount < 1) return NUMBER_VAL(0);
35+
// printf("native_len: Type=%d, IS_LIST=%d, IS_STRING=%d\n", AS_OBJ(args[0])->type, IS_LIST(args[0]), IS_STRING(args[0]));
3536
if (IS_STRING(args[0])) return NUMBER_VAL((double)AS_STRING(args[0])->length);
36-
if (IS_LIST(args[0])) return NUMBER_VAL((double)AS_LIST(args[0])->count);
37+
if (IS_LIST(args[0])) {
38+
// printf("It is a list! Count: %d\n", AS_LIST(args[0])->count);
39+
return NUMBER_VAL((double)AS_LIST(args[0])->count);
40+
}
3741
if (IS_MAP(args[0])) return NUMBER_VAL((double)AS_MAP(args[0])->count);
3842
return NUMBER_VAL(0);
3943
}

0 commit comments

Comments
 (0)