mirror of https://git.wuffs.org/MWCC
362 lines
9.3 KiB
C
362 lines
9.3 KiB
C
#ifndef COMPILER_COMMON_H
|
|
#define COMPILER_COMMON_H
|
|
|
|
#include "cw_common.h"
|
|
|
|
typedef struct HashNameNode {
|
|
struct HashNameNode *next;
|
|
SInt32 id;
|
|
SInt16 hashval;
|
|
char name[1];
|
|
} HashNameNode;
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=mac68k
|
|
#endif
|
|
// TODO move me into CPrep.h or something?
|
|
struct CPrepFileInfo {
|
|
FSSpec textfile;
|
|
HashNameNode *nameNode;
|
|
SInt32 fileModDate;
|
|
char *textbuffer;
|
|
SInt32 textlength;
|
|
SInt32 linenumber;
|
|
SInt32 pos;
|
|
Boolean hasprepline;
|
|
SInt16 fileID;
|
|
Boolean recordbrowseinfo;
|
|
Boolean unkfield123;
|
|
Boolean unkfield124;
|
|
Boolean unkfield125;
|
|
Boolean unkfield126;
|
|
};
|
|
#ifdef __MWERKS__
|
|
#pragma options align=reset
|
|
#endif
|
|
|
|
typedef struct CInt64 {
|
|
SInt32 hi;
|
|
UInt32 lo;
|
|
} CInt64;
|
|
|
|
typedef struct Float {
|
|
double value;
|
|
} Float;
|
|
|
|
typedef union MWVector128 {
|
|
UInt8 uc[16];
|
|
UInt16 us[8];
|
|
UInt32 ul[4];
|
|
float f[4];
|
|
} MWVector128;
|
|
|
|
typedef enum AccessType {
|
|
ACCESSPUBLIC,
|
|
ACCESSPRIVATE,
|
|
ACCESSPROTECTED,
|
|
ACCESSNONE
|
|
} AccessType;
|
|
|
|
typedef enum Section {
|
|
SECT_DEFAULT = 0,
|
|
SECT_TEXT = 1,
|
|
SECT_DATA = 2,
|
|
SECT_UDATA = 3,
|
|
SECT_DATA_FAR = 4,
|
|
SECT_DATA_NEAR = 5,
|
|
SECT_INIT = 6,
|
|
SECT_OBJC_CAT_CLS_METH = 7,
|
|
SECT_OBJC_CAT_INST_METH = 8,
|
|
SECT_OBJC_STRING_OBJECT = 9,
|
|
SECT_OBJC_CSTRING_OBJECT = 10,
|
|
SECT_OBJC_MESSAGE_REFS = 11,
|
|
SECT_OBJC_SEL_FIXUP = 12,
|
|
SECT_OBJC_CLS_REFS = 13,
|
|
SECT_OBJC_CLASS = 14,
|
|
SECT_OBJC_META_CLASS = 15,
|
|
SECT_OBJC_CLS_METH = 16,
|
|
SECT_OBJC_INST_METH = 17,
|
|
SECT_OBJC_PROTOCOL = 18,
|
|
SECT_OBJC_CLASS_NAMES = 19,
|
|
SECT_OBJC_METH_VAR_TYPES = 20,
|
|
SECT_OBJC_METH_VAR_NAMES = 21,
|
|
SECT_OBJC_CATEGORY = 22,
|
|
SECT_OBJC_CLASS_VARS = 23,
|
|
SECT_OBJC_INSTANCE_VARS = 24,
|
|
SECT_OBJC_MODULE_INFO = 25,
|
|
SECT_OBJC_MSYMBOLS = 26,
|
|
SECT_TEXT_CSTRING = 27,
|
|
SECT_BACKEND_SPECIFIC = 28,
|
|
SECT_MW_EX_TABLE = 28,
|
|
SECT_MW_EX_TABLE_INDEX = 29,
|
|
SECT_MW_SWITCH = 30,
|
|
SECT_8BYTE_LITERALS = 31,
|
|
SECT_4BYTE_LITERALS = 32,
|
|
// one of these next 2 is missing in pro7
|
|
SECT_MOD_INIT_FUNC = 33,
|
|
SECT_MOD_TERM_FUNC = 34,
|
|
SECT_CONST = 34,
|
|
SECT_CONST_PTR = 35,
|
|
// everything after here is known ok
|
|
SECT_NONLAZY_PTRS = 36,
|
|
SECT_COMMON_VARS = 37,
|
|
SECT_16BYTE_LITERALS = 38,
|
|
SECT_TEXT_COALESCE = 39,
|
|
SECT_DATA_COALESCE = 40,
|
|
SECT_UDATA_COALESCE = 41,
|
|
SECT_CONST_COALESCE = 42,
|
|
SECT_CONST_PTR_COALESCE = 43,
|
|
SECT_CSTR_COALESCE = 44,
|
|
N_SECTIONS = 45
|
|
} Section;
|
|
|
|
typedef struct Alias Alias;
|
|
typedef struct BClassList BClassList;
|
|
typedef struct CI_FuncData CI_FuncData;
|
|
typedef struct CLabel CLabel;
|
|
typedef struct ClassList ClassList;
|
|
typedef struct CParams CParams;
|
|
typedef struct CPrepFileInfo CPrepFileInfo;
|
|
typedef struct DeclInfo DeclInfo;
|
|
typedef struct DeclThing DeclThing; // rename me please
|
|
typedef struct DefArgCtorInfo DefArgCtorInfo;
|
|
typedef struct DepName DepName;
|
|
typedef struct EMemberInfo EMemberInfo;
|
|
typedef struct ENode ENode;
|
|
typedef struct ENodeList ENodeList;
|
|
typedef struct ExceptionAction ExceptionAction;
|
|
typedef struct ExtendedParam ExtendedParam;
|
|
typedef struct FuncArg FuncArg;
|
|
typedef struct Initializer Initializer;
|
|
typedef struct InlineXRef InlineXRef;
|
|
typedef struct MemInitializer MemInitializer;
|
|
typedef struct NameSpace NameSpace;
|
|
typedef struct NameSpaceName NameSpaceName;
|
|
typedef struct NameSpaceList NameSpaceList;
|
|
typedef struct NameSpaceLookupList NameSpaceLookupList;
|
|
typedef struct NameSpaceObjectList NameSpaceObjectList;
|
|
typedef struct ObjBase ObjBase;
|
|
typedef struct ObjEnumConst ObjEnumConst;
|
|
typedef struct ObjMemberVar ObjMemberVar;
|
|
typedef struct ObjMemberVarPath ObjMemberVarPath;
|
|
typedef struct ObjNameSpace ObjNameSpace;
|
|
typedef struct ObjType ObjType;
|
|
typedef struct ObjTypeTag ObjTypeTag;
|
|
typedef struct Object Object;
|
|
typedef struct ObjectList ObjectList;
|
|
typedef struct ObjCInfo ObjCInfo;
|
|
typedef struct ObjCMethod ObjCMethod;
|
|
typedef struct Operand Operand;
|
|
typedef struct PackedDeclInfo PackedDeclInfo;
|
|
typedef struct PCode PCode;
|
|
typedef struct PCodeArg PCodeArg;
|
|
typedef struct PCodeBlock PCodeBlock;
|
|
typedef struct PCodeLabel PCodeLabel;
|
|
typedef struct PointsToFunction PointsToFunction;
|
|
typedef struct PTFList PTFList;
|
|
typedef struct SOMInfo SOMInfo;
|
|
typedef struct Statement Statement;
|
|
typedef struct StructMember StructMember;
|
|
typedef struct Template Template;
|
|
typedef struct TemplateAction TemplateAction;
|
|
typedef struct TemplateFriend TemplateFriend;
|
|
typedef struct TemplateMember TemplateMember;
|
|
typedef struct TemplArg TemplArg;
|
|
typedef struct TemplClass TemplClass;
|
|
typedef struct TemplClassInst TemplClassInst;
|
|
typedef struct TemplateFunction TemplateFunction;
|
|
typedef struct TemplFuncInstance TemplFuncInstance;
|
|
typedef struct TemplInstance TemplInstance;
|
|
typedef struct TemplParam TemplParam;
|
|
typedef struct TemplPartialSpec TemplPartialSpec;
|
|
typedef struct TemplStack TemplStack;
|
|
typedef struct TStream TStream;
|
|
typedef struct TStreamElement TStreamElement;
|
|
typedef struct Type Type;
|
|
typedef struct TypeBitfield TypeBitfield;
|
|
typedef struct TypeClass TypeClass;
|
|
typedef struct TypeEnum TypeEnum;
|
|
typedef struct TypeFunc TypeFunc;
|
|
typedef struct TypeIntegral TypeIntegral;
|
|
typedef struct TypeList TypeList;
|
|
typedef struct TypeMemberPointer TypeMemberPointer;
|
|
typedef struct TypeMethod TypeMethod;
|
|
typedef struct TypePointer TypePointer;
|
|
typedef struct TypeStruct TypeStruct;
|
|
typedef struct TypeTemplDep TypeTemplDep;
|
|
typedef struct VarInfo VarInfo;
|
|
typedef struct VarRecord VarRecord;
|
|
typedef struct VClassList VClassList;
|
|
|
|
// Common bits for templates
|
|
typedef enum TemplParamType {
|
|
TPT_TYPE = 0,
|
|
TPT_NONTYPE,
|
|
TPT_TEMPLATE
|
|
} TemplParamType;
|
|
|
|
typedef struct TemplParamID {
|
|
UInt16 index;
|
|
UInt8 nindex;
|
|
TemplParamType type;
|
|
} TemplParamID;
|
|
|
|
typedef enum TemplDepSubType {
|
|
TDE_PARAM,
|
|
TDE_TYPEEXPR,
|
|
TDE_unk2, // may actually be 1?
|
|
TDE_CAST,
|
|
TDE_QUALNAME,
|
|
TDE_QUALTEMPL,
|
|
//TDE_OBJACCESS,
|
|
//TDE_SOURCEREF,
|
|
//TDE_FUNCCALL,
|
|
//TDE_LOCAL,
|
|
TDE_MONAND = 7,
|
|
TDE_MONPLUS,
|
|
TDE_MONMUL,
|
|
TDE_NEW,
|
|
TDE_DELETE,
|
|
TDE_ARRAY,
|
|
TDE_DYNAMIC_CAST,
|
|
TDE_STATIC_CAST,
|
|
TDE_REINTERPRET_CAST,
|
|
TDE_CONST_CAST,
|
|
TDE_TYPEID,
|
|
TDE_MEMBERACCESS,
|
|
TDE_THROW,
|
|
TDE_EXCEPTIONINIT,
|
|
TDE_LOCALINIT,
|
|
TDE_STATICINIT,
|
|
TDE_LOCALDESTROY,
|
|
TDE_ILLEGAL
|
|
} TemplDepSubType;
|
|
|
|
/// Things that can be applied to a type expression
|
|
typedef enum TEFuncSel {
|
|
TEFS_SIZEOF,
|
|
TEFS_ALIGNOF,
|
|
TEFS_UUIDOF,
|
|
TEFS_BI_ALIGN,
|
|
TEFS_BI_TYPE,
|
|
TEFS_BI_VTYPE,
|
|
TEFS_BI_CTYPE
|
|
} TEFuncSel;
|
|
|
|
/// How to access an object
|
|
/// this might not actually be in Pro7 lol
|
|
typedef struct ObjAccess {
|
|
NameSpaceObjectList *list;
|
|
TypeClass *naming;
|
|
TypeClass *member;
|
|
TemplArg *targs;
|
|
HashNameNode *name;
|
|
ENode *expr;
|
|
Boolean is_qualified;
|
|
Boolean is_member;
|
|
Boolean is_ambig : 1;
|
|
Boolean is_ptm : 1;
|
|
Boolean ext_only : 1;
|
|
} ObjAccess;
|
|
|
|
/// Qualifiers
|
|
enum {
|
|
Q_CONST = 1,
|
|
Q_VOLATILE = 2,
|
|
Q_ASM = 4,
|
|
Q_PASCAL = 8,
|
|
Q_INLINE = 0x10,
|
|
Q_REFERENCE = 0x20,
|
|
Q_EXPLICIT = 0x40,
|
|
Q_MUTABLE = 0x80,
|
|
Q_VIRTUAL = 0x100,
|
|
Q_FRIEND = 0x200,
|
|
Q_IN = 0x400,
|
|
Q_OUT = 0x800,
|
|
Q_INOUT = 0x1000,
|
|
Q_BYCOPY = 0x2000,
|
|
Q_BYREF = 0x4000,
|
|
Q_ONEWAY = 0x8000,
|
|
Q_10000 = 0x10000,
|
|
Q_20000 = 0x20000,
|
|
Q_OVERLOAD = 0x40000, // weak
|
|
Q_80000 = 0x80000,
|
|
Q_RESTRICT = 0x200000,
|
|
Q_1000000 = 0x1000000,
|
|
Q_ALIGNED_1 = 0x2000000,
|
|
Q_ALIGNED_2 = 0x4000000,
|
|
Q_ALIGNED_4 = 0x6000000,
|
|
Q_ALIGNED_8 = 0x8000000,
|
|
Q_ALIGNED_16 = 0xA000000,
|
|
Q_ALIGNED_32 = 0xC000000,
|
|
Q_ALIGNED_64 = 0x10000000,
|
|
Q_ALIGNED_128 = 0x12000000,
|
|
Q_ALIGNED_256 = 0x14000000,
|
|
Q_ALIGNED_512 = 0x16000000,
|
|
Q_ALIGNED_1024 = 0x18000000,
|
|
Q_ALIGNED_2048 = 0x1A000000,
|
|
Q_ALIGNED_4096 = 0x1C000000,
|
|
Q_ALIGNED_8192 = 0x1E000000,
|
|
Q_ALIGNED_MASK = 0x1E000000
|
|
};
|
|
|
|
enum {
|
|
EXPORT_FLAGS_INTERNAL = 0x10,
|
|
EXPORT_FLAGS_IMPORT = 0x20,
|
|
EXPORT_FLAGS_EXPORT = 0x40
|
|
};
|
|
|
|
typedef enum RegClass {
|
|
RegClass_Invalid = -1,
|
|
RegClass_SPR = 0,
|
|
RegClass_CRFIELD = 1,
|
|
RegClass_VR = 2,
|
|
RegClass_FPR = 3,
|
|
RegClass_GPR = 4,
|
|
RegClassMax = 5,
|
|
RegClass_6 = 6,
|
|
RegClass_DCR = 7
|
|
} RegClass;
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=mac68k
|
|
#endif
|
|
struct CParams {
|
|
CWPluginContext context;
|
|
CWObjectData objectdata;
|
|
Handle objectDataHandle;
|
|
Handle browseDataHandle;
|
|
SInt32 pluginRequest;
|
|
SInt32 apiVersion;
|
|
FSSpec projectFile;
|
|
SInt32 projectFileCount;
|
|
SInt32 mainFileNumber;
|
|
FSSpec mainFileSpec;
|
|
const char *mainFileText;
|
|
SInt32 mainFileTextLength;
|
|
Boolean isPrecompiling;
|
|
Boolean isAutoPrecompiling;
|
|
Boolean isPreprocessing;
|
|
Boolean isGeneratingDebugInfo;
|
|
Boolean isCachingPrecompiledHeaders;
|
|
CWBrowseOptions browseOptions;
|
|
Boolean field276;
|
|
SInt16 mainFileID;
|
|
CWDataType targetOS;
|
|
CWDataType targetCPU;
|
|
char *targetName;
|
|
};
|
|
|
|
#define FITS_IN_SHORT(value) ( (value) == ((short) (value)) )
|
|
#define FITS_IN_USHORT(value) ( (value) == ((unsigned short) (value)) )
|
|
#define FITS_IN_HI_SHORT(value) ( (value) == (value & 0xFFFF0000) )
|
|
#define FITS_IN_SHORT2(value) ( ((short) (value)) == (value) )
|
|
#define HIGH_PART(value) ( (short) (((value) >> 16) + (((value) & 0x8000) >> 15)) )
|
|
#define LOW_PART(value) ( (short) (value) )
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=reset
|
|
#endif
|
|
|
|
#endif
|