aboutsummaryrefslogtreecommitdiff
path: root/src/compile
diff options
context:
space:
mode:
Diffstat (limited to 'src/compile')
-rw-r--r--src/compile/binops.c4
-rw-r--r--src/compile/cli.c2
-rw-r--r--src/compile/expressions.c3
-rw-r--r--src/compile/optionals.c3
-rw-r--r--src/compile/types.c7
5 files changed, 9 insertions, 10 deletions
diff --git a/src/compile/binops.c b/src/compile/binops.c
index acf1e031..89111a5f 100644
--- a/src/compile/binops.c
+++ b/src/compile/binops.c
@@ -228,8 +228,10 @@ Text_t compile_binary_op(env_t *env, ast_t *ast) {
type_to_text(rhs_t), " values");
}
case Concat: {
- if (overall_t == PATH_TYPE) return Texts("Path$concat(", lhs, ", ", rhs, ")");
switch (overall_t->tag) {
+ case PathType: {
+ return Texts("Path$concat(", lhs, ", ", rhs, ")");
+ }
case TextType: {
return Texts("Text$concat(", lhs, ", ", rhs, ")");
}
diff --git a/src/compile/cli.c b/src/compile/cli.c
index ade6caa7..64abe2e7 100644
--- a/src/compile/cli.c
+++ b/src/compile/cli.c
@@ -13,7 +13,7 @@
static Text_t get_flag_options(type_t *t, Text_t separator) {
if (t->tag == BoolType) {
return Text("yes|no");
- } else if (t == PATH_TYPE) {
+ } else if (t->tag == PathType) {
return Text("path");
} else if (t->tag == EnumType) {
Text_t options = EMPTY_TEXT;
diff --git a/src/compile/expressions.c b/src/compile/expressions.c
index c3918de3..3f5d24df 100644
--- a/src/compile/expressions.c
+++ b/src/compile/expressions.c
@@ -56,8 +56,6 @@ Text_t compile_empty(type_t *t) {
if (t->tag == OptionalType) return compile_none(t);
- if (t == PATH_TYPE) return Text("NONE_PATH");
-
switch (t->tag) {
case BigIntType: return Text("I(0)");
case IntType: {
@@ -76,6 +74,7 @@ Text_t compile_empty(type_t *t) {
case TableType: return Text("EMPTY_TABLE");
case TextType: return Text("EMPTY_TEXT");
case CStringType: return Text("\"\"");
+ case PathType: return Text("NONE_PATH");
case PointerType: {
DeclareMatch(ptr, t, PointerType);
Text_t empty_pointed = compile_empty(ptr->pointed);
diff --git a/src/compile/optionals.c b/src/compile/optionals.c
index 75dff935..8cb6af2b 100644
--- a/src/compile/optionals.c
+++ b/src/compile/optionals.c
@@ -48,8 +48,6 @@ Text_t compile_none(type_t *t) {
if (t == NULL) compiler_err(NULL, NULL, NULL, "I can't compile a `none` value with no type");
- if (t == PATH_TYPE) return Text("NONE_PATH");
-
switch (t->tag) {
case BigIntType: return Text("NONE_INT");
case IntType: {
@@ -68,6 +66,7 @@ Text_t compile_none(type_t *t) {
case TableType: return Text("NONE_TABLE");
case TextType: return Text("NONE_TEXT");
case CStringType: return Text("NULL");
+ case PathType: return Text("NONE_PATH");
case PointerType: return Texts("((", compile_type(t), ")NULL)");
case ClosureType: return Text("NONE_CLOSURE");
case NumType: return Text("nan(\"none\")");
diff --git a/src/compile/types.c b/src/compile/types.c
index aac27f4c..e81ebed3 100644
--- a/src/compile/types.c
+++ b/src/compile/types.c
@@ -11,8 +11,6 @@
public
Text_t compile_type(type_t *t) {
- if (t == PATH_TYPE) return Text("Path_t");
-
switch (t->tag) {
case ReturnType: errx(1, "Shouldn't be compiling ReturnType to a type");
case AbortType: return Text("void");
@@ -21,6 +19,7 @@ Text_t compile_type(type_t *t) {
case BoolType: return Text("Bool_t");
case ByteType: return Text("Byte_t");
case CStringType: return Text("const char*");
+ case PathType: return Text("Path_t");
case BigIntType: return Text("Int_t");
case IntType: return Texts("Int", (int32_t)Match(t, IntType)->bits, "_t");
case NumType:
@@ -68,10 +67,10 @@ Text_t compile_type(type_t *t) {
case NumType:
case BoolType:
case ByteType:
+ case PathType:
case ListType:
case TableType: return Texts("Optional", compile_type(nonnull));
case StructType: {
- if (nonnull == PATH_TYPE) return Text("OptionalPath_t");
DeclareMatch(s, nonnull, StructType);
return namespace_name(s->env, s->env->namespace->parent, Texts("$Optional", s->name, "$$type"));
}
@@ -87,7 +86,6 @@ Text_t compile_type(type_t *t) {
public
Text_t compile_type_info(type_t *t) {
if (t == NULL) compiler_err(NULL, NULL, NULL, "Attempt to compile a NULL type");
- if (t == PATH_TYPE) return Text("&Path$info");
switch (t->tag) {
case BoolType:
@@ -96,6 +94,7 @@ Text_t compile_type_info(type_t *t) {
case BigIntType:
case NumType:
case CStringType: return Texts("&", type_to_text(t), "$info");
+ case PathType: return Text("&Path$info");
case TextType: {
DeclareMatch(text, t, TextType);
if (!text->lang || streq(text->lang, "Text")) return Text("&Text$info");