summaryrefslogtreecommitdiff
path: root/src/ast
diff options
context:
space:
mode:
Diffstat (limited to 'src/ast')
-rw-r--r--src/ast/ast.c17
-rw-r--r--src/ast/ast.h10
2 files changed, 27 insertions, 0 deletions
diff --git a/src/ast/ast.c b/src/ast/ast.c
index 0799845..f4922a6 100644
--- a/src/ast/ast.c
+++ b/src/ast/ast.c
@@ -168,6 +168,18 @@ int type_eq(Type *a, Type *b)
{
return 0 == strcmp(a->name, b->name);
}
+ if (a->kind == TYPE_ALIAS)
+ {
+ if (a->alias.is_opaque_alias)
+ {
+ if (b->kind != TYPE_ALIAS || !b->alias.is_opaque_alias)
+ {
+ return 0;
+ }
+ return 0 == strcmp(a->name, b->name);
+ }
+ return type_eq(a->inner, b);
+ }
if (a->kind == TYPE_POINTER || a->kind == TYPE_ARRAY)
{
return type_eq(a->inner, b->inner);
@@ -340,6 +352,8 @@ static char *type_to_string_impl(Type *t)
}
return xstrdup(t->name);
}
+ case TYPE_ALIAS:
+ return xstrdup(t->name);
default:
return xstrdup("unknown");
@@ -524,6 +538,9 @@ static char *type_to_c_string_impl(Type *t)
case TYPE_GENERIC:
return xstrdup(t->name);
+ case TYPE_ALIAS:
+ return type_to_c_string(t->inner);
+
case TYPE_ENUM:
return xstrdup(t->name);
diff --git a/src/ast/ast.h b/src/ast/ast.h
index b272cae..a868bf0 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -58,6 +58,7 @@ typedef enum
TYPE_ARRAY, ///< Fixed size array [N].
TYPE_FUNCTION, ///< Function pointer or reference.
TYPE_GENERIC, ///< Generic type parameter (T).
+ TYPE_ALIAS, ///< Opaque type alias.
TYPE_UNKNOWN ///< Unknown/unresolved type.
} TypeKind;
@@ -84,6 +85,11 @@ typedef struct Type
int has_drop; ///< 1 if type implements Drop trait (RAII).
int has_iterable; ///< 1 if type implements Iterable trait.
} traits;
+ struct
+ {
+ int is_opaque_alias;
+ char *alias_defined_in_file;
+ } alias;
};
} Type;
@@ -263,6 +269,8 @@ struct ASTNode
{
char *alias;
char *original_type;
+ int is_opaque;
+ char *defined_in_file;
} type_alias;
struct
@@ -436,6 +444,8 @@ struct ASTNode
Attribute *attributes; // Custom attributes
char **used_structs; // Names of structs used/mixed-in
int used_struct_count;
+ int is_opaque;
+ char *defined_in_file; // File where the struct is defined (for privacy check)
} strct;
struct