char* ARGV0;
char* Artifact = "ast";
+/* Builtin Types
+ *****************************************************************************/
+static void builtins(Parser* p) {
+#if 0
+ sym_add(&(p->syms), "void", VoidType());
+ sym_add(&(p->syms), "bool", UIntType(1u));
+ sym_add(&(p->syms), "byte", UIntType(8u));
+ sym_add(&(p->syms), "uint", UIntType(64u));
+ sym_add(&(p->syms), "u8", UIntType(8u));
+ sym_add(&(p->syms), "u16", UIntType(16u));
+ sym_add(&(p->syms), "u32", UIntType(32u));
+ sym_add(&(p->syms), "u64", UIntType(64u));
+ sym_add(&(p->syms), "int", IntType(64u));
+ sym_add(&(p->syms), "i8", IntType(8u));
+ sym_add(&(p->syms), "i16", IntType(16u));
+ sym_add(&(p->syms), "i32", IntType(32u));
+ sym_add(&(p->syms), "i64", IntType(64u));
+ sym_add(&(p->syms), "string", ArrayType(sym_get(&(p->syms), "byte")));
+#endif
+}
+
/* Driver Modes
*****************************************************************************/
static int emit_tokens(void) {
Kind kind;
union {
struct Type* type;
- ssize_t bits;
+ size_t bits;
struct {
struct Type* type;
size_t count;
} value;
} Type;
-Type* IntType(ssize_t nbits);
-Type* UIntType(ssize_t nbits);
-Type* ArrayOf(Type* type);
+Type* VoidType(void);
+Type* IntType(size_t nbits);
+Type* UIntType(size_t nbits);
+Type* ArrayOf(Type* type, size_t count);
Type* RefTo(Type* type);
Type* PtrTo(Type* type);
--- /dev/null
+#include <sclpl.h>
+
+static Type* mktype(Kind kind) {
+ Type* type = emalloc(sizeof(Type));
+ memset(type, 0, sizeof(Type));
+ type->kind = kind;
+ return type;
+}
+
+Type* VoidType(void) {
+ return mktype(VOID);
+}
+
+Type* IntType(size_t nbits) {
+ Type* type = mktype(INT);
+ type->value.bits = nbits;
+ return type;
+}
+
+Type* UIntType(size_t nbits) {
+ Type* type = mktype(UINT);
+ type->value.bits = nbits;
+ return type;
+}
+
+Type* ArrayOf(Type* elemtype, size_t count) {
+ Type* type = mktype(ARRAY);
+ type->value.array.type = elemtype;
+ type->value.array.count = count;
+ return type;
+}
+
+Type* RefTo(Type* type) {
+ return NULL;
+}
+
+Type* PtrTo(Type* type) {
+ return NULL;
+}