|
| bool | ps_type_is_prim (enum ps_type_type type) |
| | Returns whether type represents a primitive type.
|
| |
| struct ps_type * | ps_type_prim_new (enum ps_type_type prim_type) |
| | Constructs a new primitive type specified by prim_type.
|
| |
| struct ps_type * | ps_type_struct_new (struct ps_token *name) |
| | Constructs a new empty struct type with the name name.
|
| |
| void | ps_type_struct_add (struct ps_type *type, struct ps_type_field field) |
| | Adds the given field field to the struct type type.
|
| |
| struct ps_type * | ps_type_enum_new (struct ps_token *name) |
| | Constructs a new empty enum type with the name name.
|
| |
| void | ps_type_enum_add (struct ps_type *type, struct ps_type_variant variant) |
| | Adds the given variant variant to the struct type type.
|
| |
| struct ps_type * | ps_type_unresolved_new (struct ps_token *name) |
| | Constructs a new unresolved type corresponding to the given name.
|
| |
| struct ps_type * | ps_type_from_name (struct ps_token *name) |
| | Returns the type associated with the given name (e.g.
|
| |
| struct ps_type * | ps_type_from_tuple (struct ps_type_tuple *tuple) |
| | Constructs and returns a type for the given tuple type tuple.
|
| |
| | PS_PRINT_IMPL (ps_type, { switch(self->type) { case PS_TYPE_U8:{ fputs(_STRING(PS_PRIM_TYPE_U8), stdout);break;} case PS_TYPE_I8:{ fputs(_STRING(PS_PRIM_TYPE_I8), stdout);break;} case PS_TYPE_U16:{ fputs(_STRING(PS_PRIM_TYPE_U16), stdout);break;} case PS_TYPE_I16:{ fputs(_STRING(PS_PRIM_TYPE_I16), stdout);break;} case PS_TYPE_U32:{ fputs(_STRING(PS_PRIM_TYPE_U32), stdout);break;} case PS_TYPE_I32:{ fputs(_STRING(PS_PRIM_TYPE_I32), stdout);break;} case PS_TYPE_U64:{ fputs(_STRING(PS_PRIM_TYPE_U64), stdout);break;} case PS_TYPE_I64:{ fputs(_STRING(PS_PRIM_TYPE_I64), stdout);break;} case PS_TYPE_F32:{ fputs(_STRING(PS_PRIM_TYPE_F32), stdout);break;} case PS_TYPE_F64:{ fputs(_STRING(PS_PRIM_TYPE_F64), stdout);break;} case PS_TYPE_B:{ fputs(_STRING(PS_PRIM_TYPE_B), stdout);break;} case PS_TYPE_TUPLE:{ ps_type_tuple_print(self->value.tuple, 0);break;} case PS_TYPE_STRUCT:{ ps_type_struct_print(&self->value.struct_, 0, 0);break;} case PS_TYPE_ENUM:{ ps_type_enum_print(&self->value.enum_, 0, 0);break;} case PS_TYPE_UNRESOLVED:{ printf("%s", self->value.unresolved->start);break;} default:{ ps_abort("unknown type encountered");break;} } }) |
| |
| | PS_PRINT_IMPL (ps_type_variant, { printf("%s", self->name);ps_type_tuple_print(self->args, 0);}) |
| |
| | PS_IPRINT_IMPL (ps_type_enum, { ps_print_indent();printf("enum %.*s {\n",(int) self->name->length, self->name->start);for(usize i=0;i< self->variants->length;i++) { ps_type_variant_print(& $arr(self->variants)[i], 0);printf("\n");} ps_print_indent();printf("}");}) |
| |