2022-10-25 19:30:28 +00:00
|
|
|
#ifndef COMPILER_TEMPLATES_H
|
|
|
|
#define COMPILER_TEMPLATES_H
|
|
|
|
|
|
|
|
#include "compiler/common.h"
|
|
|
|
#include "compiler/types.h"
|
|
|
|
#include "compiler/tokens.h"
|
|
|
|
|
|
|
|
#ifdef __MWERKS__
|
|
|
|
#pragma options align=mac68k
|
|
|
|
#endif
|
|
|
|
|
2022-12-29 12:32:55 +00:00
|
|
|
struct PackedDeclInfo { // ok
|
2022-10-25 19:30:28 +00:00
|
|
|
Type *thetype;
|
|
|
|
UInt32 qual;
|
|
|
|
NameSpace *nspace;
|
|
|
|
HashNameNode *name;
|
|
|
|
TemplArg *expltargs;
|
|
|
|
SInt16 storageclass;
|
|
|
|
Section section;
|
|
|
|
UInt8 exportflags;
|
|
|
|
Boolean has_expltargs;
|
2022-12-29 12:32:55 +00:00
|
|
|
};
|
2022-10-25 19:30:28 +00:00
|
|
|
|
|
|
|
struct Template {
|
|
|
|
Template *parent;
|
|
|
|
TemplInstance *parentinst;
|
|
|
|
TemplParam *params;
|
|
|
|
Boolean is_class;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TemplateFriend { // verified via CPrec
|
|
|
|
PackedDeclInfo decl;
|
|
|
|
FileOffsetInfo fileoffset;
|
2023-01-11 22:29:53 +00:00
|
|
|
TokenStream stream;
|
2022-10-25 19:30:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct TemplateMember { // verified via CPrec
|
|
|
|
struct TemplateMember *next;
|
|
|
|
TemplParam *params;
|
|
|
|
Object *object;
|
|
|
|
FileOffsetInfo fileoffset;
|
2023-01-11 22:29:53 +00:00
|
|
|
TokenStream stream;
|
2022-10-25 19:30:28 +00:00
|
|
|
CPrepFileInfo *srcfile;
|
|
|
|
SInt32 startoffset;
|
|
|
|
SInt32 endoffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TemplInstance {
|
|
|
|
// Template *templ;
|
|
|
|
TemplInstance *parent;
|
|
|
|
TemplArg *args;
|
|
|
|
Boolean is_instantiated;
|
|
|
|
Boolean is_specialized;
|
|
|
|
Boolean is_extern;
|
|
|
|
Boolean static_instantiated;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TemplParam { // verified via CPrec
|
|
|
|
TemplParam *next;
|
|
|
|
HashNameNode *name;
|
|
|
|
TemplParamID pid;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
Type *type;
|
|
|
|
UInt32 qual;
|
|
|
|
} typeparam;
|
|
|
|
struct {
|
|
|
|
Type *type;
|
|
|
|
UInt32 qual;
|
|
|
|
ENode *defaultarg;
|
|
|
|
} paramdecl;
|
|
|
|
struct {
|
|
|
|
TemplParam *plist;
|
|
|
|
Type *defaultarg;
|
|
|
|
} templparam;
|
|
|
|
} data;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TemplArg { // verified by CPrec
|
|
|
|
TemplArg *next;
|
|
|
|
TemplParamID pid;
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
Type *type;
|
|
|
|
UInt32 qual;
|
|
|
|
} typeparam;
|
|
|
|
struct {
|
|
|
|
ENode *expr;
|
|
|
|
Boolean is_ref;
|
|
|
|
} paramdecl;
|
|
|
|
Type *ttargtype;
|
|
|
|
} data;
|
|
|
|
Boolean is_deduced;
|
|
|
|
};
|
|
|
|
|
2022-12-29 12:32:55 +00:00
|
|
|
struct DeduceInfo {
|
|
|
|
TemplArg *args;
|
|
|
|
TemplArg argBuffer[16];
|
|
|
|
int maxCount;
|
|
|
|
int count;
|
|
|
|
UInt8 x12C;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct DefAction {
|
|
|
|
DefAction *next;
|
|
|
|
TemplateAction *action;
|
|
|
|
ObjBase *refobj;
|
|
|
|
int xC;
|
|
|
|
TypeEnum *enumtype;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TypeDeduce {
|
|
|
|
TemplClass *tmclass;
|
|
|
|
TemplClassInst *inst;
|
|
|
|
TemplParam *params;
|
|
|
|
TemplArg *args;
|
|
|
|
DefAction *defActions;
|
|
|
|
Boolean x14;
|
|
|
|
Boolean x15;
|
|
|
|
Boolean x16;
|
|
|
|
Boolean x17;
|
|
|
|
UInt8 nindex;
|
|
|
|
Boolean x19;
|
|
|
|
};
|
|
|
|
|
2022-10-25 19:30:28 +00:00
|
|
|
struct TemplPartialSpec { // confirmed via CPrec (but templ might be a different type?)
|
|
|
|
TemplPartialSpec *next;
|
|
|
|
TemplClass *templ;
|
|
|
|
TemplArg *args;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TemplStack {
|
|
|
|
TemplStack *next;
|
|
|
|
union {
|
|
|
|
Object *func;
|
|
|
|
TypeClass *theclass;
|
|
|
|
} u;
|
|
|
|
Boolean is_func;
|
|
|
|
Boolean is_poi;
|
|
|
|
};
|
|
|
|
|
|
|
|
/***********/
|
|
|
|
/* Classes */
|
|
|
|
/***********/
|
|
|
|
|
|
|
|
struct TemplClass {
|
|
|
|
TypeClass theclass;
|
|
|
|
TemplClass *next;
|
2022-12-29 12:32:55 +00:00
|
|
|
TemplClass *templ_parent; // confirmed by v8
|
|
|
|
TemplClassInst *inst_parent; // confirmed by v8
|
2022-10-25 19:30:28 +00:00
|
|
|
TemplParam *templ__params;
|
|
|
|
TemplateMember *members;
|
|
|
|
TemplClassInst *instances;
|
|
|
|
TemplClass *pspec_owner;
|
|
|
|
TemplPartialSpec *pspecs;
|
|
|
|
TemplateAction *actions;
|
2022-12-29 12:32:55 +00:00
|
|
|
UInt16 lex_order_count; // confirmed by v8
|
2022-10-25 19:30:28 +00:00
|
|
|
SInt8 align;
|
|
|
|
UInt8 flags;
|
|
|
|
};
|
|
|
|
|
2022-11-07 03:06:21 +00:00
|
|
|
enum {
|
2022-12-29 12:32:55 +00:00
|
|
|
TEMPLCLASS_FLAGS_1 = 1,
|
2022-11-07 03:06:21 +00:00
|
|
|
TEMPLCLASS_FLAGS_2 = 2
|
|
|
|
};
|
|
|
|
|
2022-10-25 19:30:28 +00:00
|
|
|
struct TemplClassInst {
|
|
|
|
TypeClass theclass;
|
2022-12-29 12:32:55 +00:00
|
|
|
TemplClassInst *next; // confirmed by v8
|
|
|
|
TemplClassInst *parent; // confirmed by v8
|
2022-10-25 19:30:28 +00:00
|
|
|
TemplClass *templ;
|
|
|
|
TemplArg *inst_args;
|
|
|
|
TemplArg *oargs;
|
2022-12-29 12:32:55 +00:00
|
|
|
Boolean is_instantiated;
|
|
|
|
Boolean is_specialized;
|
|
|
|
Boolean is_extern;
|
|
|
|
Boolean x49;
|
2022-10-25 19:30:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define TEMPL_CLASS(ty) ( (TemplClass *) (ty) )
|
|
|
|
#define TEMPL_CLASS_INST(ty) ( (TemplClassInst *) (ty) )
|
2022-11-20 05:07:22 +00:00
|
|
|
#define IS_TEMPL_CLASS(ty) ( IS_TYPE_CLASS(ty) && (TYPE_CLASS(ty)->flags & CLASS_FLAGS_100) )
|
2022-12-29 12:32:55 +00:00
|
|
|
#define IS_TEMPL_CLASS_INST(ty) ( IS_TYPE_CLASS(ty) && (TYPE_CLASS(ty)->flags & CLASS_FLAGS_800) )
|
2022-10-25 19:30:28 +00:00
|
|
|
|
|
|
|
/*************/
|
|
|
|
/* Functions */
|
|
|
|
/*************/
|
|
|
|
|
|
|
|
struct TemplateFunction { // verified via CPrec
|
|
|
|
TemplateFunction *next;
|
|
|
|
TemplateFunction *unk4; // parent?
|
|
|
|
HashNameNode *name;
|
|
|
|
TemplParam *params;
|
2023-01-11 22:29:53 +00:00
|
|
|
TokenStream stream;
|
2022-10-25 19:30:28 +00:00
|
|
|
TStreamElement deftoken;
|
|
|
|
Object *tfunc;
|
|
|
|
TemplFuncInstance *instances;
|
|
|
|
CPrepFileInfo *srcfile;
|
|
|
|
SInt32 startoffset;
|
|
|
|
SInt32 endoffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct TemplFuncInstance { // verified via CPrec
|
|
|
|
TemplFuncInstance *next;
|
|
|
|
Object *object;
|
|
|
|
TemplArg *args;
|
|
|
|
Boolean is_instantiated;
|
|
|
|
Boolean is_specialized;
|
|
|
|
Boolean is_extern;
|
|
|
|
Boolean static_instantiated;
|
|
|
|
};
|
|
|
|
|
2022-11-20 05:07:22 +00:00
|
|
|
#define TEMPL_FUNC(ty) ( (TemplateFunction *) (ty) )
|
|
|
|
#define TEMPL_FUNC_INST(ty) ( (TemplFuncInstance *) (ty) )
|
|
|
|
#define IS_TEMPL_FUNC(ty) ( IS_TYPE_FUNC(ty) && (TYPE_FUNC(ty)->flags & FUNC_FLAGS_100000) )
|
|
|
|
|
2022-10-25 19:30:28 +00:00
|
|
|
/***********/
|
|
|
|
/* Actions */
|
|
|
|
/***********/
|
|
|
|
|
|
|
|
typedef enum TemplateActionType {
|
|
|
|
TAT_NESTEDCLASS,
|
|
|
|
TAT_ENUMTYPE,
|
|
|
|
TAT_FRIEND,
|
|
|
|
TAT_ENUMERATOR, // in pro7 but not pro8
|
|
|
|
TAT_BASE,
|
|
|
|
TAT_OBJECTINIT,
|
|
|
|
TAT_USINGDECL,
|
|
|
|
TAT_OBJECTDEF,
|
|
|
|
TAT_ILLEGAL
|
|
|
|
} TemplateActionType;
|
|
|
|
|
|
|
|
struct TemplateAction { // verified via CPrec
|
|
|
|
TemplateAction *next;
|
|
|
|
TStreamElement source_ref;
|
|
|
|
union {
|
|
|
|
TemplClass *tclasstype;
|
|
|
|
TypeEnum *enumtype;
|
|
|
|
TemplateFriend *tfriend;
|
|
|
|
struct {
|
|
|
|
ObjEnumConst *objenumconst;
|
|
|
|
ENode *initexpr;
|
|
|
|
} enumerator;
|
|
|
|
struct {
|
|
|
|
Type *type;
|
|
|
|
ClassList *insert_after;
|
|
|
|
AccessType access;
|
|
|
|
Boolean is_virtual;
|
|
|
|
} base;
|
|
|
|
struct {
|
|
|
|
Object *object;
|
|
|
|
ENode *initexpr;
|
|
|
|
} objectinit;
|
|
|
|
struct {
|
|
|
|
TypeTemplDep *type;
|
|
|
|
AccessType access;
|
|
|
|
} usingdecl;
|
|
|
|
ObjBase *refobj;
|
|
|
|
} u;
|
|
|
|
TemplateActionType type;
|
|
|
|
};
|
|
|
|
|
|
|
|
#ifdef __MWERKS__
|
|
|
|
#pragma options align=reset
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|