aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/expr.h5
-rw-r--r--include/parse.h15
-rw-r--r--include/type.h24
-rw-r--r--include/util.h7
4 files changed, 31 insertions, 20 deletions
diff --git a/include/expr.h b/include/expr.h
index 8b4d8b0..5b0ce59 100644
--- a/include/expr.h
+++ b/include/expr.h
@@ -32,11 +32,6 @@ struct literal_e {
} lit;
};
-struct path {
- const char **segments;
- int segsz, seglen;
-};
-
struct call_e {
struct path path;
struct disjunction_e *args;
diff --git a/include/parse.h b/include/parse.h
index de30f39..981d8c6 100644
--- a/include/parse.h
+++ b/include/parse.h
@@ -9,7 +9,8 @@ struct ast_expr {
struct ast_externfunc {
const char *name;
struct type ret;
- struct type params[];
+ struct type *params;
+ int paramsz, paramlen;
};
struct ast_param {
@@ -24,11 +25,12 @@ struct ast_block {
};
struct ast_func {
- bool pub, exported;
+ bool exported;
const char *name;
- struct ast_block block;
struct type ret;
- struct ast_param params[];
+ struct ast_param *params;
+ int paramsz, paramlen;
+ struct ast_block block;
};
enum const_global {
@@ -39,14 +41,13 @@ enum const_global {
};
struct ast_const_global {
- bool pub;
const char *name;
enum const_global kind;
union {
- struct type *type;
+ struct type type;
bool b;
struct number num;
- const char *str;
+ char *str;
} value;
};
diff --git a/include/type.h b/include/type.h
index 78a3d18..c8a6b76 100644
--- a/include/type.h
+++ b/include/type.h
@@ -2,6 +2,12 @@
#define CERC_TYPE_H
#include <stdbool.h>
#include <stdint.h>
+#include "expr.h"
+#include "lex.h"
+#include "util.h"
+
+// Only 64-bit targets are supported
+#define PLATBITS 64
struct cer_int {
bool sign;
@@ -14,11 +20,7 @@ struct cer_float {
struct cer_array {
struct type *member_type;
- int length;
-};
-
-struct cer_slice {
- struct type *member_type;
+ struct disjunction_e *length;
};
struct field {
@@ -28,6 +30,7 @@ struct field {
struct cer_struct {
struct field *fields;
+ int fieldsz, fieldlen;
};
struct variant {
@@ -36,12 +39,15 @@ struct variant {
};
struct cer_enum {
- struct cer_int tag_type;
- struct variant variants[];
+ struct type *tag_type;
+ struct variant *variants;
+ int variantsz, variantlen;
};
struct cer_union {
+ struct type *tag_type;
struct type *alts;
+ int altsz, altlen;
};
enum type_kind {
@@ -52,6 +58,7 @@ enum type_kind {
TYP_FLOAT,
TYP_INT,
TYP_OPTIONAL,
+ TYP_PATH,
TYP_POINTER,
TYP_SLICE,
TYP_STRUCT,
@@ -62,10 +69,11 @@ union type_desc {
struct cer_int i;
struct cer_float f;
struct cer_array array;
- struct cer_slice slice;
struct cer_struct s;
struct cer_enum en;
struct cer_union un;
+ struct type *inner;
+ struct path path;
};
struct type {
diff --git a/include/util.h b/include/util.h
index 5a5a819..0e2b289 100644
--- a/include/util.h
+++ b/include/util.h
@@ -1,5 +1,7 @@
#ifndef CERC_UTIL_H
#define CERC_UTIL_H
+#include <stddef.h>
+
enum exit_status {
/* EXIT_SUCCESS = 0 (defined in stdlib.h) */
EXIT_USER = 1,
@@ -9,6 +11,11 @@ enum exit_status {
EXIT_ABNORMAL = 255,
};
+struct path {
+ const char **segments;
+ int segsz, seglen;
+};
+
void *must_malloc(size_t size);
void *must_calloc(size_t nmemb, size_t size);
void *must_realloc(void *ptr, size_t size);