aboutsummaryrefslogtreecommitdiff
path: root/compile.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-11 12:50:46 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-11 12:50:46 -0400
commit908673c9d95a57e794dc1ee5708ffb511958abb9 (patch)
tree0e72884a44e0ce3b9ee2ff15f3c1a54b107af865 /compile.c
parent30d39378c721aa6506c5aa038f6da9bf98cb1527 (diff)
Optional channels (plus fixed some channel bugs)
Diffstat (limited to 'compile.c')
-rw-r--r--compile.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index 58cb2733..6688a5ed 100644
--- a/compile.c
+++ b/compile.c
@@ -222,7 +222,7 @@ CORD compile_type(type_t *t)
switch (nonnull->tag) {
case BoolType: case CStringType: case BigIntType: case NumType: case TextType:
case ArrayType: case SetType: case TableType: case FunctionType: case ClosureType:
- case PointerType: case EnumType:
+ case PointerType: case EnumType: case ChannelType:
return compile_type(nonnull);
case IntType:
return CORD_all("Optional", compile_type(nonnull));
@@ -328,7 +328,8 @@ 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 || t->tag == CStringType || t == THREAD_TYPE)
+ if (t->tag == PointerType || t->tag == FunctionType || t->tag == CStringType
+ || t->tag == ChannelType || t == THREAD_TYPE)
return CORD_all("(", compile(env, ast), " != NULL)");
else if (t->tag == BigIntType)
return CORD_all("((", compile(env, ast), ").small != 0)");
@@ -1706,6 +1707,7 @@ CORD compile(env_t *env, ast_t *ast)
case ArrayType: return "NULL_ARRAY";
case TableType: return "NULL_TABLE";
case SetType: return "NULL_TABLE";
+ case ChannelType: return "NULL";
case TextType: return "NULL_TEXT";
case CStringType: return "NULL";
case PointerType: return CORD_all("((", compile_type(t), ")NULL)");