diff options
Diffstat (limited to '')
-rw-r--r-- | CError.h | 63 | ||||
-rw-r--r-- | Help.c | 4 | ||||
-rw-r--r-- | Option.c | 655 | ||||
-rw-r--r-- | mwcc_decomp.h | 153 |
4 files changed, 735 insertions, 140 deletions
diff --git a/CError.h b/CError.h new file mode 100644 index 0000000..6137d23 --- /dev/null +++ b/CError.h @@ -0,0 +1,63 @@ +#include "CompilerTools.h" +#pragma once + +#define CError_ASSERT(cond) if (!(cond)) { CError_Internal(__FILE__, __LINE__); } +#define CError_FAIL(cond) if (cond) { CError_Internal(__FILE__, __LINE__); } + +typedef struct _CErrorBuffer { + char *start; + char *end; + unsigned long size; + unsigned long remaining; +} CErrorBuffer; + +extern void CError_Init(); +extern void CError_SetErrorToken(Token *token); +extern void CError_SetNullErrorToken(); +extern void CError_LockErrorPos(Token *token, Token **saved); +extern void CError_UnlockErrorPos(Token **saved); +extern void CError_ResetErrorSkip(); +extern void CError_GetErrorString(char *buf, short code); +extern void CError_BufferInit(CErrorBuffer *eb, char *buf, long bufSize); +extern void CError_BufferGrow(CErrorBuffer *eb, long amount); +extern void CError_BufferAppendChar(CErrorBuffer *eb, char ch); +extern void CError_BufferAppendString(CErrorBuffer *eb, const char *str); +extern void CError_BufferTerminate(CErrorBuffer *eb); +// FIX LOTS OF THESE +extern void CError_BufferAppendQualifier(CErrorBuffer *eb, int quals); +extern void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, void *targExpr); +extern void CError_BufferAppendTemplArg(CErrorBuffer *eb, void *targ); +extern void CError_BufferAppendTemplArgs(CErrorBuffer *eb, void *targs); +extern void CError_BufferAppendNameSpace(CErrorBuffer *eb, void *ns); +extern void CError_BufferAppendPType(CErrorBuffer *eb, void *ty); +extern void CError_BufferAppendTemplDepType(CErrorBuffer *eb, void *ty); +extern void CError_BufferAppendFuncArgs(CErrorBuffer *eb, void *args, unsigned char flag); +extern void CError_BufferAppendType(CErrorBuffer *eb, void *ty, int quals); +extern char *CError_GetTypeName(void *ty, int quals, unsigned char useGlobalHeap); +extern void CError_AppendUnqualFunctionName(CErrorBuffer *eb, void *unk1, void *unk2, void *unk3); +extern void CError_AppendFunctionName(CErrorBuffer *eb, void *unk1, void *unk2, void *unk3, void *unk4); +extern void CError_AppendObjectName(CErrorBuffer *eb, void *obj); +extern void CError_AppendMethodName(CErrorBuffer *eb, void *obj); +extern char *CError_GetQualifiedName(void *ns, StringNode *name); +extern char *CError_GetFunctionName(void *a, void *b, void *c); +extern char *CError_GetObjectName(void *obj); +extern char *CError_GetNameString(void *obj, StringNode *operatorName); +extern void CError_ErrorMessage(int errTable, char *buf, unsigned char flag1, unsigned char flag2); +extern void CError_BufferAppendTemplateStack(CErrorBuffer *eb); +extern void CError_ErrorMessageVA(short code, char *buf, va_list list, unsigned char flag1, unsigned char flag2); +extern void CError_VAErrorMessage(short code, va_list list, unsigned char flag1, unsigned char flag2); +extern void CError_Error(short code, ...); +extern void CError_ErrorTerm(short code); +extern void CError_ErrorSkip(short code, ...); +extern void CError_ErrorFuncCall(short code, void *aa, void *bb); +extern void CError_OverloadedFunctionError2(void *aa, void *bb, void *cc); +extern void CError_OverloadedFunctionError(void *aa, void *bb); +extern void CError_AbstractClassError(); +extern void CError_Warning(short code, ...); +extern void CError_BreakPoint(const char *a, const char *b); +extern void CError_Internal(); +extern void CError_ExpressionTooComplex(); +extern void CError_NoMem(); +extern void CError_UserBreak(); +extern void CError_CannotOpen(); +extern void CError_QualifierCheck(int quals); @@ -408,10 +408,6 @@ int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const return 1; } -inline int IsCompiler() { - return (Option_ThisTool() == (unsigned int) OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : LISTFLAGS_LINKER; -} - void Help_Options(struct OptionList *lst, int subprint, const char *keyword) { Option **opts; int toolflags; @@ -15,6 +15,8 @@ static OptionList internalset; int numoptionlists; static OptionList *optionlists[32]; +extern char curparam[1024]; // check me + enum { ARGFLAG_1 = 1, ARGFLAG_2 = 2, @@ -288,16 +290,12 @@ static void Options_Reset(OptionList *optlst) { } static void Option_SpellList(char *buffer, OptionList *conflicts, int flags) { - // r25: buffer - // r0: conflicts - // r26: flags - - Option **scan; // r30 - Boolean first; // r29 - int total; // r28 - char tmp[256]; // stack 0x58 - Option **next; // r27 - int slflags; // r6 + Option **scan; + Boolean first; + int total; + char tmp[256]; + Option **next; + int slflags; scan = conflicts->list; first = 1; @@ -305,7 +303,6 @@ static void Option_SpellList(char *buffer, OptionList *conflicts, int flags) { while (*scan) { next = scan + 1; if (!((*scan)->avail & (((parseopts.helpFlags & HELPFLAGS_SECRET) ? 0 : OTF_SECRET) | ((parseopts.helpFlags & HELPFLAGS_DEPRECATED) ? 0 : OTF_DEPRECATED) | OTF_SUBSTITUTED)) && (*scan)->names[0]) { - // 17C1BC if (!first) buffer += sprintf(buffer, ", "); if (first) @@ -365,8 +362,7 @@ int Option_AlsoPassedFromThisTool(Option *opt) { } static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok) { - // tok: r30 - ArgToken *tmp; // r0 + ArgToken *tmp; int ret; // not in stabs but i think this exists if (level == 1) { @@ -385,74 +381,607 @@ static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok) { static short endingStack[5][3]; static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok) { - // level, tok: r0 - ArgToken *tmp; // r0 + ArgToken *tmp; if (!tok) - return 0; - // todo + return 1; + if (tok->val == endingStack[level][0]) + return 1; + + if (endingStack[level][1] && tok->val == endingStack[level][1]) { + tmp = Arg_UsedToken(); + if (tmp && tmp->val == endingStack[level][2]) { + Arg_UndoToken(); + return 1; + } + Arg_UndoToken(); + } + + return 0; } static Boolean Option_IsEndingLevel(int level, ArgToken *tok) { - // level: r30 - // tok: r31 + if (!tok) + return 1; + + while (level > 0) { + if (Option_IsEndingThisLevel(level - 1, tok)) + return 1; + level--; + } + + return 0; } +enum { + OFLAGS_1 = 1, + OFLAGS_2 = 2, + OFLAGS_4 = 4, + OFLAGS_8 = 8, + OFLAGS_10 = 0x10, + OFLAGS_20 = 0x20, + OFLAGS_40 = 0x40, + OFLAGS_80 = 0x80 +}; +enum { + PFLAGS_1 = 1, + PFLAGS_2 = 2, + PFLAGS_4 = 4, + PFLAGS_8 = 8, + PFLAGS_10 = 0x10, + PFLAGS_20 = 0x20, + PFLAGS_40 = 0x40, + PFLAGS_80 = 0x80 +}; + int Option_Parse(Option *opt, int oflags) { - // opt: r24 - // oflags: r25 - int ret; // r29 - int pushed; // r28 - int samelevel; // r30 - int subparse; // r27 - int flags; // r26 - char errstr[1024]; // stack 0x3C - Option **cscan; // r30 - Option **scan; // r5 - int goingtosubparse; // r30 - ArgToken *tok; // r0 + int ret; + int pushed; + int samelevel; + int subparse; + int flags; + char errstr[1024]; + Option **cscan; + Option **scan; + int goingtosubparse; + ArgToken *tok; + + ret = 1; + pushed = 0; + samelevel = (opt->avail & OTF_GLOBAL) == (oflags & OFLAGS_1); + subparse = (oflags & OFLAGS_2) != 0; + flags = 0; + if (subparse) flags |= PFLAGS_4; + if (oflags & OFLAGS_8) flags |= PFLAGS_8; + if (oflags & OFLAGS_40) flags |= PFLAGS_1; + + if (curopt[0]) { + pushed = 1; + Option_PushOpt(opt, curopt); + } + + if (samelevel) { + if (!(flags & PFLAGS_1)) { + if ((opt->avail & OTF80000000) && (opt->avail & OTF20000)) { + Option_Warning(30); + } else if (opt->avail & OTF40000) { + cscan = opt->conflicts->list; + while (*cscan && (*cscan == opt || !((*cscan)->avail & OTF80000000))) { + ++cscan; + } + + if (*cscan && *cscan != opt) { + (*cscan)->avail &= ~OTF80000000; + Option_SpellList(errstr, opt->conflicts, oflags); + if (opt->conflicts->help) + Option_Warning(32, (*cscan)->names, errstr, opt->conflicts->help); + else + Option_Warning(31, (*cscan)->names, errstr); + } + } + } + + if (Option_ThisTool() == OTF_TOOL_COMPILER && Option_ForTool(opt, OTF_TOOL_LINKER | OTF_TOOL_DISASSEMBLER)) { + flags |= PFLAGS_2; + if (!Option_ForThisTool(opt)) + flags |= PFLAGS_1; + if (!subparse) + Arg_AddToToolArgs(&linkargs, ATK_1, 0); + Args_AddToToolArgs(&linkargs); + } + + if (!(flags & PFLAGS_1)) { + if (opt->avail & OTF_OBSOLETE) { + if (opt->help) + Option_Error(22, opt->help); + else + Option_Error(21); + flags |= PFLAGS_1; + } + + if (opt->avail & OTF_IGNORED) { + if (!(opt->avail & (OTF_WARNING | OTF_MEANINGLESS))) { + if (opt->help) + Option_Warning(27, opt->help); + else + Option_Warning(26); + } + flags |= PFLAGS_1; + } else if (opt->avail & OTF_SUBSTITUTED) { + Option_Warning(23, curopt, opt->help); + } else if (opt->avail & OTF_DEPRECATED) { + if (opt->help) + Option_Warning(25, opt->help); + else + Option_Warning(24); + } + + if (opt->avail & OTF_WARNING) + Option_Warning(28, opt->help); + if (opt->avail & OTF_MEANINGLESS) + Option_Warning(29); + } + + opt->avail |= OTF80000000; + if (opt->avail & OTF40000) { + scan = opt->conflicts->list; + opt->avail |= OTF40000000; + while (*scan) { + (*scan)->avail |= OTF40000000; + scan++; + } + } + } else { + flags |= PFLAGS_1; + } + + goingtosubparse = opt->avail & OTF8000; + if (opt->param) { + ret = Params_Parse(opt->param, flags | (goingtosubparse ? PFLAGS_20 : 0)); + } else { + tok = Arg_PeekToken(); + if (tok && tok->val == ATK_4) + Arg_UsedToken(); + } + + if (ret && goingtosubparse) { + ret = ret && Options_Parse( + opt->sub, + (oflags & ~OFLAGS_4) + | OFLAGS_2 + | ((flags & PFLAGS_1) ? OFLAGS_40 : 0) + | (subparse ? OFLAGS_10 : 0) + | ((opt->avail & OTF10000) ? OFLAGS_4 : 0) + ); + } + + if (pushed) + Option_PopOpt(curopt); + + if (Option_ThisTool() == OTF_TOOL_COMPILER && !subparse) + Arg_AddToToolArgs(&linkargs, ATK_1, 0); + + return ret; } static int Option_MatchString(char *list, char *str, int flags, int *result) { - // list: r26 - // str: r27 - // flags: r0 - // result: r28 - int str_len; // r0 - char cpy[64]; // stack 0x3C + int str_len; + char cpy[64]; + + if (result) + *result = 0; + + if (!list[0] && !str[0]) + return 1; + + while (*list) { + if (Utils_CompareOptionString(list, str, flags & OTF_CASED, 0)) + return 1; + + switch (flags & OTF_SLFLAGS_MASK) { + case OTF_SLFLAGS_8: + if (my_tolower(str[0]) == 'n' && my_tolower(str[1]) == 'o' && Utils_CompareOptionString(list, str + 2, flags & OTF_CASED, 0)) { + if (result) + *result |= 0x100000; + return 1; + } + break; + case OTF_SLFLAGS_20: + if (my_tolower(str[0]) == 'n' && my_tolower(str[1]) == 'o' && str[2] == '-' && Utils_CompareOptionString(list, str + 3, flags & OTF_CASED, 0)) { + if (result) + *result |= 0x400000; + return 1; + } + break; + case OTF_SLFLAGS_10: + str_len = strlen(str); + if (str[str_len - 1] == '-') { + strcpy(cpy, str); + cpy[str_len - 1] = 0; + if (Utils_CompareOptionString(list, cpy, flags & OTF_CASED, 0)) { + if (result) + *result |= 0x200000; + return 1; + } + } + break; + } + + while (*list && *list != '|') + ++list; + + if (*list) + ++list; + if (*list == '|') + ++list; + } + + return 0; } static Option *Option_Lookup(OptionList *search, int unk, int *flags) { - // search: r0 - // flags: r25 - Option **os; // r29 - Option *stickyopt; // r28 - int stickyflags; // r27 - Boolean matched; // r0 - char *names; // r26 + Option **os; + Option *stickyopt; + int stickyflags; + Boolean matched; + char *names; + + os = search->list; + stickyopt = 0; + stickyflags = *flags; + + if (os) { + while (*os) { + names = (*os)->names; + if (((*os)->avail & OTF2) == OTF2) { + while (*names && *names != '|') + ++names; + if (*names) + ++names; + if (*names == '|') + ++names; + } + + matched = Option_MatchString(names, curopt, (*os)->avail & (OTF_SLFLAGS_MASK | OTF_CASED), flags) && (*names || names == (*os)->names); + if (matched) { + if (!stickyopt || (*os)->names[0] == curopt[0] || strlen(curopt) > 1) + return *os; + } + + if ((*os)->avail & OTF2) { + matched = Utils_CompareOptionString((*os)->names, curopt, (*os)->avail & OTF_CASED, 2); + if (matched) + stickyflags |= OTF2; + } else { + matched = 0; + } + + if (matched) + stickyopt = *os; + + ++os; + } + } + + *flags = stickyflags; + return stickyopt; } static int Options_DoParse(OptionList *search, int flags) { - // search: r26 - // flags: r28 - int haderrors; // r30 - int parsedany; // r23 - int failed; // r24 - int matchflags; // stack 0x3C - int subparse; // r20 - ArgToken *starttok; // r0 - ArgToken *tok; // r25 - ArgToken *opttok; // r27 - Option *opt; // r16 + // search: r26 *n + // flags: r28 *n + int haderrors; // r30 *n + int parsedany; // r23 *n + int failed; // r24 *n + int matchflags; // stack 0x38 + int subparse; // r20 *n + ArgToken *starttok; // r0 (actually r19 i think?) + int mystery_r31; // figure out what var this actually is + ArgToken *tok; // r25 *n + ArgToken *opttok; // r27 *n + ArgToken *token_r18; // r18 MAYBE???? + Option *opt; // r16 *n Boolean isOpt; // r0 - char *lptr; // r17 - char *optname; // r16 - char saveopt[1024]; // stack 0xBC - // Option *opt; // r3 - // char saveopt[64]; // stack 0x7C - // ArgToken *prev; // r0 - // char sticky[64]; // stack 0x3C - // ArgToken *prev; // r16 + char *lptr; // r17 *n + char *optname; // r16 *n + + // 915 + haderrors = 0; + // 917 + failed = 0; + // 918 + matchflags = 0; + // 920 + subparse = (flags & OFLAGS_2) != 0; + // 921 + mystery_r31 = subparse && (flags & OFLAGS_10); + // 925 + opttok = 0; + // 929 + mystery_r31 = (subparse == 0) ? 1 : (mystery_r31 == 0) ? 2 : 3; + + starttok = Arg_PeekToken(); // i think this is starttok + while ((token_r18 = Arg_PeekToken())) { + parsedany = 0; + isOpt = ((mystery_r31 == 1) && (token_r18->val == ATK_3)) || ((mystery_r31 == 2) && (token_r18->val == ATK_2) && (token_r18->text[0] || search->flags & LISTFLAGS_4)) || ((mystery_r31 == 3) && (token_r18->val == ATK_4)); + // 950 17CFD4 + if ((mystery_r31 == 3) && isOpt) { + token_r18 = Arg_UsedToken(); + isOpt = token_r18 && (token_r18->val == ATK_2); + flags &= ~OFLAGS_4; + } + // 957 17D00C + if (isOpt) { + // 959 + opt = 0; + // 960 + Arg_GetTokenText(token_r18, curopt, sizeof(curopt), 0); + // 963 + if (curopt[0]) { + opt = Option_Lookup(search, 0x700000, &matchflags); + if (opt) { + opttok = token_r18; + if (!(matchflags & 2)) { + // 972 + if (token_r18->val == ATK_3) + Arg_UsedToken(); + token_r18 = Arg_UsedToken(); + } else { + lptr = opt->names; + optname = token_r18->text; + while (*lptr && *lptr != '|') + ++lptr; + token_r18 = Arg_UsedToken(); + + if (!subparse) + strcpy(token_r18->text, optname + (lptr - opt->names)); + + curopt[(lptr - opt->names)] = 0; + + if (!token_r18->text || !token_r18->text[0]) { + Option_PushOpt(0, curopt); + Option_ParamError(34, curopt); + Option_PopOpt(0); + return 0; + } + } + } + } + + // 1006 + if (!opt) { + // 1009 + if (search->flags & LISTFLAGS_4) { + char saveopt[1024]; // stack 0xBC + strcpy(saveopt, curopt); + curopt[0] = 0; + opt = Option_Lookup(search, 0, &matchflags); + strcpy(curopt, token_r18->text); + + // 1019 + if (opt) { + if (opt->names[0]) + token_r18 = Arg_UsedToken(); + if (token_r18->val == ATK_4) + Arg_UsedToken(); + haderrors = Option_Parse(opt, flags) == 0; + parsedany = 1; + if (haderrors) + failed = 1; + opt = 0; + } else { + CLPFatalError("Missing default for variable list"); + return 0; + } + // 1041 + strcpy(curopt, saveopt); + } else if (!opt) { + // 1059 + curopt[0] = 0; + // 1061 + if (mystery_r31 > 1) { + if ((flags & OFLAGS_4) && token_r18 == starttok) + return haderrors == 0; + // 1072 + if (search->flags & LISTFLAGS_2) { + if (!(flags & OFLAGS_1)) { + Option_SpellList(curparam, search, flags); + Option_Warning(20, token_r18->text, curparam); + } + Arg_UsedToken(); + parsedany = 1; + } else { + // 1090 + Option_SpellList(curparam, search, flags); + Option_Error(20, token_r18->text, curparam); + failed = 1; + haderrors++; + } + } else { + // 1099 + if ((search->flags & LISTFLAGS_2) || parseopts.ignoreUnknown) { + // 1101 + if (!(flags & OFLAGS_1)) + Option_Warning(19, token_r18->text); + Arg_UsedToken(); + Arg_GetToken(); + parsedany = 1; + } else { + // 1115 + Option_Error(19, token_r18->text); + failed = 1; + haderrors++; + } + } + } + } + + // 1126 - after_if_1006 + if (!haderrors && !failed && opt) { + flags &= ~OFLAGS_8; + if (matchflags & 0x700000) + flags |= OFLAGS_8; + haderrors = Option_Parse(opt, flags) == 0; + if (haderrors) + failed = 1; + parsedany++; + } // else: goto 1229 + } else if ((mystery_r31 == 1) && (token_r18->val == ATK_2)) { + // 1142 + opttok = 0; + curopt[0] = 0; + opt = Option_Lookup(search, 0, &matchflags); + strcpy(curopt, token_r18->text); + if (!opt) { + Option_Warning(33, curopt); + failed = 1; + } else { + if (!(flags & OFLAGS_1)) { + haderrors = Option_Parse(opt, flags) == 0; + } else { + parseopts.possibleFiles++; + haderrors = 0; + } + parsedany = 1; + if (haderrors) + failed = 1; + else + Arg_UsedToken(); + } + } else if ((mystery_r31 > 1) && Option_IsEndingLevel(mystery_r31, token_r18)) { + // 1193 + Option *opt; + char saveopt[64]; // stack 0x7C + strcpy(saveopt, curopt); + if (!(search->flags & LISTFLAGS_4)) { + curopt[0] = 0; + opt = Option_Lookup(search, 0, &matchflags); // probably wrong result reg + } else { + opt = 0; // probably wrong reg + } + // 1203 + if (!opt) { + // 1205 + if (!(flags & OFLAGS_4)) { + Option_Error(34, saveopt); + failed = 1; + haderrors++; + } else { + strcpy(curopt, saveopt); + break; + } + } else { + // 1219 + haderrors = Option_Parse(opt, flags) == 0; + parsedany = 1; + if (haderrors) + failed = 1; + } + // 1224 + strcpy(curopt, saveopt); + } + + // 1229 after_if_1126 + // This is where tok comes into play. + tok = Arg_PeekToken(); + // 1231 + if (!failed) { + if (tok && (tok->val == ATK_2) && (matchflags & 2)) { + // 1235 + ArgToken *prev; // r16 + char sticky[64]; // stack 0x3C + prev = Arg_UndoToken(); + tok = Arg_UsedToken(); + if (tok->text[0] && prev == opttok) { + if (opttok) { + strcpy(sticky, opttok->text); + sticky[strlen(tok->text)] = 0; + Option_PushOpt(0, sticky); + Param_Error(36, Arg_GetTokenName(tok)); + Option_PopOpt(0); + } else { + CLPReportError(36, Arg_GetTokenName(tok)); + } + // 1251 + haderrors++; + // goes to 1323 + } else { + // 1256 + if (!tok->text[0]) + tok = Arg_UsedToken(); + // 1257 + if (flags & OFLAGS_1) + parseopts.possibleFiles++; + // goes to 1323 + } + } else { + // 1267 + if (Option_IsEndingThisLevel(mystery_r31 - 1, tok)) + break; + if (Option_IsEndingThisLevel(mystery_r31 + 1, tok)) { + // 1276 + ArgToken *prev = tok; // r16 + tok = Arg_UsedToken(); + // 1278 + if ((mystery_r31 != 1) || (tok->val != ATK_3)) { + // 1280 + if (opttok) { + Option_PushOpt(0, opttok->text); + if (tok->val == ATK_2) + Param_Error(36, Arg_GetTokenName(tok)); + else + Param_Error(35, Arg_GetTokenName(prev)); + Option_PopOpt(opttok->text); + } else if (tok->val == ATK_2) { + // 1292 + CLPReportError(36, Arg_GetTokenName(tok)); + } else { + // 1294 + CLPReportError(35, Arg_GetTokenName(prev)); + } + haderrors++; + failed++; + } + // goto 1323 + } else if ((mystery_r31 < 2) && Option_IsEndingThisLevel(mystery_r31 + 2, tok)) { + // 1303 + if (opttok) { + Option_PushOpt(0, opttok->text); + if (tok->val == ATK_2) + Param_Error(36, Arg_GetTokenName(tok)); + else + Param_Error(35, Arg_GetTokenName(tok)); + Option_PopOpt(opttok->text); + } else if (tok->val == ATK_2) { + CLPReportError(36, Arg_GetTokenName(tok)); + } else { + CLPReportError(35, Arg_GetTokenName(tok)); + } + haderrors++; + failed++; + } + } + } // else: 1323 + + if (haderrors || failed) { + while (!Option_IsEndingLevel(mystery_r31, tok)) + tok = Arg_GetToken(); + if (!tok) + tok = Arg_UndoToken(); +#line 1335 + OPTION_ASSERT(tok); + } + + if (!parsedany || haderrors) + break; + + if (Option_IsEndingThisLevel(mystery_r31, tok)) + Arg_UsedToken(); + else if (!Option_ContinuesThisLevel(mystery_r31, tok)) + break; + } + + return haderrors == 0; } int Options_Parse(OptionList *options, int flags) { diff --git a/mwcc_decomp.h b/mwcc_decomp.h index f0bd518..e462bae 100644 --- a/mwcc_decomp.h +++ b/mwcc_decomp.h @@ -286,6 +286,7 @@ enum { }; enum { LISTFLAGS_NONE = 0, + LISTFLAGS_2 = 2, LISTFLAGS_4 = 4, LISTFLAGS_COMPILER = 0x100, LISTFLAGS_LINKER = 0x200, @@ -832,13 +833,16 @@ typedef struct Target { int count8; int countC; CWTargetInfo *targetInfo; - Segments segments; - Overlays overlays; + struct { + // not sure how much stuff exactly is part of this struct + Segments segments; + Overlays overlays; + } linkage; int x28; - Files accessPathFiles; - Files files2; + Files files; + Files pchs; Incls incls; - Paths systemPaths; + Paths sysPaths; Paths userPaths; CWDataType language; CWDataType cpu; @@ -851,14 +855,14 @@ typedef struct Target { unsigned long linkerFlags; unsigned long postLinkerFlags; OSPathSpec cwd; - VFile *vfiles; + VFile *virtualFiles; struct Target *next; } Target; // assumed name typedef struct Plugin { BasePluginCallbacks *cb; - CompilerLinkerPluginCallbacks *clcb; - ParserPluginCallbacks *pcb; + CompilerLinkerPluginCallbacks *cl_cb; + ParserPluginCallbacks *pr_cb; void *context; char *versionInfoASCII; struct Plugin *next; @@ -917,35 +921,35 @@ extern void Res_Cleanup(); /* CLPlugins.c */ //static void GetToolVersionInfo(); extern const ToolVersionInfo *Plugin_GetToolVersionInfo(); -//static const char *Plugin_GetDisplayName(Plugin *plugin); -extern const char *Plugin_GetDropInName(Plugin *plugin); -extern VersionInfo *Plugin_GetVersionInfo(Plugin *plugin); -extern const char *Plugin_GetVersionInfoASCII(Plugin *plugin); -extern DropInFlags *Plugin_GetDropInFlags(Plugin *plugin); -extern CWDataType Plugin_GetPluginType(Plugin *plugin); -extern const CWTargetList *Plugin_CL_GetTargetList(Plugin *plugin); -extern const CWPanelList *Plugin_GetPanelList(Plugin *plugin); -extern const CWExtMapList *Plugin_CL_GetExtMapList(Plugin *plugin); -extern const OSFileTypeMappingList *Plugin_GetFileTypeMappingList(Plugin *plugin); -extern const CWObjectFlags *Plugin_CL_GetObjectFlags(Plugin *plugin); -extern Boolean Plugin_MatchesName(Plugin *plugin, const char *name); -extern Boolean Plugin_CL_MatchesTarget(Plugin *plugin, CWDataType cpu, CWDataType os, Boolean flag); +//static const char *Plugin_GetDisplayName(Plugin *pl); +extern const char *Plugin_GetDropInName(Plugin *pl); +extern VersionInfo *Plugin_GetVersionInfo(Plugin *pl); +extern const char *Plugin_GetVersionInfoASCII(Plugin *pl); +extern DropInFlags *Plugin_GetDropInFlags(Plugin *pl); +extern CWDataType Plugin_GetPluginType(Plugin *pl); +extern const CWTargetList *Plugin_CL_GetTargetList(Plugin *pl); +extern const CWPanelList *Plugin_GetPanelList(Plugin *pl); +extern const CWExtMapList *Plugin_CL_GetExtMapList(Plugin *pl); +extern const OSFileTypeMappingList *Plugin_GetFileTypeMappingList(Plugin *pl); +extern const CWObjectFlags *Plugin_CL_GetObjectFlags(Plugin *pl); +extern Boolean Plugin_MatchesName(Plugin *pl, const char *name); +extern Boolean Plugin_CL_MatchesTarget(Plugin *pl, CWDataType cpu, CWDataType os, Boolean flag); extern Boolean Plugins_CL_HaveMatchingTargets(Plugin *a, Plugin *b, Boolean flag); //static CL_MatchesExtMapping(CWExtensionMapping *em, CWDataType type, const char *extension, Boolean flag); -extern Boolean Plugin_CL_MatchesFileType(Plugin *plugin, CWDataType type, const char *extension, Boolean flag); -extern Boolean Plugin_MatchesType(Plugin *plugin, CWDataType plugintype, CWDataType edit_language, Boolean flag); -extern Boolean Plugin_Pr_MatchesPlugin(Plugin *plugin, void *unk1, void *unk2, void *unk3); // fixme -extern Boolean Plugin_Pr_MatchesPanels(Plugin *plugin, void *unk1, void *unk2); // fixme -extern Boolean Plugin_CL_WriteObjectFile(Plugin *plugin, FSSpec *fss1, FSSpec *fss2, CWDataType creator, CWDataType filetype, Handle h); -extern Boolean Plugin_CL_GetCompilerMapping(Plugin *plugin, CWDataType type, const char *extension, CompilerMappingFlags *flags); -//static Boolean SupportedPlugin(Plugin *plugin, const char **errmsg); -//static Boolean VerifyPanels(Plugin *plugin); -extern Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *clcb, const ParserPluginCallbacks *pcb); -extern void Plugin_Free(Plugin *plugin); -extern int Plugin_VerifyPanels(Plugin *plugin); +extern Boolean Plugin_CL_MatchesFileType(Plugin *pl, CWDataType type, const char *extension, Boolean flag); +extern Boolean Plugin_MatchesType(Plugin *pl, CWDataType plugintype, CWDataType edit_language, Boolean flag); +extern Boolean Plugin_Pr_MatchesPlugin(Plugin *pl, void *unk1, void *unk2, void *unk3); // fixme +extern Boolean Plugin_Pr_MatchesPanels(Plugin *pl, void *unk1, void *unk2); // fixme +extern Boolean Plugin_CL_WriteObjectFile(Plugin *pl, FSSpec *srcfss, FSSpec *outfss, CWDataType creator, CWDataType filetype, Handle data); +extern Boolean Plugin_CL_GetCompilerMapping(Plugin *pl, CWDataType type, const char *extension, CompilerMappingFlags *flags); +//static Boolean SupportedPlugin(Plugin *pl, const char **errmsg); +//static Boolean VerifyPanels(Plugin *pl); +extern Plugin *Plugin_New(const BasePluginCallbacks *cb, const CompilerLinkerPluginCallbacks *cl_cb, const ParserPluginCallbacks *pr_cb); +extern void Plugin_Free(Plugin *pl); +extern int Plugin_VerifyPanels(Plugin *pl); extern void Plugins_Init(); extern void Plugins_Term(); -extern int Plugins_Add(Plugin *plugin); +extern int Plugins_Add(Plugin *pl); extern Plugin *Plugins_MatchName(Plugin *first, const char *name); extern Plugin *Plugins_CL_MatchTarget(Plugin *first, CWDataType cpu, CWDataType os, CWDataType plugintype, CWDataType edit_language); extern Plugin *Plugins_CL_MatchFileType(Plugin *first, CWDataType type, const char *extension, Boolean flag); @@ -957,9 +961,9 @@ extern Plugin *Plugins_GetParserForPlugin(...); // TODO fixme args extern Plugin *Plugins_GetCompilerForLinker(Plugin *first, Plugin *linker, CWDataType type, const char *extension, CWDataType edit_language); extern Boolean Plugins_GetPluginList(Plugin *first, int *count, void **list); // TODO fixme define list struct extern Boolean Plugins_GetPrefPanelUnion(Plugin *first, int *count, void **list); // TODO fixme define struct -extern Boolean Plugin_AddFileTypeMappings(Plugin *plugin, void *unk); +extern Boolean Plugin_AddFileTypeMappings(Plugin *pl, void *unk); extern Boolean Plugins_AddFileTypeMappingsForTarget(Plugin *first, void *unk, CWDataType cpu, CWDataType os); -extern short Plugin_Call(Plugin *plugin, void *context); +extern short Plugin_Call(Plugin *pl, void *context); /********************************/ /* ?? parser_cb */ @@ -1076,7 +1080,7 @@ typedef struct Proj { OSNameSpec projName; } Proj; extern int Proj_Initialize(Proj *proj); -extern int Proj_Terminate(Proj *proj); +extern int Proj_Terminate(Proj *this); /********************************/ /* ?? License */ @@ -1114,7 +1118,7 @@ extern Boolean SendParserRequest( ToolVersionInfo *toolVersionInfo ); extern Boolean SendCompilerRequest(Plugin *plugin, File *file, short request); -extern Boolean SendTargetInfoRequest(Target *target, Plugin *plugin, int flags); +extern Boolean SendTargetInfoRequest(Target *target, Plugin *linker, int flags); extern Boolean SendLinkerRequest(Plugin *plugin, int flags, CWTargetInfo *targetInfo); extern Boolean SendDisassemblerRequest(Plugin *plugin, File *file); extern Boolean SendInitOrTermRequest(Plugin *plugin, Boolean action); @@ -1307,6 +1311,9 @@ extern void GetIndString(Str255 theString, short strListID, short index); extern char *getindstring(char *theString, short strListID, short index); extern void NumToString(long theNum, Str255 theString); extern void StringToNum(ConstStr255Param theString, long *theNum); + +/********************************/ +/* MacFileTypes.c */ extern int AddFileTypeMappingList(void *a, void *b); // TODO sig extern void UseFileTypeMappings(void *a); // TODO sig extern OSErr SetMacFileType(const FSSpec *fss, void *a); // TODO sig @@ -1316,13 +1323,13 @@ extern OSErr GetMacFileType(const FSSpec *fss, void *a); // TODO sig /* CLFiles.c */ extern File *File_New(); extern void File_Free(File *file); -extern int Files_Initialize(Files *files); -extern int Files_Terminate(Files *files); -extern int Files_AddFile(Files *files, File *file); -extern int Files_InsertFile(Files *files, File *file, int index); -extern File *Files_GetFile(Files *files, int index); -extern File *Files_FindFile(Files *files, OSSpec *spec); -extern int Files_Count(Files *files); +extern int Files_Initialize(Files *this); +extern int Files_Terminate(Files *this); +extern int Files_AddFile(Files *this, File *file); +extern int Files_InsertFile(Files *this, File *file, int index); +extern File *Files_GetFile(Files *this, int filenum); +extern File *Files_FindFile(Files *this, OSSpec *spec); +extern int Files_Count(Files *this); extern int VFiles_Initialize(VFile **vfiles); extern int VFiles_Terminate(VFile **vfiles); extern VFile *VFile_New(const char *name, Handle data); @@ -1331,37 +1338,37 @@ extern VFile *VFiles_Find(VFile *vfiles, const char *name); /********************************/ /* CLOverlays.c */ -extern int Overlays_Initialize(Overlays *overlays); -extern int Overlays_Terminate(Overlays *overlays); -extern int Overlays_AddOvlGroup(Overlays *overlays, OvlGroup *group, int *pIndex); -extern OvlGroup *Overlays_GetOvlGroup(Overlays *overlays, int index); -extern int Overlays_CountGroups(Overlays *overlays); -extern int Overlays_AddFileToOverlay(Overlays *overlays, int groupIndex, int overlayIndex, int fileID); -extern Overlay *Overlays_GetOverlayInGroup(Overlays *overlays, int groupIndex, int overlayIndex); -extern int Overlays_GetFileInOverlay(Overlays *overlays, int groupIndex, int overlayIndex, int fileIndex); +extern int Overlays_Initialize(Overlays *this); +extern int Overlays_Terminate(Overlays *this); +extern int Overlays_AddOvlGroup(Overlays *this, OvlGroup *grp, int *pIndex); +extern OvlGroup *Overlays_GetOvlGroup(Overlays *this, int index); +extern int Overlays_CountGroups(Overlays *this); +extern int Overlays_AddFileToOverlay(Overlays *this, int groupIndex, int overlayIndex, int fileID); +extern Overlay *Overlays_GetOverlayInGroup(Overlays *this, int groupIndex, int overlayIndex); +extern int Overlays_GetFileInOverlay(Overlays *this, int groupIndex, int overlayIndex, int fileIndex); extern OvlGroup *OvlGroup_New(const char *name, CWAddr64 addr); -extern void OvlGroup_Delete(OvlGroup *group); -extern int OvlGroup_AddOverlay(OvlGroup *group, Overlay *overlay, int *pIndex); -extern Overlay *OvlGroup_GetOverlay(OvlGroup *group, int index); -extern int OvlGroup_CountOverlays(OvlGroup *group); +extern void OvlGroup_Delete(OvlGroup *grp); +extern int OvlGroup_AddOverlay(OvlGroup *this, Overlay *oly, int *pIndex); +extern Overlay *OvlGroup_GetOverlay(OvlGroup *this, int index); +extern int OvlGroup_CountOverlays(OvlGroup *this); extern Overlay *Overlay_New(const char *name); -extern void Overlay_Delete(Overlay *overlay); -extern int Overlay_AddFile(Overlay *overlay, int fileID, int *pIndex); -extern int Overlay_GetFile(Overlay *overlay, int index); -extern int Overlay_CountFiles(Overlay *overlay); +extern void Overlay_Delete(Overlay *oly); +extern int Overlay_AddFile(Overlay *oly, int fileID, int *pIndex); +extern int Overlay_GetFile(Overlay *oly, int index); +extern int Overlay_CountFiles(Overlay *oly); /********************************/ /* CLSegs.c */ extern Segment *Segment_New(const char *name, unsigned short a); extern void Segment_Free(Segment *segment); -extern int Segments_Initialize(Segments *segments); -extern int Segments_Terminate(Segments *segments); +extern int Segments_Initialize(Segments *segs); +extern int Segments_Terminate(Segments *segs); //static Boolean Segments_GrowSegments(Segments *segments, unsigned short *pIndex); -extern int Segments_AddSegment(Segments *segments, Segment *segment, unsigned short *pIndex); -extern Boolean Segments_InsertSegment(Segments *segments, unsigned short index, Segment *segment); -extern Boolean Segments_DeleteSegment(Segments *segments, unsigned short index); -extern Segment *Segments_GetSegment(Segments *segments, unsigned short index); -extern unsigned short Segments_Count(const Segments *segments); +extern int Segments_AddSegment(Segments *segs, Segment *segment, unsigned short *pIndex); +extern Boolean Segments_InsertSegment(Segments *segs, unsigned short index, Segment *segment); +extern Boolean Segments_DeleteSegment(Segments *segs, unsigned short index); +extern Segment *Segments_GetSegment(Segments *segs, unsigned short index); +extern unsigned short Segments_Count(const Segments *segs); /********************************/ /* CLDropinCallbacks_V10.cpp */ @@ -1397,7 +1404,7 @@ extern void OS_GetFileHandleSpec(const OSFileHandle *fh, OSSpec *spec); /********************************/ /* CLDependencies.c */ -extern int Incls_Initialize(Incls *incls); +extern int Incls_Initialize(Incls *incls, Target *targ); extern void Incls_Terminate(Incls *incls); // IsSysIncl // MakeInclFileSpec @@ -1427,14 +1434,14 @@ extern Boolean WriteBrowseData(File *file); /********************************/ /* CLBrowser.c */ // GetBrowseTableInfoAndLock -extern int Browser_Initialize(OSHandle *hand); +extern int Browser_Initialize(OSHandle *browsetable); //static int Destroy(OSHandle *hand); -extern int Browser_Terminate(OSHandle *hand); -extern int Browser_SearchFile(OSHandle *hand, const char *path, short *pIndex); -extern int Browser_SearchAndAddFile(OSHandle *hand, const char *path, short *pIndex); +extern int Browser_Terminate(OSHandle *browsetable); +extern int Browser_SearchFile(OSHandle *browsetable, const char *fullpath, short *pIndex); +extern int Browser_SearchAndAddFile(OSHandle *browsetable, const char *fullpath, short *pIndex); //static long CalcDiskSpaceRequirements(...); // needs table type //static int ConvertMemToDisk(...); // needs table type -extern int Browser_PackBrowseFile(Handle h, OSHandle *hand, OSHandle *hand2); +extern int Browser_PackBrowseFile(Handle browsedata, OSHandle *browsetable, OSHandle *hand2); /********************************/ /* ?? Include Cache */ |