This repository has been archived on 2024-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
arf/analyzer/primitives.go

64 lines
2.1 KiB
Go
Raw Normal View History

2022-09-08 10:59:49 -06:00
package analyzer
// This is a global, cannonical list of primitive and built-in types.
2022-10-11 22:48:55 -06:00
// PrimitiveF32 is a 32 bit floating point primitive.
var PrimitiveF32 = createPrimitive("F32", Type {})
// PrimitiveF64 is a 64 bit floating point primitive.
var PrimitiveF64 = createPrimitive("F64", Type {})
// PrimitiveInt is a signed integer word primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveInt = createPrimitive("Int", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveUInt is an unsigned integer word primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveUInt = createPrimitive("UInt", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI8 is a signed 8 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveI8 = createPrimitive("I8", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI16 is a signed 16 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveI16 = createPrimitive("I16", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI32 is a signed 32 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveI32 = createPrimitive("I32", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI64 is a signed 64 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveI64 = createPrimitive("I64", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI8 is an unsigned 8 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveU8 = createPrimitive("U8", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI16 is an unsigned 16 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveU16 = createPrimitive("U16", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI32 is an unsigned 32 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveU32 = createPrimitive("U32", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveI64 is an unsigned 64 bit integer primitive.
2022-09-10 17:50:18 -06:00
var PrimitiveU64 = createPrimitive("U64", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveObj is a blank object primitive.
var PrimitiveObj = createPrimitive("Obj", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveFace is a blank interface primitive. It accepts any value.
2022-09-10 17:50:18 -06:00
var PrimitiveFace = createPrimitive("Face", Type {})
2022-10-11 22:48:55 -06:00
// PrimitiveFunc is a blank function interface primitive. It is useless.
var PrimitiveFunc = createPrimitive("Func", Type {})
2022-09-08 10:59:49 -06:00
2022-10-11 22:48:55 -06:00
// BuiltInString is a built in string type. It is a dynamic array of UTF-32
// codepoints.
2022-09-10 17:50:18 -06:00
var BuiltInString = createPrimitive("String", Type {
2022-10-04 15:25:05 -06:00
actual: &PrimitiveU32,
2022-09-10 17:50:18 -06:00
kind: TypeKindVariableArray,
})
2022-09-08 10:59:49 -06:00
2022-09-10 17:50:18 -06:00
// createPrimitive provides a quick way to construct a primitive for the above
// list.
func createPrimitive (name string, inherits Type) (primitive TypeSection) {
primitive.where = locator { name: name }
2022-09-21 19:25:48 -06:00
primitive.what = inherits
2022-09-10 17:50:18 -06:00
return
2022-09-08 10:59:49 -06:00
}