MWCC/includes/compiler/common.h

346 lines
9.6 KiB
C
Raw Normal View History

2022-10-25 19:30:28 +00:00
#ifndef COMPILER_COMMON_H
#define COMPILER_COMMON_H
#include "cw_common.h"
enum { CR = 13, LF = 10 };
2022-10-25 19:30:28 +00:00
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,
SECT_MOD_INIT_FUNC = 33,
2022-11-07 03:06:21 +00:00
SECT_CONST = 34,
SECT_CONST_PTR = 35,
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,
2022-12-29 12:32:55 +00:00
//SECT_CSTR_COALESCE = 44,
N_SECTIONS = 44
2022-10-25 19:30:28 +00:00
} Section;
typedef struct Alias Alias;
2022-10-25 19:30:28 +00:00
typedef struct BClassList BClassList;
typedef struct CI_FuncData CI_FuncData;
typedef struct CLabel CLabel;
2023-01-20 11:56:38 +00:00
typedef struct ClassLayout ClassLayout;
2022-11-07 03:06:21 +00:00
typedef struct ClassList ClassList;
typedef struct CompilerLinkerParamBlk CompilerLinkerParamBlk;
typedef struct CPrepFileInfo CPrepFileInfo;
2022-12-29 12:32:55 +00:00
typedef struct CScopeSave CScopeSave;
typedef struct DeclFucker DeclFucker;
2022-11-07 03:06:21 +00:00
typedef struct DeclInfo DeclInfo;
typedef struct DeclThing DeclThing; // rename me please
2022-12-29 12:32:55 +00:00
typedef struct DeduceInfo DeduceInfo;
typedef struct DefAction DefAction;
2022-10-25 19:30:28 +00:00
typedef struct DefArgCtorInfo DefArgCtorInfo;
typedef struct DepName DepName;
2022-11-07 03:06:21 +00:00
typedef struct EMemberInfo EMemberInfo;
2022-10-25 19:30:28 +00:00
typedef struct ENode ENode;
typedef struct ENodeList ENodeList;
typedef struct ExceptionAction ExceptionAction;
2022-12-29 12:32:55 +00:00
typedef struct ExceptSpecList ExceptSpecList;
2022-10-25 19:30:28 +00:00
typedef struct ExtendedParam ExtendedParam;
2022-12-29 12:32:55 +00:00
typedef struct FileOffsetInfo FileOffsetInfo;
2022-10-25 19:30:28 +00:00
typedef struct FuncArg FuncArg;
2022-12-29 12:32:55 +00:00
typedef struct GList GList;
2022-10-25 19:30:28 +00:00
typedef struct Initializer Initializer;
typedef struct InlineXRef InlineXRef;
2022-12-29 12:32:55 +00:00
typedef struct Macro Macro;
2022-10-25 19:30:28 +00:00
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;
2022-12-29 12:32:55 +00:00
typedef struct ObjectTemplated ObjectTemplated;
typedef struct ObjCCategory ObjCCategory;
2022-10-25 19:30:28 +00:00
typedef struct ObjCInfo ObjCInfo;
typedef struct ObjCMethod ObjCMethod;
2022-12-29 12:32:55 +00:00
typedef struct ObjCMethodArg ObjCMethodArg;
typedef struct ObjCMethodList ObjCMethodList;
typedef struct ObjCNamedArg ObjCNamedArg;
typedef struct ObjCProtocol ObjCProtocol;
typedef struct ObjCProtocolList ObjCProtocolList;
typedef struct ObjCSelector ObjCSelector;
typedef struct OLinkList OLinkList;
2022-11-07 03:06:21 +00:00
typedef struct Operand Operand;
typedef struct PackedDeclInfo PackedDeclInfo;
typedef struct PCode PCode;
typedef struct PCodeArg PCodeArg;
typedef struct PCodeBlock PCodeBlock;
2022-10-25 19:30:28 +00:00
typedef struct PCodeLabel PCodeLabel;
typedef struct PointsToFunction PointsToFunction;
typedef struct PTFList PTFList;
typedef struct SOMInfo SOMInfo;
typedef struct Statement Statement;
typedef struct StructMember StructMember;
2022-12-29 12:32:55 +00:00
typedef struct SwitchCase SwitchCase;
typedef struct SwitchInfo SwitchInfo;
2022-10-25 19:30:28 +00:00
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 TemplParam TemplParam;
typedef struct TemplPartialSpec TemplPartialSpec;
typedef struct TemplStack TemplStack;
2023-01-11 22:29:53 +00:00
typedef struct TokenStream TokenStream;
2022-10-25 19:30:28 +00:00
typedef struct TStreamElement TStreamElement;
typedef struct Type Type;
typedef struct TypeBitfield TypeBitfield;
typedef struct TypeClass TypeClass;
2022-12-29 12:32:55 +00:00
typedef struct TypeDeduce TypeDeduce;
2022-10-25 19:30:28 +00:00
typedef struct TypeEnum TypeEnum;
typedef struct TypeFunc TypeFunc;
typedef struct TypeIntegral TypeIntegral;
2022-11-07 03:06:21 +00:00
typedef struct TypeList TypeList;
2022-10-25 19:30:28 +00:00
typedef struct TypeMemberPointer TypeMemberPointer;
typedef struct TypeMemberFunc TypeMemberFunc;
2022-12-29 12:32:55 +00:00
typedef struct TypeObjCID TypeObjCID;
2022-10-25 19:30:28 +00:00
typedef struct TypePointer TypePointer;
typedef struct TypeStruct TypeStruct;
typedef struct TypeTemplDep TypeTemplDep;
typedef struct VarInfo VarInfo;
typedef struct VarRecord VarRecord;
2022-11-07 03:06:21 +00:00
typedef struct VClassList VClassList;
2022-10-25 19:30:28 +00:00
// 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,
2022-12-29 12:32:55 +00:00
TDE_SIZEOF,
TDE_ALIGNOF,
2022-10-25 19:30:28 +00:00
TDE_CAST,
TDE_QUALNAME,
2022-12-29 12:32:55 +00:00
TDE_OBJ,
TDE_SOURCEREF,
TDE_ADDRESS_OF
2022-10-25 19:30:28 +00:00
} TemplDepSubType;
/// Qualifiers
enum {
Q_CONST = 1,
Q_VOLATILE = 2,
2023-01-10 11:05:21 +00:00
Q_CV = Q_CONST | Q_VOLATILE,
2022-10-25 19:30:28 +00:00
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,
2023-01-20 11:56:38 +00:00
Q_INLINE_DATA = 0x10000, // this object contains constant data in its union
2022-11-07 03:06:21 +00:00
Q_20000 = 0x20000,
2023-01-20 11:56:38 +00:00
Q_WEAK = 0x40000, // weak
Q_MANGLE_NAME = 0x80000, // adds C++ mangling info to a name
Q_IS_OBJC_ID = 0x100000, // Objective-C ID
2022-10-25 19:30:28 +00:00
Q_RESTRICT = 0x200000,
2023-01-20 11:56:38 +00:00
Q_IS_TEMPLATED = 0x400000, // is templated from another object?
2022-11-07 03:06:21 +00:00
Q_1000000 = 0x1000000,
2022-10-25 19:30:28 +00:00
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
};
2022-11-07 03:06:21 +00:00
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;
2022-11-07 03:06:21 +00:00
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
struct CompilerLinkerParamBlk {
2022-11-07 03:06:21 +00:00
CWPluginContext context;
CWObjectData object;
Handle objectdata;
Handle browsedata;
SInt32 request;
SInt32 version;
FSSpec targetfile;
SInt32 numfiles;
SInt32 whichfile;
FSSpec sourcefile;
const char *sourcetext;
SInt32 sourcetextsize;
Boolean precompile;
Boolean autoprecompile;
Boolean preprocess;
Boolean SYMinfo;
Boolean caching_includes;
CWBrowseOptions browseoptions;
Boolean recordbrowseinfo;
SInt16 browserfileID;
2022-11-07 03:06:21 +00:00
CWDataType targetOS;
CWDataType targetCPU;
char *idetargetname;
2022-11-07 03:06:21 +00:00
};
#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) >> 15) & 1)) )
#define LOW_PART(value) ( (short) (value) )
// The PowerPC code generator has a bug which breaks the PowerPC code generator,
// causing 32-bit value loads to emit "addi x, y, 0" even if the lower 16 bits are
// zero. This define simulates that behaviour on other platforms
#ifdef CW_REPLICATE_PPC_CODEGEN_BUG
#define LOW_PART_BUGGY(value) (value)
#else
#define LOW_PART_BUGGY(value) ( (short) (value) )
#endif
2022-11-07 03:06:21 +00:00
#ifdef __MWERKS__
#pragma options align=reset
#endif
2022-10-25 19:30:28 +00:00
#endif