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-12-29 12:32:55 +00:00
|
|
|
EINITTRYCATCH,
|
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 {
|
2022-12-29 12:32:55 +00:00
|
|
|
Type *type;
|
2022-10-25 19:30:28 +00:00
|
|
|
} typeexpr;
|
|
|
|
struct {
|
|
|
|
ENodeList *args;
|
|
|
|
Type *type;
|
|
|
|
UInt32 qual;
|
|
|
|
} cast;
|
|
|
|
struct {
|
|
|
|
TypeTemplDep *type;
|
|
|
|
HashNameNode *name;
|
|
|
|
} qual;
|
|
|
|
struct {
|
|
|
|
ENode *expr;
|
|
|
|
TStreamElement *token;
|
|
|
|
} sourceref;
|
|
|
|
ENode *monadic;
|
|
|
|
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-12-14 00:16:59 +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)) )
|
|
|
|
#define ENODE_IS4(_enode, _etype1, _etype2, _etype3, _etype4) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) || ENODE_IS((_enode), (_etype4)) )
|
2023-01-10 11:05:21 +00:00
|
|
|
#define ENODE_IS5(_enode, _etype1, _etype2, _etype3, _etype4, _etype5) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) || ENODE_IS((_enode), (_etype4)) || ENODE_IS((_enode), (_etype5)) )
|
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-12-14 00:16:59 +00:00
|
|
|
// 0 to 8, 0x30 to 0x31
|
|
|
|
#define ENODE_CASE_MONADIC \
|
|
|
|
case EPOSTINC: \
|
|
|
|
case EPOSTDEC: \
|
|
|
|
case EPREINC: \
|
|
|
|
case EPREDEC: \
|
|
|
|
case EINDIRECT: \
|
|
|
|
case EMONMIN: \
|
|
|
|
case EBINNOT: \
|
|
|
|
case ELOGNOT: \
|
|
|
|
case EFORCELOAD: \
|
|
|
|
case ETYPCON: \
|
2022-12-29 12:32:55 +00:00
|
|
|
case EBITFIELD
|
2022-12-14 00:16:59 +00:00
|
|
|
|
|
|
|
// 9 to 0x1B
|
|
|
|
#define ENODE_CASE_DIADIC_1 \
|
|
|
|
case EMUL: \
|
|
|
|
case EMULV: \
|
|
|
|
case EDIV: \
|
|
|
|
case EMODULO: \
|
|
|
|
case EADDV: \
|
|
|
|
case ESUBV: \
|
|
|
|
case EADD: \
|
|
|
|
case ESUB: \
|
|
|
|
case ESHL: \
|
|
|
|
case ESHR: \
|
|
|
|
case ELESS: \
|
|
|
|
case EGREATER: \
|
|
|
|
case ELESSEQU: \
|
|
|
|
case EGREATEREQU: \
|
|
|
|
case EEQU: \
|
|
|
|
case ENOTEQU: \
|
|
|
|
case EAND: \
|
|
|
|
case EXOR: \
|
2022-12-29 12:32:55 +00:00
|
|
|
case EOR
|
2022-12-14 00:16:59 +00:00
|
|
|
|
|
|
|
// 0x1E to 0x28, 0x2D, 0x2F
|
|
|
|
#define ENODE_CASE_ASSIGN \
|
|
|
|
case EASS: \
|
|
|
|
case EMULASS: \
|
|
|
|
case EDIVASS: \
|
|
|
|
case EMODASS: \
|
|
|
|
case EADDASS: \
|
|
|
|
case ESUBASS: \
|
|
|
|
case ESHLASS: \
|
|
|
|
case ESHRASS: \
|
|
|
|
case EANDASS: \
|
|
|
|
case EXORASS: \
|
|
|
|
case EORASS: \
|
|
|
|
case EBCLR: \
|
2022-12-29 12:32:55 +00:00
|
|
|
case EBSET
|
|
|
|
|
2023-01-10 11:05:21 +00:00
|
|
|
// 9 to 0x2F
|
2022-12-29 12:32:55 +00:00
|
|
|
#define ENODE_CASE_DIADIC_ALL \
|
|
|
|
case EMUL: \
|
|
|
|
case EMULV: \
|
|
|
|
case EDIV: \
|
|
|
|
case EMODULO: \
|
|
|
|
case EADDV: \
|
|
|
|
case ESUBV: \
|
|
|
|
case EADD: \
|
|
|
|
case ESUB: \
|
|
|
|
case ESHL: \
|
|
|
|
case ESHR: \
|
|
|
|
case ELESS: \
|
|
|
|
case EGREATER: \
|
|
|
|
case ELESSEQU: \
|
|
|
|
case EGREATEREQU: \
|
|
|
|
case EEQU: \
|
|
|
|
case ENOTEQU: \
|
|
|
|
case EAND: \
|
|
|
|
case EXOR: \
|
|
|
|
case EOR: \
|
|
|
|
case ELAND: \
|
|
|
|
case ELOR: \
|
|
|
|
case EASS: \
|
|
|
|
case EMULASS: \
|
|
|
|
case EDIVASS: \
|
|
|
|
case EMODASS: \
|
|
|
|
case EADDASS: \
|
|
|
|
case ESUBASS: \
|
|
|
|
case ESHLASS: \
|
|
|
|
case ESHRASS: \
|
|
|
|
case EANDASS: \
|
|
|
|
case EXORASS: \
|
|
|
|
case EORASS: \
|
|
|
|
case ECOMMA: \
|
|
|
|
case EPMODULO: \
|
|
|
|
case EROTL: \
|
|
|
|
case EROTR: \
|
|
|
|
case EBCLR: \
|
|
|
|
case EBTST: \
|
|
|
|
case EBSET
|
2022-12-14 00:16:59 +00:00
|
|
|
|
2022-10-25 19:30:28 +00:00
|
|
|
#ifdef __MWERKS__
|
|
|
|
#pragma options align=reset
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|