hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

builtins.ha (2255B)


      1 // License: MPL-2.0
      2 // (c) 2021 Drew DeVault <sir@cmpwn.com>
      3 
      4 // [[_type]] representation of bool.
      5 export const builtin_bool: _type = _type {
      6 	repr = builtin::BOOL,
      7 	sz = 1, _align = 1,
      8 	...
      9 };
     10 
     11 // [[_type]] representation of f32.
     12 export const builtin_f32: _type = _type {
     13 	repr = builtin::F32,
     14 	sz = 4, _align = 4,
     15 	...
     16 };
     17 
     18 // [[_type]] representation of f64.
     19 export const builtin_f64: _type = _type {
     20 	repr = builtin::F64,
     21 	sz = 8, _align = 8,
     22 	...
     23 };
     24 
     25 // [[_type]] representation of i8.
     26 export const builtin_i8: _type = _type {
     27 	repr = builtin::I8,
     28 	sz = 1, _align = 1,
     29 	...
     30 };
     31 
     32 // [[_type]] representation of i16.
     33 export const builtin_i16: _type = _type {
     34 	repr = builtin::I16,
     35 	sz = 2, _align = 2,
     36 	...
     37 };
     38 
     39 // [[_type]] representation of i32.
     40 export const builtin_i32: _type = _type {
     41 	repr = builtin::I32,
     42 	sz = 4, _align = 4,
     43 	...
     44 };
     45 
     46 // [[_type]] representation of i64.
     47 export const builtin_i64: _type = _type {
     48 	repr = builtin::I64,
     49 	sz = 8, _align = 8,
     50 	...
     51 };
     52 
     53 // [[_type]] representation of null.
     54 export const builtin_null: _type = _type {
     55 	repr = builtin::NULL,
     56 	sz = 0, _align = 0,
     57 	...
     58 };
     59 
     60 // [[_type]] representation of rune.
     61 export const builtin_rune: _type = _type {
     62 	repr = builtin::RUNE,
     63 	sz = 4, _align = 4,
     64 	...
     65 };
     66 
     67 // [[_type]] representation of u8.
     68 export const builtin_u8: _type = _type {
     69 	repr = builtin::U8,
     70 	sz = 1, _align = 1,
     71 	...
     72 };
     73 
     74 // [[_type]] representation of u16.
     75 export const builtin_u16: _type = _type {
     76 	repr = builtin::U16,
     77 	sz = 2, _align = 2,
     78 	...
     79 };
     80 
     81 // [[_type]] representation of u32.
     82 export const builtin_u32: _type = _type {
     83 	repr = builtin::U32,
     84 	sz = 4, _align = 4,
     85 	...
     86 };
     87 
     88 // [[_type]] representation of u64.
     89 export const builtin_u64: _type = _type {
     90 	repr = builtin::U64,
     91 	sz = 8, _align = 8,
     92 	...
     93 };
     94 
     95 // [[_type]] representation of void.
     96 export const builtin_void: _type = _type {
     97 	repr = builtin::VOID,
     98 	sz = 0, _align = 0,
     99 	...
    100 };
    101 
    102 @init fn init() void = {
    103 	const builtins = [
    104 		&builtin_bool,
    105 		&builtin_f32,
    106 		&builtin_f64,
    107 		&builtin_i8,
    108 		&builtin_i16,
    109 		&builtin_i32,
    110 		&builtin_i64,
    111 		&builtin_null,
    112 		&builtin_rune,
    113 		&builtin_u8,
    114 		&builtin_u16,
    115 		&builtin_u32,
    116 		&builtin_u64,
    117 		&builtin_void,
    118 	];
    119 	for (let i = 0z; i < len(builtins); i += 1) {
    120 		builtins[i].id = hash(builtins[i]);
    121 	};
    122 };