summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--compiler/main.c14
-rw-r--r--compiler/parser/parser.c6
-rw-r--r--compiler/parser/type.c1
-rw-r--r--test.c1
-rw-r--r--test.q50
6 files changed, 62 insertions, 11 deletions
diff --git a/.gitignore b/.gitignore
index 7ec5f2c..351ac9d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -5,6 +5,7 @@
quarkc
.vscode/
.vs/
+unused/
*.a
*.d
*.o
diff --git a/compiler/main.c b/compiler/main.c
index da261bc..ada6243 100644
--- a/compiler/main.c
+++ b/compiler/main.c
@@ -174,6 +174,14 @@ parse_args(int argc, char **argv)
}
static void
+print_ptrs(int n_ptrs)
+{
+ for (int n = 0; n < n_ptrs; n++) {
+ putchar('*');
+ }
+}
+
+static void
print_alias(struct type *typ)
{
printf("alias (%lu bytes, %d pointer(s))", typ->size, typ->n_ptrs);
@@ -207,7 +215,7 @@ print_struct(struct type *typ)
{
struct struct_member *mem;
- printf("struct {\n");
+ printf("struct (%lu bytes) {\n", typ->size);
for (size_t r = 0; r < typ->members.n_rows; r++) {
mem = (struct struct_member*)typ->members.rows[r].head;
@@ -216,7 +224,9 @@ print_struct(struct type *typ)
}
do {
- printf(" %.*s %.*s; (%d pointer(s))\n", (int)mem->typ->name_len, mem->typ->name, (int)mem->name_len, mem->name, mem->n_ptrs);
+ printf(" %.*s", (int)mem->typ->name_len, mem->typ->name);
+ print_ptrs(mem->n_ptrs);
+ printf(" %.*s;\n", (int)mem->name_len, mem->name);
mem = (struct struct_member*)mem->hashmap_entry.list_entry.next;
} while (mem != (struct struct_member*)&typ->members.rows[r]);
diff --git a/compiler/parser/parser.c b/compiler/parser/parser.c
index aeec48b..261385b 100644
--- a/compiler/parser/parser.c
+++ b/compiler/parser/parser.c
@@ -79,6 +79,10 @@ parser_init(struct parser *ctx, char *source)
debug("Initializing parser...\n");
lexer_init(&ctx->lexer, source);
- add_builtin(ctx->types, "uint32", 4, 0);
add_builtin(ctx->types, "any", 0, 0);
+ add_builtin(ctx->types, "uint", sizeof(void*), 0);
+ add_builtin(ctx->types, "uint64", 8, 0);
+ add_builtin(ctx->types, "uint32", 4, 0);
+ add_builtin(ctx->types, "uint16", 2, 0);
+ add_builtin(ctx->types, "uint8", 1, 0);
}
diff --git a/compiler/parser/type.c b/compiler/parser/type.c
index 4ac9327..e0990c3 100644
--- a/compiler/parser/type.c
+++ b/compiler/parser/type.c
@@ -189,6 +189,7 @@ parse_struct(struct parser *ctx, struct type *typ)
}
next_token(ctx);
}
+ typ->size = off;
next_token(ctx);
return true;
diff --git a/test.c b/test.c
deleted file mode 100644
index b09fed5..0000000
--- a/test.c
+++ /dev/null
@@ -1 +0,0 @@
-int main \ No newline at end of file
diff --git a/test.q b/test.q
index 3af6676..6e92c35 100644
--- a/test.q
+++ b/test.q
@@ -1,13 +1,49 @@
type EfiStatus: uint32;
type EfiHandle: any*;
-type TestEnum: enum {
- nog,
- bal
+type EfiGuid: struct {
+ uint32 data1;
+ uint16 data2;
+ uint16 data3;
};
-type TestStruct: struct {
- EfiStatus status;
- EfiHandle imageHandle;
- any* systemTable;
+type EfiTableHeader: struct {
+ uint64 signature;
+ uint32 revision;
+ uint32 headerSize;
+ uint32 crc32;
+ uint32 reserved;
+};
+
+type EfiRuntimeServices: struct {
+ EfiTableHeader hdr;
+};
+
+type EfiBootServices: struct {
+ EfiTableHeader hdr;
+};
+
+type EfiConfigurationTable: struct {
+ EfiGuid vendorGuid;
+ any* vendorTable;
+};
+
+type EfiSystemTable: struct {
+ EfiTableHeader hdr;
+
+ any* firmwareVendor;
+ uint32 firmwareRevision;
+
+ EfiHandle consoleInHandle;
+ any* conIn;
+ EfiHandle consoleOutHandle;
+ any* conOut;
+ EfiHandle standardErrorHandle;
+ any* stdErr;
+
+ EfiRuntimeServices* runtimeServices;
+ EfiBootServices* bootServices;
+
+ uint numberOfTableEntries;
+ EfiConfigurationTable* configurationTable;
};