Skip to content
Matt Basta edited this page Mar 3, 2015 · 3 revisions

There are three basic categories for types in BType. array, struct, and primitives.

Primitives

A primitive is any value that can be represented as a single numeric constant. There are four public primitives in BType:

  • int: Signed 32-bit integer
  • bool: Boolean value represented by a single byte
  • float: 64-bit floating point number
  • sfloat: 32-bit floating point number

More information about primitives can be found in the built-in types page.

Primitives can only be extended by the compiler (for now). Methods cannot be added to primitives.

Arrays

An array is a fixed-length block of memory used to contain zero or more instances of or references to objects of another type. For instance, an array may have a length of four and contain four floats.

Arrays are the basic building block for strings and their derivative types. The contents of the array is determined by the type that it will contain. An array containing primitives will store the primitives as its elements, meaning the size of the array in bytes is N*M+sizeof(uint)*2 where N is the number of elements, M is the number of bytes required to represent one of the primitive values that the array will contain and sizeof(uint) is the number of bytes required to represent a private uint value. For all other types, a reference to the object will be stored in the array, meaning the size of the array in bytes is N*sizeof(pointer)+sizeof(uint)*2 where sizeof(pointer) is the size of the pointer type used in the BType implementation (in many cases, this may be a uint).

When instantiating an array, a length and a type attribute MUST be provided.

Structs

A struct is a type which contains one or more heterogeneous types. A struct is used to represent any other types not representable by the categories above.