Skip to content

Commit

Permalink
Implement TO_STRING and 'IMAGE for composite types
Browse files Browse the repository at this point in the history
  • Loading branch information
nickg committed Aug 6, 2023
1 parent ea12e4a commit e5a030a
Show file tree
Hide file tree
Showing 13 changed files with 507 additions and 188 deletions.
14 changes: 14 additions & 0 deletions src/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2366,3 +2366,17 @@ void copy_with_renaming(tree_t *roots, int nroots, tree_copy_pred_t tree_pred,
}
list_free(&copy_ctx.copied_subs);
}

bool all_character_literals(type_t type)
{
assert(type_is_enum(type));

type_t base = type_base_recur(type);
const int nlits = type_enum_literals(base);
for (int i = 0; i < nlits; i++) {
if (ident_char(tree_ident(type_enum_literal(base, i)), 0) != '\'')
return false;
}

return true;
}
1 change: 1 addition & 0 deletions src/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ bool is_type_attribute(attr_kind_t kind);
type_t get_type_or_null(tree_t t);
type_t subtype_for_string(tree_t str, type_t base);
tree_t change_ref(tree_t name, tree_t new);
bool all_character_literals(type_t type);

void copy_with_renaming(tree_t *roots, int nroots, tree_copy_pred_t tree_pred,
type_copy_pred_t type_pred, void *context,
Expand Down
Loading

0 comments on commit e5a030a

Please sign in to comment.