From 312a19c781da1c31ff1e3dc71c319663a8be9148 Mon Sep 17 00:00:00 2001 From: _ov4 Date: Thu, 22 Oct 2026 13:56:44 +0000 Subject: feat(codegen): accept pointer types to any C type in EXTERN A pseudocode pointer type now counts as a C type, in EXTERN signatures and as a C-struct field, when it finally points to a non-void C type or a C struct, as in TYPE PInt = ^C_INT. A pointer cycle such as TYPE P = ^P and a pointer to a pseudocode type stay rejected. Co-Authored-By: Claude Opus 5.5 --- include/cps/TypeSystem.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/cps/TypeSystem.h b/include/cps/TypeSystem.h index 1c1e422..f8427f3 100644 --- a/include/cps/TypeSystem.h +++ b/include/cps/TypeSystem.h @@ -154,12 +154,15 @@ public: std::string &Err); bool sameType(const std::string &Left, const std::string &Right) const; const TypeInfo *promoteCScalar(const TypeInfo *Info) const; - // A TYPE record (not a CLASS) whose fields are C scalars, C pointers, - // C structs or pointer types to C structs. Otherwise Why, if given, - // names the first offending field and its type. + // Follows pseudocode pointer types to the type they finally point to: + // Info itself when it is not one, nullptr for a cycle (TYPE P = ^P). + const TypeInfo *pointerBase(const TypeInfo *Info) const; + // A TYPE record (not a CLASS) whose fields are C types, C structs or + // pointer types to either. Otherwise Why, if given, names the first + // offending field and its type. bool isCStruct(const TypeInfo *Info, std::string *Why = nullptr) const; // Crosses the EXTERN "C" boundary: a non-void C type, a C struct or a - // pointer type to one. + // pointer type to either. bool isExternType(const TypeInfo *Info) const; const TypeInfo *commonCScalar(const TypeInfo *Left, const TypeInfo *Right) const; -- cgit v1.3.1-4-g156e