diff options
| author | Mustafa Quraish <[email protected]> | 2022-02-07 03:02:39 -0500 |
|---|---|---|
| committer | Mustafa Quraish <[email protected]> | 2022-02-07 03:18:08 -0500 |
| commit | 3817688851fae07b1d6a13ba2ce1906fc9811f8f (patch) | |
| tree | bb936b224cada39dc7ede856d9f15a4000950526 /compiler/types.cup | |
| parent | Add missing files to self-hosted directory (diff) | |
| download | cup-3817688851fae07b1d6a13ba2ce1906fc9811f8f.tar.xz cup-3817688851fae07b1d6a13ba2ce1906fc9811f8f.zip | |
[cup] Self-hosting is now possible! Make some tweaks to match C output
A bit of a chonky commit, but this ports over the remaining (well,
almost) everything from the C implementation to the self-hosted
compiler.
The only things that really remain right now are (1) defer support
and (2) support for constants in local scopes. There were used barely
enough so for now their uses have been removed, but I'll implement
them back later. Not sure how useful (2) is though.
Diffstat (limited to 'compiler/types.cup')
| -rw-r--r-- | compiler/types.cup | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/compiler/types.cup b/compiler/types.cup index 10a2d6f..9b0d822 100644 --- a/compiler/types.cup +++ b/compiler/types.cup @@ -1,4 +1,5 @@ import "std/common.cup" +import "std/vector.cup" enum BaseType { TYPE_VOID, @@ -19,11 +20,7 @@ struct Type { struct_name: char*; size: int; array_size: int; - fields: struct { - names: char**; - types: Type**; - num_fields: int; - }; + fields: Vector*; // Vector<Variable*>; }; fn size_for_base_type(type: int): int { @@ -86,7 +83,8 @@ fn create_type_string(typ: Type *): char* { else if (typ.typ == TYPE_CHAR) strcat(buf, "char"); else if (typ.typ == TYPE_VOID) strcat(buf, "void"); else if (typ.typ == TYPE_ANY) strcat(buf, "any"); - else die("type_to_string: unknown type"); + else if (typ.typ == TYPE_STRUCT) strcat(buf, typ.struct_name); + else die("create_type_string: unknown type"); return buf; } |