mirror of https://git.wuffs.org/MWCC
881 lines
27 KiB
C
881 lines
27 KiB
C
#include "compiler/common.h"
|
|
|
|
// THESE TYPES ARE NOT YET SORTED
|
|
#include "compiler/tokens.h"
|
|
#include "compiler/CompilerTools.h"
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=mac68k
|
|
#endif
|
|
|
|
enum {
|
|
AlignMode0_Mac68k,
|
|
AlignMode1_Mac68k4byte,
|
|
AlignMode2_PPC,
|
|
AlignMode3_1Byte,
|
|
AlignMode4_2Byte,
|
|
AlignMode5_4Byte,
|
|
AlignMode6_8Byte,
|
|
AlignMode7_16Byte,
|
|
AlignMode8
|
|
};
|
|
|
|
// not sure how many of these are char and how many are unsigned char or Boolean
|
|
typedef struct COpts {
|
|
char little_endian;
|
|
char codegen_dynamic;
|
|
char codegen_pic;
|
|
char no_common;
|
|
char no_implicit_templates;
|
|
char absolutepath; // determines the path written to debug info
|
|
char x06; // linker/objgen related
|
|
short cpu;
|
|
char schedule_cpu;
|
|
unsigned char schedule_mode; // may be an enum??
|
|
SInt32 debuglisting;
|
|
char profile;
|
|
char traceback;
|
|
char disable_registers;
|
|
char fp_contract;
|
|
char no_register_save_helpers;
|
|
char ppc_unroll_speculative;
|
|
short ppc_unroll_instructions_limit;
|
|
short ppc_unroll_factor_limit;
|
|
char altivec_model;
|
|
UInt8 x1B; // altivec/vrsave related
|
|
UInt8 code_alignment;
|
|
char x1D;
|
|
UInt8 x1E; // some register used in TOC_use_isel
|
|
UInt8 gen_fsel;
|
|
char ppc_opt_bclr_bcctr;
|
|
char use_lmw_stmw;
|
|
char report_heap_info;
|
|
char misaligned_mem_access;
|
|
char switch_tables;
|
|
char prepare_compress;
|
|
char some_alignment; // used in CMach_AllocationAlignment
|
|
char asmsemicolcomment;
|
|
char asmpoundcomment;
|
|
StringPtr oldprefixname;
|
|
short inlinelevel;
|
|
int inline_max_size;
|
|
int inline_max_total_size;
|
|
char inline_bottom_up;
|
|
Boolean cplusplus;
|
|
Boolean ecplusplus;
|
|
char objective_c;
|
|
char objc_strict;
|
|
char ARM_conform;
|
|
char ARM_scoping;
|
|
char require_prototypes;
|
|
char trigraphs;
|
|
char only_std_keywords;
|
|
char enumsalwaysint;
|
|
char ANSI_strict;
|
|
char mpwc_relax;
|
|
char mpwc_newline;
|
|
char ignore_oldstyle;
|
|
char cpp_extensions;
|
|
char pointercast_lvalue;
|
|
char useRTTI;
|
|
char delete_exception;
|
|
char _4B;
|
|
Boolean oldalignment;
|
|
char unsignedchars;
|
|
char multibyteaware;
|
|
char autoinline;
|
|
char defer_codegen;
|
|
Boolean direct_to_som;
|
|
char som_env_check;
|
|
char som_call_opt;
|
|
char booltruefalse;
|
|
char old_enum_mangler;
|
|
char longlong;
|
|
char longlong_enums;
|
|
char no_tfuncinline;
|
|
char _59;
|
|
char flat_include;
|
|
char syspath_once;
|
|
char always_import;
|
|
char simple_class_byval;
|
|
char wchar_type;
|
|
char vbase_ctor_offset;
|
|
char vbase_abi_v2;
|
|
char def_inherited;
|
|
char template_patch;
|
|
char template_friends;
|
|
char faster_pch_gen;
|
|
char array_new_delete;
|
|
Boolean dollar_identifiers;
|
|
char def_inline_tfuncs;
|
|
char arg_dep_lookup;
|
|
Boolean simple_prepdump;
|
|
char line_prepdump;
|
|
char fullpath_prepdump;
|
|
char old_mtemplparser;
|
|
char suppress_init_code;
|
|
char reverse_bitfields;
|
|
Boolean c9x;
|
|
char float_constants;
|
|
char no_static_dtors;
|
|
char longlong_prepeval;
|
|
char const_strings;
|
|
char dumpir;
|
|
char experimental;
|
|
char gcc_extensions;
|
|
char stdc_fp_contract;
|
|
char stdc_fenv_access;
|
|
char stdc_cx_limitedr;
|
|
char old_argmatch;
|
|
char optEH;
|
|
char optEH2;
|
|
char new_mangler;
|
|
char microsoft;
|
|
Boolean warningerrors;
|
|
char pedantic;
|
|
char check_header_flags;
|
|
Boolean supress_warnings;
|
|
Boolean warn_illpragma;
|
|
char warn_emptydecl;
|
|
char warn_possunwant;
|
|
char warn_unusedvar;
|
|
char warn_unusedarg;
|
|
char warn_extracomma;
|
|
char warn_hidevirtual;
|
|
char warn_largeargs;
|
|
char warn_implicitconv;
|
|
char warn_notinlined;
|
|
char warn_structclass;
|
|
char warn_padding;
|
|
char warn_no_side_effect;
|
|
char warn_resultnotused;
|
|
char warn_ptr_int_conv;
|
|
char align_mode;
|
|
Boolean align_array_members;
|
|
char dont_reuse_strings;
|
|
char pool_strings;
|
|
char explicit_zero_data;
|
|
char readonly_strings;
|
|
char exceptions;
|
|
char _99;
|
|
char dont_inline;
|
|
char always_inline;
|
|
char peephole;
|
|
char global_optimizer;
|
|
char side_effects;
|
|
char internal;
|
|
char import;
|
|
char export;
|
|
char lib_export;
|
|
char nosyminline;
|
|
char force_active;
|
|
char optimizationlevel;
|
|
char optimize_for_size;
|
|
char optimizewithasm;
|
|
char crippled;
|
|
char opt_common_subs;
|
|
char opt_loop_invariants;
|
|
char opt_propagation;
|
|
char opt_dead_assignments;
|
|
char opt_strength_reduction;
|
|
char opt_strength_reduction_strict;
|
|
char opt_dead_code;
|
|
char opt_lifetimes;
|
|
char _B1; // unused?
|
|
char opt_unroll_loops;
|
|
char opt_vectorize_loops;
|
|
char _B4; // amount of IRO passes?
|
|
char opt_pointer_analysis;
|
|
char opt_pointer_analysis_mode;
|
|
char loop_unroll_count;
|
|
char loop_unroll_size_threshold;
|
|
char isGeneratingDebugInfo;
|
|
CWDataType pchCreator;
|
|
CWDataType pchType;
|
|
CWDataType text;
|
|
HashNameNode *forcedSegment; // when set by #pragma segment
|
|
} COpts;
|
|
|
|
typedef 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;
|
|
} CParams;
|
|
|
|
|
|
typedef struct VarInfo { // OK!
|
|
Object *func;
|
|
SInt32 usage;
|
|
TStreamElement deftoken;
|
|
SInt16 varnumber;
|
|
Boolean noregister;
|
|
Boolean used;
|
|
UInt8 flags;
|
|
UInt8 rclass;
|
|
SInt16 reg;
|
|
SInt16 regHi;
|
|
} VarInfo;
|
|
|
|
|
|
|
|
typedef struct DefArgCtorInfo {
|
|
Object *default_func;
|
|
ENode *default_arg;
|
|
} DefArgCtorInfo;
|
|
|
|
typedef struct XRefOffset {
|
|
UInt32 xrefoffset;
|
|
SInt32 offset;
|
|
} XRefOffset;
|
|
|
|
typedef struct InlineXRef {
|
|
struct InlineXRef *next;
|
|
Object *object;
|
|
UInt16 xrefmode;
|
|
UInt16 numxrefs;
|
|
XRefOffset xref[1];
|
|
} InlineXRef;
|
|
|
|
|
|
typedef enum StatementType {
|
|
ST_NOP = 1,
|
|
ST_LABEL,
|
|
ST_GOTO,
|
|
ST_EXPRESSION,
|
|
ST_SWITCH,
|
|
ST_IFGOTO,
|
|
ST_IFNGOTO,
|
|
ST_RETURN,
|
|
ST_OVF,
|
|
ST_EXIT,
|
|
ST_ENTRY,
|
|
ST_BEGINCATCH,
|
|
ST_ENDCATCH,
|
|
ST_ENDCATCHDTOR,
|
|
ST_GOTOEXPR,
|
|
ST_ASM,
|
|
ST_BEGINLOOP,
|
|
ST_ENDLOOP,
|
|
ST_ILLEGAL
|
|
} StatementType;
|
|
|
|
typedef enum ExceptionActionType {
|
|
EAT_NOP,
|
|
EAT_DESTROYLOCAL,
|
|
EAT_DESTROYLOCALCOND,
|
|
EAT_DESTROYLOCALOFFSET,
|
|
EAT_DESTROYLOCALPOINTER,
|
|
EAT_DESTROYLOCALARRAY,
|
|
EAT_DESTROYPARTIALARRAY,
|
|
EAT_DESTROYMEMBER,
|
|
EAT_DESTROYMEMBERCOND,
|
|
EAT_DESTROYMEMBERARRAY,
|
|
EAT_DELETEPOINTER,
|
|
EAT_DELETELOCALPOINTER,
|
|
EAT_DELETEPOINTERCOND,
|
|
EAT_CATCHBLOCK,
|
|
EAT_ACTIVECATCHBLOCK,
|
|
EAT_SPECIFICATION,
|
|
EAT_TERMINATE,
|
|
EAT_DESTROYBASE,
|
|
EAT_NACTIONS
|
|
} ExceptionActionType;
|
|
|
|
typedef struct ExceptionAction {
|
|
struct ExceptionAction *prev;
|
|
union {
|
|
struct {
|
|
Object *local;
|
|
Object *dtor;
|
|
} destroy_local;
|
|
struct {
|
|
Object *local;
|
|
Object *cond;
|
|
Object *dtor;
|
|
} destroy_local_cond;
|
|
struct {
|
|
Object *local;
|
|
Object *dtor;
|
|
SInt32 offset;
|
|
} destroy_local_offset;
|
|
struct {
|
|
Object *pointer;
|
|
Object *dtor;
|
|
} destroy_local_pointer;
|
|
struct {
|
|
Object *localarray;
|
|
Object *dtor;
|
|
SInt32 elements;
|
|
SInt32 element_size;
|
|
} destroy_local_array;
|
|
struct {
|
|
Object *arraypointer;
|
|
Object *arraycounter;
|
|
Object *dtor;
|
|
Object *element_size;
|
|
} destroy_partial_array;
|
|
struct {
|
|
Object *objectptr;
|
|
Object *dtor;
|
|
SInt32 offset;
|
|
} destroy_member;
|
|
struct {
|
|
Object *objectptr;
|
|
Object *cond;
|
|
Object *dtor;
|
|
SInt32 offset;
|
|
} destroy_member_cond;
|
|
struct {
|
|
Object *objectptr;
|
|
Object *dtor;
|
|
SInt32 offset;
|
|
SInt32 elements;
|
|
SInt32 element_size;
|
|
} destroy_member_array;
|
|
struct {
|
|
Object *pointerobject;
|
|
Object *deletefunc;
|
|
} delete_pointer;
|
|
struct {
|
|
Object *pointerobject;
|
|
Object *deletefunc;
|
|
Object *cond;
|
|
} delete_pointer_cond;
|
|
struct {
|
|
Object *catch_object;
|
|
Object *catch_info_object;
|
|
CLabel *catch_label;
|
|
Object *catch_typeid;
|
|
Type *catch_type;
|
|
UInt32 catch_qual;
|
|
} catch_block;
|
|
struct {
|
|
Object *catch_info_object;
|
|
Boolean call_dtor;
|
|
} active_catch_block;
|
|
struct {
|
|
SInt32 unexp_ids;
|
|
Object **unexp_id;
|
|
CLabel *unexp_label;
|
|
Object *unexp_info_object;
|
|
} specification;
|
|
struct {
|
|
Object *object;
|
|
Boolean is_dep;
|
|
} local;
|
|
} data;
|
|
ExceptionActionType type;
|
|
} ExceptionAction;
|
|
|
|
typedef struct Statement {
|
|
struct Statement *next;
|
|
StatementType type;
|
|
char marked;
|
|
UInt8 flags;
|
|
UInt16 value;
|
|
ENode *expr;
|
|
CLabel *label;
|
|
ExceptionAction *dobjstack;
|
|
SInt32 sourceoffset;
|
|
HashNameNode *sourcefilepath;
|
|
} Statement;
|
|
|
|
typedef struct CLabel {
|
|
struct CLabel *next;
|
|
Statement *stmt;
|
|
HashNameNode *uniquename;
|
|
HashNameNode *name;
|
|
PCodeLabel *pclabel;
|
|
void *sicg_label;
|
|
} CLabel;
|
|
|
|
typedef struct MemInitializer {
|
|
struct MemInitializer *next;
|
|
union {
|
|
ENodeList *nodes;
|
|
ENode *expr;
|
|
} e;
|
|
union {
|
|
ObjMemberVar *ivar;
|
|
Type *type;
|
|
} u;
|
|
Boolean is_ivar;
|
|
Boolean is_expr;
|
|
} MemInitializer;
|
|
|
|
|
|
typedef enum DepNameType {
|
|
DNT_NAME,
|
|
DNT_CONVERSION,
|
|
DNT_DTOR,
|
|
DNT_NAMESPACE,
|
|
DNT_QUALNAME,
|
|
DNT_TEMPLATE,
|
|
DNT_TYPENAME
|
|
} DepNameType;
|
|
|
|
typedef struct DepName {
|
|
struct DepName *next;
|
|
union {
|
|
HashNameNode *name;
|
|
NameSpace *nspace;
|
|
struct {
|
|
Type *type;
|
|
UInt32 qual;
|
|
} conv;
|
|
struct {
|
|
HashNameNode *name;
|
|
TemplArg *args;
|
|
} templ;
|
|
struct {
|
|
HashNameNode *name;
|
|
Type *type;
|
|
} tname;
|
|
} u;
|
|
DepNameType type;
|
|
} DepName;
|
|
|
|
|
|
|
|
|
|
|
|
typedef enum SubKind {
|
|
SUBKIND_NAMESPACE,
|
|
SUBKIND_TYPE,
|
|
SUBKIND_OBJECT
|
|
} SubKind;
|
|
|
|
typedef struct Substitution {
|
|
struct Substitution *next;
|
|
union {
|
|
NameSpace *nspace;
|
|
struct {
|
|
Type *type;
|
|
UInt32 qual;
|
|
} type;
|
|
Object *obj;
|
|
} u;
|
|
int id;
|
|
SubKind kind;
|
|
} Substitution;
|
|
|
|
|
|
// CScope.c
|
|
extern Boolean cscope_is_member_func;
|
|
extern Object *cscope_currentfunc;
|
|
extern TypeClass *cscope_currentclass;
|
|
extern NameSpace *cscope_current;
|
|
extern NameSpace *cscope_root;
|
|
|
|
typedef struct CScopeSave {
|
|
NameSpace *current;
|
|
TypeClass *currentclass;
|
|
Object *currentfunc;
|
|
Boolean is_member_func;
|
|
} CScopeSave; // assumed name
|
|
|
|
typedef struct CScopeParseResult {
|
|
NameSpace *nspace_0;
|
|
HashNameNode *name_4;
|
|
Type *x8;
|
|
void *xC;
|
|
ObjBase *obj_10;
|
|
NameSpaceObjectList *nsol_14;
|
|
BClassList *bcl_18;
|
|
Boolean x1C;
|
|
Boolean x1D;
|
|
Boolean isambig;
|
|
Boolean x1F;
|
|
Boolean x20;
|
|
Boolean x21;
|
|
} CScopeParseResult;
|
|
|
|
typedef struct CScopeNSIterator {
|
|
NameSpace *nspace;
|
|
NameSpaceLookupList *lookup;
|
|
CScopeParseResult *result;
|
|
} CScopeNSIterator;
|
|
|
|
typedef struct CScopeObjectIterator {
|
|
NameSpace *nspace;
|
|
NameSpaceName *nextname;
|
|
NameSpaceObjectList *currlist;
|
|
int hashindex;
|
|
} CScopeObjectIterator;
|
|
|
|
extern void CScope_Setup();
|
|
extern void CScope_Cleanup();
|
|
extern void CScope_GetScope(CScopeSave *save);
|
|
extern void CScope_SetNameSpaceScope(NameSpace *nspace, CScopeSave *save);
|
|
extern void CScope_SetClassScope(TypeClass *cls, CScopeSave *save);
|
|
extern void CScope_SetClassDefScope(TypeClass *cls, CScopeSave *save);
|
|
extern void CScope_SetFunctionScope(Object *function, CScopeSave *save);
|
|
extern void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag, CScopeSave *save);
|
|
extern void CScope_RestoreScope(CScopeSave *saved);
|
|
extern Boolean CScope_IsEmptySymTable();
|
|
extern Boolean CScope_IsInLocalNameSpace(NameSpace *nspace);
|
|
extern NameSpaceObjectList *CScope_FindName(NameSpace *nspace, HashNameNode *name);
|
|
extern NameSpaceName *CScope_FindNameSpaceName(NameSpace *nspace, HashNameNode *name);
|
|
extern NameSpaceObjectList *CScope_InsertName(NameSpace *nspace, HashNameNode *name);
|
|
extern NameSpaceObjectList *CScope_ArgumentDependentNameLookup(NameSpaceObjectList *list, HashNameNode *name, ENodeList *argNodes, Boolean flag);
|
|
extern NameSpace *CScope_NewHashNameSpace(HashNameNode *name);
|
|
extern NameSpace *CScope_NewListNameSpace(HashNameNode *name, Boolean is_global);
|
|
extern NameSpace *CScope_FindNonClassNonFunctionNS(NameSpace *nspace);
|
|
extern NameSpace *CScope_FindGlobalNS(NameSpace *nspoce);
|
|
extern Boolean CScope_IsStdNameSpace(NameSpace *nspace);
|
|
extern Boolean CScope_IsEmptyNameSpace(NameSpace *nspace);
|
|
extern void CScope_MergeNameSpace(NameSpace *dst, NameSpace *src);
|
|
extern void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj);
|
|
extern void CScope_AddGlobalObject(Object *obj);
|
|
extern NameSpaceLookupList *CScope_BuildNameSpaceLookupList(NameSpace *nspace);
|
|
extern Boolean CScope_FindQualifiedClassMember(CScopeParseResult *result, TypeClass *tclass, HashNameNode *name);
|
|
extern Type *CScope_GetType(NameSpace *nspace, HashNameNode *name, void **unk6);
|
|
extern Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name);
|
|
extern Boolean CScope_ParseExprName(CScopeParseResult *result);
|
|
extern Boolean CScope_ParseDeclName(CScopeParseResult *result);
|
|
extern Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, Boolean flag2);
|
|
extern Boolean CScope_ParseElaborateName(CScopeParseResult *result);
|
|
extern Boolean CScope_FindObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name);
|
|
extern Boolean CScope_FindNonClassObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name);
|
|
extern NameSpaceObjectList *CScope_FindObjectList(CScopeParseResult *result, HashNameNode *name);
|
|
extern Boolean CScope_PossibleTypeName(HashNameNode *name);
|
|
extern Boolean CScope_FindClassMemberObject(TypeClass *tclass, CScopeParseResult *result, HashNameNode *name);
|
|
extern void CScope_InitObjectIterator(CScopeObjectIterator *iterator, NameSpace *nspace);
|
|
extern ObjBase *CScope_NextObjectIteratorObject(CScopeObjectIterator *iterator);
|
|
extern NameSpaceObjectList *CScope_NextObjectIteratorObjectList(CScopeObjectIterator *iterator);
|
|
extern void CScope_DefineTypeTag(NameSpace *nspace, HashNameNode *name, Type *type);
|
|
extern Type *CScope_GetLocalTagType(NameSpace *nspace, HashNameNode *name);
|
|
extern Boolean CScope_FindTypeName(NameSpace *nspace, HashNameNode *name, CScopeParseResult *result);
|
|
extern NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNode *name);
|
|
extern BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass);
|
|
extern Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boolean flag);
|
|
extern void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, HashNameNode *name, AccessType access);
|
|
extern void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access);
|
|
extern void CScope_ParseNameSpaceAlias(HashNameNode *name);
|
|
extern void CScope_ParseUsingDirective(NameSpace *nspace);
|
|
|
|
// CMachine.c
|
|
extern TypeIntegral stbool;
|
|
extern TypeIntegral stchar;
|
|
extern TypeIntegral stsignedchar;
|
|
extern TypeIntegral stunsignedchar;
|
|
extern TypeIntegral stwchar;
|
|
extern TypeIntegral stsignedshort;
|
|
extern TypeIntegral stunsignedshort;
|
|
extern TypeIntegral stsignedint;
|
|
extern TypeIntegral stunsignedint;
|
|
extern TypeIntegral stsignedlong;
|
|
extern TypeIntegral stunsignedlong;
|
|
extern TypeIntegral stsignedlonglong;
|
|
extern TypeIntegral stunsignedlonglong;
|
|
extern TypeIntegral stfloat;
|
|
extern TypeIntegral stshortdouble;
|
|
extern TypeIntegral stdouble;
|
|
extern TypeIntegral stlongdouble;
|
|
|
|
extern TypeStruct stvectorunsignedchar;
|
|
extern TypeStruct stvectorsignedchar;
|
|
extern TypeStruct stvectorboolchar;
|
|
extern TypeStruct stvectorunsignedshort;
|
|
extern TypeStruct stvectorsignedshort;
|
|
extern TypeStruct stvectorboolshort;
|
|
extern TypeStruct stvectorunsignedlong;
|
|
extern TypeStruct stvectorsignedlong;
|
|
extern TypeStruct stvectorboollong;
|
|
extern TypeStruct stvectorfloat;
|
|
extern TypeStruct stvectorpixel;
|
|
extern TypeStruct stvector;
|
|
|
|
extern void CMach_Configure();
|
|
extern SInt32 CMach_GetQUALalign(UInt32 qual);
|
|
extern SInt32 CMach_ArgumentAlignment(Type *type);
|
|
extern SInt32 CMach_AllocationAlignment(Type *type, UInt32 qual);
|
|
extern CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right);
|
|
extern CInt64 CMach_CalcIntMonadic(Type *type, short op, CInt64 val);
|
|
extern CInt64 CMach_CalcIntConvertFromFloat(Type *type, Float fval);
|
|
extern void CMach_InitIntMem(Type *type, CInt64 val, void *mem);
|
|
extern void CMach_InitVectorMem(Type *type, MWVector128 val, void *mem);
|
|
extern Float CMach_CalcFloatDiadic(Type *type, Float left, short op, Float right);
|
|
extern Float CMach_CalcFloatMonadic(Type *type, short op, Float fval);
|
|
extern Boolean CMach_CalcFloatDiadicBool(Type *type, Float left, short op, Float right);
|
|
extern Boolean CMach_CalcVectorDiadicBool(Type *type, MWVector128 *left, short op, MWVector128 *right);
|
|
extern char *CMach_FloatScan(char *input, Float *result, Boolean *fail);
|
|
extern Float CMach_CalcFloatConvertFromInt(Type *type, CInt64 val);
|
|
extern Float CMach_CalcFloatConvert(Type *type, Float fval);
|
|
extern Boolean CMach_FloatIsZero(Float fval);
|
|
extern Boolean CMach_FloatIsOne(Float fval);
|
|
extern Boolean CMach_FloatIsNegOne(Float fval);
|
|
extern void CMach_InitFloatMem(Type *type, Float val, void *mem);
|
|
extern void CMach_PrintFloat(char *buf, Float val);
|
|
extern void CMach_PragmaParams();
|
|
extern void CMach_AdjustFuntionArgs();
|
|
extern SInt16 CMach_GetStructAlign(TypeStruct *tstruct);
|
|
extern SInt16 CMach_GetClassAlign(TypeClass *tclass);
|
|
extern SInt16 CMach_GetTypeAlign(Type *type);
|
|
extern SInt16 CMach_MemberAlignValue(Type *type, SInt32 var);
|
|
extern void CMach_StructLayoutInitOffset(SInt32 offset);
|
|
extern SInt32 CMach_StructLayoutGetCurSize();
|
|
extern SInt32 CMach_StructLayoutGetOffset(Type *type, UInt32 qual);
|
|
extern SInt32 CMach_StructLayoutBitfield(TypeBitfield *tbitfield, UInt32 qual);
|
|
extern UInt8 CMach_GetFunctionResultClass(TypeFunc *tfunc);
|
|
extern Boolean CMach_PassResultInHiddenArg(Type *type);
|
|
extern const char *CMach_GetCPU();
|
|
extern Boolean CMach_FloatIsPowerOf2(Float flt);
|
|
extern Float CMach_FloatReciprocal(Float flt);
|
|
extern SInt32 CMach_RoundedSizeOf(Object *object);
|
|
extern void CMach_ReInitRuntimeObjects();
|
|
|
|
// CPrep.c
|
|
typedef struct Macro {
|
|
struct Macro *next;
|
|
HashNameNode *name;
|
|
void *c;
|
|
Boolean xC;
|
|
Boolean xD;
|
|
Boolean is_special;
|
|
Boolean xF;
|
|
void *e;
|
|
} Macro;
|
|
typedef struct TokenStack {
|
|
char *pos;
|
|
char *macrostart;
|
|
Macro *macro;
|
|
Boolean macrocheck;
|
|
} TokenStack;
|
|
|
|
extern CParams *cparamblkptr;
|
|
extern short tk;
|
|
extern CInt64 tkintconst;
|
|
extern Float tkfloatconst;
|
|
extern char *tkstring;
|
|
extern HashNameNode *tkidentifier;
|
|
extern SInt32 tksize;
|
|
extern short ispascalstring;
|
|
extern short nlflag;
|
|
extern SInt32 lines;
|
|
extern Boolean spaceskip;
|
|
extern struct Macro **macrohashtable;
|
|
extern Boolean cprep_nomem_exit;
|
|
extern Boolean cprep_nostring;
|
|
extern Boolean cprep_eoltokens;
|
|
extern TokenStack tokenstack[128];
|
|
extern short tokenstacklevel;
|
|
extern SInt32 cprep_cursymfile; // might be a ptr?
|
|
extern char *pos;
|
|
extern char *macropos;
|
|
extern char *nextcharpos;
|
|
extern char CPrep_SkipNewCommentChar;
|
|
extern Boolean preprocessing_only;
|
|
extern Handle stringmem;
|
|
extern SInt32 maxstringsize;
|
|
extern char cprep_idarray[256];
|
|
extern Boolean was_escchar;
|
|
extern Boolean macrocheck;
|
|
extern Boolean widestring;
|
|
extern Boolean at_linestart;
|
|
extern char *prep_file_start;
|
|
extern char *prep_file_end;
|
|
extern char *macrostart;
|
|
extern Boolean cprep_strconcat;
|
|
extern CPrepFileInfo *prep_file;
|
|
extern short filesp;
|
|
extern SInt32 linenumber;
|
|
extern GList pplist;
|
|
extern TStreamElement *ts_current;
|
|
extern SInt32 ts_preread_elements;
|
|
|
|
extern void CPrep_InsertSpecialMacro(Macro *macro, char *name);
|
|
extern void CPrep_InsertSpecialMacros();
|
|
extern void CPrep_RemoveSpecialMacros();
|
|
extern Boolean setupprep();
|
|
extern void cleanupprep();
|
|
extern void CPrep_TSBufferGrow(int amount);
|
|
extern void CPrep_TokenStreamGetState(SInt32 *state);
|
|
extern void CPrep_TokenStreamSetState(SInt32 *state);
|
|
extern void CPrep_UnLex();
|
|
extern void CPrep_TokenStreamSetCurState(SInt32 *state);
|
|
extern void CPrep_StreamGetBlock();
|
|
extern void CPrep_StreamGetSemicolon();
|
|
extern void CPrep_StreamGetTemplate();
|
|
extern void CPrep_StreamInsert();
|
|
extern void CPrep_StreamRemove();
|
|
extern void CPrep_RemoveTokens();
|
|
extern void CPrep_TokenStreamFlush();
|
|
extern void CPrep_CurStreamElement();
|
|
extern void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SInt32 *selectionoffset, short *tokensize, SInt32 *linenumber, char *buf1, short *tokenoffset, short *tokenlength, char *buf2, short *lastarg);
|
|
extern void CPrep_Error(short code);
|
|
extern void CPrep_ErrorName(short code, const char *name);
|
|
extern void CPrep_Warning(short code);
|
|
extern void CPrep_WarningName(short code, const char *name);
|
|
extern void CPrep_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2);
|
|
extern void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2);
|
|
extern void popfile();
|
|
extern void CPrep_SetSourceFile();
|
|
extern void CPrep_GetSourceFilePath();
|
|
extern void CPrep_NewFileOffsetInfo();
|
|
extern void CPrep_GetFileOffsetInfo();
|
|
extern void CPrep_GetFileOffsetInfo2();
|
|
extern void CPrep_ResetFileInfo();
|
|
extern void CPrep_GetPrepPos();
|
|
extern Boolean C_Compiler(CParams *param);
|
|
extern void poptokenseq();
|
|
extern void foundnl();
|
|
extern void newline();
|
|
extern short notendofline();
|
|
extern char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2);
|
|
extern void macrotest();
|
|
extern void CPrep_PragmaLex();
|
|
extern void CPrep_PushOption();
|
|
extern void CPrep_PopOption();
|
|
extern void preprocessor();
|
|
extern void CPrep_BrowserTokenOffset();
|
|
extern void CPrep_BrowserFileOffset();
|
|
extern void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset);
|
|
extern CPrepFileInfo *CPrep_BrowserCurrentFile();
|
|
|
|
// CPrepTokenizer.c
|
|
extern short prepskipnextchar();
|
|
extern short prepnextchar();
|
|
extern short prepnextstringchar(char *str, Boolean flag);
|
|
extern void CPrep_MatchChar(char ch, Boolean flag);
|
|
extern char *CPrep_MatchChar2(char *str, char ch, Boolean flag);
|
|
extern short prepcurchar();
|
|
extern char *ReadIdentifier(char *str);
|
|
extern char *CPrep_SkipNewComment(char *str);
|
|
extern Boolean skipendoflinematch(char *str, Boolean flag);
|
|
extern void skipendofline();
|
|
extern void CPrep_SkipAsmComment();
|
|
extern short lookahead();
|
|
extern short lookahead_noeol();
|
|
extern short lex();
|
|
extern short plex();
|
|
extern short lexidentifier();
|
|
|
|
// LOOSE DECLS
|
|
extern Boolean C_Compiler(CParams *param);
|
|
extern void PrecompilerRead(short refnum, void *buffer);
|
|
extern void CodeGen_InitCompiler();
|
|
extern void CodeGen_TermCompiler();
|
|
extern void CodeGen_InitBackEndOptions();
|
|
extern void CodeGen_UpdateOptimizerOptions();
|
|
extern void CodeGen_UpdateBackEndOptions();
|
|
extern void MWUnmangle(const char *name, char *buf, int size);
|
|
extern COpts copts;
|
|
extern CParams *cparamblkptr;
|
|
extern FuncArg elipsis;
|
|
extern FuncArg oldstyle;
|
|
extern HashNameNode *constructor_name_node;
|
|
extern HashNameNode *destructor_name_node;
|
|
extern char *CMangler_GetOperator(HashNameNode *str);
|
|
extern jmp_buf errorreturn;
|
|
extern Boolean cprep_nomem_exit;
|
|
extern Boolean anyerrors;
|
|
extern Boolean fatalerrors;
|
|
extern SInt32 lines;
|
|
extern char string[256];
|
|
extern TemplStack *ctempl_curinstance;
|
|
typedef struct ParserTryBlock {
|
|
struct ParserTryBlock *next;
|
|
jmp_buf jmpbuf;
|
|
NameSpace *cscope_current;
|
|
TypeClass *cscope_currentclass;
|
|
Object *cscope_currentfunc;
|
|
TemplStack *ctempl_curinstance;
|
|
TStreamElement *cerror_locktoken;
|
|
Boolean cscope_is_member_func;
|
|
} ParserTryBlock;
|
|
extern ParserTryBlock *trychain;
|
|
extern Boolean in_assembler;
|
|
extern Boolean preprocessing_only;
|
|
extern void AssemblerError();
|
|
#include "compiler/types.h"
|
|
extern short tk;
|
|
extern HashNameNode *tkidentifier;
|
|
extern short lex();
|
|
extern short notendofline();
|
|
extern short lookahead();
|
|
extern Object *CClass_Constructor(TypeClass *tclass);
|
|
extern Object *CClass_Destructor(TypeClass *tclass);
|
|
extern int CClass_CheckPures(TypeClass *tclass);
|
|
extern Boolean CParser_IsPublicRuntimeObject(Object *obj);
|
|
extern Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2);
|
|
extern Boolean CTemplTool_EqualArgs(TemplArg *a, TemplArg *b);
|
|
extern TypeTemplDep *CDecl_NewTemplDepType(TypeTemplDepType tdtype);
|
|
extern GList name_mangle_list;
|
|
extern void CPrep_UnLex();
|
|
extern Type *CTempl_ClassGetType(TypeClass *tclass);
|
|
extern short is_typesame(Type *t1, Type *t2);
|
|
extern Boolean is_unsigned(Type *type);
|
|
extern void CDecl_CompleteType(Type *type);
|
|
extern TemplArg *CTempl_ParseUncheckTemplArgs(void *fixmelater, Boolean flag);
|
|
extern SInt32 CClass_VirtualBaseOffset(TypeClass *tclass, TypeClass *base);
|
|
extern Boolean CClass_IsMoreAccessiblePath(BClassList *a, BClassList *b);
|
|
extern Boolean CClass_ClassDominates(TypeClass *a, TypeClass *b);
|
|
extern Boolean CParser_CheckTemplateClassUsage(TemplClass *tmclass, Boolean flag);
|
|
extern Type *CTempl_ParseTemplTemplParam(Type *t);
|
|
extern void CClass_CheckPathAccess(BClassList *bcl, void *unk, AccessType access);
|
|
extern BClassList *CClass_GetPathCopy(BClassList *path, Boolean flag);
|
|
extern AccessType global_access;
|
|
extern UInt32 CParser_GetTypeQualifiers(Type *type, UInt32 qual);
|
|
extern void CTemplClass_RegisterUsingDecl(TemplClass *tclass, Type *target, AccessType access);
|
|
extern void CodeGen_InsertSpecialMacros();
|
|
extern char *CodeGen_ExpandSpecialMacro(Macro *macro);
|
|
extern void CPrep_PreprocessDumpFileInfo(Boolean flag);
|
|
extern Boolean gForceSourceLoc;
|
|
extern void ObjGen_SegmentName(); // might take an arg, not sure since it's empty
|
|
|
|
enum {
|
|
CPU_PPC401,
|
|
CPU_PPC403,
|
|
CPU_PPC505,
|
|
CPU_PPC509,
|
|
CPU_PPC555,
|
|
CPU_PPC601,
|
|
CPU_PPC602,
|
|
CPU_PPC603,
|
|
CPU_PPC603e,
|
|
CPU_PPC604,
|
|
CPU_PPC604e,
|
|
CPU_PPC740,
|
|
CPU_PPC750,
|
|
CPU_PPC801,
|
|
CPU_PPC821,
|
|
CPU_PPC823,
|
|
CPU_PPC850,
|
|
CPU_PPC860,
|
|
CPU_PPC8240,
|
|
CPU_PPC8260,
|
|
CPU_PPC7400 = 0x15,
|
|
CPU_PPCGEKKO,
|
|
CPU_PPCELF,
|
|
CPU_PPC7450,
|
|
CPU_PPC556,
|
|
CPU_PPC565
|
|
};
|
|
|
|
extern char *ScanFloat(char *input, double *output, Boolean *fail);
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=reset
|
|
#endif
|