2022-10-25 19:30:28 +00:00
|
|
|
#ifndef COMPILER_ENODE_H
|
|
|
|
#define COMPILER_ENODE_H
|
|
|
|
|
|
|
|
#include "compiler/common.h"
|
|
|
|
|
|
|
|
#ifdef __MWERKS__
|
|
|
|
#pragma options align=mac68k
|
|
|
|
#endif
|
|
|
|
|
|
|
|
typedef enum ENodeType {
|
|
|
|
EPOSTINC,
|
|
|
|
EPOSTDEC,
|
|
|
|
EPREINC,
|
|
|
|
EPREDEC,
|
|
|
|
EINDIRECT,
|
|
|
|
EMONMIN,
|
|
|
|
EBINNOT,
|
|
|
|
ELOGNOT,
|
|
|
|
EFORCELOAD,
|
|
|
|
EMUL,
|
|
|
|
EMULV,
|
|
|
|
EDIV,
|
|
|
|
EMODULO,
|
|
|
|
EADDV,
|
|
|
|
ESUBV,
|
|
|
|
EADD,
|
|
|
|
ESUB,
|
|
|
|
ESHL,
|
|
|
|
ESHR,
|
|
|
|
ELESS,
|
|
|
|
EGREATER,
|
|
|
|
ELESSEQU,
|
|
|
|
EGREATEREQU,
|
|
|
|
EEQU,
|
|
|
|
ENOTEQU,
|
|
|
|
EAND,
|
|
|
|
EXOR,
|
|
|
|
EOR,
|
|
|
|
ELAND,
|
|
|
|
ELOR,
|
|
|
|
EASS,
|
|
|
|
EMULASS,
|
|
|
|
EDIVASS,
|
|
|
|
EMODASS,
|
|
|
|
EADDASS,
|
|
|
|
ESUBASS,
|
|
|
|
ESHLASS,
|
|
|
|
ESHRASS,
|
|
|
|
EANDASS,
|
|
|
|
EXORASS,
|
|
|
|
EORASS,
|
|
|
|
ECOMMA,
|
|
|
|
EPMODULO,
|
|
|
|
EROTL,
|
|
|
|
EROTR,
|
|
|
|
EBCLR,
|
|
|
|
EBTST,
|
|
|
|
EBSET,
|
|
|
|
ETYPCON,
|
|
|
|
EBITFIELD,
|
|
|
|
EINTCONST,
|
|
|
|
EFLOATCONST,
|
|
|
|
ESTRINGCONST,
|
|
|
|
ECOND,
|
|
|
|
EFUNCCALL,
|
|
|
|
EFUNCCALLP,
|
|
|
|
EOBJREF,
|
|
|
|
EMFPOINTER,
|
|
|
|
ENULLCHECK,
|
|
|
|
EPRECOMP,
|
|
|
|
ETEMP,
|
|
|
|
EARGOBJ,
|
|
|
|
ELOCOBJ,
|
|
|
|
ELABEL,
|
|
|
|
ESETCONST,
|
|
|
|
ENEWEXCEPTION,
|
|
|
|
ENEWEXCEPTIONARRAY,
|
2022-11-07 03:06:21 +00:00
|
|
|
EMYSTERY67, // no name???
|
2022-10-25 19:30:28 +00:00
|
|
|
EOBJLIST,
|
|
|
|
EMEMBER,
|
|
|
|
ETEMPLDEP,
|
|
|
|
EINSTRUCTION,
|
|
|
|
EDEFINE,
|
|
|
|
EREUSE,
|
|
|
|
EASSBLK,
|
|
|
|
EVECTOR128CONST,
|
|
|
|
ECONDASS,
|
|
|
|
MAXEXPR
|
|
|
|
} ENodeType;
|
|
|
|
|
|
|
|
|
2022-11-07 03:06:21 +00:00
|
|
|
struct EMemberInfo {
|
|
|
|
BClassList *path;
|
2022-11-20 05:07:22 +00:00
|
|
|
ENode *expr;
|
|
|
|
NameSpaceObjectList *list;
|
|
|
|
TemplArg *templargs;
|
|
|
|
Boolean pr_1D;
|
|
|
|
Boolean x11;
|
|
|
|
Boolean isambig;
|
2022-11-07 03:06:21 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2022-10-25 19:30:28 +00:00
|
|
|
struct ENodeList {
|
|
|
|
ENodeList *next;
|
|
|
|
ENode *node;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef union ENodeUnion {
|
|
|
|
CInt64 intval;
|
|
|
|
Float floatval;
|
|
|
|
SInt32 longval;
|
|
|
|
ENode *monadic;
|
|
|
|
Object *objref;
|
|
|
|
CLabel *label;
|
|
|
|
MWVector128 vector128val;
|
|
|
|
struct {
|
|
|
|
ENode *left;
|
|
|
|
ENode *right;
|
|
|
|
} diadic;
|
|
|
|
struct {
|
|
|
|
ENode *cond;
|
|
|
|
ENode *expr1;
|
|
|
|
ENode *expr2;
|
|
|
|
} cond;
|
|
|
|
struct {
|
|
|
|
ENode *funcref;
|
|
|
|
ENodeList *args;
|
|
|
|
TypeFunc *functype;
|
|
|
|
} funccall;
|
2022-11-07 03:06:21 +00:00
|
|
|
//ObjAccess objaccess;
|
2022-10-25 19:30:28 +00:00
|
|
|
struct {
|
|
|
|
ENode *accessnode;
|
|
|
|
ENode *mfpointer;
|
|
|
|
} mfpointer;
|
|
|
|
struct {
|
|
|
|
ENode *nullcheckexpr;
|
|
|
|
ENode *condexpr;
|
|
|
|
SInt32 precompid;
|
|
|
|
} nullcheck;
|
|
|
|
SInt32 precompid;
|
|
|
|
struct {
|
|
|
|
Type *type;
|
|
|
|
SInt32 uniqueid;
|
|
|
|
Boolean needs_dtor;
|
|
|
|
} temp;
|
|
|
|
struct {
|
|
|
|
SInt32 size;
|
|
|
|
char *data;
|
2022-11-07 03:06:21 +00:00
|
|
|
//SInt32 segnum; ??
|
2022-10-25 19:30:28 +00:00
|
|
|
char ispascal;
|
|
|
|
char ispacked;
|
|
|
|
} string;
|
|
|
|
struct {
|
|
|
|
SInt32 size;
|
|
|
|
char *data;
|
|
|
|
} set;
|
|
|
|
struct {
|
|
|
|
ENode *initexpr;
|
|
|
|
ENode *tryexpr;
|
|
|
|
Object *pointertemp;
|
|
|
|
Object *deletefunc;
|
|
|
|
} newexception;
|
|
|
|
struct {
|
|
|
|
ENode *initexpr;
|
|
|
|
ENode *tryexpr;
|
|
|
|
ENode *catchexpr;
|
|
|
|
ENode *result;
|
|
|
|
} itc;
|
|
|
|
struct {
|
|
|
|
Object *objref;
|
|
|
|
SInt32 offset;
|
|
|
|
} addr;
|
2022-11-07 03:06:21 +00:00
|
|
|
struct {
|
|
|
|
NameSpaceObjectList *list;
|
|
|
|
TemplArg *templargs;
|
2022-11-20 05:07:22 +00:00
|
|
|
HashNameNode *name;
|
2022-11-07 03:06:21 +00:00
|
|
|
} objlist;
|
2022-11-20 05:07:22 +00:00
|
|
|
EMemberInfo *emember;
|
2022-10-25 19:30:28 +00:00
|
|
|
void *inst;
|
|
|
|
MemInitializer *ctorinit;
|
|
|
|
Statement *stmt;
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
TemplParamID pid;
|
|
|
|
struct {
|
|
|
|
union {
|
|
|
|
Type *type;
|
|
|
|
ENode *expr;
|
|
|
|
} u;
|
|
|
|
TEFuncSel sel;
|
|
|
|
Boolean is_expr;
|
|
|
|
} typeexpr;
|
|
|
|
struct {
|
|
|
|
ENodeList *args;
|
|
|
|
Type *type;
|
|
|
|
UInt32 qual;
|
|
|
|
} cast;
|
|
|
|
struct {
|
|
|
|
TypeTemplDep *type;
|
|
|
|
HashNameNode *name;
|
|
|
|
} qual;
|
|
|
|
struct {
|
|
|
|
TypeTemplDep *type;
|
|
|
|
HashNameNode *name;
|
|
|
|
TemplArg *args;
|
|
|
|
} qualtempl;
|
2022-11-07 03:06:21 +00:00
|
|
|
//ObjAccess objaccess;
|
2022-10-25 19:30:28 +00:00
|
|
|
struct {
|
|
|
|
ENode *expr;
|
|
|
|
TStreamElement *token;
|
|
|
|
} sourceref;
|
|
|
|
ENode *monadic;
|
|
|
|
struct {
|
|
|
|
ENode *expr;
|
|
|
|
ENodeList *args;
|
|
|
|
} funccall;
|
2022-11-07 03:06:21 +00:00
|
|
|
// have my doubts about this one
|
|
|
|
/*struct {
|
2022-10-25 19:30:28 +00:00
|
|
|
Type *type;
|
|
|
|
UInt32 qual;
|
|
|
|
ENode *arraydim;
|
|
|
|
ENodeList *placement;
|
|
|
|
ENodeList *initlist;
|
|
|
|
Boolean is_global;
|
|
|
|
Boolean has_init;
|
2022-11-07 03:06:21 +00:00
|
|
|
} nw;*/
|
2022-10-25 19:30:28 +00:00
|
|
|
struct {
|
|
|
|
ENode *expr;
|
|
|
|
Boolean is_global;
|
|
|
|
Boolean is_array;
|
|
|
|
} del;
|
|
|
|
struct {
|
|
|
|
ENode *left;
|
|
|
|
ENode *right;
|
|
|
|
} dyadic;
|
|
|
|
struct {
|
|
|
|
ENode *expr;
|
|
|
|
Type *type;
|
|
|
|
UInt32 qual;
|
|
|
|
} newcast;
|
|
|
|
struct {
|
|
|
|
ENode *expr;
|
|
|
|
DepName *dname;
|
|
|
|
Boolean is_pointer;
|
|
|
|
} member;
|
|
|
|
struct {
|
|
|
|
Object *object;
|
|
|
|
Object *info;
|
|
|
|
} exinit;
|
|
|
|
struct {
|
|
|
|
Object *obj;
|
|
|
|
Initializer *init;
|
|
|
|
} varinit;
|
|
|
|
Object *obj;
|
|
|
|
} u;
|
|
|
|
TemplDepSubType subtype;
|
|
|
|
} templdep;
|
|
|
|
} ENodeUnion;
|
|
|
|
|
|
|
|
struct ENode {
|
|
|
|
ENodeType type;
|
|
|
|
UInt8 cost;
|
2022-11-07 03:06:21 +00:00
|
|
|
UInt16 flags;
|
2022-10-25 19:30:28 +00:00
|
|
|
Boolean ignored;
|
|
|
|
Boolean hascall;
|
|
|
|
// void *loc; - might not be in pro7?
|
|
|
|
Type *rtype;
|
|
|
|
PointsToFunction *pointsTo;
|
|
|
|
ENodeUnion data;
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ENODE_FLAG_CONST = Q_CONST,
|
|
|
|
ENODE_FLAG_VOLATILE = Q_VOLATILE,
|
2022-11-07 03:06:21 +00:00
|
|
|
ENODE_FLAG_QUALS = Q_CONST | Q_VOLATILE,
|
|
|
|
ENODE_FLAG_10 = 0x10,
|
|
|
|
ENODE_FLAG_80 = 0x80
|
2022-10-25 19:30:28 +00:00
|
|
|
};
|
|
|
|
|
2022-11-07 03:06:21 +00:00
|
|
|
#define ENODE_IS(_enode, _etype) ( (_enode)->type == (_etype) )
|
2022-11-20 05:07:22 +00:00
|
|
|
#define ENODE_IS2(_enode, _etype1, _etype2) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS(_enode, (_etype2)) )
|
|
|
|
#define ENODE_IS3(_enode, _etype1, _etype2, _etype3) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS(_enode, (_etype2)) || ENODE_IS(_enode, (_etype3)) )
|
2022-11-07 03:06:21 +00:00
|
|
|
#define ENODE_IS_RANGE(_enode, _lo, _hi) ( ((_enode)->type >= (_lo)) && ((_enode)->type <= (_hi)) )
|
2022-11-20 05:07:22 +00:00
|
|
|
#define ENODE_QUALS(_enode) ( (UInt32) ( (_enode)->flags & ENODE_FLAG_QUALS ) )
|
|
|
|
#define ENODE_IS_INDIRECT_TO(_enode, _etype) ( ENODE_IS((_enode), EINDIRECT) && ENODE_IS((_enode)->data.monadic, (_etype)) )
|
|
|
|
#define ENODE_IS_ASSIGN(_enode) ( ENODE_IS_RANGE((_enode), EASS, EORASS) )
|
|
|
|
#define ENODE_IS_ASSIGN_TO(_enode, _etype) ( ENODE_IS_RANGE((_enode), EASS, EORASS) && ENODE_IS((_enode)->data.diadic.left->data.monadic, (_etype)) )
|
2022-11-07 03:06:21 +00:00
|
|
|
|
2022-10-25 19:30:28 +00:00
|
|
|
#ifdef __MWERKS__
|
|
|
|
#pragma options align=reset
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|