Skip to content

Commit 2faebf4

Browse files
committed
feat: Implement stdlib_core for registering standard library modules and core native functions.
1 parent 3587320 commit 2faebf4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/stdlib/stdlib_core.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,12 @@ extern Value native_clock(int argCount, Value* args);
3333
static Value native_len(int argCount, Value* args) {
3434
if (argCount < 1) return NUMBER_VAL(0);
3535
if (IS_STRING(args[0])) return NUMBER_VAL((double)AS_STRING(args[0])->length);
36-
SYNTAX_ERROR_HERE;
37-
if (IS_LIST(args[0])) return NUMBER_VAL((double)AS_LIST(args[0])->count);
36+
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]));
37+
if (IS_STRING(args[0])) return NUMBER_VAL((double)AS_STRING(args[0])->length);
38+
if (IS_LIST(args[0])) {
39+
printf("It is a list! Count: %d\n", AS_LIST(args[0])->count);
40+
return NUMBER_VAL((double)AS_LIST(args[0])->count);
41+
}
3842
if (IS_DICTIONARY(args[0])) return NUMBER_VAL((double)AS_DICTIONARY(args[0])->items.count);
3943
return NUMBER_VAL(0);
4044
}

0 commit comments

Comments
 (0)