+++ /dev/null
-Currently, there are many janky things about structs in Onyx. I want
-to revisit all of the code related to them and fix all the issues I
-am having. To recap, here are all of the features that are required
-for structs to work:
- * #union
- * #size
- * #align
- * `use` members
- * struct literals
- * polymorphic structs
-
-All of these features work well individually, but when used together
-(such as struct literals over polymoprhic structs), they have many
-issues.
-
-Here is a brief explanation of the current data model:
- * AstStruct contains:
- - an array of AstStructMembers
- - the minimum size
- - the minimum alignment
-
- * AstStructMembers contain:
- - A symbol (token) for the name
- - the initial value
-
- * AstStructLiterals contain:
- - an array of values (unnamed)
- - an array of AstStructMembers representing named values
-
- * AstPolyStructs contain:
- - the base AstStruct
- - an array of tokens representing the parameters
- - the scope the struct was defined in
-
-In principle, this is the simple way each of the features should work:
- * #union
- - use 'max' instead of '+' when computing struct size
- - all members have offset 0
- * #size
- - the size is the minimum of the size given and the computed size
- * #align
- - the alignment is the minimum of the alignment given and the computed alignment
- * `use` members
- - adds members of used type to member list, with proper offsets
- * struct literals
- - ensures all values needed for the struct are present (no
- automatic zero values)
- * polymorphic structs
- - copy the base struct, introduce the type symbols, resolve symbols, win