diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:39:56 -0400 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2024-09-11 12:39:56 -0400 |
| commit | 30d39378c721aa6506c5aa038f6da9bf98cb1527 (patch) | |
| tree | 5051263c667915bfd9178bbfdf691afb54088e3f /compile.c | |
| parent | 210179ee672a0c3799328a54e886f574b3823e3d (diff) | |
Optional C Strings
Diffstat (limited to 'compile.c')
| -rw-r--r-- | compile.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -328,7 +328,7 @@ static CORD compile_optional_check(env_t *env, ast_t *ast) { type_t *t = get_type(env, ast); t = Match(t, OptionalType)->type; - if (t->tag == PointerType || t->tag == FunctionType) + if (t->tag == PointerType || t->tag == FunctionType || t->tag == CStringType || t == THREAD_TYPE) return CORD_all("(", compile(env, ast), " != NULL)"); else if (t->tag == BigIntType) return CORD_all("((", compile(env, ast), ").small != 0)"); @@ -1688,6 +1688,8 @@ CORD compile(env_t *env, ast_t *ast) switch (ast->tag) { case Nil: { type_t *t = parse_type_ast(env, Match(ast, Nil)->type); + if (t == THREAD_TYPE) return "NULL"; + switch (t->tag) { case BigIntType: return "NULL_INT"; case IntType: { @@ -1705,6 +1707,7 @@ CORD compile(env_t *env, ast_t *ast) case TableType: return "NULL_TABLE"; case SetType: return "NULL_TABLE"; case TextType: return "NULL_TEXT"; + case CStringType: return "NULL"; case PointerType: return CORD_all("((", compile_type(t), ")NULL)"); case ClosureType: return "NULL_CLOSURE"; case NumType: return "nan(\"null\")"; |
