generate: Parse primitive types into actual types rather than named types

This commit is contained in:
2025-07-10 21:53:21 -04:00
parent 3bf365a7a9
commit 5a3296a842
2 changed files with 27 additions and 5 deletions

View File

@@ -95,6 +95,28 @@ func (this *parser) parseType() (Type, error) {
switch this.Kind() {
case TokenIdent:
switch this.Value() {
case "U8": return TypeInt { Bits: 8 }, this.Next()
case "U16": return TypeInt { Bits: 16 }, this.Next()
case "U32": return TypeInt { Bits: 32 }, this.Next()
case "U64": return TypeInt { Bits: 64 }, this.Next()
case "U128": return TypeInt { Bits: 128 }, this.Next()
case "U256": return TypeInt { Bits: 256 }, this.Next()
case "I8": return TypeInt { Bits: 8, Signed: true }, this.Next()
case "I16": return TypeInt { Bits: 16, Signed: true }, this.Next()
case "I32": return TypeInt { Bits: 32, Signed: true }, this.Next()
case "I64": return TypeInt { Bits: 64, Signed: true }, this.Next()
case "I128": return TypeInt { Bits: 128, Signed: true }, this.Next()
case "I256": return TypeInt { Bits: 256, Signed: true }, this.Next()
case "F16": return TypeFloat { Bits: 16 }, this.Next()
case "F32": return TypeFloat { Bits: 32 }, this.Next()
case "F64": return TypeFloat { Bits: 64 }, this.Next()
case "F128": return TypeFloat { Bits: 128 }, this.Next()
case "F256": return TypeFloat { Bits: 256 }, this.Next()
case "String": return TypeString { }, this.Next()
case "Buffer": return TypeBuffer { }, this.Next()
case "Table": return TypeTable { }, this.Next()
}
return this.parseTypeNamed()
case TokenLBracket:
return this.parseTypeArray()