From 35d488e972a9dd75ce3867c000405f128b79c615 Mon Sep 17 00:00:00 2001 From: Ash Wolf Date: Sun, 15 Jan 2023 12:14:05 +0000 Subject: reorganise things a bit to align further with the actual names/structure --- CMakeLists.txt | 52 +- command_line/C++_Parser/Src/Library/Arguments.c | 590 ++++++++++ command_line/C++_Parser/Src/Library/Help.c | 561 ++++++++++ command_line/C++_Parser/Src/Library/IO.c | 83 ++ .../C++_Parser/Src/Library/OptimizerHelpers.c | 166 +++ command_line/C++_Parser/Src/Library/Option.c | 1136 +++++++++++++++++++ command_line/C++_Parser/Src/Library/Parameter.c | 1145 ++++++++++++++++++++ command_line/C++_Parser/Src/Library/ParserErrors.c | 119 ++ command_line/C++_Parser/Src/Library/ParserFace.c | 298 +++++ .../C++_Parser/Src/Library/ParserHelpers-cc.c | 156 +++ .../C++_Parser/Src/Library/ParserHelpers.c | 535 +++++++++ command_line/C++_Parser/Src/Library/Projects.c | 241 ++++ .../C++_Parser/Src/Library/StaticParserGlue.c | 29 + .../Src/Library/StdTargetWarningHelpers-cc.c | 81 ++ command_line/C++_Parser/Src/Library/Targets.c | 65 ++ .../C++_Parser/Src/Library/ToolHelpers-cc.c | 36 + command_line/C++_Parser/Src/Library/ToolHelpers.c | 289 +++++ command_line/C++_Parser/Src/Library/Utils.c | 174 +++ command_line/CmdLine/Src/CLFileTypes.c | 29 + command_line/CmdLine/Src/Clients/CLStaticMain.c | 10 +- command_line/CmdLine/Src/uFileTypeMappings.c | 31 - command_line/PluginLib/Src/Internal/COSToolsCLT.c | 292 +++++ .../Src/Internal/CWSecretPluginCallbacks.cpp | 39 + .../Src/Library/CWParserPluginsPrivate.cpp | 207 ++++ .../PluginLib/Src/Library/CWPluginsPrivate.cpp | 513 +++++++++ .../Src/Library/DropInCompilerLinkerPrivate.cpp | 501 +++++++++ .../Src/Options/Glue/ParserGlue-mach-ppc-cc.c | 8 +- .../Src/Options/Glue/TargetOptimizer-ppc-mach.c | 71 ++ .../Src/Options/Glue/TargetWarningHelpers-ppc-cc.c | 84 -- .../MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c | 4 +- .../Tools_PPC/Src/Plugin/libimp-mach-ppc.c | 4 +- .../Tools_PPC/Src/Static/cc-mach-ppc-mw.c | 12 +- compiler_and_linker/FrontEnd/C/CPrep.c | 206 ++-- compiler_and_linker/FrontEnd/C/CPrepTokenizer.c | 20 +- compiler_and_linker/unsorted/CABI.c | 48 +- compiler_and_linker/unsorted/CBrowse.c | 10 +- compiler_and_linker/unsorted/CClass.c | 6 +- compiler_and_linker/unsorted/CCompiler.c | 102 +- compiler_and_linker/unsorted/CDecl.c | 48 +- compiler_and_linker/unsorted/CExpr.c | 8 +- compiler_and_linker/unsorted/CExpr2.c | 4 +- compiler_and_linker/unsorted/CFunc.c | 48 +- compiler_and_linker/unsorted/CInit.c | 16 +- compiler_and_linker/unsorted/CInline.c | 38 +- compiler_and_linker/unsorted/CMachine.c | 42 +- compiler_and_linker/unsorted/CObjC.c | 2 +- compiler_and_linker/unsorted/COptimizer.c | 10 +- compiler_and_linker/unsorted/CParser.c | 42 +- compiler_and_linker/unsorted/CPrec.c | 10 +- compiler_and_linker/unsorted/CRTTI.c | 6 +- compiler_and_linker/unsorted/CSOM.c | 10 +- compiler_and_linker/unsorted/CTemplateClass.c | 10 +- compiler_and_linker/unsorted/CTemplateNew.c | 16 +- compiler_and_linker/unsorted/CodeGen.c | 120 +- compiler_and_linker/unsorted/CodeGenOptPPC.c | 62 +- compiler_and_linker/unsorted/FuncLevelAsmPPC.c | 6 +- compiler_and_linker/unsorted/FunctionCalls.c | 4 +- compiler_and_linker/unsorted/GenStabs.c | 4 +- compiler_and_linker/unsorted/GlobalOptimizer.c | 8 +- compiler_and_linker/unsorted/InlineAsmPPC.c | 6 +- compiler_and_linker/unsorted/InstrSelection.c | 24 +- compiler_and_linker/unsorted/IrOptimizer.c | 50 +- compiler_and_linker/unsorted/IroExprRegeneration.c | 4 +- compiler_and_linker/unsorted/IroLoop.c | 16 +- compiler_and_linker/unsorted/IroPointerAnalysis.c | 2 +- compiler_and_linker/unsorted/IroUnrollLoop.c | 4 +- compiler_and_linker/unsorted/LoopOptimization.c | 16 +- compiler_and_linker/unsorted/MachO.c | 8 +- compiler_and_linker/unsorted/ObjGenMachO.c | 14 +- compiler_and_linker/unsorted/PCodeAssembly.c | 12 +- compiler_and_linker/unsorted/PCodeListing.c | 2 +- compiler_and_linker/unsorted/Peephole.c | 2 +- compiler_and_linker/unsorted/RegisterInfo.c | 2 +- compiler_and_linker/unsorted/Scheduler.c | 4 +- compiler_and_linker/unsorted/SpillCode.c | 4 +- compiler_and_linker/unsorted/StackFrame.c | 12 +- compiler_and_linker/unsorted/StructMoves.c | 2 +- compiler_and_linker/unsorted/TOC.c | 12 +- includes/compiler/CBrowse.h | 6 +- includes/compiler/CCompiler.h | 2 +- includes/compiler/CParser.h | 149 ++- includes/compiler/CPrep.h | 6 +- includes/compiler/common.h | 44 +- includes/cw_common.h | 4 +- includes/plugin.h | 4 +- osx_build.sh | 411 +++---- unsorted/Arguments.c | 590 ---------- unsorted/Help.c | 561 ---------- unsorted/IO.c | 83 -- unsorted/OptimizerHelpers.c | 166 --- unsorted/Option.c | 1136 ------------------- unsorted/Parameter.c | 1145 -------------------- unsorted/ParserErrors.c | 119 -- unsorted/ParserFace.c | 298 ----- unsorted/ParserHelpers-cc.c | 156 --- unsorted/ParserHelpers.c | 535 --------- unsorted/Projects.c | 241 ---- unsorted/StaticParserGlue.c | 29 - unsorted/TargetOptimizer-ppc-mach.c | 71 -- unsorted/Targets.c | 65 -- unsorted/ToolHelpers-cc.c | 36 - unsorted/ToolHelpers.c | 289 ----- unsorted/Utils.c | 174 --- unsorted/uCOS.c | 292 ----- unsorted/uContext1.cpp | 513 --------- unsorted/uContextCL.cpp | 501 --------- unsorted/uContextParser.cpp | 207 ---- unsorted/uContextSecret.cpp | 39 - 108 files changed, 8269 insertions(+), 8266 deletions(-) create mode 100644 command_line/C++_Parser/Src/Library/Arguments.c create mode 100644 command_line/C++_Parser/Src/Library/Help.c create mode 100644 command_line/C++_Parser/Src/Library/IO.c create mode 100644 command_line/C++_Parser/Src/Library/OptimizerHelpers.c create mode 100644 command_line/C++_Parser/Src/Library/Option.c create mode 100644 command_line/C++_Parser/Src/Library/Parameter.c create mode 100644 command_line/C++_Parser/Src/Library/ParserErrors.c create mode 100644 command_line/C++_Parser/Src/Library/ParserFace.c create mode 100644 command_line/C++_Parser/Src/Library/ParserHelpers-cc.c create mode 100644 command_line/C++_Parser/Src/Library/ParserHelpers.c create mode 100644 command_line/C++_Parser/Src/Library/Projects.c create mode 100644 command_line/C++_Parser/Src/Library/StaticParserGlue.c create mode 100644 command_line/C++_Parser/Src/Library/StdTargetWarningHelpers-cc.c create mode 100644 command_line/C++_Parser/Src/Library/Targets.c create mode 100644 command_line/C++_Parser/Src/Library/ToolHelpers-cc.c create mode 100644 command_line/C++_Parser/Src/Library/ToolHelpers.c create mode 100644 command_line/C++_Parser/Src/Library/Utils.c create mode 100644 command_line/CmdLine/Src/CLFileTypes.c delete mode 100644 command_line/CmdLine/Src/uFileTypeMappings.c create mode 100644 command_line/PluginLib/Src/Internal/COSToolsCLT.c create mode 100644 command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp create mode 100644 command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp create mode 100644 command_line/PluginLib/Src/Library/CWPluginsPrivate.cpp create mode 100644 command_line/PluginLib/Src/Library/DropInCompilerLinkerPrivate.cpp create mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetOptimizer-ppc-mach.c delete mode 100644 compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c delete mode 100644 unsorted/Arguments.c delete mode 100644 unsorted/Help.c delete mode 100644 unsorted/IO.c delete mode 100644 unsorted/OptimizerHelpers.c delete mode 100644 unsorted/Option.c delete mode 100644 unsorted/Parameter.c delete mode 100644 unsorted/ParserErrors.c delete mode 100644 unsorted/ParserFace.c delete mode 100644 unsorted/ParserHelpers-cc.c delete mode 100644 unsorted/ParserHelpers.c delete mode 100644 unsorted/Projects.c delete mode 100644 unsorted/StaticParserGlue.c delete mode 100644 unsorted/TargetOptimizer-ppc-mach.c delete mode 100644 unsorted/Targets.c delete mode 100644 unsorted/ToolHelpers-cc.c delete mode 100644 unsorted/ToolHelpers.c delete mode 100644 unsorted/Utils.c delete mode 100644 unsorted/uCOS.c delete mode 100644 unsorted/uContext1.cpp delete mode 100644 unsorted/uContextCL.cpp delete mode 100644 unsorted/uContextParser.cpp delete mode 100644 unsorted/uContextSecret.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b39958c..7760667 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ add_executable(mwcc command_line/CmdLine/Src/MacEmul/Memory.c command_line/CmdLine/Src/MacEmul/Files.c command_line/CmdLine/Src/MacEmul/TextUtils.c - command_line/CmdLine/Src/uFileTypeMappings.c + command_line/CmdLine/Src/CLFileTypes.c command_line/CmdLine/Src/Project/CLFiles.c command_line/CmdLine/Src/Project/CLOverlays.c command_line/CmdLine/Src/Project/CLSegs.c @@ -51,13 +51,15 @@ add_executable(mwcc command_line/CmdLine/Src/CLIncludeFileCache.c command_line/CmdLine/Src/CLLoadAndCache.c command_line/CmdLine/Src/MacEmul/ErrMgr.c + compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c - unsorted/TargetOptimizer-ppc-mach.c - unsorted/OptimizerHelpers.c - compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c + compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetOptimizer-ppc-mach.c + + command_line/C++_Parser/Src/Library/OptimizerHelpers.c + command_line/C++_Parser/Src/Library/StdTargetWarningHelpers-cc.c command_line/C++_Parser/Src/Library/WarningHelpers.c compiler_and_linker/unsorted/CCompiler.c @@ -176,26 +178,28 @@ add_executable(mwcc compiler_and_linker/unsorted/GCCInlineAsm.c compiler_and_linker/unsorted/BitVectors.c - unsorted/StaticParserGlue.c - unsorted/ParserFace.c - unsorted/ParserHelpers.c - unsorted/ToolHelpers.c - unsorted/ParserHelpers-cc.c - unsorted/Arguments.c - unsorted/ToolHelpers-cc.c - unsorted/IO.c - unsorted/Projects.c - unsorted/Targets.c - unsorted/Option.c - unsorted/ParserErrors.c - unsorted/Utils.c - unsorted/Parameter.c - unsorted/Help.c - unsorted/uContext1.cpp - unsorted/uContextCL.cpp - unsorted/uContextSecret.cpp - unsorted/uCOS.c - unsorted/uContextParser.cpp + command_line/C++_Parser/Src/Library/StaticParserGlue.c + command_line/C++_Parser/Src/Library/ParserFace.c + command_line/C++_Parser/Src/Library/ParserHelpers.c + command_line/C++_Parser/Src/Library/ToolHelpers.c + command_line/C++_Parser/Src/Library/ParserHelpers-cc.c + command_line/C++_Parser/Src/Library/Arguments.c + command_line/C++_Parser/Src/Library/ToolHelpers-cc.c + command_line/C++_Parser/Src/Library/IO.c + command_line/C++_Parser/Src/Library/Projects.c + command_line/C++_Parser/Src/Library/Targets.c + command_line/C++_Parser/Src/Library/Option.c + command_line/C++_Parser/Src/Library/ParserErrors.c + command_line/C++_Parser/Src/Library/Utils.c + command_line/C++_Parser/Src/Library/Parameter.c + command_line/C++_Parser/Src/Library/Help.c + + command_line/PluginLib/Src/Library/CWPluginsPrivate.cpp + command_line/PluginLib/Src/Library/DropInCompilerLinkerPrivate.cpp + command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp + command_line/PluginLib/Src/Internal/COSToolsCLT.c + command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp + unsorted/uLibImporter.c unsorted/CmdLineBuildDate.c diff --git a/command_line/C++_Parser/Src/Library/Arguments.c b/command_line/C++_Parser/Src/Library/Arguments.c new file mode 100644 index 0000000..631f282 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/Arguments.c @@ -0,0 +1,590 @@ +#include "parser.h" + +char compat; +char *MAINOPTCHAR; +char *FIRSTARGCHAR; +char *SEPOPTSTR; +char SEPOPTCHAR; +char SEP1; +char SEP2; +char SEP3; +char RESPFILECHAR; +char *RESPFILESTR; +static ArgToken *argtoks; +static int numargtoks; +static int maxargtoks; +unsigned char parserDebug; +static unsigned char in_response_file; +static int margc; +static int margind; +static char **margv; +static OSFileHandle respfilehandle; +static char *respfile; +static char *respfilestart; +static unsigned long respfilesize; +static int scantok; +anon0_50 linkargs; +anon0_50 prelinkargs; +anon0_50 postlinkargs; + +static void Arg_AddToken(short val, char *text); +static void Arg_Setup(int argc, char **argv); +static void Arg_SkipRespFileWS(); +static unsigned char Arg_OpenRespFile(const char *name); +static void Arg_CloseRespFile(); +static char *Arg_GetRespFileToken(); +static char *Arg_GetNext(unsigned char allow_resp); +static unsigned char Arg_GotMore(); +static void Arg_Parse(); +static void Arg_GrowArgs(anon0_50 *ta); +static void Arg_GrowArg(anon0_50 *ta, char *txt); + +static void Arg_AddToken(short val, char *text) { + ArgToken *cur; + ArgToken *prev; + ArgToken *pprev; + ArgToken *ppprev; + ArgToken *pppprev; + + if (numargtoks > 0) + prev = &argtoks[numargtoks - 1]; + else + prev = 0; + + if (prev && prev->val == ATK_ARG && prev->text[0] == 0) { + pppprev = ppprev = pprev = 0; + if (numargtoks > 3) + pppprev = &argtoks[numargtoks - 4]; + if (numargtoks > 2) + ppprev = &argtoks[numargtoks - 3]; + if (numargtoks > 1) + pprev = &argtoks[numargtoks - 2]; + + if (pprev) { + if ((int) val == ATK_ARG_END && (pprev->val == ATK_COMMA || pprev->val == ATK_EQUALS) && (ppprev->val != ATK_ARG || pppprev->val != ATK_OPTION)) { + if (parserDebug) + printf("Coalescing args with '%s'\n", Arg_GetTokenName(pprev)); + val = pprev->val; + numargtoks -= 2; + } else if (pprev->val == ATK_ARG_END && ((int) val == ATK_COMMA || (int) val == ATK_EQUALS)) { + if (parserDebug) + printf("Coalescing args, removing '%s'\n", Arg_GetTokenName(pprev)); + numargtoks -= 2; + } + } + } + + if (numargtoks >= maxargtoks) { + argtoks = (ArgToken *) xrealloc("argument list", argtoks, sizeof(ArgToken) * (maxargtoks + 16)); + maxargtoks += 16; + } + + cur = &argtoks[numargtoks]; + cur->val = val; + if (text) + cur->text = xstrdup(text); + else + cur->text = 0; + numargtoks++; +} + +static void Arg_Setup(int argc, char **argv) { + in_response_file = 0; + respfile = 0; + margc = argc; + margv = argv; + margind = 1; +} + +static void Arg_SkipRespFileWS(void) { +restart: + while (respfile[0] && isspace(respfile[0])) + ++respfile; + + if (respfile[0] == '\\' && respfile[1] == '#') { + ++respfile; + return; + } + + if (respfile[0] == '#') { + if ((respfile > respfilestart) ? (respfile[-1] != '\\') : 1) { + while (respfile[0] && respfile[0] != 10 && respfile[0] != 13) + ++respfile; + + while (respfile[0] == 13 || respfile[0] == 10) + ++respfile; + + goto restart; + } + } +} + +static unsigned char Arg_OpenRespFile(const char *name) { + struct OSSpec spec; + int err; + + if ( + (err = OS_MakeFileSpec(name, &spec)) + || (err = OS_NewFileHandle(&spec, 0, 0, &respfilehandle)) + || (err = OS_AppendHandle(&respfilehandle.hand, "", 1)) + || (err = OS_LockFileHandle(&respfilehandle, &respfile, &respfilesize)) + ) { + CLPOSAlert(CLPStr74, (short) err, "response ", name); + return 0; + } else { + respfilestart = respfile; + Arg_SkipRespFileWS(); + in_response_file = 1; + return 1; + } +} + +static void Arg_CloseRespFile(void) { + in_response_file = 0; + OS_FreeFileHandle(&respfilehandle); +} + +static char *Arg_GetRespFileToken(void) { + char *start; + char *ptr; + int quoting; + + quoting = 0; + if (respfile[0] == 0) + return 0; + + start = ptr = respfile; + while (respfile[0]) { + if (!quoting && isspace(respfile[0])) + break; + + if (respfile[0] == '"') { + quoting = !quoting; + respfile++; + } else if (respfile[0] == '\\' && respfile[1] == '"') { + *ptr = '"'; + respfile += 2; + ptr++; + } else { + *(ptr++) = *(respfile++); + } + } + + if (respfile[0]) + Arg_SkipRespFileWS(); + *ptr = 0; + return start; +} + +static char *Arg_GetNext(unsigned char allow_resp) { + char *ret; + int rfclen; + char *rfcequ; + +restart: + if (!in_response_file) { + rfclen = 1; + ret = margv[margind++]; + if (ret[0] == '\\' && ret[1] == RESPFILECHAR) { + ret++; + } else if (allow_resp) { + if (ret[0] == RESPFILECHAR || (RESPFILESTR[0] && !ustrncmp(ret, RESPFILESTR, rfclen = strlen(RESPFILESTR))) && ret[rfclen]) { + rfcequ = strchr(ret + rfclen, '='); + if (rfcequ) + rfclen = (rfcequ + 1) - ret; + if (Arg_OpenRespFile(ret + rfclen)) + goto restart; + ret = 0; + } + } + } else { + ret = Arg_GetRespFileToken(); + if (!ret) { + Arg_CloseRespFile(); + goto restart; + } + } + + if (parserDebug) + fprintf(stderr, "Got arg = '%s'\n", ret ? ret : ""); + + return ret; +} + +static unsigned char Arg_GotMore(void) { + if (!in_response_file) + return margind < margc; + else if (respfile[0]) + return 1; + else + return margind < margc; +} + +static void Arg_Parse(void) { + unsigned char isOpt; + unsigned char isList; + char *arg; + char *argstart; + char buffer[4096]; + char *bufptr; + char ch; + + isOpt = 0; + isList = 0; + while (Arg_GotMore()) { + argstart = arg = Arg_GetNext(1); + if (!arg) + break; + + bufptr = buffer; + buffer[0] = 0; + isList = 0; + + if (arg[0] && arg[1] && strchr(MAINOPTCHAR, arg[0])) { + if (isOpt) + Arg_AddToken(ATK_ARG_END, 0); + buffer[0] = arg[1]; + buffer[1] = 0; + isOpt = 1; + isList = 0; + bufptr++; + arg += 2; + } else { + isOpt = 0; + } + + while (arg && arg[0]) { + ch = arg[0]; + if (arg[0] == '\\' && (arg[1] == SEP1 || arg[1] == SEP2 || arg[1] == SEP3)) { + ch = 0x80 | *(++arg); + } else if (compat == 1 && arg[0] == ':' && arg[1] == '\\') { + ch |= 0x80; + } + + if (ch != SEP1 && ch != SEP2 && ch != SEP3) { + if ((ch & 0x7F) == SEP1 || (ch & 0x7F) == SEP2 || (ch & 0x7F) == SEP3) + ch &= 0x7F; + *(bufptr++) = ch; + if (bufptr >= &buffer[sizeof(buffer)]) { + CLPReportError(CLPStr2, argstart, argstart + strlen(argstart) - 15, sizeof(buffer)); + } + *bufptr = 0; + } else { + if (isOpt) { + Arg_AddToken(ATK_OPTION, buffer); + Arg_AddToken(ATK_ARG, buffer); + } else { + Arg_AddToken(ATK_ARG, buffer); + } + + Arg_AddToken( + (unsigned char) ((ch == ',') ? ATK_COMMA : (((ch == '=') || (ch == SEP3)) ? ATK_EQUALS : ATK_END)), + 0 + ); + + bufptr = buffer; + buffer[0] = 0; + + if (ch == SEP1 || ch == SEP2 || ch == SEP3) + isOpt = 0; + isList = 1; + } + + arg++; + } + + // 1799C8 + if (isOpt && bufptr > &buffer[0]) { + Arg_AddToken(ATK_OPTION, buffer + (isList && strchr(MAINOPTCHAR, buffer[0]))); + Arg_AddToken(ATK_ARG, buffer + (isList && strchr(MAINOPTCHAR, buffer[0])) + 1); + } else { + Arg_AddToken(ATK_ARG, buffer); + Arg_AddToken(ATK_ARG_END, 0); + } + } + + if (isOpt || isList) + Arg_AddToken(ATK_ARG_END, 0); + Arg_AddToken(ATK_END, 0); +} + +enum { + COMPAT_0, + COMPAT_1, + COMPAT_2 +}; + +void Arg_Init(int theargc, char **theargv) { + int p; + int x; + + maxargtoks = 0; + numargtoks = 0; + parserDebug = 0; + if (theargc > 1 && !strcmp(theargv[1], "--parser-debug")) { + parserDebug = 1; + memmove(&theargv[1], &theargv[2], sizeof(char *) * (theargc - 1)); + theargc--; + } + + if ((int) compat == COMPAT_0) { + MAINOPTCHAR = "-"; + FIRSTARGCHAR = "="; + SEPOPTSTR = " "; + SEP1 = ','; + SEP2 = '='; + SEP3 = '='; + RESPFILECHAR = '@'; + RESPFILESTR = ""; + } else if ((int) compat == COMPAT_1) { + MAINOPTCHAR = "/-"; + FIRSTARGCHAR = ":"; + SEPOPTSTR = ":"; + SEP1 = ','; + SEP2 = '='; + SEP3 = ':'; + RESPFILECHAR = '@'; + RESPFILESTR = ""; + } else if ((int) compat == COMPAT_2) { + if (!MAINOPTCHAR) + MAINOPTCHAR = "-"; + if (!FIRSTARGCHAR) + FIRSTARGCHAR = "="; + if (!SEPOPTSTR) + SEPOPTSTR = " "; + if (!SEP1) + SEP1 = ','; + if (!SEP2) + SEP2 = '='; + if (!SEP3) + SEP3 = '='; + if (!RESPFILECHAR) + RESPFILECHAR = '@'; + if (!RESPFILESTR) + RESPFILESTR = ""; + } else { + CLPFatalError("Unknown parser compatibility type (%d)\n", (int) compat); + } + + if (parserDebug) { + printf("Incoming arguments: \n"); + for (p = 0; p < theargc; p++) { + printf("[%s] ", theargv[p]); + } + printf("\n"); + } + + Arg_Setup(theargc, theargv); + Arg_Parse(); + Arg_Reset(); + + if (parserDebug) { + for (x = 0; x < numargtoks; x++) { + printf("TOKEN: '%s'\n", Arg_GetTokenName(&argtoks[x])); + } + } +} + +void Arg_Terminate(void) { + ArgToken *cur; + + while (numargtoks > 0) { + cur = &argtoks[--numargtoks]; + if (cur->text) + free(cur->text); + } + + if (maxargtoks) + free(argtoks); + maxargtoks = 0; +} + +void Arg_Reset(void) { + scantok = 0; +} + +void Arg_Stop(ArgToken *where) { + ArgToken *cur; + + while (&argtoks[numargtoks] > where) { + cur = &argtoks[--numargtoks]; + if (cur->text) + free(cur->text); + cur->val = ATK_END; + cur->text = 0; + } + + argtoks[numargtoks++].val = ATK_ARG_END; + argtoks[numargtoks++].val = ATK_END; + scantok = numargtoks - 2; +} + +ArgToken *Arg_PeekToken(void) { + if (scantok >= numargtoks) + return 0; + else + return &argtoks[scantok]; +} + +ArgToken *Arg_UsedToken(void) { + if (scantok < numargtoks) + scantok++; + return Arg_PeekToken(); +} + +int Arg_IsEmpty(void) { + ArgToken *tok; + + tok = Arg_PeekToken(); + return (tok == 0 || tok->val == ATK_END); +} + +ArgToken *Arg_GetToken(void) { + ArgToken *ret; + + ret = Arg_PeekToken(); + if (ret) + scantok++; + return ret; +} + +ArgToken *Arg_UndoToken(void) { + if (scantok > 0) { + scantok--; + return Arg_PeekToken(); + } else { + return 0; + } +} + +const char *Arg_GetTokenName(ArgToken *tok) { + if ((int) tok->val == ATK_ARG) + return tok->text; + + return + ((int) tok->val == ATK_OPTION) ? "option" : + ((int) tok->val == ATK_COMMA) ? "comma" : + (((int) compat == COMPAT_1 && (int) tok->val == ATK_EQUALS)) ? "colon or equals" : + (((int) compat != COMPAT_1 && (int) tok->val == ATK_EQUALS)) ? "equals" : + ((int) tok->val == ATK_ARG_END) ? "end of argument" : + ((int) tok->val == ATK_END) ? "end of command line" : + ""; +} + +const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn) { + const char *ptr; + char *bptr; + int curlen; + + bptr = buffer; + curlen = 0; + if (tok->val == ATK_ARG || tok->val == ATK_OPTION) + ptr = tok->text; + else + ptr = Arg_GetTokenName(tok); + + while (*ptr && curlen++ < maxlen) { + *(bptr++) = *(ptr++); + } + + if (curlen < maxlen) { + bptr[0] = 0; + } else { + bptr[-1] = 0; + if (warn) + CLPReportWarning(CLPStr56, buffer, ptr + strlen(ptr) - ((maxlen <= 32) ? maxlen : 32), maxlen); + } + + return buffer; +} + +static void Arg_GrowArgs(anon0_50 *ta) { + int len; + + if (!ta->argv || (ta->argc + 1) >= ta->nargv) { + len = ta->nargv; + ta->nargv = len + 16; + ta->argv = xrealloc("argument list", ta->argv, sizeof(char *) * (ta->nargv + 1)); + while (len <= ta->nargv) { + ta->argv[len++] = 0; + } + } + + ta->argc++; +} + +static void Arg_GrowArg(anon0_50 *ta, char *txt) { + char **ptr; + int ptrlen; + + ptr = &ta->argv[ta->argc]; + + if (*ptr == 0) { + *ptr = xstrdup(txt); + } else { + ptrlen = strlen(*ptr); + *ptr = xrealloc("command line", *ptr, ptrlen + strlen(txt) + 1); + strcpy(*ptr + ptrlen, txt); + } +} + +void Arg_InitToolArgs(anon0_50 *ta) { + ta->argc = 0; + ta->nargv = 0; + ta->argv = 0; + Arg_GrowArgs(ta); +} + +void Arg_AddToToolArgs(anon0_50 *ta, short tokval, char *toktxt) { + switch (tokval) { + case ATK_END: + Arg_FinishToolArgs(ta); + break; + case ATK_ARG_END: + if (ta->argv && ta->argv[ta->argc]) + Arg_GrowArgs(ta); + break; + case ATK_ARG: + Arg_GrowArg(ta, toktxt); + break; + case ATK_OPTION: + Arg_GrowArg(ta, "-"); + break; + case ATK_EQUALS: + Arg_GrowArg(ta, "="); + break; + case ATK_COMMA: + Arg_GrowArg(ta, ","); + break; + default: + CLPFatalError(__FILE__, 787, "Unknown token (%d)", tokval); + break; + } +} + +void Arg_FinishToolArgs(anon0_50 *ta) { + Arg_GrowArgs(ta); + ta->argv[ta->argc] = 0; +} + +void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args) { + args->argc = 1; + args->argv = ta->argv; + + while (args->argv[args->argc]) + args->argc++; + + args->envp = 0; +} + +void Arg_FreeToolArgs(anon0_50 *ta) { + int x; + + if (ta->argv) { + for (x = 1; x < ta->argc; x++) { + if (ta->argv[x]) + free(ta->argv[x]); + } + free(ta->argv); + } +} diff --git a/command_line/C++_Parser/Src/Library/Help.c b/command_line/C++_Parser/Src/Library/Help.c new file mode 100644 index 0000000..74849a1 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/Help.c @@ -0,0 +1,561 @@ +#include "parser.h" + +typedef struct _Side { + short offset; + short width; + char buffer[1024]; + short bptr; + short blen; + short indent; + short vrow; + short vcol; + Boolean atEOL; + Boolean impInd; +} Side; + +short helpExtras; +Boolean showedHelp; +Side left; +Side right; +Side all; +char **helptext; +static char outLine[256]; + +static void Help_Output(Side *left, Side *right); +static void Help_OutputSingle(Side *all); +static void Help_Flush(void); + +static void Side_Init(Side *s, short offset, short width) { + memset(s, 0, sizeof(Side)); + s->offset = offset; + s->width = width; +} + +static void Side_Print(Side *s, const char *format, ...) { + char c; + char *text; + char buffer[1024]; + va_list args; + + va_start(args, format); + vsprintf(buffer, format, args); + va_end(args); + + text = buffer; + while (*text) { + if (s->blen < 1024) { + c = *(text++); + if (c == '~' && *text == '~') { + c = *MAINOPTCHAR; + text++; + } + + s->buffer[(s->bptr + s->blen) & 1023] = c; + s->blen++; + } else { + if (s == &left) + Help_Output(&left, &right); + else + Help_OutputSingle(&all); + } + } +} + +static void Side_NewLine(Side *s) { + Side_Print(s, "\n"); +} + +static void Side_Indent(Side *s, short how) { + if ((s->width - s->indent - how) > (parseopts.ioCols / 8)) + s->indent += how; + else if ((s->width - s->indent - 1) > (parseopts.ioCols / 10)) + s->indent++; +} + +static void Side_Outdent(Side *s, short how) { + if ((s->width - s->indent) < (parseopts.ioCols / 8)) + s->indent++; + else if (s->indent >= how) + s->indent -= how; +} + +static unsigned char isBreaker(char c) { + return (c == 10) || (c == 13) || (c == 32) || (c == 9) || (c == 8) || (c == '|'); +} + +static void Side_DumpLine(Side *s) { + short col; + short len; + short afterspace; + short eol; + short ind; + char c; + + eol = 0; + ind = 0; + col = s->offset + s->indent; + s->vcol = s->indent; + len = 0; + afterspace = s->width - s->indent; + + while (s->blen > 0 && s->vcol < s->width && !eol && !ind) { + c = s->buffer[s->bptr]; + outLine[col + len] = c; + s->vcol++; + len++; + + if (isBreaker(c)) { + afterspace = len; + eol = (c == '\n') || (c == '\r'); + eol += (c == '\r'); + ind = (c == '\b') || (c == '\t'); + ind += (c == '\b'); + } + + s->bptr = (s->bptr + 1) & 1023; + s->blen--; + } + + if (s->blen || eol || ind) { + s->blen += len - afterspace; + s->bptr = (s->bptr - (len - afterspace)) & 1023; + if (eol || ind) { + len++; + afterspace--; + } + + while (len > afterspace) { + outLine[col + --len] = ' '; + } + } + + s->vcol = 0; + s->vrow++; + s->atEOL = (eol == 1) || ind || !s->blen; + if ((s->atEOL || ind) && s->impInd) { + Side_Outdent(s, parseopts.ioCols / 40); + s->impInd = 0; + } + if (ind) { + if (ind == 1) + Side_Indent(s, parseopts.ioCols / 25); + else + Side_Outdent(s, parseopts.ioCols / 25); + } else if (!s->atEOL && s != &all && !s->impInd) { + Side_Indent(s, parseopts.ioCols / 40); + s->impInd = 1; + } +} + +static void Help_PrintLine(void) { + HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, outLine); +} + +static void Help_Output(Side *left, Side *right) { + while (left->blen || right->blen) { + memset(outLine, ' ', parseopts.ioCols); + outLine[left->offset + left->width + 1] = '#'; + if (left->atEOL && right->atEOL) + left->atEOL = right->atEOL = 0; + if (!left->atEOL) + Side_DumpLine(left); + if (!right->atEOL) + Side_DumpLine(right); + Help_PrintLine(); + } +} + +static void Help_OutputSingle(Side *all) { + while (all->blen) { + memset(outLine, ' ', parseopts.ioCols); + if (all->atEOL) + all->atEOL = 0; + if (!all->atEOL) + Side_DumpLine(all); + Help_PrintLine(); + } +} + +static void Help_Flush(void) { + Help_Output(&left, &right); +} + +static void Help_NewLine(void) { + Side_NewLine(&left); + Side_NewLine(&right); +} + +int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword) { + char pfbuf[512]; + char slflags; + int listFlags; + Boolean allNoArgs; + PARAM_T *lastparam; + Boolean print; + Boolean printMe; + + if (!opt->names[0] && !(lst->flags & LISTFLAGS_4)) + return 0; + + if (keyword && keyword[0] && !strstr(opt->names, keyword) && (!opt->help || !strstr(opt->help, keyword))) + return 0; + + if ((opt->avail & OTF_SECRET) && !(parseopts.helpFlags & HELPFLAGS_SECRET)) + return 0; + + if ((opt->avail & OTF_OBSOLETE) && !(parseopts.helpFlags & HELPFLAGS_OBSOLETE)) + return 0; + + if ((opt->avail & OTF_DEPRECATED) && !(parseopts.helpFlags & HELPFLAGS_DEPRECATED)) + return 0; + + if ((opt->avail & OTF_IGNORED) && !(parseopts.helpFlags & HELPFLAGS_IGNORED)) + return 0; + + if ((opt->avail & OTF_MEANINGLESS) && !(parseopts.helpFlags & HELPFLAGS_MEANINGLESS)) + return 0; + + if (!(parseopts.helpFlags & HELPFLAGS_NORMAL) && !(opt->avail & OTF_ALL_HIDDEN_BY_DEFAULT)) + return 0; + + if (opt->help || (opt->avail & OTF_HAS_SUB_OPTIONS)) { + allNoArgs = 1; + lastparam = 0; + if (parseopts.helpFlags & HELPFLAGS_SPACES) + Help_NewLine(); + if ((opt->avail & OTF_GLOBAL) && !subprint) + Side_Print(&right, "global; "); + if (compat != 1 && (opt->avail & OTF_CASED)) + Side_Print(&right, "cased; "); + + slflags = (subprint == 0) ? SLFLAGS_1 : SLFLAGS_2; + switch (opt->avail & OTF_SLFLAGS_MASK) { + case OTF_SLFLAGS_8: + slflags = slflags | SLFLAGS_8; + break; + case OTF_SLFLAGS_10: + slflags = slflags | SLFLAGS_10; + break; + case OTF_SLFLAGS_20: + slflags = slflags | SLFLAGS_20; + break; + } + if (opt->avail & OTF_STICKY) + slflags = slflags | SLFLAGS_40; + + Utils_SpellList(opt->names[0] ? opt->names : "...", pfbuf, slflags); + Side_Print(&left, pfbuf); + + if (opt->avail & OTF_OBSOLETE) + Side_Print(&right, "obsolete;\r"); + if (opt->avail & OTF_COMPATIBILITY) + Side_Print(&right, "compatibility;\r"); + if (opt->avail & OTF_IGNORED) + Side_Print(&right, "ignored;\r"); + + listFlags = ((lst->flags & LISTFLAGS_COMPILER) ? OTF_TOOL_COMPILER : 0) | ((lst->flags & LISTFLAGS_LINKER) ? OTF_TOOL_LINKER : 0) | ((lst->flags & LISTFLAGS_DISASSEMBLER) ? OTF_TOOL_DISASSEMBLER : 0); + if (!Option_ForThisTool(opt) || Option_AlsoPassedFromThisTool(opt) || listFlags != Option_ThisTool()) { + print = 0; + printMe = 1; + if ((opt->avail & OTF_TOOL_MASK) != (unsigned int) listFlags) + print = 1; + if (Option_ForThisTool(opt) && Option_AlsoPassedFromThisTool(opt)) + printMe = 0; + + if (print) { + char opttool[64] = ""; // stack 0x44 + if ((opt->avail & OTF_TOOL_MASK) == (unsigned int) OTF_TOOL_MASK) { + strcat(opttool, "all tools"); + } else { + if (Option_ForTool(opt, OTF_TOOL_COMPILER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_COMPILER) || printMe)) { + strcat(opttool, "this tool"); + } + if (Option_ForTool(opt, OTF_TOOL_LINKER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_LINKER) || printMe)) { + if (opttool[0]) + strcat(opttool, ", "); + strcat(opttool, "linker"); + } + if (Option_ForTool(opt, OTF_TOOL_DISASSEMBLER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_DISASSEMBLER) || printMe)) { + if (opttool[0]) + strcat(opttool, ", "); + strcat(opttool, "disassembler"); + } + if (!Option_ForTool(opt, OTF_TOOL_MASK)) + strcat(opttool, "another tool"); + } + + if (printMe || !Option_ForThisTool(opt)) { + Side_Print(&right, "for %s;\r", opttool); + } else if (parseopts.passingArgs) { + Side_Print(&right, "passed to %s;\r", opttool); + } + } + } + + if (opt->avail & OTF_WARNING) + Side_Print(&right, "warning:\r"); + + if (opt->avail & OTF_DEPRECATED) + Side_Print(&right, "deprecated;\rinstead use "); + else if (opt->avail & OTF_SUBSTITUTED) + Side_Print(&right, "substituted with "); + + if (opt->help) + Side_Print(&right, "%s", opt->help); + + if (opt->param && !(opt->avail & OTF_IGNORED)) { + PARAM_T *scan = opt->param; + PARAM_T *firstparam = 0; + const char *desc; + const char *help; + const char *defaul; + while (scan) { + if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_1) { + if (!firstparam) + firstparam = scan; + + allNoArgs = 0; + Param_DescHelp(scan, &desc, &help, &defaul); + if (desc) { + if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { + if (SEPOPTSTR[0] == ' ') { + Side_Print(&left, (scan != firstparam) ? "[," : subprint ? "[=" : " ["); + } else { + Side_Print(&left, "[%s", (scan != firstparam) ? "," : subprint ? "=" : SEPOPTSTR); + } + } else { + Side_Print(&left, (scan != firstparam) ? "," : subprint ? "=" : ((opt->avail & OTF_STICKY) && !strchr(opt->names, '|')) ? "" : SEPOPTSTR); + } + Side_Print(&left, "%s", desc); + if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { + Side_Print(&left, "]"); + } + if (help) { + if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_2) + Side_Print(&right, "; for '%s', %s", desc, help); + else + Side_Print(&right, "; if parameter specified, %s", help); + } + if (defaul && !(opt->avail & OTF_HIDE_DEFAULT)) { + if (firstparam == scan) + Side_Print(&right, "; default is %s", defaul); + else + Side_Print(&right, ",%s", defaul); + } + } + } + lastparam = scan; + scan = scan->next; + } + + if (allNoArgs && !(opt->avail & OTF_HIDE_DEFAULT)) { + PARAM_T *scan = opt->param; + Boolean isdefault = scan ? 1 : 0; + while (scan && isdefault) { + isdefault &= Param_Compare(scan); + scan = scan->next; + } + + if (isdefault) + Side_Print(&right, "; default"); + } + } + + if (opt->avail & OTF_MEANINGLESS) + Side_Print(&right, "; meaningless for this target"); + + if ((opt->avail & OTF_HAS_SUB_OPTIONS) && opt->sub) { + if (!allNoArgs) { + Side_Print( + &left, + "%s", + (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? ((lastparam->flags & PARAMFLAGS_8) ? "[=" : "[,") : ((lastparam->flags & PARAMFLAGS_8) ? "=" : ",") + ); + } else if (!(opt->avail & OTF_STICKY)) { + if (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) { + if (SEPOPTSTR[0] == ' ') + Side_Print(&left, subprint ? "[=" : " ["); + else + Side_Print(&left, "[%s", subprint ? "=" : SEPOPTSTR); + } else { + Side_Print(&left, "%c", subprint ? '=' : SEPOPTSTR[0]); + } + } else { + if (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) { + Side_Print(&left, subprint ? "[" : (SEPOPTSTR[0] == ' ') ? " [" : "["); + } + } + + Side_Print( + &left, + "%s%s%s", + opt->sub->help ? opt->sub->help : "keyword", + (opt->sub->flags & PARAMFLAGS_1) ? "" : "[,...]", + (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? "]" : "" + ); + + Side_Print(&left, "\t"); + Side_Print(&right, "\t"); + Help_Options(opt->sub, 1, ""); + Side_Print(&right, "\b"); + Side_Print(&left, "\b"); + } else { + Side_Print(&left, "\n"); + Side_Print(&right, "\n"); + } + } + + Help_Flush(); + return 1; +} + +void Help_Options(struct OptionList *lst, int subprint, const char *keyword) { + Option **opts; + int toolflags; + Boolean show; + + opts = lst->list; + toolflags = 0; + if (Option_ThisTool() == OTF_TOOL_COMPILER) { + toolflags |= LISTFLAGS_COMPILER; + } else { + toolflags |= LISTFLAGS_LINKER; + } + + // review me maybe? + if (!subprint && (parseopts.helpFlags & HELPFLAGS_TOOL)) { + if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_THIS && (lst->flags & LISTFLAGS_TOOL_MASK) && !(lst->flags & toolflags)) + return; + if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_OTHER && (((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) toolflags) || ((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) LISTFLAGS_NONE))) + return; + } + + if (lst->help && !subprint && opts[0]) { + Help_Line('-'); + Side_Print(&all, "%s", lst->help); + Help_OutputSingle(&all); + Help_Line('-'); + } + + while (*opts) { + show = 0; + if (!(parseopts.helpFlags & HELPFLAGS_TOOL)) { + if (((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) && (parseopts.passingArgs ? (Option_ForTool(*opts, OTF_TOOL_LINKER) || Option_ForTool(*opts, OTF_TOOL_DISASSEMBLER)) : 1) && Option_ForThisTool(*opts)) + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) { + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_THIS) && Option_ForThisTool(*opts)) { + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && !Option_ForThisTool(*opts)) { + show = 1; + } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && Option_ForTool(*opts, ~Option_ThisTool() & OTF_TOOL_MASK)) { + show = 1; + } + + if (show) + Help_Option(lst, *opts, subprint, keyword); + + ++opts; + } + + if (subprint && (parseopts.helpFlags & HELPFLAGS_SPACES)) + Help_NewLine(); + Help_Flush(); + if (!subprint) + HPrintF(helptext, "\n"); +} + +void Help_Usage(void) { + Side_Print( + &all, + "\tGuide to help:\b" + "\tWhen an option is specified as '~~xxx | yy[y] | zzz', then either '~~xxx', '~~yy', '~~yyy', or '~~zzz' matches the option.\b" + "\tAn option given as '~~[no]xxx' may be given as '~~xxx' or '~~noxxx'; '~~noxxx' reverses the meaning of the option.\b" + ); + Help_OutputSingle(&all); + + Side_Print( + &all, + "\tFor most options, the option and the parameters are separated by a %sspace. When the option's name is '~~xxx+', however, the parameter must directly follow the option, without the '+' (as in '~~xxx45').\b", + (compat != 1) ? "" : "colon or " + ); + Side_Print( + &all, + "\tA parameter included in brackets '[]' is optional. An ellipsis '...' indicates that the previous type of parameter may be repeated as a list.\b" + ); + Help_OutputSingle(&all); + + Side_Print( + &all, + "\t%s-- \"compatability\" indicates that the option is borrowed from another vendor's tool and may only approximate its counterpart.\r" + "-- \"global\" indicates that the option has an effect over the entire command line and is parsed before any other options. When several global options are specified, they are interpreted in order.\r" + "-- \"deprecated\" indicates that the option will be eliminated in the future and should not be used any longer. An alternative form is supplied.\r", + (compat != 1) ? "-- \"cased\" indicates that the option is case-sensitive. By default, no options are case-sensitive.\r" : ""); + Help_OutputSingle(&all); + + Side_Print( + &all, + "-- \"ignored\" means the option will be accepted but has no effect on the tool.\r" + "-- \"meaningless\" means the option is accepted but probably has no meaning for the target OS.\r" + "-- \"obsolete\" means the option was once deprecated and is now gone.\r" + "-- \"substituted\" means the option has the same effect as another. This points out a preferred form and prevents confusion when similar options appear in the help.\r" + "-- \"default\" in the help text indicates that the given value or variation of an option will be used unless otherwise overridden. \b" + ); + Help_OutputSingle(&all); + + Side_Print( + &all, + "\tThe symbols ',' %s separate options and parameters unconditionally; to include one of these symbols in a parameter or filename, escape it (e.g., as '\\,' in mwcc file.c\\,v).\b\n", + (compat != 1) ? "and '='" : ", ':', and '='" + ); + Help_OutputSingle(&all); + + if (parseopts.passingArgs && pTool->TYPE == CWDROPINCOMPILERTYPE) + Side_Print( + &all, + "\tThis tool calls the linker (unless a compiler option such as ~~c prevents it) and understands linker options -- use '~~help tool=other' to see them. Options marked \"passed to linker\" are used by the compiler and the linker; options marked \"for linker\" are used only by the linker. When using the compiler and linker separately, you must pass the common options to both.\b\n" + ); + Help_OutputSingle(&all); +} + +void Help_Null(void) { + Side_Print(&all, + "%s [options, filenames...]\n\nExecute '%s %shelp' for more information.", + OS_GetFileNamePtr(parseopts.args->argv[0]), + OS_GetFileNamePtr(parseopts.args->argv[0]), + MAINOPTCHAR + ); + Help_OutputSingle(&all); +} + +void Help_Init(void) { + short lb; + short le; + short rb; + short re; + + if (!(helptext = NewHandle(0))) { + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } + + lb = parseopts.ioCols / 40; + le = (parseopts.ioCols / 3) + lb; + rb = le + 3 + ((parseopts.ioCols / 60) & ~1); + re = parseopts.ioCols - 1; + Side_Init(&left, lb, le - lb); + Side_Init(&right, rb, re - rb); + Side_Init(&all, 0, re); +} + +void Help_Line(char ch) { + char line[256]; + memset(line, ch, 255); + line[255] = 0; + HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, line); +} + +void Help_Term(void) { + ShowTextHandle(0, helptext); + DisposeHandle(helptext); +} diff --git a/command_line/C++_Parser/Src/Library/IO.c b/command_line/C++_Parser/Src/Library/IO.c new file mode 100644 index 0000000..36d809b --- /dev/null +++ b/command_line/C++_Parser/Src/Library/IO.c @@ -0,0 +1,83 @@ +#include "parser.h" + +void ShowTextHandle(const char *description, Handle text) { + CWMemHandle mh; + + if (!text) + return; + + if (description) + CLPStatus(71, description); + CWSecretAttachHandle(parseopts.context, text, &mh); + CWParserDisplayTextHandle(parseopts.context, description, mh); +} + +void ShowVersion(Boolean decorate) { + char *vplugin; + char *valtplugin; + const char *bdate; + const char *btime; + Handle txt; + int x; + + vplugin = 0; + valtplugin = 0; + if (parseopts.printedVersion) + return; + + txt = NewHandle(0); + if (!txt) { + fprintf(stderr, "\n*** Out of memory\n"); + exit(-23); + } + + for (x = 0; x < parseopts.numPlugins; x++) { + if (parseopts.plugins[x].plugintype == CWDROPINDRIVERTYPE) continue; + if (parseopts.plugins[x].plugintype == CWDROPINPARSERTYPE) continue; + + if (pTool->TYPE == parseopts.plugins[x].plugintype) { + if (!vplugin && pTool->LANG == parseopts.plugins[x].language) + vplugin = parseopts.plugins[x].version; + else + valtplugin = parseopts.plugins[x].version; + } + } + + CWParserGetBuildDate(parseopts.context, &bdate, &btime); + HPrintF(txt, "\n"); + if (parseopts.toolVersion) { + HPrintF( + txt, + "%s.\n%s, %s\nAll rights reserved.\n%s\n", + pTool->toolInfo, + parseopts.toolVersion->copyright, + parseopts.toolVersion->company, + parseopts.toolVersion->version + ); + } else { + HPrintF( + txt, + "%s.\nCopyright (c)%s Metrowerks, Inc.\nAll rights reserved.\n%s\n", + pTool->toolInfo, + pTool->copyright, + vplugin ? vplugin : valtplugin ? valtplugin : "" + ); + } + + HPrintF(txt, "Runtime Built: %s %s\n", bdate, btime); + HPrintF(txt, "\n"); + + if (decorate) { + HPrintF( + txt, + "Please enter '%s %chelp' for information about options.\n\n", + OS_GetFileNamePtr(parseopts.args->argv[0]), + MAINOPTCHAR[0] + ); + } + + ShowTextHandle(0, txt); + DisposeHandle(txt); + + parseopts.printedVersion = 1; +} diff --git a/command_line/C++_Parser/Src/Library/OptimizerHelpers.c b/command_line/C++_Parser/Src/Library/OptimizerHelpers.c new file mode 100644 index 0000000..4085363 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/OptimizerHelpers.c @@ -0,0 +1,166 @@ +#include "parser.h" + +Boolean setOldOptimizerOptions; + +typedef struct { + Boolean commonsubs; + Boolean loopinvariants; + Boolean propagation; + Boolean deadstore; + Boolean strengthreduction; + Boolean deadcode; + Boolean lifetimes; +} PIROptimizer; // assumed name + +static PIROptimizer pIrOptimizer = {0}; + +Pragma irPragmas[] = { + &pIrOptimizer.commonsubs, "opt_common_subs", 0, + &pIrOptimizer.loopinvariants, "opt_loop_invariants", 0, + &pIrOptimizer.propagation, "opt_propagation", 0, + &pIrOptimizer.deadstore, "opt_dead_assignments", 0, + &pIrOptimizer.deadcode, "opt_dead_code", 0, + &pIrOptimizer.strengthreduction, "opt_strength_reduction", 0, + &pIrOptimizer.lifetimes, "opt_lifetimes", 0, + 0, 0, 0 +}; + +int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int) { + if (setOldOptimizerOptions) + Option_Warning(CLPStr62); + + memset(&pIrOptimizer, 0, sizeof(pIrOptimizer)); + TargetSetPragmaOptimizationsToUnspecified(); + return 1; +} + +int SetOptFlags(const char *opt, void *str, const char *, int flags) { + // this is very similar to ToolHelper + // might also fail to match + unsigned char *ptr; + Boolean set; + Boolean no; + UInt16 flag; + + ptr = (unsigned char *) str; + no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3); + set = (Boolean) (no ^ 1); + + while (*ptr) { + if (*ptr == '+') { + set = !no; + } else if (*ptr == '-') { + set = no; + } else if (*ptr == '|') { + set = (Boolean) (no ^ 1); + } else { + flag = (ptr[0] << 8) | ptr[1]; + + if ((flag >= 'G0' && flag <= 'G4') || (flag == 'Gs') || (flag == 'Gp')) + SetPragmaOptimizationsToUnspecified(opt, NULL, NULL, 0); + + switch (flag) { + case 'Cs': + pIrOptimizer.commonsubs = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Li': + pIrOptimizer.loopinvariants = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Pr': + pIrOptimizer.propagation = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Ds': + pIrOptimizer.deadstore = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Sr': + pIrOptimizer.strengthreduction = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Dc': + pIrOptimizer.deadcode = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'Lt': + pIrOptimizer.lifetimes = set ? 1 : 2; + setOldOptimizerOptions = 1; + break; + case 'G0': + pGlobalOptimizer.optimizationlevel = set ? 0 : 0; + break; + case 'G1': + pGlobalOptimizer.optimizationlevel = set ? 1 : 0; + break; + case 'G2': + pGlobalOptimizer.optimizationlevel = set ? 2 : 0; + break; + case 'G3': + pGlobalOptimizer.optimizationlevel = set ? 3 : 0; + break; + case 'G4': + pGlobalOptimizer.optimizationlevel = set ? 4 : 0; + break; + case 'Gs': + pGlobalOptimizer.optfor = set ? 1 : 0; + break; + case 'Gp': + pGlobalOptimizer.optfor = set ? 0 : 1; + break; + default: + if (!TargetSetOptFlags(flag, set)) + CLPFatalError("Bad optimizer settings in %s (%c%c)\n", str, ptr[0], ptr[1]); + } + + ++ptr; + } + + ++ptr; + } + + return 1; +} + +int DisplayOptimizationOptions(const char *, void *, const char *, int) { + SInt32 oldsize; + Handle h; + + h = NewHandle(0); + if (!h) + exit(-23); + + HPrintF(h, "\t- global optimizer level %d\n", pGlobalOptimizer.optimizationlevel); + HPrintF(h, "\t- global optimize for %s\n", (pGlobalOptimizer.optfor == 0) ? "speed" : "size"); + + oldsize = GetHandleSize(h); + if (pIrOptimizer.commonsubs) + HPrintF(h, "\t- common subexpression elimination %s\n", (pIrOptimizer.commonsubs == 1) ? "on" : "off"); + if (pIrOptimizer.loopinvariants) + HPrintF(h, "\t- loop invariants %s\n", (pIrOptimizer.loopinvariants == 1) ? "on" : "off"); + if (pIrOptimizer.commonsubs) + HPrintF(h, "\t- constant propagation %s\n", (pIrOptimizer.propagation == 1) ? "on" : "off"); + if (pIrOptimizer.deadstore) + HPrintF(h, "\t- dead store elimination %s\n", (pIrOptimizer.deadstore == 1) ? "on" : "off"); + if (pIrOptimizer.deadcode) + HPrintF(h, "\t- dead code elimination %s\n", (pIrOptimizer.deadcode == 1) ? "on" : "off"); + if (pIrOptimizer.strengthreduction) + HPrintF(h, "\t- strength reduction %s\n", (pIrOptimizer.strengthreduction == 1) ? "on" : "off"); + if (pIrOptimizer.lifetimes) + HPrintF(h, "\t- variable lifetimes %s\n", (pIrOptimizer.lifetimes == 1) ? "on" : "off"); + + if (oldsize == GetHandleSize(h)) + HPrintF(h, "\t- no extra global optimizations\n"); + + HPrintF(h, "Backend-specific optimizer options:\n"); + + oldsize = GetHandleSize(h); + TargetDisplayOptimizationOptions(h); + if (oldsize == GetHandleSize(h)) + HPrintF(h, "\t- no extra backend-specific optimizations\n"); + + ShowTextHandle(NULL, h); + DisposeHandle(h); + return 1; +} diff --git a/command_line/C++_Parser/Src/Library/Option.c b/command_line/C++_Parser/Src/Library/Option.c new file mode 100644 index 0000000..2a53f38 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/Option.c @@ -0,0 +1,1136 @@ +#include "parser.h" + +#define MAXSTACK 8 + +static OptionList *optionlists[32]; +int numoptionlists; +static OptionList internalset; +static OptionList legalset; +int numinternalset; +int numlegalset; +int maxlegalset; +char curopt[1024]; +Opt48 oStack[8]; +int oStackPtr; + +enum { + ARGFLAG_1 = 1, + ARGFLAG_2 = 2, + ARGFLAG_4 = 4, + ARGFLAG_8 = 8, + ARGFLAG_10 = 0x10, + ARGFLAG_20 = 0x20, + ARGFLAG_40 = 0x40, + ARGFLAG_80 = 0x80 +}; + +enum { + ARGSPELLFLAG_1 = 1, + ARGSPELLFLAG_2 = 2, + ARGSPELLFLAG_4 = 4, + ARGSPELLFLAG_8 = 8, + ARGSPELLFLAG_10 = 0x10, + ARGSPELLFLAG_20 = 0x20, + ARGSPELLFLAG_40 = 0x40, + ARGSPELLFLAG_80 = 0x80 +}; + +enum { + OPTSPELLFLAG_1 = 1, + OPTSPELLFLAG_2 = 2, + OPTSPELLFLAG_4 = 4, + OPTSPELLFLAG_8 = 8, + OPTSPELLFLAG_10 = 0x10, + OPTSPELLFLAG_20 = 0x20, + OPTSPELLFLAG_40 = 0x40, + OPTSPELLFLAG_80 = 0x80 +}; + +static void Option_PushList(OptionList *lst) { + Args_Push(1, lst, 0); +} + +static void Option_PushOpt(Option *opt, const char *optname) { + char *cpy; + short flags = ARGFLAG_2; + if (opt && (opt->avail & OTF_STICKY)) { + if (Utils_CompareOptionString(opt->names, optname, opt->avail & OTF_CASED, OTF_STICKY)) { + flags |= ARGFLAG_80; + } + } + cpy = xstrdup(optname); + Args_Push(flags, opt, cpy); +} + +static void Option_PopOpt(char *optname) { + Opt48 *os = Args_Pop(ARGFLAG_2); + if (optname) + strcpy(optname, os->e.o.curopt); + free(os->e.o.curopt); +} + +static void Option_PopList(void) { + Args_Pop(ARGFLAG_1); +} + +void Args_InitStack(void) { + oStackPtr = 0; +} +int Args_StackSize(void) { + return oStackPtr; +} + +void Args_Push(short flags, void *first, void *second) { + OS_ASSERT(104, oStackPtr 0) { + short prev = + (flags & ARGFLAG_1) ? ARGFLAG_2 : + (flags & ARGFLAG_2) ? ARGFLAG_1 : + (flags & ARGFLAG_4) ? ARGFLAG_2 : -1; + OS_ASSERT(111, oStack[oStackPtr-1].flags & prev); + } + + oStack[oStackPtr].e.v.first = first; + oStack[oStackPtr].e.v.second = second; + oStack[oStackPtr].flags = flags; + oStackPtr++; +} + +Opt48 *Args_Pop(short flags) { + OS_ASSERT(122, oStackPtr>0); + --oStackPtr; + OS_ASSERT(124, oStack[oStackPtr].flags & flags); + return &oStack[oStackPtr]; +} + +void Args_SpellStack(char *buffer, short flags) { + char *bptr; + Opt48 *os; + int sp; + int level; + + bptr = buffer; + sp = 0; + level = 0; + os = &oStack[sp]; + + while (sp < oStackPtr) { + if (!flags || !(os->flags & ARGFLAG_20)) { + if (os->flags & ARGFLAG_4) { + Opt48 *po = os - 1; + if (!(os[-1].flags & ARGFLAG_40)) { + if ((level == 1 || level == 2) && !(po->flags & ARGFLAG_80)) + *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; + os[-1].flags |= ARGFLAG_40; + } else if (level == 2) { + *(bptr++) = ','; + } else if (level == 3) { + *(bptr++) = '='; + } + strcpy(bptr, os->e.param); + bptr += strlen(bptr); + } else if (os->flags & ARGFLAG_2) { + if (level == 1) { + *(bptr++) = MAINOPTCHAR[0]; + } else if (level == 2) { + Opt48 *po = os - 2; + if (!(os[-1].flags & ARGFLAG_40) && !(po->flags & ARGFLAG_80)) + *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; + } + + if (os[-1].flags & ARGFLAG_40) { + if (level == 2) { + if (flags & ARGSPELLFLAG_20) + *(bptr++) = ','; + else + *(bptr++) = ' '; + } + } else { + if (level == 3) { + *(bptr++) = '='; + } + } + + os[-1].flags |= ARGFLAG_40; + strcpy(bptr, os->e.o.curopt); + bptr += strlen(bptr); + } + + if (flags & ARGSPELLFLAG_20) + os->flags |= ARGFLAG_20; + } + + if (os->flags & ARGFLAG_1) + level++; + + ++sp; + ++os; + } +} + +void Args_AddToToolArgs(anon0_50 *ta) { + char buffer[4096]; + char *nptr; + + Args_SpellStack(buffer, ARGSPELLFLAG_20); + nptr = strchr(buffer, '\n'); + if (nptr) { + *(nptr++) = 0; + Arg_AddToToolArgs(ta, 2, buffer); + Arg_AddToToolArgs(ta, 1, 0); + } else { + nptr = buffer; + } + Arg_AddToToolArgs(ta, 2, nptr); +} + +void Options_Init(void) { + numoptionlists = 0; + maxlegalset = 0; + numlegalset = 0; + numinternalset = 0; + + if (legalset.list) + free(legalset.list); + if (internalset.list) + free(internalset.list); + + legalset.list = 0; + legalset.flags = + ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | + ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | + ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); + internalset.list = 0; + internalset.flags = + ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | + ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | + ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); + + Args_InitStack(); +} + +OptionList *Options_GetOptions(void) { + return &legalset; +} + +void Options_SortOptions(void) { + int r; + + if (numinternalset > 0) { + legalset.list = (Option **) xrealloc("options", legalset.list, sizeof(Option *) * (numinternalset + 1)); + for (r = 0; r < numinternalset; r++) { + if (internalset.list[r]->avail & (OTF_STICKY | OTF_CASED)) + legalset.list[numlegalset++] = internalset.list[r]; + } + for (r = 0; r < numinternalset; r++) { + if (!(internalset.list[r]->avail & (OTF_STICKY | OTF_CASED))) + legalset.list[numlegalset++] = internalset.list[r]; + } + legalset.list[numlegalset] = 0; + + if (internalset.list) + free(internalset.list); + internalset.list = 0; + numinternalset = 0; + } +} + +static void Options_AddOption(Option *opt) { + if (numinternalset >= maxlegalset) { + maxlegalset += 32; + internalset.list = (Option **) xrealloc("options", internalset.list, sizeof(Option *) * (maxlegalset + 1)); + } + + internalset.list[numinternalset++] = opt; + internalset.list[numinternalset] = 0; +} + +int Options_AddList(OptionList *optlst) { + Option **ptr; + + if (numoptionlists >= 32) + CLPFatalError("Too many option lists defined!"); + + optionlists[numoptionlists++] = optlst; + for (ptr = optlst->list; *ptr; ptr++) + Options_AddOption(*ptr); + + return 1; +} + +int Options_AddLists(OptionList **optlst) { + int ret = 1; + OptionList **ptr; + + for (ptr = optlst; *ptr; ptr++) { + ret = Options_AddList(*ptr); + if (!ret) + return ret; + } + + return ret; +} + +static void Options_Reset(OptionList *optlst) { + Option **os; + + os = optlst->list; + if (os) { + for (; *os; os++) { + (*os)->avail &= ~(OTF_INTERNAL_ALREADY_SEEN | OTF_INTERNAL_SEEN_CONFLICTED); + } + } +} + +static void Option_SpellList(char *buffer, OptionList *conflicts, int flags) { + Option **scan; + Boolean first; + int total; + char tmp[256]; + Option **next; + int slflags; + + scan = conflicts->list; + first = 1; + total = 0; + 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]) { + if (!first) + buffer += sprintf(buffer, ", "); + if (first) + first = 0; + + if (total > 1) { + while (*next && (((*next)->avail & (((parseopts.helpFlags & HELPFLAGS_SECRET) ? 0 : OTF_SECRET) | ((parseopts.helpFlags & HELPFLAGS_DEPRECATED) ? 0 : OTF_DEPRECATED) | OTF_SUBSTITUTED)) || !(*next)->names[0])) { + ++next; + } + + if (!*next) + buffer += sprintf(buffer, "or "); + } + + slflags = (flags & OPTSPELLFLAG_2) ? SLFLAGS_2 : SLFLAGS_1; + switch ((*scan)->avail & OTF_SLFLAGS_MASK) { + case OTF_SLFLAGS_8: + slflags |= SLFLAGS_8; + break; + case OTF_SLFLAGS_20: + slflags |= SLFLAGS_20; + break; + case OTF_SLFLAGS_10: + slflags |= SLFLAGS_10; + break; + } + + Utils_SpellList((*scan)->names, tmp, slflags); + total++; + buffer += sprintf(buffer, "%s", tmp); + + if ((*scan)->avail & OTF_HAS_SUB_OPTIONS) + buffer += sprintf(buffer, " ..."); + } + scan++; + } +} + +int Option_ForTool(Option *opt, int which) { + return !which || (opt->avail & which); +} + +int Option_ThisTool(void) { + return (pTool->TYPE == CWDROPINCOMPILERTYPE) ? OTF_TOOL_COMPILER : OTF_TOOL_LINKER; +} + +int Option_ForThisTool(Option *opt) { + return !Option_ForTool(opt, OTF_TOOL_MASK) || Option_ForTool(opt, Option_ThisTool()); +} + +int Option_AlsoPassedToTool(Option *opt, int which) { + return Option_ForThisTool(opt) && Option_ForTool(opt, which); +} + +int Option_AlsoPassedFromThisTool(Option *opt) { + return Option_ForThisTool(opt) && Option_ForTool(opt, ~Option_ThisTool() & OTF_TOOL_MASK); +} + +static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok) { + ArgToken *tmp; + int ret; // not in stabs but i think this exists + + if (level == 1) { + return (tok->val == ATK_ARG_END) || (tok->val == ATK_OPTION) || (tok->val == ATK_ARG); + } else if (level == 2) { + tmp = Arg_UsedToken(); + ret = (tok->val == ATK_COMMA && tmp->val != ATK_OPTION) || (tok->val == ATK_ARG && tmp->val != ATK_ARG_END); + Arg_UndoToken(); + return ret; + } else if (level == 3) { + return (tok->val == ATK_EQUALS) || (tok->val == ATK_ARG); + } else { + return 0; + } +} + +static short endingStack[5][3] = { + ATK_END, ATK_END, ATK_END, + ATK_ARG_END, ATK_COMMA, ATK_OPTION, + ATK_COMMA, ATK_END, ATK_END, + ATK_EQUALS, ATK_END, ATK_END, + ATK_END, ATK_END, ATK_END +}; +static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok) { + ArgToken *tmp; + + if (!tok) + 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) { + if (!tok) + return 1; + + while (level > 0) { + if (Option_IsEndingThisLevel(level - 1, tok)) + return 1; + level--; + } + + return 0; +} + +int Option_Parse(Option *opt, int oflags) { + 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 & OTF_INTERNAL_ALREADY_SEEN) && (opt->avail & OTF_ONLY_ONCE)) { + Option_Warning(CLPStr30_OptionShouldNotBeSpecifiedMultipleTimes); + } else if (opt->avail & OTF_HAS_CONFLICTS) { + cscan = opt->conflicts->list; + while (*cscan && (*cscan == opt || !((*cscan)->avail & OTF_INTERNAL_ALREADY_SEEN))) { + ++cscan; + } + + if (*cscan && *cscan != opt) { + (*cscan)->avail &= ~OTF_INTERNAL_ALREADY_SEEN; + Option_SpellList(errstr, opt->conflicts, oflags); + if (opt->conflicts->help) + Option_Warning(CLPStr32_OptionOverridesEffectWithHelp, (*cscan)->names, errstr, opt->conflicts->help); + else + Option_Warning(CLPStr31_OptionOverridesEffect, (*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_ARG_END, 0); + Args_AddToToolArgs(&linkargs); + } + + if (!(flags & PFLAGS_1)) { + if (opt->avail & OTF_OBSOLETE) { + if (opt->help) + Option_Error(CLPStr22_OptionObsoleteWithHelp, opt->help); + else + Option_Error(CLPStr21_OptionObsolete); + flags |= PFLAGS_1; + } + + if (opt->avail & OTF_IGNORED) { + if (!(opt->avail & (OTF_WARNING | OTF_MEANINGLESS))) { + if (opt->help) + Option_Warning(CLPStr27_OptionIgnoredWithText, opt->help); + else + Option_Warning(CLPStr26_OptionIgnored); + } + flags |= PFLAGS_1; + } else if (opt->avail & OTF_SUBSTITUTED) { + Option_Warning(CLPStr23_OptionXSubstitutedWithX, curopt, opt->help); + } else if (opt->avail & OTF_DEPRECATED) { + if (opt->help) + Option_Warning(CLPStr25_OptionDeprecatedWithHelp, opt->help); + else + Option_Warning(CLPStr24_OptionDeprecated); + } + + if (opt->avail & OTF_WARNING) + Option_Warning(CLPStr28_WarningText, opt->help); + if (opt->avail & OTF_MEANINGLESS) + Option_Warning(CLPStr29_OptionHasNoEffect); + } + + opt->avail |= OTF_INTERNAL_ALREADY_SEEN; + if (opt->avail & OTF_HAS_CONFLICTS) { + scan = opt->conflicts->list; + opt->avail |= OTF_INTERNAL_SEEN_CONFLICTED; + while (*scan) { + (*scan)->avail |= OTF_INTERNAL_SEEN_CONFLICTED; + scan++; + } + } + } else { + flags |= PFLAGS_1; + } + + goingtosubparse = opt->avail & OTF_HAS_SUB_OPTIONS; + if (opt->param) { + ret = Params_Parse(opt->param, flags | (goingtosubparse ? PFLAGS_20 : 0)); + } else { + tok = Arg_PeekToken(); + if (tok && tok->val == ATK_EQUALS) + 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 & OTF_SUB_OPTIONS_OPTIONAL) ? OFLAGS_4 : 0) + ); + } + + if (pushed) + Option_PopOpt(curopt); + + if (Option_ThisTool() == OTF_TOOL_COMPILER && !subparse) + Arg_AddToToolArgs(&linkargs, ATK_ARG_END, 0); + + return ret; +} + +static int Option_MatchString(char *list, char *str, int flags, int *result) { + 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) { + 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 & OTF_STICKY) == OTF_STICKY) { + 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 & OTF_STICKY) { + matched = Utils_CompareOptionString((*os)->names, curopt, (*os)->avail & OTF_CASED, 2); + if (matched) + stickyflags |= OTF_STICKY; + } else { + matched = 0; + } + + if (matched) + stickyopt = *os; + + ++os; + } + } + + *flags = stickyflags; + return stickyopt; +} + +static int Options_DoParse(OptionList *search, int flags) { + // 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 *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_OPTION)) || ((mystery_r31 == 2) && (token_r18->val == ATK_ARG) && (token_r18->text[0] || search->flags & LISTFLAGS_4)) || ((mystery_r31 == 3) && (token_r18->val == ATK_EQUALS)); + // 950 17CFD4 + if ((mystery_r31 == 3) && isOpt) { + token_r18 = Arg_UsedToken(); + isOpt = token_r18 && (token_r18->val == ATK_ARG); + 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_OPTION) + 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(CLPStr34_ArgumentsExpected, 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_EQUALS) + 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_ALLOW_UNKNOWNS) { + if (!(flags & OFLAGS_1)) { + Option_SpellList(curparam, search, flags); + Option_Warning(CLPStr20_UnknownOptionX_ExpectedOneOfX, token_r18->text, curparam); + } + Arg_UsedToken(); + parsedany = 1; + } else { + // 1090 + Option_SpellList(curparam, search, flags); + Option_Error(CLPStr20_UnknownOptionX_ExpectedOneOfX, token_r18->text, curparam); + failed = 1; + haderrors++; + } + } else { + // 1099 + if ((search->flags & LISTFLAGS_ALLOW_UNKNOWNS) || parseopts.ignoreUnknown) { + // 1101 + if (!(flags & OFLAGS_1)) + Option_Warning(CLPStr19_UnknownOptionX, token_r18->text); + Arg_UsedToken(); + Arg_GetToken(); + parsedany = 1; + } else { + // 1115 + Option_Error(CLPStr19_UnknownOptionX, 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_ARG)) { + // 1142 + opttok = 0; + curopt[0] = 0; + opt = Option_Lookup(search, 0, &matchflags); + strcpy(curopt, token_r18->text); + if (!opt) { + Option_Warning(CLPStr33_NoDefaultHandlerSetUpForX_Ignoring, curopt); + failed = 1; + } else { + if (!(flags & OFLAGS_1)) { + haderrors = Option_Parse(opt, flags) == 0; + } else { + parseopts.possibleFiles++; + haderrors = 0; + } + parsedany++; + 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(CLPStr34_ArgumentsExpected, 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_ARG) && (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(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + Option_PopOpt(0); + } else { + CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, 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_OPTION)) { + // 1280 + if (opttok) { + Option_PushOpt(0, opttok->text); + if (tok->val == ATK_ARG) + Param_Error(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + else + Param_Error(CLPStr35_TokenXNotExpected, Arg_GetTokenName(prev)); + Option_PopOpt(opttok->text); + } else if (tok->val == ATK_ARG) { + // 1292 + CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + } else { + // 1294 + CLPReportError(CLPStr35_TokenXNotExpected, 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_ARG) + Param_Error(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + else + Param_Error(CLPStr35_TokenXNotExpected, Arg_GetTokenName(tok)); + Option_PopOpt(opttok->text); + } else if (tok->val == ATK_ARG) { + CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); + } else { + CLPReportError(CLPStr35_TokenXNotExpected, Arg_GetTokenName(tok)); + } + haderrors++; + failed++; + } + } + } // else: 1323 + + if (haderrors || failed) { + while (!Option_IsEndingLevel(mystery_r31, tok)) + tok = Arg_GetToken(); + if (!tok) + tok = Arg_UndoToken(); + OS_ASSERT(1335, 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) { + // options: r30 + // flags: r31 + int ret; // r31 + char savecuropt[64]; // stack 0x3C + + Options_Reset(options); + Option_PushList(options); + + if (!(flags & 2)) { + ret = Options_DoParse(options, flags); + if (Option_ThisTool() == OTF_TOOL_COMPILER) + Arg_AddToToolArgs(&linkargs, 1, 0); + } else { + strcpy(savecuropt, curopt); + ret = Options_DoParse(options, flags); + strcpy(curopt, savecuropt); + } + + Option_PopList(); + return ret; +} + +int Option_ParseDefaultOption(OptionList *options) { + // options: r31 + int ret; // r31 + Option *dopt; // r0 + int matchflags; // 0x3C + + Options_Reset(options); + Option_PushList(options); + + strcpy(curopt, "defaultoptions"); + dopt = Option_Lookup(options, 0, &matchflags); + if (!dopt) { + CLPFatalError("Default options not defined"); + ret = 1; + } else { + ret = Option_Parse(dopt, 0); + } + + Option_PopList(); + return ret; +} + +void Option_ParamError(short id, va_list ap) { + char buf[4096]; + + CLPGetErrorString(id, buf); + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + CLPReportError_V(buf, ap); +} + +void Option_ParamWarning(short id, va_list ap) { + char buf[1024]; + + CLPGetErrorString(id, buf); + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + CLPReportWarning_V(buf, ap); +} + +void Option_OptionError(short id, va_list ap) { + char buf[1024]; + + CLPGetErrorString(id, buf); + if (Args_StackSize() >= 2) { + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + } + CLPReportError_V(buf, ap); +} + +void Option_OptionWarning(short id, va_list ap) { + char buf[1024]; + + CLPGetErrorString(id, buf); + if (Args_StackSize() >= 2) { + sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); + Args_SpellStack(&buf[strlen(buf)], 0); + sprintf(&buf[strlen(buf)], "'"); + } + CLPReportWarning_V(buf, ap); +} + +void Option_Error(short id, ...) { + va_list va; + va_start(va, id); + Option_OptionError(id, va); + va_end(va); +} + +void Option_Warning(short id, ...) { + va_list va; + va_start(va, id); + Option_OptionWarning(id, va); + va_end(va); +} + +int Options_Help(const char *keyword) { + // keyword: r31 + int scan; // r26 + OptionList *lst; // r25 + + Help_Init(); + + if (parseopts.helpFlags & HELPFLAGS_USAGE) { + ShowVersion(1); + Help_Line('='); + Help_Usage(); + } else { + ShowVersion(1); + for (scan = 0; scan < numoptionlists; scan++) { + if ((lst = optionlists[scan])) { + if (parseopts.helpFlags & HELPFLAGS_8000) { + if (keyword && keyword[0] && lst->help && strstr(lst->help, keyword)) + Help_Options(lst, 0, ""); + } else { + Help_Options(lst, 0, keyword); + } + } + } + } + + Help_Term(); + return 1; +} + +int Option_Help(const char *opt) { + // opt: r31 + Option *find; // r29 + int matchflags; // stack 0x3C + int ret; // r29 + + find = 0; + Option_PushList(Options_GetOptions()); + Option_PushOpt(0, "help"); + if (opt[0] == MAINOPTCHAR[0]) + strcpy(curopt, opt + 1); + else + strcpy(curopt, opt); + + if (!curopt[1]) + find = Option_Lookup(Options_GetOptions(), 0x700002, &matchflags); + if (!find) + find = Option_Lookup(Options_GetOptions(), 0x700000, &matchflags); + + if (find) { + Help_Init(); + if (!Help_Option(Options_GetOptions(), find, 0, "")) + CLPReportWarning(CLPStr38_NoHelpAvailableForOptionX, opt); + Help_Term(); + ret = 1; + } else { + Option_Error(CLPStr19_UnknownOptionX, opt); + ret = 0; + } + + Option_PopOpt(curopt); + Option_PopList(); + return ret; +} + +int Options_DisplayHelp(void) { + if (parseopts.helpFlags & HELPFLAGS_1) + return Option_Help(parseopts.helpKey); + else + return Options_Help(parseopts.helpKey); +} diff --git a/command_line/C++_Parser/Src/Library/Parameter.c b/command_line/C++_Parser/Src/Library/Parameter.c new file mode 100644 index 0000000..31669e1 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/Parameter.c @@ -0,0 +1,1145 @@ +#include "parser.h" + +char curparam[4096]; +char *descparam = &curparam[0]; +char *helpparam = &curparam[1024]; +char *defaultparam = &curparam[2048]; + +#define copy_8(dst, src) \ +do { \ +((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ +} while (0) + +#define copy_16(dst, src) \ +do { \ +((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ +((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ +} while (0) + +#define copy_32(dst, src) \ +do { \ +((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ +((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ +((unsigned char *) (dst))[2] = ((unsigned char *) (src))[2]; \ +((unsigned char *) (dst))[3] = ((unsigned char *) (src))[3]; \ +} while (0) + +#define inline_write_32(dst, val) do { \ +union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ +copy_32(_arg.bytes, val); \ +_val.lg = _arg.lg; \ +copy_32(dst, _val.bytes); \ +} while (0) + +#define inline_write_16(dst, val) do { \ +union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ +copy_16(_arg.bytes, val); \ +_val.sh = _arg.sh; \ +copy_16(dst, _val.bytes); \ +} while (0) + +#define inline_write_8(ptr, val) copy_8(ptr, val) + +#define inline_andor_32(dst, and, or) do { \ +union {unsigned char bytes[4]; unsigned long lg;} _val, _arg, _arg2; \ +copy_32(_val.bytes, dst); \ +copy_32(_arg.bytes, and); \ +copy_32(_arg2.bytes, or); \ +_val.lg = (_val.lg & ~_arg.lg) | _arg2.lg; \ +copy_32(dst, _val.bytes); \ +} while(0) + +#define inline_andor_16(dst, and, or) do { \ +union {unsigned char bytes[2]; unsigned short sh;} _val, _arg, _arg2; \ +copy_16(_val.bytes, dst); \ +copy_16(_arg.bytes, and); \ +copy_16(_arg2.bytes, or); \ +_val.sh = (_val.sh & ~_arg.sh) | _arg2.sh; \ +copy_16(dst, _val.bytes); \ +} while(0) + +#define inline_andor_8(dst, and, or) do { \ +((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] & ~((unsigned char *) (and))[0]) | ((unsigned char *) (or))[0]; \ +} while(0) + +#define inline_xor_32(dst, arg) do { \ +union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ +copy_32(_val.bytes, dst); \ +copy_32(_arg.bytes, arg); \ +_val.lg = _val.lg ^ _arg.lg; \ +copy_32(dst, _val.bytes); \ +} while(0) + +#define inline_xor_16(dst, arg) do { \ +union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ +copy_16(_val.bytes, dst); \ +copy_16(_arg.bytes, arg); \ +_val.sh = _val.sh ^ _arg.sh; \ +copy_16(dst, _val.bytes); \ +} while(0) + +#define inline_xor_8(dst, arg) do { \ +((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] ^ ((unsigned char *) (arg))[0]); \ +} while(0) + +// forward declaration +static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec); +static int Param_Parse(PARAM_T *param, const char *cparam, int flags); + +static int Param_None(PARAM_T *p, const char *pstr, int flags) { + return 1; +} + +static void DescHelpParam_None(PARAM_T *p, const char **desc, const char **help, const char **defaul) { + *desc = 0; + *help = 0; + *defaul = 0; +} + +static int CompareParam_None(PARAM_T *p) { + return 0; +} + +static void DescHelpParam_Number(NUM_T *p, const char **desc, const char **help, const char **defaul) { + unsigned long value; + unsigned char value8; + unsigned short value16; + + value = 0; + *desc = 0; + if (p->myname) + *desc = p->myname; + + if (p->size == 1) { + if (!*desc) + *desc = "byte"; + if (p->num) copy_8(&value8, p->num); + value = value8; + } else if (p->size == 2) { + if (!*desc) + *desc = "short"; + if (p->num) copy_16(&value16, p->num); + value = value16; + } else if (p->size == 4) { + if (!*desc) + *desc = "long"; + if (p->num) copy_32(&value, p->num); + } + + if (p->size == 4) { + if (p->lo != p->hi) + sprintf(helpparam, "range 0x%x - 0x%x", p->lo, p->hi); + *help = helpparam; + if (value <= 0x10000) + sprintf(defaultparam, "%u", value); + else + sprintf(defaultparam, "0x%x", value); + *defaul = defaultparam; + } else { + if (p->lo != p->hi) + sprintf(helpparam, "range %u - %u", p->lo, p->hi); + *help = helpparam; + sprintf(defaultparam, "%u", value); + *defaul = defaultparam; + } + + if (!p->num) + *defaul = 0; + if (p->lo == p->hi) + *help = 0; +} + +static int CompareParam_Number(NUM_T *p) { + return 0; +} + +static int Param_Number(NUM_T *p, const char *pstr, int flags) { + unsigned long val; + unsigned long lo; + unsigned long hi; + const char *opstr; + + val = 0; + opstr = pstr; + if (!pstr[0]) { + Param_Error(5, "", pstr); + return 0; + } + + if (((*pstr == '0') && my_tolower(pstr[1]) == 'x') || (*pstr == '$')) { + // 218 + if (pstr[0] == '$') + pstr += 1; + else + pstr += 2; + + while (*pstr) { + if (!my_isxdigit(*pstr)) { + Param_Error(5, "hexadecimal ", opstr); + return 0; + } + + if (val > 0xFFFFFFF) { + Param_Error(4, opstr); + return 0; + } + + val = (val << 4) | (my_isdigit(*pstr) ? (*pstr - '0') : (my_tolower(*pstr) - 'a' + 10)); + ++pstr; + } + } else if (pstr[0] == '0') { + pstr += 1; + + while (*pstr) { + if (*pstr < '0' || *pstr >= '8') { + Param_Error(5, "octal ", opstr); + return 0; + } + + if (val > 0x1FFFFFFF) { + Param_Error(4, opstr); + return 0; + } + + val = (val << 3) | (*pstr - '0'); + ++pstr; + } + } else { + while (*pstr) { + if (!my_isdigit(*pstr)) { + Param_Error(5, "decimal ", opstr); + return 0; + } + + if (val > 0x19999999) { + Param_Error(4, opstr); + return 0; + } + + val = (val * 10) + (*pstr - '0'); + ++pstr; + } + } + + if (p->lo == p->hi) { + if (p->size == 1) { + lo = 0; + hi = 0xFF; + } else if (p->size == 2) { + lo = 0; + hi = 0xFFFF; + } else { + lo = 0; + hi = 0xFFFFFFFF; + } + } else { + lo = p->lo; + hi = p->hi; + } + + if (!p->fit && (val < lo || val > hi)) { + Param_Error(6, val, lo, hi); + return 0; + } + + if (val < lo) { + Param_Warning(7, val, lo, hi, lo); + val = lo; + } else if (val > hi) { + Param_Warning(7, val, lo, hi, hi); + val = hi; + } + + if (p->size == 1) { + unsigned char val8 = val; + inline_write_8(p->num, &val8); + } + + if (p->size == 2) { + unsigned short val16 = val; + inline_write_16(p->num, &val16); + } else if (p->size == 4) { + unsigned long val32 = val; + inline_write_32(p->num, &val32); + } + + return 1; +} + +static void DescHelpParam_FTypeCreator(FTYPE_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else if (p->iscreator) + *desc = "creator"; + else + *desc = "type"; + + if (!p->fc) { + *defaul = 0; + } else { + unsigned long tmp; + unsigned char *ptr; + + ptr = (unsigned char *) defaultparam; + tmp = *p->fc; + ptr[0] = '\''; + ptr[1] = tmp & 0xFF; + ptr[2] = (tmp >> 8) & 0xFF; + ptr[3] = (tmp >> 16) & 0xFF; + ptr[4] = (tmp >> 24) & 0xFF; + ptr[5] = '\''; + ptr[6] = 0; + *defaul = defaultparam; + } +} + +static int CompareParam_FTypeCreator(FTYPE_T *p) { + return 0; +} + +static int Param_FTypeCreator(FTYPE_T *p, const char *pstr, int flags) { + char x[4] = " "; + int cnt; + const char *opstr; + + cnt = 0; + opstr = pstr; + while (*pstr && cnt < 4) { + x[cnt++] = *(pstr++); + } + + if (*pstr) { + Param_Error(8, opstr); + return 0; + } + + inline_write_32(p->fc, &x); + return 1; +} + +static void DescHelpParam_String(STRING_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else + *desc = "string"; + + if (!p->str) { + *help = 0; + *defaul = 0; + } else { + sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); + *help = helpparam; + + if (*p->str) { + sprintf(defaultparam, "'%s'", p->str); + *defaul = defaultparam; + } else { + *defaul = "none"; + } + } +} + +static int CompareParam_String(STRING_T *p) { + return 0; +} + +static int Param_String(STRING_T *p, const char *pstr, int flags) { + int len; + + len = strlen(pstr); + strncpy(p->str, pstr, p->maxlen - 1); + if (p->pstring) + c2pstr(p->str); + + if (len > p->maxlen) { + Param_Error(9, pstr, pstr + len - 5, p->maxlen - 1); + return 0; + } + + return 1; +} + +static void DescHelpParam_ID_or_SYM(STRING_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else if (p->which == PARAMWHICH_Id) + *desc = "identifier"; + else + *desc = "symbol"; + + if (!p->str) { + *help = *defaul = 0; + } else { + sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); + *help = helpparam; + + if (*p->str) { + sprintf(defaultparam, "'%s'", p->str); + *defaul = defaultparam; + } else { + *defaul = "none"; + } + } +} + +static int CompareParam_ID_or_SYM(STRING_T *p) { + return 0; +} + +static int Param_ID_or_SYM(STRING_T *p, const char *pstr, int flags) { + const char *ptr; + const char *x; + + if (Param_String(p, pstr, flags)) { + if (p->which == PARAMWHICH_Id) { + x = "$_"; + } else if (p->which == PARAMWHICH_Sym) { + x = "_.$@?#"; + } + + for (ptr = pstr; *ptr; ++ptr) { + if (ptr == pstr && my_isdigit(*ptr)) + Param_Warning(10, pstr); + + if (!my_isalnum(*ptr) && !strchr(x, *ptr)) + Param_Warning(11, pstr, *ptr); + } + + return 1; + } else { + return 0; + } +} + +static void DescHelpParam_OnOff(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { + unsigned char def; + + if (p->myname) + *desc = p->myname; + else + *desc = "on|off"; + + *help = 0; + if (!p->var) { + *defaul = 0; + } else { + if (p->var) + *((unsigned char *) &def) = *((unsigned char *) p->var); + if (def) + *defaul = "on"; + else + *defaul = "off"; + } +} + +static int CompareParam_OnOff(ONOFF_T *p) { + return 0; +} + +static int Param_OnOff(ONOFF_T *p, const char *pstr, int flags) { + Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; + + if (!ustrcmp(pstr, "on")) { + *(p->var) = mytrue; + } else if (!ustrcmp(pstr, "off")) { + *(p->var) = mytrue == 0; + } else { + Param_Error(12, pstr); + return 0; + } + + return 1; +} + +static void DescHelpParam_OffOn(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { + unsigned char def; + + if (p->myname) + *desc = p->myname; + else + *desc = "off|on"; + + *help = 0; + if (!p->var) { + *defaul = 0; + } else { + if (p->var) + *((unsigned char *) &def) = *((unsigned char *) p->var); + if (!def) + *defaul = "on"; + else + *defaul = "off"; + } +} + +static int CompareParam_OffOn(OFFON_T *p) { + return 0; +} + +static int Param_OffOn(OFFON_T *p, const char *pstr, int flags) { + Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; + + if (!ustrcmp(pstr, "off")) { + *(p->var) = mytrue; + } else if (!ustrcmp(pstr, "on")) { + *(p->var) = mytrue == 0; + } else { + Param_Error(12, pstr); + return 0; + } + + return 1; +} + +static void DescHelpParam_FilePath(FILEPATH_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else + *desc = "filepath"; + + *help = 0; + *defaul = p->defaultstr; +} + +static int CompareParam_FilePath(FILEPATH_T *p) { + return 0; +} + +static int Param_FilePath(FILEPATH_T *p, const char *pstr, int flags) { + int err; + OSSpec spec; + char canon[256]; + int clen; + + if (!pstr[0]) { + ((unsigned char *) p->filename)[0] = 0; + return 1; + } + + err = OS_MakeFileSpec(pstr, &spec); + if (err) { + Param_Error(18, pstr, OS_GetErrText(err)); + return 0; + } + + OS_SpecToString(&spec, canon, sizeof(canon)); + if (p->fflags & 1) { + c2pstrcpy(p->filename, canon); + } else { + clen = strlen(canon); + if (clen > p->maxlen) { + Param_Error(13, canon + clen - 32, canon); + return 0; + } + strcpy(p->filename, canon); + } + + return 1; +} + +static void DescHelpParam_Mask(MASK_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_Mask(MASK_T *p) { + if (p->size == 1) { + unsigned char or8 = p->ormask, and8 = p->andmask, val8; + if (p->num) copy_8(&val8, p->num); + return ((val8 & ~and8) | or8) == val8; + } else if (p->size == 2) { + unsigned short or16 = p->ormask, and16 = p->andmask, val16; + if (p->num) copy_16(&val16, p->num); + return ((val16 & ~and16) | or16) == val16; + } else { + unsigned long or32 = p->ormask, and32 = p->andmask, val32; + if (p->num) copy_32(&val32, p->num); + return ((val32 & ~and32) | or32) == val32; + } +} + +static int Param_Mask(MASK_T *p, const char *pstr, int flags) { + if (p->size == 1) { + unsigned char or8 = p->ormask, and8 = p->andmask, tmp8; + if (flags & PARAMPARSEFLAGS_8) { + tmp8 = and8; + and8 = and8 | or8; + or8 = tmp8; + } + inline_andor_8(p->num, &and8, &or8); + } else if (p->size == 2) { + unsigned short or16 = p->ormask, and16 = p->andmask, tmp16; + if (flags & PARAMPARSEFLAGS_8) { + tmp16 = and16; + and16 = and16 | or16; + or16 = tmp16; + } + inline_andor_16(p->num, &and16, &or16); + } else { + unsigned long or32 = p->ormask, and32 = p->andmask, tmp32; + if (flags & PARAMPARSEFLAGS_8) { + tmp32 = and32; + and32 = and32 | or32; + or32 = tmp32; + } + inline_andor_32(p->num, &and32, &or32); + } + return 1; +} + +static void DescHelpParam_Toggle(TOGGLE_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_Toggle(TOGGLE_T *p) { + if (p->size == 1) { + unsigned char mask8, val8; + mask8 = (unsigned char) p->mask; + if (p->num) copy_8(&val8, p->num); + return (val8 ^ mask8) == val8; + } else if (p->size == 2) { + unsigned short mask16, val16; + mask16 = (unsigned short) p->mask; + if (p->num) copy_16(&val16, p->num); + return (val16 ^ mask16) == val16; + } else { + unsigned long mask32, val32; + mask32 = p->mask; + if (p->num) copy_16(&val32, p->num); // BUG ALERT + return (val32 ^ mask32) == val32; + } +} + +static int Param_Toggle(TOGGLE_T *p, const char *pstr, int flags) { + if (p->size == 1) { + unsigned char val8; + val8 = (unsigned char) p->mask; + inline_xor_8(p->num, &val8); + } else if (p->size == 2) { + unsigned short val16; + val16 = (unsigned short) p->mask; + inline_xor_16(p->num, &val16); + } else { + inline_xor_32(p->num, &p->mask); + } + return 1; +} + +static void DescHelpParam_Set(SET_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_Set(SET_T *p) { + if (p->size == 1) { + unsigned char set8, val8; + set8 = (unsigned char) p->value; + if (p->num) copy_8(&val8, p->num); + return set8 == val8; + } else if (p->size == 2) { + unsigned short set16, val16; + set16 = (unsigned short) p->value; + if (p->num) copy_16(&val16, p->num); + return set16 == val16; + } else { + unsigned long set32, val32; + set32 = p->value; + if (p->num) copy_32(&val32, p->num); + return set32 == val32; + } +} + +static int Param_Set(SET_T *p, const char *pstr, int flags) { + if (p->size == 1) { + unsigned char val8; + val8 = (unsigned char) p->value; + if ((flags & PARAMPARSEFLAGS_8) && val8 <= 1) + val8 = (val8 == 0); + inline_write_8(p->num, &val8); + } else if (p->size == 2) { + unsigned short val16; + val16 = (unsigned short) p->value; + if ((flags & PARAMPARSEFLAGS_8) && val16 <= 1) + val16 = (val16 == 0); + inline_write_16(p->num, &val16); + } else { + unsigned long val32; + val32 = p->value; + if ((flags & PARAMPARSEFLAGS_8) && val32 <= 1) + val32 = (val32 == 0); + inline_write_32(p->num, &val32); + } + return 1; +} + +static void DescHelpParam_SetString(SETSTRING_T *p, const char **desc, const char **help, const char **defaul) { + *help = 0; + *desc = 0; + *defaul = 0; +} + +static int CompareParam_SetString(SETSTRING_T *p, int flags) { + if (p->pstring) + return pstrcmp((const unsigned char *) p->var, (const unsigned char *) p->value) == 0; + else + return strcmp(p->var, p->value) == 0; +} + +static int Param_SetString(SETSTRING_T *p, const char *pstr, int flags) { + if (p->pstring) + memcpy(p->var, p->value, p->value[0]); + else + strcpy(p->var, p->value); + return 1; +} + +static void DescHelpParam_Generic(GENERIC_T *p, const char **desc, const char **help, const char **defaul) { + if (p->myname) + *desc = p->myname; + else if ((p->flags & PARAMFLAGS_3) != 1) + *desc = "xxx"; + else + *desc = 0; + *help = p->help; + *defaul = 0; +} + +static int CompareParam_Generic(GENERIC_T *p) { + return 0; +} + +static int Param_Generic(GENERIC_T *p, const char *pstr, int flags) { + return p->parse(curopt, p->var, pstr, flags); +} + +static void DescHelpParam_Setting(SETTING_T *p, const char **desc, const char **help, const char **defaul) { + char *dptr = descparam; + + dptr += sprintf(dptr, "%s", p->myname ? p->myname : "var"); + if ((p->flags & PARAMFLAGS_3) != 1) { + sprintf(dptr, + "%s=%s%s", + (p->flags & PARAMFLAGS_2) ? "[" : "", + p->valuename ? p->valuename : "...", + (p->flags & PARAMFLAGS_2) ? "]" : "" + ); + } + *desc = descparam; + *help = 0; + *defaul = 0; +} + +static int CompareParam_Setting(SETTING_T *p) { + return 0; +} + +static int Param_Setting(SETTING_T *p, const char *pstr, int flags) { + char savevar[256]; + const char *vstr; + ArgToken *tok; + Boolean equals = 0; + + if (!pstr) { + Param_Error(40); + return 0; + } + + strncpy(savevar, pstr, sizeof(savevar)); + tok = Arg_PeekToken(); + if (tok && tok->val == ATK_EQUALS) { + Arg_UsedToken(); + equals = 1; + if (!Param_GetArgument((PARAM_T *) p, &vstr, flags)) + return 0; + } else { + vstr = 0; + } + + if (!vstr && equals) + vstr = ""; + + return p->parse(savevar, vstr); +} + +static void DescHelpParam_IfArg(IFARG_T *p, const char **desc, const char **help, const char **defaul) { + const char *d1 = 0; + const char *d2 = 0; + const char *h1 = 0; + const char *h2 = 0; + const char *df1 = 0; + const char *df2 = 0; + char desclocal[1024]; + char *dptr = desclocal; + char helplocal[1024]; + char *hptr = helplocal; + const char *ind; + + desclocal[0] = 0; + helplocal[0] = 0; + + if (p->parg) + Param_DescHelp(p->parg, &d1, &h1, &df1); + if (p->pnone) + Param_DescHelp(p->pnone, &d2, &h2, &df2); + + if (p->helpa && p->helpn) { + if (df1) + hptr += sprintf(hptr, "%s (default is %s), else %s", p->helpa, df1, p->helpn); + else + hptr += sprintf(hptr, "%s, else %s", p->helpa, p->helpn); + } else if (p->helpa) { + hptr += sprintf(hptr, "%s", p->helpa); + if (df1) + hptr += sprintf(hptr, "; default is %s", df1); + } else if (p->helpn) { + hptr += sprintf(hptr, "nothing, else %s", p->helpn); + } + + if (d1) { + if (p->myname) { + dptr += sprintf(dptr, "[%s]", p->myname ? p->myname: "param"); + } else if (h1) { + ind = strchr(d1, '\n'); + if (!ind) + ind = d1 + strlen(d1); + dptr += sprintf(dptr, "[%.*s]", ind - d1, d1); + } else { + dptr += sprintf(dptr, "[%s]", d1); + d1 = 0; + } + } + + if (h1 || h2) { + dptr += sprintf(dptr, "\n\t"); + hptr += sprintf(hptr, "\n\t"); + if (h1) { + if (d1) + dptr += sprintf(dptr, "%s", d1); + if (h1) + hptr += sprintf(hptr, "%s", h1); + if (h2) { + dptr += sprintf(dptr, "\b\t"); + hptr += sprintf(hptr, "\b\t"); + } + } + if (h2) { + if (d2) + dptr += sprintf(dptr, "%s", d2); + else + dptr += sprintf(dptr, "(if blank)"); + if (h2) + hptr += sprintf(hptr, "%s", h2); + dptr += sprintf(dptr, "\n"); + hptr += sprintf(hptr, "\n"); + } + dptr += sprintf(dptr, "\b"); + hptr += sprintf(hptr, "\b"); + } + + if (dptr != desclocal) { + strcpy(descparam, desclocal); + *desc = descparam; + } else { + *desc = 0; + } + + if (hptr != helplocal) { + strcpy(helpparam, helplocal); + *help = helpparam; + } else { + *help = 0; + } + + *defaul = 0; +} + +static int CompareParam_IfArg(IFARG_T *p) { + return 0; +} + +static int Param_IfArg(IFARG_T *p, const char *pstr, int flags) { + if (pstr) + return Param_Parse(p->parg, pstr, flags); + else if (p->pnone) + return Param_Parse(p->pnone, pstr, flags); + else + return 1; +} + +typedef int (*PARSE_FUNC)(PARAM_T *, const char *, int); +PARSE_FUNC ParamParsers[16] = { + (PARSE_FUNC) &Param_None, + (PARSE_FUNC) &Param_FTypeCreator, + (PARSE_FUNC) &Param_FilePath, + (PARSE_FUNC) &Param_Number, + (PARSE_FUNC) &Param_String, + (PARSE_FUNC) &Param_ID_or_SYM, + (PARSE_FUNC) &Param_ID_or_SYM, + (PARSE_FUNC) &Param_OnOff, + (PARSE_FUNC) &Param_OffOn, + (PARSE_FUNC) &Param_Mask, + (PARSE_FUNC) &Param_Toggle, + (PARSE_FUNC) &Param_Set, + (PARSE_FUNC) &Param_SetString, + (PARSE_FUNC) &Param_Generic, + (PARSE_FUNC) &Param_IfArg, + (PARSE_FUNC) &Param_Setting +}; + +static int Param_Parse(PARAM_T *param, const char *cparam, int flags) { + if (!param) + CLPFatalError("PARAM_T is NULL"); + + if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { + return ParamParsers[param->which](param, cparam, flags); + } else { + CLPFatalError("Unhandled PARAM_T (%d)", param->which); + return 0; + } +} + +typedef void (*DESC_HELP_FUNC)(PARAM_T *, const char **, const char **, const char **); +DESC_HELP_FUNC DescHelpParams[16] = { + (DESC_HELP_FUNC) &DescHelpParam_None, + (DESC_HELP_FUNC) &DescHelpParam_FTypeCreator, + (DESC_HELP_FUNC) &DescHelpParam_FilePath, + (DESC_HELP_FUNC) &DescHelpParam_Number, + (DESC_HELP_FUNC) &DescHelpParam_String, + (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, + (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, + (DESC_HELP_FUNC) &DescHelpParam_OnOff, + (DESC_HELP_FUNC) &DescHelpParam_OffOn, + (DESC_HELP_FUNC) &DescHelpParam_Mask, + (DESC_HELP_FUNC) &DescHelpParam_Toggle, + (DESC_HELP_FUNC) &DescHelpParam_Set, + (DESC_HELP_FUNC) &DescHelpParam_SetString, + (DESC_HELP_FUNC) &DescHelpParam_Generic, + (DESC_HELP_FUNC) &DescHelpParam_IfArg, + (DESC_HELP_FUNC) &DescHelpParam_Setting +}; +void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul) { + *desc = 0; + *help = 0; + *defaul = 0; + + if (!param) { + CLPFatalError("PARAM_T is NULL"); + return; + } + + if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { + DescHelpParams[param->which](param, desc, help, defaul); + } else { + CLPFatalError("Unhandled PARAM_T (%d)", param->which); + } +} + +typedef int (*COMPARE_FUNC)(PARAM_T *); +COMPARE_FUNC CompareParams[16] = { + (COMPARE_FUNC) &CompareParam_None, + (COMPARE_FUNC) &CompareParam_FTypeCreator, + (COMPARE_FUNC) &CompareParam_FilePath, + (COMPARE_FUNC) &CompareParam_Number, + (COMPARE_FUNC) &CompareParam_String, + (COMPARE_FUNC) &CompareParam_ID_or_SYM, + (COMPARE_FUNC) &CompareParam_ID_or_SYM, + (COMPARE_FUNC) &CompareParam_OnOff, + (COMPARE_FUNC) &CompareParam_OffOn, + (COMPARE_FUNC) &CompareParam_Mask, + (COMPARE_FUNC) &CompareParam_Toggle, + (COMPARE_FUNC) &CompareParam_Set, + (COMPARE_FUNC) &CompareParam_SetString, + (COMPARE_FUNC) &CompareParam_Generic, + (COMPARE_FUNC) &CompareParam_IfArg, + (COMPARE_FUNC) &CompareParam_Setting +}; +int Param_Compare(PARAM_T *param) { + if (!param) + CLPFatalError("PARAM_T is NULL"); + + if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { + return CompareParams[param->which](param); + } else { + CLPFatalError("Unhandled PARAM_T (%d)", param->which); + return 0; + } +} + +static void Param_PushParam(const char *param) { + Args_Push(4, (void *) param, 0); +} + +static void Param_PopParam(void) { + Args_Pop(4); +} + +static Boolean Param_IsNonTextFile(const char *fname, Boolean warn) { + OSSpec tmp; + CWDataType mactype; + Boolean isfile; + + if (!OS_MakeSpec(fname, &tmp, &isfile)) { + if (isfile) { + if (!OS_Status(&tmp)) { + if (!OS_GetMacFileType(&tmp, &mactype)) { + if (mactype != 'TEXT') { + if (warn) + Param_Warning(77, fname); + return 1; + } + } + } + } + } + + return 0; +} + +static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec) { + int subparse; + short nextOpt; + short nextParam; + short lastOpt; + ArgToken *tok; + + subparse = (exec & PARAMPARSEFLAGS_4) != 0; + nextOpt = !subparse ? ATK_ARG_END : ATK_COMMA; + nextParam = !subparse ? ATK_COMMA : ATK_EQUALS; + lastOpt = !subparse ? ATK_END : ATK_ARG_END; + + tok = Arg_PeekToken(); + OS_ASSERT(1467, tok); + + if ((param->flags & PARAMFLAGS_3) == 0) { + if (tok->val == nextParam || tok->val == ATK_EQUALS) + tok = Arg_UsedToken(); + if (tok->val == nextOpt || tok->val == nextParam || tok->val == lastOpt) { + Param_Error(34); + return 0; + } + if (tok->val != ATK_ARG) { + Param_Error(57, "parameter", Arg_GetTokenName(tok)); + return 0; + } + Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); + Arg_UsedToken(); + *cparam = curparam; + + if (param->flags & PARAMFLAGS_8) { + tok = Arg_PeekToken(); + if (tok->val == ATK_EQUALS) + Arg_UsedToken(); + } + } else if (param->flags & PARAMFLAGS_1) { + *cparam = 0; + if (tok->val == ATK_EQUALS && !subparse) { + if (!(exec & PARAMPARSEFLAGS_40)) { + Param_Error(37); + return 0; + } + Arg_UsedToken(); + } + } else if (param->flags & PARAMFLAGS_2) { + if (tok->val == nextOpt || tok->val == lastOpt) { + *cparam = 0; + } else if (tok->val == nextParam) { + tok = Arg_UsedToken(); + if (tok->val == ATK_ARG) { + Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); + if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { + *cparam = 0; + } else { + Arg_UsedToken(); + *cparam = curparam; + } + } else { + *cparam = 0; + } + } else if (tok->val == ATK_ARG && !tok->text[0]) { + tok = Arg_UsedToken(); + if (tok->val == nextParam) + Arg_UsedToken(); + *cparam = 0; + } else if ((exec & PARAMPARSEFLAGS_4) && tok->val != ATK_EQUALS) { + *cparam = 0; + } else { + if (tok->val == ATK_EQUALS) + tok = Arg_UsedToken(); + if (tok->val == ATK_ARG) { + Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); + if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { + *cparam = 0; + } else { + Arg_UsedToken(); + *cparam = curparam; + } + } else { + *cparam = 0; + } + } + } else { + CLPFatalError("Unknown parameter type"); + } + + if (pTool->TYPE == CWDROPINCOMPILERTYPE && (exec & PARAMPARSEFLAGS_2) && *cparam) { + if (!(exec & PARAMPARSEFLAGS_10)) { + if (subparse) + Arg_AddToToolArgs(&linkargs, ATK_EQUALS, 0); + else + Arg_AddToToolArgs(&linkargs, ATK_COMMA, 0); + } + Param_PushParam(*cparam); + Args_AddToToolArgs(&linkargs); + Param_PopParam(); + } + + return 1; +} + +int Params_Parse(PARAM_T *param, int flags) { + const char *cparam; + flags |= PARAMPARSEFLAGS_10; + + if (param) { + while (param) { + if (flags & PARAMPARSEFLAGS_20) + flags |= PARAMPARSEFLAGS_40; + + if (!Param_GetArgument(param, &cparam, flags)) + return 0; + + if (!(flags & PARAMPARSEFLAGS_1)) { + if (!Param_Parse(param, cparam, flags | (short) ((param->flags & PARAMFLAGS_4) ? PARAMPARSEFLAGS_20 : 0))) + return 0; + } else if (param->flags & PARAMFLAGS_4) { + if (!Param_GetArgument(param, &cparam, flags | PARAMPARSEFLAGS_4)) + return 0; + } + + if (cparam) + flags &= ~PARAMPARSEFLAGS_10; + flags &= ~PARAMPARSEFLAGS_40; + param = param->next; + } + } + + return 1; +} + +void Param_Error(short id, ...) { + va_list va; + va_start(va, id); + Option_ParamError(id, va); + va_end(va); +} + +void Param_Warning(short id, ...) { + va_list va; + va_start(va, id); + Option_ParamWarning(id, va); + va_end(va); +} diff --git a/command_line/C++_Parser/Src/Library/ParserErrors.c b/command_line/C++_Parser/Src/Library/ParserErrors.c new file mode 100644 index 0000000..df5e67e --- /dev/null +++ b/command_line/C++_Parser/Src/Library/ParserErrors.c @@ -0,0 +1,119 @@ +#include "parser.h" + +static char errorbuf[1024]; + +void CLPReportError_V(const char *format, va_list ap) { + vsprintf(errorbuf, format, ap); + CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeError, 0); + parseopts.hadErrors = 1; +} + +void CLPReportWarning_V(const char *format, va_list ap) { + vsprintf(errorbuf, format, ap); + CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeWarning, 0); +} + +void CLPReport_V(const char *format, va_list ap) { + vsprintf(errorbuf, format, ap); + CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeInfo, 0); +} + +void CLPStatus_V(const char *format, va_list ap) { + vsprintf(errorbuf, format, ap); + CWShowStatus(parseopts.context, errorbuf, NULL); +} + +void CLPAlert_V(const char *format, va_list ap) { + vsprintf(errorbuf, format, ap); + CWAlert(parseopts.context, errorbuf, NULL, NULL, NULL); + parseopts.hadErrors = 1; +} + +void CLPOSAlert_V(const char *format, SInt32 err, va_list ap) { + vsprintf(errorbuf, format, ap); + CWAlert(parseopts.context, errorbuf, "Operating system error:", OS_GetErrText(err), NULL); +} + +char *CLPGetErrorString(SInt16 errid, char *buffer) { + getindstring(buffer, 12010, errid); + return buffer; +} + +void CLPReportError(SInt16 errid, ...) { + char format[256]; + va_list va; + + CLPGetErrorString(errid, format); + va_start(va, errid); + CLPReportError_V(format, va); + va_end(va); +} + +void CLPReportWarning(SInt16 errid, ...) { + char format[256]; + va_list va; + + CLPGetErrorString(errid, format); + va_start(va, errid); + CLPReportWarning_V(format, va); + va_end(va); +} + +void CLPReport(SInt16 errid, ...) { + char format[256]; + va_list va; + + CLPGetErrorString(errid, format); + va_start(va, errid); + CLPReport_V(format, va); + va_end(va); +} + +void CLPAlert(SInt16 errid, ...) { + char format[256]; + va_list va; + + CLPGetErrorString(errid, format); + va_start(va, errid); + CLPAlert_V(format, va); + va_end(va); +} + +void CLPOSAlert(SInt16 errid, SInt16 err, ...) { + char format[256]; + va_list va; + + CLPGetErrorString(errid, format); + va_start(va, err); + CLPOSAlert_V(format, err, va); + va_end(va); +} + +void CLPProgress(SInt16 errid, ...) { + char format[256]; + va_list va; + + CLPGetErrorString(errid, format); + va_start(va, errid); + CLPStatus_V(format, va); + va_end(va); +} + +void CLPStatus(SInt16 errid, ...) { + char format[256]; + va_list va; + + CLPGetErrorString(errid, format); + va_start(va, errid); + CLPStatus_V(format, va); + va_end(va); +} + +void CLPFatalError(const char *format, ...) { + va_list va; + + va_start(va, format); + CLPAlert_V(format, va); + va_end(va); + longjmp(exit_plugin, -123); +} diff --git a/command_line/C++_Parser/Src/Library/ParserFace.c b/command_line/C++_Parser/Src/Library/ParserFace.c new file mode 100644 index 0000000..a005ece --- /dev/null +++ b/command_line/C++_Parser/Src/Library/ParserFace.c @@ -0,0 +1,298 @@ +#include "parser.h" + +const char *failedCallback; +jmp_buf exit_plugin; +ParseOptsType parseopts; + +static CWResult SetupParamBlock(CWPluginContext context) { + CWResult result; + int x; + Handle h; + PCmdLineEnvir cle; + + memset(&parseopts, 0, sizeof(parseopts)); + parseopts.context = context; + + result = CWSecretGetNamedPreferences(context, "CmdLine Environment", &h); + if (result) + return result; + + cle = **((PCmdLineEnvir **) h); + parseopts.underIDE = cle.underIDE; + parseopts.ioRows = cle.rows; + parseopts.ioCols = cle.cols; + + result = CWParserGetCommandLine(context, &parseopts.args); + if (result) + return result; + + result = CWParserGetToolInfo(context, &parseopts.toolVersion); + if (result) + return result; + + result = CWParserGetTargetInfo(context, &parseopts.cpu, &parseopts.os); + if (result) + return result; + + result = CWParserGetPanels(context, &parseopts.numPanels, &parseopts.panelNames); + if (result) + return result; + + result = CWParserGetPlugins(context, &parseopts.numPlugins, &parseopts.plugins); + if (result) + return result; + + parseopts.passingArgs = 0; + for (x = 0; x < parseopts.numPlugins; x++) { + if (parseopts.plugins[x].storeCommandLine) + parseopts.passingArgs = 1; + } + + return 0; +} + +static CWResult SetupOptions(CWPluginContext context) { + if (!pTool) { + return 2; + } else { + SetupParserToolOptions(); + return 0; + } +} + +static CWResult Parse(CWPluginContext context) { + CWResult result; + + parseopts.success = 1; + parseopts.currentSegment = 1; + parseopts.currentOverlayGroup = 0; + parseopts.currentOverlay = 0; + + Arg_InitToolArgs(&linkargs); + Arg_InitToolArgs(&prelinkargs); + Arg_InitToolArgs(&postlinkargs); + + if (pTool->PreParse) + parseopts.success &= pTool->PreParse(); + + Arg_Init(parseopts.args->argc, parseopts.args->argv); + parseopts.noOptions = Arg_IsEmpty(); + parseopts.success &= Options_Parse(Options_GetOptions(), OFLAGS_1) && !parseopts.hadErrors; + Arg_Reset(); + + result = Parser_StorePanels(context); + if (result) + return result; + + if (pTool->MidParse && parseopts.success) + parseopts.success &= pTool->MidParse(); + + result = Parser_StorePanels(context); + if (result) + return result; + + if (parseopts.showHelp && parseopts.success) + parseopts.success &= Options_DisplayHelp(); + + Arg_Reset(); + if (parseopts.success) + parseopts.success &= Options_Parse(Options_GetOptions(), 0) && !parseopts.hadErrors; + + if (pTool->PostParse && parseopts.success) + parseopts.success &= pTool->PostParse(); + + Arg_Terminate(); + + return (parseopts.success && !parseopts.hadErrors) ? cwNoErr : cwErrRequestFailed; +} + +Handle Parser_FindPrefPanel(const char *name) { + int idx; + Handle h; + + for (idx = 0; idx < pTool->numPrefDataPanels; idx++) { + if (!ustrcmp(name, pTool->prefDataPanels[idx].name)) { + h = NewHandle(pTool->prefDataPanels[idx].size); + if (!h) + return NULL; + + HLock(h); + memcpy(*h, pTool->prefDataPanels[idx].ptr, pTool->prefDataPanels[idx].size); + HUnlock(h); + return h; + } + } + + return NULL; +} + +CWResult Parser_StorePanels(CWPluginContext context) { + int idx; + CWResult result; + const char *name; + Handle h; + + for (idx = 0; idx < parseopts.numPanels; idx++) { + name = parseopts.panelNames[idx]; + h = Parser_FindPrefPanel(name); + if (h) { + result = CWParserSetNamedPreferences(parseopts.context, name, h); + if (result) { + CLPReportError(CLPStr68, name); + return result; + } + } + } + + return cwNoErr; +} + +static CWResult StoreResults(CWPluginContext context) { + int idx; // r25 + CWResult result; + CWCommandLineArgs args; + UInt32 id; // r8 + UInt32 lg; // r10 + + result = Parser_StorePanels(context); + if (result) + return result; + + for (idx = 0; idx < parseopts.numPlugins; idx++) { + if (parseopts.plugins[idx].plugintype == CWDROPINLINKERTYPE && parseopts.plugins[idx].storeCommandLine) { + if (parseopts.plugins[idx].dropinflags & isPreLinker) { + Arg_ToolArgsForPlugin(&prelinkargs, &args); + } else if (parseopts.plugins[idx].dropinflags & isPostLinker) { + Arg_ToolArgsForPlugin(&postlinkargs, &args); + } else { + Arg_ToolArgsForPlugin(&linkargs, &args); + } + result = CWParserStoreCommandLineForPlugin(parseopts.context, idx, &args); + if (result) + return result; + } else if (parseopts.plugins[idx].storeCommandLine) { + id = parseopts.plugins[idx].plugintype; + lg = parseopts.plugins[idx].language; + fprintf(stderr, + "*** No support for %c%c%c%c/%c%c%c%c tool\n", + (id & 0xFF000000) >> 24, + (id & 0x00FF0000) >> 16, + (id & 0x0000FF00) >> 8, + (id & 0x000000FF), + (lg & 0xFF000000) >> 24, + (lg & 0x00FF0000) >> 16, + (lg & 0x0000FF00) >> 8, + (lg & 0x000000FF) + ); + } + } + + return cwNoErr; +} + +CWPLUGIN_ENTRY (CWParser_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize) { + static const DropInFlags sFlags = { + kCurrentDropInFlagsVersion, + CWDROPINPARSERTYPE, + 7, + 0, + 'Seep', + 12 + }; + *flags = &sFlags; + *flagsSize = sizeof(sFlags); + return 0; +} + +CWPLUGIN_ENTRY (CWParser_GetDropInName)(const char **dropinName) { + static const char *sDropInName = "Command-Line Parser"; + *dropinName = sDropInName; + return 0; +} + +CWPLUGIN_ENTRY (CWParser_GetDisplayName)(const char **displayName) { + static const char *sDisplayName = "Command-Line Parser"; + *displayName = sDisplayName; + return 0; +} + +CWPLUGIN_ENTRY (CWParser_GetPanelList)(const CWPanelList **panelList) { + static CWPanelList sPanelList = { + kCurrentCWFamilyListVersion, + 0, + 0 + }; + *panelList = &sPanelList; + return 0; +} + +CWPLUGIN_ENTRY (CWParser_GetTargetList)(const CWTargetList **targetList) { + static CWDataType sCPU = '****'; + static CWDataType sOS = '****'; + static CWTargetList sTargetList = { + kCurrentCWTargetListVersion, + 1, + &sCPU, + 1, + &sOS + }; + *targetList = &sTargetList; + return 0; +} + +CWPLUGIN_ENTRY (CWParser_GetVersionInfo)(const VersionInfo **versioninfo) { + static const VersionInfo vi = { + 1, 1, 0, 0 + }; + *versioninfo = &vi; + return 0; +} + +CWPLUGIN_ENTRY (Parser_SupportsPlugin)(const struct CLPluginInfo *pluginfo, CWDataType cpu, CWDataType os, Boolean *isSupported) { + *isSupported = ParserToolMatchesPlugin(pluginfo->plugintype, pluginfo->language, cpu, os); + return 0; +} + +CWPLUGIN_ENTRY (Parser_SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported) { + *isSupported = ParserToolHandlesPanels(numPanels, panelNames); + return 0; +} + +CWPLUGIN_ENTRY (parser_main)(CWPluginContext context) { + CWResult result; + SInt32 request; + + CWGetPluginRequest(context, &request); + result = setjmp(exit_plugin); + if (result == 0) { + switch (request) { + case reqInitialize: + result = 0; + break; + case 0: + break; + case 1: + result = SetupParamBlock(context); + if (!result) + result = Parser_StorePanels(context); + break; + case 2: + result = SetupParamBlock(context); + if (!result) { + result = SetupOptions(context); + if (!result) { + result = Parse(context); + if (!result) + result = StoreResults(context); + } + } + break; + } + } else { + if (failedCallback && result != 1) + fprintf(stderr, "Unexpected error in %s [%d]\n", failedCallback, result); + } + CWDonePluginRequest(context, result); + + return result; +} diff --git a/command_line/C++_Parser/Src/Library/ParserHelpers-cc.c b/command_line/C++_Parser/Src/Library/ParserHelpers-cc.c new file mode 100644 index 0000000..07315b3 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/ParserHelpers-cc.c @@ -0,0 +1,156 @@ +#include "parser.h" + +Handle definesHandle; + +int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags) { + AddStringToHandle(&definesHandle, (const char *) str); + if (param) + AddStringToHandle(&definesHandle, param); + return 1; +} + +int Opt_DefineSymbol(const char *var, const char *value) { + char tmp[1024]; + + if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ') || pTool->LANG == Lang_Rez) { + sprintf(tmp, "#define %s %s\n", var, value ? value : "1"); + } else if (pTool->LANG == Lang_Pascal) { + sprintf(tmp, "{$definec %s %s}\n", var, value ? value : "1"); + } else { + sprintf(tmp, "Option '-D|d' is not supported with this plugin"); + CLPReportError(CLPStr28_WarningText, tmp); + return 0; + } + + AddStringToHandle(&definesHandle, tmp); + return 1; +} + +int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags) { + char tmp[300]; + + if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) { + sprintf(tmp, "#undef %s\n", arg); + } else if (pTool->LANG == Lang_Pascal) { + sprintf(tmp, "{$undefc %s}\n", arg); + } else { + sprintf(tmp, "Option -%s is not supported with this plugin", opt); + CLPReportError(CLPStr28_WarningText, tmp); + return 0; + } + + AddStringToHandle(&definesHandle, tmp); + return 1; +} + +int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags) { + char tmp[300]; + + handle = !handle ? &definesHandle : handle; + if (!filename[0]) + return 1; + + if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) { + if (filename[0] == '<' && filename[strlen(filename) - 1] == '>') { + snprintf(tmp, sizeof(tmp), "#include %s\n", filename); + } else { + snprintf(tmp, sizeof(tmp), "#include \"%s\"\n", filename); + } + } else if (pTool->LANG == Lang_Pascal) { + snprintf(tmp, sizeof(tmp), "{$I+}\n{$I %s}\n{$I-}\n", filename); + } else { + sprintf(tmp, "Option -%s is not supported with this plugin", opt); + CLPReportError(CLPStr28_WarningText, tmp); + return 0; + } + + AddStringToHandle((Handle *) handle, tmp); + return 1; +} + +int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags) { + if (flags & PARAMPARSEFLAGS_8) + *((unsigned char *) flag) = PR_OFF; + else + *((unsigned char *) flag) = PR_ON; + return 1; +} + +int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags) { + if (flags & PARAMPARSEFLAGS_8) + *((unsigned char *) flag) = PR_ON; + else + *((unsigned char *) flag) = PR_OFF; + return 1; +} + +int Opt_PragmaOnOff(const char *, void *flag, const char *arg) { + if (!arg) { + CLPReportError(CLPStr34_ArgumentsExpected); + return 0; + } + + if (!ustrcmp(arg, "on")) { + *((unsigned char *) flag) = PR_ON; + } else if (!ustrcmp(arg, "off")) { + *((unsigned char *) flag) = PR_OFF; + } else { + CLPReportError(CLPStr12, arg); + return 0; + } + + return 1; +} + +int Opt_PragmaOffOn(const char *, void *flag, const char *arg) { + if (!arg) { + CLPReportError(CLPStr34_ArgumentsExpected); + return 0; + } + + if (!ustrcmp(arg, "on")) { + *((unsigned char *) flag) = PR_OFF; + } else if (!ustrcmp(arg, "off")) { + *((unsigned char *) flag) = PR_ON; + } else { + CLPReportError(CLPStr12, arg); + return 0; + } + + return 1; +} + +int SetupPragmas(const Pragma *pragmas) { + const char *set; + char on; + char off; + char tmp[300]; + + while (pragmas->pragma) { + if (pragmas->flags == PRAGMA_FLAGS_0 || pragmas->flags == PRAGMA_FLAGS_1) { + set = 0; + on = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_ON : PR_OFF; + off = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_OFF : PR_ON; + if (*((char *)pragmas->value) == on) + set = "on"; + else if (*((char *)pragmas->value) == off) + set = "off"; + else if (*((char *)pragmas->value) == PR_AUTO) + set = "auto"; + else if (*((char *)pragmas->value) == PR_RESET) + set = "reset"; + else + OS_ASSERT(186, *((char *)pragmas->value) == PR_UNSET); + + if (set) { + snprintf(tmp, sizeof(tmp), "#pragma %s %s\n", pragmas->pragma, set); + AddStringToHandle(&definesHandle, tmp); + } + } else { + OS_ASSERT(195, !"Can't handle pragma"); + } + pragmas++; + } + + return 1; +} diff --git a/command_line/C++_Parser/Src/Library/ParserHelpers.c b/command_line/C++_Parser/Src/Library/ParserHelpers.c new file mode 100644 index 0000000..4cb793e --- /dev/null +++ b/command_line/C++_Parser/Src/Library/ParserHelpers.c @@ -0,0 +1,535 @@ +#include "parser.h" +#include "cmdline.h" +#include + +SInt16 lastStage; +Boolean dashIMinusMovesPaths; +Boolean usedDashIMinus; +Boolean namingSysPaths; +static char STSbuf[256]; + +int FindFileInPath(const char *filename, OSSpec *fss) { + CWFileInfo fi; + CWResult result; + + fi.fullsearch = 1; + fi.dependencyType = 0; + fi.suppressload = 1; + fi.isdependentoffile = kCurrentCompiledFile; + + result = CWFindAndLoadFile(parseopts.context, filename, &fi); + if (!result) { + OS_FSSpec_To_OSSpec(&fi.filespec, fss); + return 1; + } else { + return 0; + } +} + +char *GetEnvVar(const char *name, Boolean warn, const char **match) { + const char *nptr; + const char *last; + char *ret; + + nptr = name; + last = name; + while (*nptr) { + ret = getenv(nptr); + if (ret) { + if (match) + *match = nptr; + return ret; + } + last = nptr; + nptr = &nptr[1 + strlen(nptr)]; + } + + if (warn) + CLPReportWarning(CLPStr52, last); + *match = 0; + return 0; +} + +static Boolean MatchesExtension(const char *list, const char *filename) { + char *fn; + const char *eptr; + const char *ptr; + + fn = OS_GetFileNamePtr((char *) filename); + eptr = strrchr(fn, '.'); + if (!eptr) + return 0; + if (!list) + return 1; + + ptr = eptr; + while (*list) { + if (*list == '|' && !*ptr) + return 1; + + if (my_tolower(*list) == my_tolower(*ptr)) { + list++; + ptr++; + continue; + } + + while (*list && *list != '|') + list++; + if (*list) + list++; + ptr = eptr; + } + + return !*list && !*ptr; +} + +int Opt_AddAccessPath(const char *opt, void *var, const char *arg, int flags) { + OSPathSpec spec; + int err; + + arg = arg ? arg : opt; + if (!arg) + return 0; + if (!arg[0]) + return 1; + + if (strlen(arg) >= 256) { + CLPReportError(CLPStr13, arg + strlen(arg) - 32, 256); + return 0; + } + + err = OS_MakePathSpec(0, arg, &spec); + if (err == ENOENT || err == ENOENT) { + CLPReportWarning(CLPStr45, arg); + return 1; + } else if (err != 0) { + CLPOSAlert(CLPStr45, err, arg); + return 1; + } + + // this 'if' gets optimised unnecessarily + if (!AddAccessPath(&spec, namingSysPaths, 0, var != NULL)) + return 0; + else + return 1; +} + +int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg, int flags) { + OSPathSpec spec; + int err; + + arg = arg ? arg : opt; + if (!arg) + return 0; + if (!arg[0]) + return 1; + + if (strlen(arg) >= 256) { + CLPReportError(CLPStr13, arg + strlen(arg) - 32, 256); + return 0; + } + + err = OS_MakePathSpec(0, arg, &spec); + if (err == ENOENT || err == ENOENT) { + CLPReportWarning(CLPStr45, arg); + return 1; + } else if (err != 0) { + CLPOSAlert(CLPStr45, err, arg); + return 1; + } else { + Frameworks_AddPath(&spec); + return 1; + } +} + +int Opt_AddFramework(const char *opt, void *var, const char *arg, int flags) { + if (!Frameworks_AddFramework(arg ? arg : opt, 0, 0)) + return 0; + else + return 1; +} + +void ListParseMessage(void (*errprint)(const char *, va_list), const char *envvar, SInt16 id, ...) { + char buf[1024]; + va_list ap; + + if (envvar && envvar[0]) + sprintf(buf, "In environment variable '%s':\n", envvar); + else + buf[0] = 0; + + CLPGetErrorString(id, buf + strlen(buf)); + va_start(ap, id); + errprint(buf, ap); + va_end(ap); +} + +int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, SInt32 position, Boolean recursive) { + char tmp[256]; + Boolean recurse; + OSPathSpec spec; + int err; + short type; + char *ptr; + + type = (Boolean) ((system == 1) ? 1 : 0) | (!source ? 0 : 2); + recurse = (list[0] == '+'); + if (recurse) + ++list; + + if (!strchr(list, sep1)) + sep1 = sep2; + + while (*list) { + ptr = tmp; + while (*list && *list != sep1 && (ptr + 1) < &tmp[256]) { + *(ptr++) = *(list++); + } + *ptr = 0; + + if ((ptr + 1) >= &tmp[256]) { + ListParseMessage( + CLPReportError_V, + (source == 1) ? text : NULL, + CLPStr9, + tmp, + tmp + strlen(tmp) - 16, + 256); + return 0; + } + + err = OS_MakePathSpec(0, tmp, &spec); + if (err) { + ListParseMessage( + CLPReportWarning_V, + (source == 1) ? text : NULL, + CLPStr45, + tmp); + } else { + AddAccessPath(&spec, type, position, recurse ^ recursive); + } + + if (*list) + ++list; + recurse = *list == '+'; + if (recurse) + ++list; + } + + return 1; +} + +int Opt_FindAndAddFile(const char *opt, void *var, const char *arg, int flags) { + OSSpec spec; + int err; + Boolean isfile; + + arg = arg ? arg : opt; + if (!arg) + return 0; + if (!*arg) + return 1; + + parseopts.userSpecifiedFiles++; + err = OS_MakeSpec(arg, &spec, &isfile); + if (!err) + err = OS_Status(&spec); + + if (!err && !isfile) { + CLPReportError(CLPStr47, arg); + parseopts.unusedFiles++; + return 0; + } else if (err && err != ENOENT) { + CLPOSAlert(CLPStr44, err, arg); + parseopts.unusedFiles++; + return 0; + } else if (err && parseopts.alwaysUsePaths) { + err = FindFileInPath(arg, &spec) ? 0 : ENOENT; + } + + if (err) { + CLPReportError(CLPStr44, arg); + parseopts.unusedFiles++; + return 0; + } + + if (var && !MatchesExtension((const char *) var, arg)) + CLPReportWarning(CLPStr76, arg, var); + + if (!AddFileToProject(&spec, lastStage, parseopts.lastoutputname, 1, -1)) { + parseopts.unusedFiles++; + return 0; + } else { + parseopts.lastoutputname[0] = 0; + return 1; + } +} + +int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg) { + OSSpec spec; + int err; + Boolean isfile; + + arg = arg ? arg : opt; + if (!arg) + return 0; + if (!*arg) + return 1; + + parseopts.userSpecifiedFiles++; + if (var && !MatchesExtension((const char *) var, arg)) + CLPReportWarning(CLPStr76, arg, var); + + err = OS_MakeSpec(arg, &spec, &isfile); + if (!err) + err = OS_Status(&spec); + + if (!err && !isfile) { + CLPReportError(CLPStr47, arg); + parseopts.unusedFiles++; + return 0; + } else if (err && parseopts.alwaysUsePaths) { + err = FindFileInPath(arg, &spec) ? 0 : ENOENT; + } + + if (!AddFileToProject(&spec, 0, 0, err == 0, -1)) { + parseopts.unusedFiles++; + return 0; + } else { + return AddAccessPath(&spec.path, 1, -1, 0) != 0; + } +} + +int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *name) { + OSSpec spec; + Boolean failed; + const char *eptr; + const char *eend; + char tmpname[64]; + + if (strlen(name) >= 56) { + CLPReportError(CLPStr13, name + strlen(name) - 32, 64); + return 0; + } + + failed = 1; + if (!var) + var = ".lib|.a"; + + eptr = (const char *) var; + while (eptr && *eptr) { + eend = eptr; + while (*eend && *eend != '|') + ++eend; + + sprintf(tmpname, "lib%s%*.*s", name, eend - eptr, eend - eptr, eptr); + if (FindFileInPath(tmpname, &spec)) { + failed = 0; + break; + } + + if (*eend) + eptr = eend + 1; + else + eptr = eend; + } + + if (failed) { + failed = !FindFileInPath(name, &spec); + if (failed) + CLPReportError(CLPStr49, name, var, name); + } + + if (!failed) { + if (!AddFileToProject(&spec, 0, 0, 1, -1)) { + parseopts.unusedFiles++; + failed = 1; + } + } + + return !failed; +} + +int AddFileList(const char *list, char sep1, char sep2, int source, char *text, SInt32 position) { + char tmp[256]; + OSSpec spec; + char *ptr; + + if (!strchr(list, sep1)) + sep1 = sep2; + + while (*list) { + ptr = tmp; + while (*list && *list != sep1 && (ptr + 1) < &tmp[256]) { + *(ptr++) = *(list++); + } + *ptr = 0; + + if ((ptr + 1) >= &tmp[256]) { + ListParseMessage( + CLPReportError_V, + (source == 1) ? text : 0, + CLPStr9, + tmp, + tmp + strlen(tmp) - 16, + 256 + ); + return 0; + } + + if (!FindFileInPath(tmp, &spec)) { + if (OS_IsDir(&spec)) { + ListParseMessage( + CLPReportError_V, + (source == 1) ? text : 0, + CLPStr16, + tmp + ); + } else { + ListParseMessage( + CLPReportWarning_V, + (source == 1) ? text : 0, + CLPStr44, + tmp + ); + } + } else { + AddFileToProject(&spec, 0, 0, 1, position); + } + + if (*list) + ++list; + } + + return 1; +} + +int IsFileInOutputDirectory(const OSSpec *file) { + OSPathSpec outdir; + GetOutputFileDirectory(&outdir); + return OS_EqualPathSpec(&outdir, &file->path); +} + +void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen) { + char filename[64]; + OSSpec spec; + int err; + + err = OS_MakeFileSpec(input, &spec); + if (err) { + CLPOSAlert(CLPStr64, err, input); + name[0] = 0; + return; + } + + if (!IsFileInOutputDirectory(&spec)) { + CLPReportWarning(CLPStr61, OS_SpecToStringRelative(&spec, 0, STSbuf, sizeof(STSbuf))); + } + + OS_NameSpecToString(&spec.name, filename, 256); + if (strlen(filename) >= maxlen) { + CLPReportWarning(CLPStr65, filename, maxlen - 1); + filename[maxlen - 1] = 0; + } + + strcpy(name, filename); +} + +void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len) { + GetCFileNameInOutputDirectory(input, (char *) name, len); + c2pstr((char *) name); +} + +void AddStringLenToHandle(Handle *h, const char *str, int len) { + SInt32 old; + + if (!*h) { + if ((*h = NewHandle(len + 1))) { + HLock(*h); + memcpy(**h, str, len); + (**h)[len] = 0; + HUnlock(*h); + } else { + exit(-23); + } + } else { + old = GetHandleSize(*h) - 1; + SetHandleSize(*h, old + len + 1); + if (MemError() == noErr) { + HLock(*h); + memcpy(**h + old, str, len); + (**h)[old + len] = 0; + HUnlock(*h); + } else { + exit(-23); + } + } +} + +void AddStringToHandle(Handle *h, const char *str) { + AddStringLenToHandle(h, str, strlen(str)); +} + +int Opt_PrintVersion(const char *opt, void *var, const char *arg, int flags) { + ShowVersion(0); + return 1; +} + +void GetFirstSourceFilenameBase(char *buffer, char *defaul) { + int cnt; + OSSpec spec; + char compiler[32]; + int x; + char *ext; + + cnt = GetFileCount(); + for (x = 0; x < cnt; x++) { + if (GetFileInfo(x, &spec, compiler)) { + if (compiler[0]) { + if (!strstr(compiler, "Lib")) { + OS_NameSpecToString(&spec.name, buffer, 256); + ext = strrchr(buffer, '.'); + if (ext) + *ext = 0; + memmove(buffer, buffer, strlen(buffer) + 1); + return; + } + } + } + } + + strcpy(buffer, defaul); +} + +int Opt_SavePrefs(const char *opt, void *var, const char *arg, int flags) { + Parser_StorePanels(parseopts.context); + return 1; +} + +int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **endptr) { + char *end; + + if (arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X')) { + *ret = strtol(arg + 2, &end, 16); + } else if (arg[0] == '0') { + *ret = strtol(arg + 1, &end, 8); + } else { + *ret = strtol(arg, &end, 10); + } + + if (endptr) + *endptr = end; + + if (*end && emit_error) { + CLPReportError(CLPStr5, "", arg); + return 0; + } + + return 1; +} + +int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg, int flags) { + if (dashIMinusMovesPaths && !usedDashIMinus) + MoveSystemPathsIntoUserList(); + return 1; +} diff --git a/command_line/C++_Parser/Src/Library/Projects.c b/command_line/C++_Parser/Src/Library/Projects.c new file mode 100644 index 0000000..dca9df2 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/Projects.c @@ -0,0 +1,241 @@ +#include "parser.h" + +extern char STSbuf[256]; + +int GetFileCount(void) { + SInt32 num; + CWGetProjectFileCount(parseopts.context, &num); + return num; +} + +void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename) { + CWResult result; + if (outfilename && outfilename[0]) { + result = CWParserSetFileOutputName(parseopts.context, position, which ? which : 1, outfilename); + if (result) { + failedCallback = "CWParserSetFileOutputName"; + longjmp(exit_plugin, result); + } + } +} + +int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position) { + CWFileSpec cws; + CWNewProjectEntryInfo pei; + CWResult result; + int err; + + err = OS_OSSpec_To_FSSpec(oss, &cws); + if (err) { + CLPOSAlert(44, err, OS_SpecToStringRelative(oss, 0, STSbuf, sizeof(STSbuf))); + return 0; + } + + if (position == -2) { + pei.position = 0; + } else if (position == -1) { + CWGetProjectFileCount(parseopts.context, &pei.position); + } else if (position == 0) { + pei.position = -1; + } else { + pei.position = position; + } + + pei.segment = parseopts.currentSegment; + pei.overlayGroup = parseopts.currentOverlayGroup; + pei.overlay = parseopts.currentOverlay; + pei.groupPath = NULL; + pei.mergeintooutput = parseopts.mergeIntoOutput; + pei.weakimport = parseopts.weakImport; + pei.initbefore = parseopts.initBefore; + result = CWAddProjectEntry(parseopts.context, &cws, exists == 0, &pei, &position); + if (result) { + failedCallback = "CWAddProjectEntry"; + longjmp(exit_plugin, result); + } + parseopts.initBefore = 0; + parseopts.weakImport = 0; + parseopts.mergeIntoOutput = 0; + SetFileOutputName(position, which, outfilename); + return 1; +} + +Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin) { + CWProjectFileInfo pfi; + if (CWGetFileInfo(parseopts.context, position, 1, &pfi)) + return 0; + + OS_FSSpec_To_OSSpec(&pfi.filespec, spec); + strncpy(plugin, pfi.dropinname, 32); + plugin[31] = 0; + return 1; +} + +int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive) { + CWNewAccessPathInfo api; + CWResult result; + OSSpec spec; + int err; + CWAccessPathListInfo apli; + + if ((err = OS_MakeSpecWithPath(oss, NULL, 0, &spec)) || (err = OS_OSSpec_To_FSSpec(&spec, &api.pathSpec))) { + CLPOSAlert(45, err, OS_PathSpecToString(&spec.path, STSbuf, sizeof(STSbuf))); + return 0; + } + + if (position == -2) { + api.position = 0; + } else if (position == -1 || position == 0) { + api.position = -1; + } else if (position == -1) { + result = CWGetAccessPathListInfo(parseopts.context, &apli); + if (result) { + failedCallback = "CWGetAccessPathListInfo"; + longjmp(exit_plugin, result); + } + if ((type & 1) == 1) { + api.position = apli.systemPathCount; + } else { + api.position = apli.userPathCount; + } + } else { + api.position = position; + } + + api.type = (type & 1) ? cwSystemPath : cwUserPath; + api.type = api.type | (CWAccessPathType) ((type & 2) ? cwAccessPathTypeFlag2 : 0); + api.recursive = recursive; + + result = CWParserAddAccessPath(parseopts.context, &api); + if (result) { + failedCallback = "CWParserAddAccessPath"; + longjmp(exit_plugin, result); + } + + return 1; +} + +int MoveSystemPathsIntoUserList(void) { + CWResult result = CWParserSwapAccessPaths(parseopts.context); + return result == cwNoErr; +} + +void AddVirtualFile(const char *filename, Handle *text) { + CWResult result; + CWMemHandle mh; + + if (*text) { + CWSecretAttachHandle(parseopts.context, *text, &mh); + result = CWParserCreateVirtualFile(parseopts.context, filename, mh); + if (result) { + failedCallback = "CWParserCreateVirtualFile"; + longjmp(exit_plugin, result); + } + DisposeHandle(*text); + *text = NULL; + } +} + +void GetOutputFileDirectory(OSPathSpec *dir) { + CWResult result; + CWFileSpec idefss; + OSSpec spec; + + result = CWGetOutputFileDirectory(parseopts.context, &idefss); + if (result) { + failedCallback = "CWGetOutputFileDirectory"; + longjmp(exit_plugin, result); + } + + OS_FSSpec_To_OSSpec(&idefss, &spec); + *dir = spec.path; +} + +void SetOutputFileDirectory(OSPathSpec *dir) { + CWResult result; + CWFileSpec idefss; + OSSpec spec; + + OS_MakeSpecWithPath(dir, NULL, 0, &spec); + OS_OSSpec_To_FSSpec(&spec, &idefss); + + result = CWParserSetOutputFileDirectory(parseopts.context, &idefss); + if (result) { + failedCallback = "CWParserSetOutputFileDirectory"; + longjmp(exit_plugin, result); + } +} + +void AddOverlayGroup(const char *name, CWAddr64 *addr, SInt32 *groupnum, SInt32 *overlaynum) { + CWResult result; + + *overlaynum = -1; + result = CWParserAddOverlay1Group(parseopts.context, name, addr, groupnum); + if (result) { + if (result == cwErrInvalidCallback) { + CLPReportError(72); + } else { + failedCallback = "CWParserAddOverlay1Group"; + longjmp(exit_plugin, result); + } + } +} + +void AddOverlay(SInt32 groupnum, const char *name, SInt32 *overlaynum) { + CWResult result; + + result = CWParserAddOverlay1(parseopts.context, name, groupnum, overlaynum); + if (result) { + if (result == cwErrInvalidCallback) { + CLPReportError(72); + } else { + failedCallback = "CWParserAddOverlay1"; + longjmp(exit_plugin, result); + } + } +} + +void AddSegment(const char *name, SInt16 attrs, SInt32 *segmentnum) { + CWResult result; + + result = CWParserAddSegment(parseopts.context, name, attrs, segmentnum); + if (result) { + if (result == cwErrInvalidCallback) { + CLPReportError(73); + } else { + failedCallback = "CWParserAddSegment"; + longjmp(exit_plugin, result); + } + } +} + +void ChangeSegment(SInt32 segmentnum, const char *name, SInt16 attrs) { + CWResult result; + + result = CWParserSetSegment(parseopts.context, segmentnum, name, attrs); + if (result) { + if (result == cwErrInvalidCallback) { + CLPReportError(73); + } else { + failedCallback = "CWParserSetSegment"; + longjmp(exit_plugin, result); + } + } +} + +int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs) { + CWResult result; + CWProjectSegmentInfo psi; + + result = CWGetSegmentInfo(parseopts.context, segmentnum, &psi); + if (result) { + if (result == cwErrInvalidCallback) { + CLPReportError(73); + } + return 0; + } + + strcpy(name, psi.name); + *attrs = psi.attributes; + return 1; +} diff --git a/command_line/C++_Parser/Src/Library/StaticParserGlue.c b/command_line/C++_Parser/Src/Library/StaticParserGlue.c new file mode 100644 index 0000000..7a44487 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/StaticParserGlue.c @@ -0,0 +1,29 @@ +#include "parser.h" +#include "cmdline.h" + +static BasePluginCallbacks cb = { + parser_main, + CWParser_GetDropInFlags, + CWParser_GetDisplayName, + CWParser_GetDropInName, + CWParser_GetPanelList, + NULL, + NULL, + CWParser_GetVersionInfo, + NULL +}; + +static ParserPluginCallbacks pr_cb = { + Parser_SupportsPlugin, + Parser_SupportsPanels +}; + +int RegisterStaticParserPlugins(void) { + return RegisterStaticParserPlugin(&cb, &pr_cb); +} + +#include "ParserErrors.r" + +int RegisterStaticParserResources(void) { + return RegisterResource("Parser Strings", 12010, STR12010); +} diff --git a/command_line/C++_Parser/Src/Library/StdTargetWarningHelpers-cc.c b/command_line/C++_Parser/Src/Library/StdTargetWarningHelpers-cc.c new file mode 100644 index 0000000..c1f378d --- /dev/null +++ b/command_line/C++_Parser/Src/Library/StdTargetWarningHelpers-cc.c @@ -0,0 +1,81 @@ +#include "parser.h" + +PExtraWarningC pExtraWarningC = {0}; +Pragma warningPragmas[] = { + &pExtraWarningC.warn_largeargs, "warn_largeargs", 0, + &pExtraWarningC.warn_padding, "warn_padding", 0, + &pExtraWarningC.warn_resultnotused, "warn_resultnotused", 0, + &pExtraWarningC.warn_ptr_int_conv, "warn_ptr_int_conv", 0, + &pExtraWarningC.warn_no_side_effect, "warn_no_side_effect", 0, + 0, 0, 0 +}; + +int TargetSetWarningFlags(short val, Boolean set) { + switch (val) { + case 'Ip': pWarningC.warn_illpragma = set; break; + case 'Ed': pWarningC.warn_emptydecl = set; break; + case 'Pu': pWarningC.warn_possunwant = set; break; + case 'Uv': pWarningC.warn_unusedvar = set; break; + case 'Ua': pWarningC.warn_unusedarg = set; break; + case 'Ec': pWarningC.warn_extracomma = set; break; + case 'Pd': pWarningC.pedantic = set; break; + case 'Hv': pWarningC.warn_hidevirtual = set; break; + case 'Ic': pWarningC.warn_implicitconv = set; break; + case 'Ni': pWarningC.warn_notinlined = set; break; + case 'Sc': pWarningC.warn_structclass = set; break; + case 'Pa': pExtraWarningC.warn_padding = set ? PR_ON : PR_OFF; break; + case 'Nu': pExtraWarningC.warn_resultnotused = set ? PR_ON : PR_OFF; break; + case 'Se': pExtraWarningC.warn_no_side_effect = set ? PR_ON : PR_OFF; break; + case 'PI': pExtraWarningC.warn_ptr_int_conv = set ? PR_ON : PR_OFF; break; + case 'La': pExtraWarningC.warn_largeargs = set ? PR_ON : PR_OFF; break; + case 'We': pWarningC.warningerrors = set; break; + case 'Cp': pFrontEndC.checkprotos = set; break; + default: return 0; + } + + return 1; +} + +void TargetDisplayWarningOptions(Handle txt) { + HPrintF(txt, "C language warning options:\n"); + + if (pWarningC.warn_illpragma) + HPrintF(txt, "\t- illegal pragmas\n"); + if (pWarningC.warn_emptydecl) + HPrintF(txt, "\t- empty declarations\n"); + if (pWarningC.warn_possunwant) + HPrintF(txt, "\t- possible unwanted effects\n"); + if (pWarningC.warn_unusedvar) + HPrintF(txt, "\t- unused variables\n"); + if (pWarningC.warn_unusedarg) + HPrintF(txt, "\t- unused arguments\n"); + if (pWarningC.warn_extracomma) + HPrintF(txt, "\t- extra commas\n"); + if (pWarningC.pedantic) + HPrintF(txt, "\t- pedantic\n"); + if (pWarningC.warn_hidevirtual) + HPrintF(txt, "\t- hidden virtual functions\n"); + if (pWarningC.warn_implicitconv) + HPrintF(txt, "\t- implicit conversions\n"); + if (pWarningC.warn_notinlined) + HPrintF(txt, "\t- 'inline' not performed\n"); + if (pWarningC.warn_structclass) + HPrintF(txt, "\t- struct/class conflict\n"); + if (pExtraWarningC.warn_largeargs == 1) + HPrintF(txt, "\t- large args passed to unprototyped functions\n"); + if (pExtraWarningC.warn_padding == 1) + HPrintF(txt, "\t- padding added between struct members\n"); + if (pExtraWarningC.warn_resultnotused == 1) + HPrintF(txt, "\t- result of non-void function call not used\n"); + if (pExtraWarningC.warn_no_side_effect == 1) + HPrintF(txt, "\t- use of expressions as statements without side effects\n"); + if (pExtraWarningC.warn_ptr_int_conv == 1) + HPrintF(txt, "\t- implicit integer/pointer conversions\n"); + if (pFrontEndC.checkprotos) + HPrintF(txt, "\t- checking prototypes\n"); + + if (pWarningC.warningerrors) + HPrintF(txt, "\t- warnings are errors\n"); + else + HPrintF(txt, "\t- warnings are not errors\n"); +} diff --git a/command_line/C++_Parser/Src/Library/Targets.c b/command_line/C++_Parser/Src/Library/Targets.c new file mode 100644 index 0000000..378b9d7 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/Targets.c @@ -0,0 +1,65 @@ +#include "parser.h" + +ParserTool *pTool; + +int SetParserToolInfo(ParserTool *tool) { + pTool = tool; + + OS_ASSERT(16, pTool->toolInfo && (parseopts.toolVersion || pTool->copyright)); + + return 1; +} + +Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os) { + if (!pTool) { + CLPFatalError("No options loaded for command line\n"); + return 0; + } + + if ( + (type == CWDROPINANYTYPE || pTool->TYPE == CWDROPINANYTYPE || pTool->TYPE == type) && + (lang == Lang_Any || pTool->LANG == Lang_Any || pTool->LANG == lang) && + (cpu == targetCPUAny || pTool->CPU == targetCPUAny || pTool->CPU == cpu) && + (os == targetOSAny || pTool->OS == targetOSAny || pTool->OS == os) + ) + { + return 1; + } else { + return 0; + } +} + +Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames) { + int idx; + int scan; + + if (!pTool) + CLPFatalError("No options loaded for command line\n"); + + for (idx = 0; idx < numPanels; idx++) { + for (scan = 0; scan < pTool->numPrefPanels; scan++) { + if (!ustrcmp(pTool->prefPanels[scan], panelNames[idx])) + break; + } + + if (scan >= pTool->numPrefPanels) + break; + } + + if (idx >= numPanels) + return 1; + else + return 0; +} + +Boolean SetupParserToolOptions(void) { + int idx; + + Options_Init(); + for (idx = 0; idx < pTool->numOptionLists; idx++) { + Options_AddList(pTool->optionLists[idx]); + } + Options_SortOptions(); + + return 1; +} diff --git a/command_line/C++_Parser/Src/Library/ToolHelpers-cc.c b/command_line/C++_Parser/Src/Library/ToolHelpers-cc.c new file mode 100644 index 0000000..b58f188 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/ToolHelpers-cc.c @@ -0,0 +1,36 @@ +#include "parser.h" +#include "cmdline.h" + +int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int) { + CLPFatalError("Calling linker option '%s'\n", opt); + return 0; +} + +int Opt_DummyLinkerSettingRoutine(const char *var, const char *val) { + CLPFatalError("Calling linker settings option '%s'='%s'\n", var, val ? val : ""); + return 0; +} + +void FinishCompilerTool(void) { + SInt32 numfiles; + + if (parseopts.lastoutputname[0]) { + numfiles = GetFileCount(); + + if (pCmdLine.stages == CmdLineStageMask_Dp) { + strcpy(pCmdLineCompiler.outMakefile, parseopts.lastoutputname); + } else if (outputOrdering == OutputOrdering2) { + if (parseopts.possibleFiles > 0 || parseopts.userSpecifiedFiles > 0) + CLPReportError(41, parseopts.lastoutputname); + else + CLPReportError(42, parseopts.lastoutputname); + } else { + SetFileOutputName(numfiles - 1, lastStage, parseopts.lastoutputname); + } + + parseopts.lastoutputname[0] = 0; + } + + if (setOutputDirectory) + pCmdLineCompiler.relPathInOutputDir = 0; +} diff --git a/command_line/C++_Parser/Src/Library/ToolHelpers.c b/command_line/C++_Parser/Src/Library/ToolHelpers.c new file mode 100644 index 0000000..e872546 --- /dev/null +++ b/command_line/C++_Parser/Src/Library/ToolHelpers.c @@ -0,0 +1,289 @@ +#include "parser.h" +#include "cmdline.h" +#include + +extern char STSbuf[256]; + +static Boolean setStage; +char linkerOutputFilename[256]; +Boolean setLinkerOutputFilename; +Boolean setOutputDirectory; +SInt16 outputOrdering; + +int Opt_HandleOutputName(const char *opt, void *, const char *filename, int flags) { + OSSpec spec; + int err; + SInt32 result; + Boolean isfile; + + if (!filename) + filename = opt; + + if ((pCmdLine.state == OptsCmdLineState_3 || (pCmdLine.state == OptsCmdLineState_0 && pTool->TYPE == CWDROPINLINKERTYPE)) && pCmdLine.toDisk != 4) { + if (setLinkerOutputFilename) { + CLPReportError(CLPStr41, filename); + return 0; + } + setLinkerOutputFilename = 1; + if (pTool->TYPE == CWDROPINCOMPILERTYPE) { + strncpy(linkerOutputFilename, filename, 256); + } else { + OSSpec spec; + int err; + Boolean isfile; + err = OS_MakeSpec(filename, &spec, &isfile); + if (err) { + CLPOSAlert(CLPStr64, err, filename); + return 0; + } + if (isfile) + OS_NameSpecToString(&spec.name, linkerOutputFilename, 256); + SetOutputFileDirectory(&spec.path); + } + return 1; + } else { + err = OS_MakeSpec(filename, &spec, &isfile); + if (err) { + CLPOSAlert(CLPStr64, err, filename); + return 0; + } + + if (!err && !isfile) { + FSSpec ofd; + if (setOutputDirectory) { + CLPReportError(CLPStr59, filename); + return 0; + } + setOutputDirectory = 1; + + OS_OSSpec_To_FSSpec(&spec, &ofd); + result = CWParserSetOutputFileDirectory(parseopts.context, &ofd); + if (result) { + failedCallback = "CWParserSetOutputFileDirectory"; + longjmp(exit_plugin, result); + } + return 1; + } else { + SInt32 index; + CWProjectFileInfo pfi; + if (parseopts.lastoutputname[0]) { + CLPReportError(CLPStr41, filename); + return 0; + } + strncpy(parseopts.lastoutputname, filename, 256); + if (pCmdLine.stages == CmdLineStageMask_Dp) + return 1; + + if (outputOrdering == OutputOrdering0 || outputOrdering == OutputOrdering1) { + CWGetProjectFileCount(parseopts.context, &index); + while (index-- > 0) { + if (!CWGetFileInfo(parseopts.context, index, 0, &pfi) && pfi.filetype == CWFOURCHAR('T','E','X','T')) { + outputOrdering = OutputOrdering1; + break; + } + } + + if (index <= 0) { + CWGetProjectFileCount(parseopts.context, &index); + if (index > 0) + outputOrdering = OutputOrdering1; + --index; + } + + if (outputOrdering == OutputOrdering0) { + outputOrdering = OutputOrdering2; + return 1; + } + + SetFileOutputName(index, lastStage, parseopts.lastoutputname); + parseopts.lastoutputname[0] = 0; + } + + return 1; + } + } +} + +int ValidateToolState(Boolean mustHaveFiles) { + if (parseopts.noOptions) { + pCmdLine.state = OptsCmdLineState_1; + ShowVersion(1); + return 1; + } + + if (parseopts.success) { + if (!parseopts.userSpecifiedFiles) { + if (!parseopts.hadAnyOutput) { + if (mustHaveFiles) { + CLPReportError(CLPStr70); + return 0; + } + } else { + if (mustHaveFiles) + pCmdLine.state = OptsCmdLineState_1; + return 1; + } + } else if (parseopts.unusedFiles > 0) { + CLPReportError(CLPStr69); + return 0; + } + } + + if (pCmdLine.state == OptsCmdLineState_0 || (parseopts.userSpecifiedFiles > 0 && pCmdLine.state == OptsCmdLineState_1)) + pCmdLine.state = OptsCmdLineState_3; + + if (!setStage) { + pCmdLine.stages = CmdLineStageMask_Cg; + if (pCmdLine.state == OptsCmdLineState_2) + pCmdLine.toDisk |= 2; + } + + if (pCmdLine.state == OptsCmdLineState_3 && !(pCmdLine.stages & CmdLineStageMask_Cg)) + pCmdLine.state = OptsCmdLineState_2; + + return 1; +} + +void ToolReportMessage(SInt16 errid, SInt16 type, va_list va) { + char str[256]; + char buf[1024]; + + GetIndString((StringPtr) str, 13000, errid); + p2cstr((StringPtr) str); + vsprintf(buf, str, va); + CWReportMessage(parseopts.context, 0, buf, 0, type, 0); +} + +void ToolReportWarning(SInt16 id, ...) { + va_list va; + va_start(va, id); + ToolReportMessage(id, messagetypeWarning, va); + va_end(va); +} + +void ToolReportError(SInt16 id, ...) { + va_list va; + va_start(va, id); + ToolReportMessage(id, messagetypeError, va); + va_end(va); + parseopts.hadErrors = 1; +} + +void ToolReportOSError(SInt16 id, int err, ...) { + char str[256]; + char buf[1024]; + va_list va; + + GetIndString((StringPtr) str, 13000, id); + p2cstr((StringPtr) str); + va_start(va, err); + vsprintf(buf, str, va); + va_end(va); + CWAlert(parseopts.context, buf, OS_GetErrText(err), 0, 0); +} + +void ToolReportInfo(SInt16 id, ...) { + va_list va; + va_start(va, id); + ToolReportMessage(id, messagetypeInfo, va); + va_end(va); +} + +int Opt_DoNotLink(const char *opt, void *var, const char *arg) { + if (pCmdLine.state == OptsCmdLineState_3 || pCmdLine.state == OptsCmdLineState_0 || pCmdLine.state == OptsCmdLineState_1) + pCmdLine.state = OptsCmdLineState_2; + return 1; +} + +int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg, int flags) { + if (pCmdLine.verbose) + pCmdLine.verbose++; + else + pCmdLine.verbose = 2; + + Parser_StorePanels(parseopts.context); + return 1; +} + +int Opt_SetStage(const char *opt, void *str, const char *arg, int flags) { + unsigned char *ptr; + Boolean set; + Boolean no; + UInt16 flag; + + ptr = (unsigned char *) str; + // doesn't match - type issue with 'no' + no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3); + set = (Boolean) (no ^ 1); + + while (*ptr) { + if (*ptr == '+') { + set = !no; + } else if (*ptr == '-') { + set = no; + } else if (*ptr == '|') { + set = (Boolean) (no ^ 1); + } else { + flag = (ptr[0] << 8) | ptr[1]; + setStage = 1; + + switch (flag) { + case 'Cg': + if (set) + pCmdLine.stages |= CmdLineStageMask_Cg; + else + pCmdLine.stages &= ~CmdLineStageMask_Cg; + lastStage = CmdLineStage_Cg; + break; + case 'Ds': + if (set) + pCmdLine.stages |= CmdLineStageMask_Ds; + else + pCmdLine.stages &= ~CmdLineStageMask_Ds; + lastStage = CmdLineStage_Ds; + break; + case 'Pp': + if (set) + pCmdLine.stages |= CmdLineStageMask_Pp; + else + pCmdLine.stages &= ~CmdLineStageMask_Pp; + lastStage = CmdLineStage_Pp; + break; + case 'Dp': + if (set) + pCmdLine.stages |= CmdLineStageMask_Dp; + else + pCmdLine.stages &= ~CmdLineStageMask_Dp; + break; + default: + CLPFatalError("Bad stage settings in %s (%c%c)\n", str, ptr[0], ptr[1]); + } + + ++ptr; + } + + ++ptr; + } + + return 1; +} + +int Opt_RedirectStream(const char *opt, void *file, const char *filename) { + OSSpec spec; + int err; + FILE *nw; + + err = OS_MakeFileSpec(filename, &spec); + if (err) { + CLPReportError(CLPStr78, filename, OS_GetErrText(err)); + return 0; + } + + nw = freopen(OS_SpecToString(&spec, STSbuf, 256), "wt", (FILE *) file); + if (!nw) { + CLPReportError(CLPStr78, filename, strerror(errno)); + return 0; + } + + return 1; +} diff --git a/command_line/C++_Parser/Src/Library/Utils.c b/command_line/C++_Parser/Src/Library/Utils.c new file mode 100644 index 0000000..b627c4d --- /dev/null +++ b/command_line/C++_Parser/Src/Library/Utils.c @@ -0,0 +1,174 @@ +#include "parser.h" + +int my_tolower(char c) { + if (c >= 'A' && c <= 'Z') + return c | 0x20; + else + return c; +} + +int my_isdigit(char c) { + return (c >= '0' && c <= '9'); +} + +int my_isalpha(char c) { + return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); +} + +int my_isalnum(char c) { + return my_isdigit(c) || my_isalpha(c); +} + +int my_isxdigit(char c) { + return my_isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); +} + +char *Utils_SpellList(char *list, char *buffer, char opts) { + char *sptr; + char *eptr; + char *nptr; + char *bptr; + int pflen; + int npflen; + int undo; + char *neptr; + int cnt; + + undo = 0; + bptr = buffer; + sptr = list; + pflen = 0; + while (sptr) { + if ((opts & 1) && !pflen) + *(bptr++) = *MAINOPTCHAR; + + eptr = strchr(sptr, '|'); + if (!eptr) { + eptr = sptr + strlen(sptr); + nptr = 0; + } else if (eptr[1] == '|') { + nptr = 0; + } else { + nptr = eptr + 1; + } + + if (undo == 0 && !pflen) { + if (opts & 8) { + *(bptr++) = '['; + *(bptr++) = 'n'; + *(bptr++) = 'o'; + *(bptr++) = ']'; + } + if (opts & 0x20) { + *(bptr++) = '['; + *(bptr++) = 'n'; + *(bptr++) = 'o'; + *(bptr++) = '-'; + *(bptr++) = ']'; + } + } + + npflen = 0; + if (nptr) { + while (sptr < nptr && *nptr && *nptr != '|' && sptr[npflen] == nptr[npflen]) + npflen++; + + if (npflen) { + neptr = strchr(nptr, '|'); + if (!neptr) + neptr = nptr + strlen(nptr); + if ((neptr - nptr) < (eptr - sptr) || ((sptr[1] && sptr[1] != '|') ? (sptr[1] != nptr[1]) : 0)) + npflen = 0; + if (opts & 0x40) + npflen = 0; + } + } + + if (pflen) { + sptr += pflen; + while (sptr < eptr) { + *(bptr++) = *(sptr++); + } + if (npflen > pflen) { + *(bptr++) = '['; + undo++; + } + if (npflen < pflen) { + *(bptr++) = ']'; + undo--; + } + } else if (npflen) { + for (cnt = npflen; cnt > 0; cnt--) { + *(bptr++) = *(sptr++); + } + *(bptr++) = '['; + undo++; + } + + while (sptr < eptr) { + *(bptr++) = *(sptr++); + } + + if (opts & 0x10) { + *(bptr++) = '['; + *(bptr++) = '-'; + *(bptr++) = ']'; + } + if (opts & 0x40) { + *(bptr++) = '+'; + } + + sptr = nptr; + if (nptr && bptr[-1] != '[') { + if ((opts & 1) || (bptr[-1] == ']') || ((opts & 8) && !undo)) { + *(bptr++) = ' '; + *(bptr++) = '|'; + *(bptr++) = ' '; + } else { + *(bptr++) = '|'; + } + } + + opts &= ~0x40; + pflen = npflen; + } + + for (cnt = undo; cnt; cnt--) { + *(bptr++) = ']'; + } + + if (opts & 4) + bptr += sprintf(bptr, "=..."); + + *bptr = 0; + return bptr; +} + +int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky) { + const char *ae; + const char *be; + + for (ae = a; *ae && *ae != '|'; ae++) {} + for (be = b; *be && *be != '|'; be++) {} + + if (sticky && (be - b) < (ae - a)) + return 0; + + if (cased) { + while (a < ae && b < be) { + if (*a != *b) + break; + a++; + b++; + } + } else { + while (a < ae && b < be) { + if (my_tolower(*a) != my_tolower(*b)) + break; + a++; + b++; + } + } + + return (a == ae) && (sticky || b == be); +} diff --git a/command_line/CmdLine/Src/CLFileTypes.c b/command_line/CmdLine/Src/CLFileTypes.c new file mode 100644 index 0000000..3416603 --- /dev/null +++ b/command_line/CmdLine/Src/CLFileTypes.c @@ -0,0 +1,29 @@ +#include "cmdline.h" + +void AddFileTypeMappingList(OSFileTypeMappings **list, const OSFileTypeMappingList *entry) { + OS_AddFileTypeMappingList(list, entry); +} + +void UseFileTypeMappings(OSFileTypeMappings *list) { + OS_UseFileTypeMappings(list); +} + +OSErr SetMacFileType(const FSSpec *spec, OSType mactype) { + OSSpec ospec; + OSErr err; + + err = OS_FSSpec_To_OSSpec(spec, &ospec); + if (err) + return err; + return OS_SetMacFileType(&ospec, mactype); +} + +OSErr GetMacFileType(const FSSpec *spec, OSType *mactype) { + OSSpec ospec; + OSErr err; + + err = OS_FSSpec_To_OSSpec(spec, &ospec); + if (err) + return err; + return OS_GetMacFileType(&ospec, mactype); +} diff --git a/command_line/CmdLine/Src/Clients/CLStaticMain.c b/command_line/CmdLine/Src/Clients/CLStaticMain.c index 871dcef..77910fe 100644 --- a/command_line/CmdLine/Src/Clients/CLStaticMain.c +++ b/command_line/CmdLine/Src/Clients/CLStaticMain.c @@ -4,16 +4,16 @@ extern const char *CMDLINE_BUILD_TIME; extern const char *CMDLINE_BUILD_DATE; // Glue functions -extern int RegisterStaticParserPlugins(); -extern int RegisterStaticParserResources(); +extern int RegisterStaticParserPlugins(void); +extern int RegisterStaticParserResources(void); extern void GetStaticTarget(OSType *cpu, OSType *os); extern void GetStaticPluginType(OSType *language, OSType *plugintype); extern void GetStaticParserPluginType(OSType *style); -extern int RegisterStaticTargetResources(); -extern int RegisterStaticTargetPlugins(); +extern int RegisterStaticTargetResources(void); +extern int RegisterStaticTargetPlugins(void); -extern int RegisterStaticParserToolInfo(); +extern int RegisterStaticParserToolInfo(void); int main(int argc, char **argv) { OSType cpu; diff --git a/command_line/CmdLine/Src/uFileTypeMappings.c b/command_line/CmdLine/Src/uFileTypeMappings.c deleted file mode 100644 index 56aaea5..0000000 --- a/command_line/CmdLine/Src/uFileTypeMappings.c +++ /dev/null @@ -1,31 +0,0 @@ -#include "cmdline.h" - -// I don't actually have a name for this file, annoyingly enough - -void AddFileTypeMappingList(OSFileTypeMappings **list, const OSFileTypeMappingList *entry) { - OS_AddFileTypeMappingList(list, entry); -} - -void UseFileTypeMappings(OSFileTypeMappings *list) { - OS_UseFileTypeMappings(list); -} - -OSErr SetMacFileType(const FSSpec *spec, OSType mactype) { - OSSpec ospec; - OSErr err; - - err = OS_FSSpec_To_OSSpec(spec, &ospec); - if (err) - return err; - return OS_SetMacFileType(&ospec, mactype); -} - -OSErr GetMacFileType(const FSSpec *spec, OSType *mactype) { - OSSpec ospec; - OSErr err; - - err = OS_FSSpec_To_OSSpec(spec, &ospec); - if (err) - return err; - return OS_GetMacFileType(&ospec, mactype); -} diff --git a/command_line/PluginLib/Src/Internal/COSToolsCLT.c b/command_line/PluginLib/Src/Internal/COSToolsCLT.c new file mode 100644 index 0000000..11f1668 --- /dev/null +++ b/command_line/PluginLib/Src/Internal/COSToolsCLT.c @@ -0,0 +1,292 @@ +#include "cw_common.h" +#include "cos.h" + +extern Boolean systemHandles; + +static StringPtr COS_pstrcpy(StringPtr dst, ConstStringPtr src) { + short cnt; + for (cnt = src[0]; cnt >= 0; cnt--) { + *(dst++) = *(src++); + } + return dst; +} + +static StringPtr COS_pstrcat(StringPtr dst, ConstStringPtr src) { + // not matching + short as; + short bs; + + bs = *(src++); + as = dst[0]; + if ((bs + as) > 255) + bs = 255 - as; + + dst[0] += bs; + dst = &dst[as]; + dst++; + + while (bs-- > 0) { + *(dst++) = *(src++); + } + return dst; +} + +static void COS_pstrcharcat(StringPtr to, char ch) { + if (to[0] < 255) { + to[0]++; + to[to[0]] = ch; + } +} + +static short COS_pstrcmp(ConstStringPtr a, ConstStringPtr b) { + short as, bs; + if ((bs = *(b++)) != (as = *(a++))) + return 1; + while (as-- > 0) { + if (*(a++) != *(b++)) + return 1; + } + return 0; +} + +Handle COS_NewHandle(SInt32 byteCount) { + return NewHandle(byteCount); +} + +Handle COS_NewOSHandle(SInt32 logicalSize) { + OSErr err; + Handle h; + + if (systemHandles) { + h = TempNewHandle(logicalSize, &err); + if (!err) + return h; + } + + return NULL; +} + +void COS_FreeHandle(Handle handle) { + DisposeHandle(handle); +} + +Boolean COS_ResizeHandle(Handle handle, SInt32 newSize) { + SetHandleSize(handle, newSize); + return LMGetMemErr() == noErr; +} + +SInt32 COS_GetHandleSize(Handle handle) { + return GetHandleSize(handle); +} + +void COS_LockHandle(Handle handle) { + HLock(handle); +} + +void COS_LockHandleHi(Handle handle) { + HLockHi(handle); +} + +void COS_UnlockHandle(Handle handle) { + HUnlock(handle); +} + +int COS_GetHandleState(Handle handle) { + return HGetState(handle); +} + +void COS_SetHandleState(Handle handle, int state) { + HSetState(handle, state); +} + +Boolean COS_IsLockedState(int state) { + return (state & 0x80) >> 7; +} + +char *COS_NewPtr(SInt32 byteCount) { + return NewPtr(byteCount); +} + +char *COS_NewPtrClear(SInt32 byteCount) { + return NewPtrClear(byteCount); +} + +void COS_FreePtr(char *ptr) { + DisposePtr(ptr); +} + +void COS_AppendPtrToHandle(char *ptr1, Handle hand2, SInt32 size) { + PtrAndHand(ptr1, hand2, size); +} + +OSErr COS_GetMemErr(void) { + return LMGetMemErr(); +} + +SInt32 COS_GetTicks(void) { + return LMGetTicks(); +} + +SInt32 COS_GetTime(void) { + return LMGetTime(); +} + +void COS_GetString(char *buffer, SInt16 strListID, SInt16 index) { + GetIndString((StringPtr) buffer, strListID, index); + p2cstr((StringPtr) buffer); +} + +void COS_GetPString(StringPtr buffer, SInt16 strListID, SInt16 index) { + GetIndString((StringPtr) buffer, strListID, index); +} + +Boolean COS_IsMultiByte(const void *str1, const void *str2) { + return OS_IsMultiByte(str1, str2); +} + +OSErr COS_FileNew(const FSSpec *spec, SInt16 *refNum, OSType creator, OSType fileType) { + OSErr err; + + HDelete(spec->vRefNum, spec->parID, spec->name); + err = HCreate(spec->vRefNum, spec->parID, spec->name, creator, fileType); + if (!err) + err = HOpenDF(spec->vRefNum, spec->parID, spec->name, fsRdWrPerm, refNum); + return err; +} + +OSErr COS_FileOpen(const FSSpec *spec, SInt16 *refNum) { + return HOpenDF(spec->vRefNum, spec->parID, spec->name, fsRdPerm, refNum); +} + +OSErr COS_FileGetType(const FSSpec *spec, OSType *fileType) { + OSErr err; + FInfo fi; + + err = HGetFInfo(spec->vRefNum, spec->parID, spec->name, &fi); + *fileType = fi.fdType; + return err; +} + +OSErr COS_FileGetSize(SInt16 refNum, SInt32 *logEOF) { + return GetEOF(refNum, logEOF); +} + +OSErr COS_FileRead(SInt16 refNum, void *buffPtr, SInt32 count) { + return FSRead(refNum, &count, buffPtr); +} + +OSErr COS_FileWrite(SInt16 refNum, const void *buffPtr, SInt32 count) { + return FSWrite(refNum, &count, buffPtr); +} + +OSErr COS_FileGetPos(SInt16 refNum, SInt32 *filePos) { + return GetFPos(refNum, filePos); +} + +OSErr COS_FileSetPos(SInt16 refNum, SInt32 filePos) { + return SetFPos(refNum, fsFromStart, filePos); +} + +OSErr COS_FileClose(SInt16 refNum) { + return FSClose(refNum); +} + +void COS_FileSetFSSpec(FSSpec *spec, ConstStringPtr path) { + char buf[256]; + OSSpec ospec; + + memcpy(buf, path + 1, path[0]); + buf[path[0]] = 0; + + if (OS_MakeSpec(buf, &ospec, NULL) || OS_OSSpec_To_FSSpec(&ospec, spec)) { + spec->vRefNum = 0; + spec->parID = 0; + c2pstrcpy(spec->name, buf); + } +} + +OSErr COS_FileMakeFSSpec(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, FSSpec *spec) { + int oerr; + OSPathSpec opspec; + char buf[256]; + OSSpec ospec; + + oerr = OS_VolDir_To_OSPathSpec(vRefNum, dirID, &opspec); + if (oerr) + return OS_MacError(oerr); + + p2cstrcpy(buf, fileName); + oerr = OS_MakeSpecWithPath(&opspec, buf, 0, &ospec); + if (oerr) { + pstrncpy(spec->name, fileName, 256); + return OS_MacError(oerr); + } else { + return OS_MacError(OS_OSSpec_To_FSSpec(&ospec, spec)); + } +} + +OSErr COS_FileMakeFSSpecWithPath(const FSSpec *inputSpec, ConstStringPtr fileName, FSSpec *spec) { + spec->vRefNum = inputSpec->vRefNum; + spec->parID = inputSpec->parID; + COS_pstrcpy(spec->name, fileName); + return noErr; +} + +OSErr COS_FileGetFileInfo(const FSSpec *spec, OSType *creator, OSType *fileType) { + OSErr err; + FInfo fi; + err = HGetFInfo(spec->vRefNum, spec->parID, spec->name, &fi); + if (fileType) + *fileType = fi.fdType; + if (creator) + *creator = fi.fdCreator; + return err; +} + +void COS_FileGetFSSpecInfo(const FSSpec *spec, SInt16 *vRefNum, SInt32 *dirID, StringPtr fileName) { + if (vRefNum) + *vRefNum = spec->vRefNum; + if (dirID) + *dirID = spec->parID; + if (fileName) + COS_pstrcpy(fileName, spec->name); +} + +static void COS_MakePath(SInt16 vRefNum, SInt32 dirID, StringPtr path) { + FSSpec fss; + OSSpec oss; + fss.vRefNum = vRefNum; + fss.parID = dirID; + COS_pstrcpy(fss.name, path); + if (!OS_FSSpec_To_OSSpec(&fss, &oss)) { + OS_SpecToString(&oss, (char *) path, 256); + c2pstr((char *) path); + } +} + +void COS_FileGetPathName(char *buffer, const FSSpec *spec, SInt32 *mdDat) { + HParamBlockRec rec; + + if (mdDat) { + rec.fileParam.ioNamePtr = (StringPtr) spec->name; + rec.fileParam.ioVRefNum = spec->vRefNum; + rec.fileParam.ioDirID = spec->parID; + rec.fileParam.ioFDirIndex = 0; + if (!PBHGetFInfoSync(&rec)) + *mdDat = rec.fileParam.ioFlMdDat; + else + *mdDat = 0; + } + + COS_pstrcpy((StringPtr) buffer, spec->name); + COS_MakePath(spec->vRefNum, spec->parID, (StringPtr) buffer); + p2cstr((StringPtr) buffer); +} + +int COS_EqualFileSpec(const FSSpec *a, const FSSpec *b) { + if (a->vRefNum != b->vRefNum) + return 0; + if (a->parID != b->parID) + return 0; + return COS_pstrcmp(a->name, b->name) == 0; +} diff --git a/command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp b/command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp new file mode 100644 index 0000000..b33ca81 --- /dev/null +++ b/command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp @@ -0,0 +1,39 @@ +#include "plugin_internal.h" + +static Boolean ValidateContext(CWPluginContext context) { + return context && (context->shellSignature == CWFOURCHAR('C','W','I','E')); +} + +typedef CWResult (*cbSecretAttachHandleType)(CWPluginContext, Handle, CWMemHandle *); +typedef CWResult (*cbSecretDetachHandleType)(CWPluginContext, CWMemHandle, Handle *); +typedef CWResult (*cbSecretPeekHandleType)(CWPluginContext, CWMemHandle, Handle *); +typedef CWResult (*cbSecretGetNamedPreferencesType)(CWPluginContext, const char *, Handle *); + +CW_CALLBACK CWSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return ((cbSecretAttachHandleType) context->callbacks->cbInternal[0])(context, handle, memHandle); +} + +CW_CALLBACK CWSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return ((cbSecretDetachHandleType) context->callbacks->cbInternal[1])(context, memHandle, handle); +} + +CW_CALLBACK CWSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return ((cbSecretPeekHandleType) context->callbacks->cbInternal[2])(context, memHandle, handle); +} + +CW_CALLBACK CWSecretGetNamedPreferences(CWPluginContext context, const char *prefsname, Handle *prefsdata) { + if (!prefsdata) + return cwErrInvalidParameter; + + CWMemHandle memHandle; + CWResult res = CWGetNamedPreferences(context, prefsname, &memHandle); + if (!res) + res = CWSecretDetachHandle(context, memHandle, prefsdata); + return res; +} diff --git a/command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp b/command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp new file mode 100644 index 0000000..6973b4d --- /dev/null +++ b/command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp @@ -0,0 +1,207 @@ +#include "plugin_internal.h" + +static CWParserContext *GetContext(CWPluginContext context) { + if (context && (context->pluginType == CWDROPINPARSERTYPE)) + return static_cast(context); + else + return 0; +} + +CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **bdate, const char **btime) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!bdate) + return cwErrInvalidParameter; + if (!btime) + return cwErrInvalidParameter; + *bdate = pc->build_date; + *btime = pc->build_time; + return cwNoErr; +} + +CW_CALLBACK CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **args) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!args) + return cwErrInvalidParameter; + *args = pc->args; + return cwNoErr; +} + +CW_CALLBACK CWParserGetTargetInfo(CWPluginContext context, CWDataType *cpu, CWDataType *os) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!cpu) + return cwErrInvalidParameter; + if (!os) + return cwErrInvalidParameter; + *cpu = pc->cpu; + *os = pc->os; + return cwNoErr; +} + +CW_CALLBACK CWParserGetToolInfo(CWPluginContext context, const ToolVersionInfo **toolVersionInfo) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!toolVersionInfo) + return cwErrInvalidParameter; + *toolVersionInfo = pc->build_tool; + return cwNoErr; +} + +CW_CALLBACK CWParserGetPlugins(CWPluginContext context, int *numPlugins, const CLPluginInfo **pluginInfo) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!numPlugins) + return cwErrInvalidParameter; + if (!pluginInfo) + return cwErrInvalidParameter; + *numPlugins = pc->numPlugins; + *pluginInfo = pc->plugins; + return cwNoErr; +} + +CW_CALLBACK CWParserGetPanels(CWPluginContext context, int *numPanels, const char ***panelNames) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!numPanels) + return cwErrInvalidParameter; + if (!panelNames) + return cwErrInvalidParameter; + *numPanels = pc->numPanels; + *panelNames = pc->panelNames; + return cwNoErr; +} + +CW_CALLBACK CWParserStoreCommandLineForPanel(CWPluginContext context, int index, const CWCommandLineArgs *args) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (index < 0 || index >= pc->numPanels) + return cwErrInvalidParameter; + if (!args) + return cwErrInvalidParameter; + pc->panel_args[index] = *args; + return cwNoErr; +} + +CW_CALLBACK CWParserStoreCommandLineForPlugin(CWPluginContext context, int index, const CWCommandLineArgs *args) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (index < 0 || index >= pc->numPlugins) + return cwErrInvalidParameter; + if (!args) + return cwErrInvalidParameter; + pc->plugin_args[index] = *args; + return cwNoErr; +} + +CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, Handle paneldata) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!panelName) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetNamedPreferences(pc, panelName, paneldata); +} + +CW_CALLBACK CWParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!api) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddAccessPath(pc, api); +} + +CW_CALLBACK CWParserSwapAccessPaths(CWPluginContext context) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + return pc->callbacks->cbParserSwapAccessPaths(pc); +} + +CW_CALLBACK CWParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!idefss) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetOutputFileDirectory(pc, idefss); +} + +CW_CALLBACK CWParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!outfilename) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetFileOutputName(pc, position, which, outfilename); +} + +CW_CALLBACK CWParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + if (!addr) + return cwErrInvalidParameter; + if (!newGroupNumber) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddOverlay1Group(pc, name, addr, newGroupNumber); +} + +CW_CALLBACK CWParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + if (!newOverlayNumber) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddOverlay1(pc, name, groupNumber, newOverlayNumber); +} + +CW_CALLBACK CWParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + if (!newSegmentNumber) + return cwErrInvalidParameter; + return pc->callbacks->cbParserAddSegment(pc, name, attrs, newSegmentNumber); +} + +CW_CALLBACK CWParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs) { + CWParserContext *pc; + if (!(pc = GetContext(context))) + return cwErrInvalidCallback; + if (!name) + return cwErrInvalidParameter; + return pc->callbacks->cbParserSetSegment(pc, segmentNumber, name, attrs); +} + +CW_CALLBACK CWParserCreateVirtualFile(CWPluginContext context, const char *name, CWMemHandle text) { + CWNewTextDocumentInfo info; + info.documentname = name; + info.text = text; + info.markDirty = 1; + return CWCreateNewTextDocument(context, &info); +} + +CW_CALLBACK CWParserDisplayTextHandle(CWPluginContext context, const char *name, CWMemHandle text) { + CWNewTextDocumentInfo info; + info.documentname = name; + info.text = text; + info.markDirty = 0; + return CWCreateNewTextDocument(context, &info); +} diff --git a/command_line/PluginLib/Src/Library/CWPluginsPrivate.cpp b/command_line/PluginLib/Src/Library/CWPluginsPrivate.cpp new file mode 100644 index 0000000..2e0df81 --- /dev/null +++ b/command_line/PluginLib/Src/Library/CWPluginsPrivate.cpp @@ -0,0 +1,513 @@ +#include "plugin_internal.h" + +// Forward declarations +CWResult OSErrtoCWResult(OSErr err); + +static Boolean ValidateContext(CWPluginContext context) { + return context + && (context->shellSignature == CWFOURCHAR('C','W','I','E')) + && (context->request != reqInitialize) + && (context->request != reqTerminate) + && (context->request != reqIdle); +} + +static Boolean ValidateInitTermContext(CWPluginContext context) { + return context + && (context->shellSignature == CWFOURCHAR('C','W','I','E')) + && ((context->request == reqInitialize) + || (context->request == reqTerminate) + || (context->request == reqIdle)); +} + +static Boolean IsVCSContext(CWPluginContext context) { + return context && (context->pluginType == CWDROPINVCSTYPE); +} + +CW_CALLBACK CWGetPluginRequest(CWPluginContext context, SInt32 *request) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (request == NULL) + return cwErrInvalidParameter; + + *request = context->request; + return cwNoErr; +} + +CW_CALLBACK CWGetAPIVersion(CWPluginContext context, SInt32 *version) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (version == NULL) + return cwErrInvalidParameter; + + *version = context->apiVersion; + return cwNoErr; +} + +CW_CALLBACK CWGetIDEInfo(CWPluginContext context, CWIDEInfo *info) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (info == NULL) + return cwErrInvalidParameter; + + *info = *context->shellInfo; + return cwNoErr; +} + +CW_CALLBACK CWGetCallbackOSError(CWPluginContext context, CWOSResult *error) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (error == NULL) + return cwErrInvalidParameter; + + *error = context->callbackOSError; + return cwNoErr; +} + +CW_CALLBACK CWSetPluginOSError(CWPluginContext context, CWOSResult error) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + + context->pluginOSError = error; + return cwNoErr; +} + +CW_CALLBACK CWGetProjectFile(CWPluginContext context, CWFileSpec *projectSpec) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (projectSpec == NULL) + return cwErrInvalidParameter; + + *projectSpec = context->projectFile; + return cwNoErr; +} + +CW_CALLBACK CWGetTargetDataDirectory(CWPluginContext context, CWFileSpec *targetDataDirectorySpec) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (targetDataDirectorySpec == NULL) + return cwErrInvalidParameter; + if (context->targetDataDirectorySpec == NULL) + return cwErrInvalidCallback; + + *targetDataDirectorySpec = *context->targetDataDirectorySpec; + return cwNoErr; +} + +CW_CALLBACK CWGetTargetName(CWPluginContext context, char *name, short maxLength) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + + if (context->apiVersion >= 8) + return context->callbacks->cbGetTargetName(context, name, maxLength); + else + return cwErrRequestFailed; +} + +CW_CALLBACK CWGetProjectFileCount(CWPluginContext context, SInt32 *count) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (count == NULL) + return cwErrInvalidParameter; + + *count = context->numFiles; + return cwNoErr; +} + +CW_CALLBACK CWGetOutputFileDirectory(CWPluginContext context, CWFileSpec *outputFileDirectory) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (outputFileDirectory == NULL) + return cwErrInvalidParameter; + + *outputFileDirectory = context->outputFileDirectory; + return cwNoErr; +} + +CW_CALLBACK CWGetOverlay1GroupsCount(CWPluginContext context, SInt32 *count) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (count == NULL) + return cwErrInvalidParameter; + + *count = context->numOverlayGroups; + return cwNoErr; +} + +CW_CALLBACK CWGetFileInfo(CWPluginContext context, SInt32 whichfile, Boolean checkFileLocation, CWProjectFileInfo *fileinfo) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (fileinfo == NULL) + return cwErrInvalidParameter; + + return context->callbacks->cbGetFileInfo(context, whichfile, checkFileLocation, fileinfo); +} + +CW_CALLBACK CWFindAndLoadFile(CWPluginContext context, const char *filename, CWFileInfo *fileinfo) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (filename == NULL) + return cwErrInvalidParameter; + if (fileinfo == NULL) + return cwErrInvalidParameter; + + return context->callbacks->cbFindAndLoadFile(context, filename, fileinfo); +} + +static CWResult EnsureCachedAccessPaths(CWPluginContext context) { + if (!context->accessPathList) { + CWResult res = context->callbacks->cbCacheAccessPathList(context); + if (res) + return res; + if (!context->accessPathList) + return cwErrRequestFailed; + } + return cwNoErr; +} + +CW_CALLBACK CWGetAccessPathListInfo(CWPluginContext context, CWAccessPathListInfo *pathListInfo) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + if (pathListInfo == NULL) + return cwErrInvalidParameter; + if (context->apiVersion < 10) + return cwErrInvalidCallback; + CWResult res = EnsureCachedAccessPaths(context); + if (res) + return res; + pathListInfo->systemPathCount = context->accessPathList->systemPathCount; + pathListInfo->userPathCount = context->accessPathList->userPathCount; + pathListInfo->alwaysSearchUserPaths = context->accessPathList->alwaysSearchUserPaths; + pathListInfo->convertPaths = context->accessPathList->convertPaths; + return cwNoErr; +} + +CW_CALLBACK CWGetAccessPathInfo(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, CWAccessPathInfo *pathInfo) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + if (pathInfo == NULL) + return cwErrInvalidParameter; + if (context->apiVersion < 10) + return cwErrInvalidCallback; + CWResult res = EnsureCachedAccessPaths(context); + if (res) + return res; + + IDEAccessPath *paths; + SInt32 count; + switch (pathType) { + case cwSystemPath: + paths = context->accessPathList->systemPaths; + count = context->accessPathList->systemPathCount; + break; + case cwUserPath: + paths = context->accessPathList->userPaths; + count = context->accessPathList->userPathCount; + break; + default: + return cwErrInvalidParameter; + } + + if (whichPath < 0 || whichPath >= count) + return cwErrInvalidParameter; + + IDEAccessPath *path = &paths[whichPath]; + pathInfo->pathSpec = path->pathSpec; + pathInfo->recursive = path->recursive; + pathInfo->subdirectoryCount = path->subdirectoryCount; + return cwNoErr; +} + +CW_CALLBACK CWGetAccessPathSubdirectory(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, + SInt32 whichSubdirectory, CWFileSpec *subdirectory) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + if (subdirectory == NULL) + return cwErrInvalidParameter; + if (context->apiVersion < 10) + return cwErrInvalidCallback; + CWResult res = EnsureCachedAccessPaths(context); + if (res) + return res; + + IDEAccessPath *paths; + SInt32 count; + switch (pathType) { + case cwSystemPath: + paths = context->accessPathList->systemPaths; + count = context->accessPathList->systemPathCount; + break; + case cwUserPath: + paths = context->accessPathList->userPaths; + count = context->accessPathList->userPathCount; + break; + default: + return cwErrInvalidParameter; + } + + if (whichPath < 0 || whichPath >= count) + return cwErrInvalidParameter; + + IDEAccessPath *path = &paths[whichPath]; + if (whichSubdirectory < 0 || whichSubdirectory >= path->subdirectoryCount) + return cwErrInvalidParameter; + + *subdirectory = path->subdirectories[whichSubdirectory]; + return cwNoErr; +} + +CW_CALLBACK CWGetFileText(CWPluginContext context, const CWFileSpec *filespec, const char **text, SInt32 *textLength, + short *filedatatype) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + if (!filespec) + return cwErrInvalidParameter; + if (!text) + return cwErrInvalidParameter; + if (!textLength) + return cwErrInvalidParameter; + if (!filedatatype) + return cwErrInvalidParameter; + return context->callbacks->cbGetFileText(context, filespec, text, textLength, filedatatype); +} + +CW_CALLBACK CWReleaseFileText(CWPluginContext context, const char *text) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + + if (text) + return context->callbacks->cbReleaseFileText(context, text); + else + return cwNoErr; +} + +CW_CALLBACK CWGetSegmentInfo(CWPluginContext context, SInt32 whichsegment, CWProjectSegmentInfo *segmentinfo) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (!segmentinfo) + return cwErrInvalidParameter; + return context->callbacks->cbGetSegmentInfo(context, whichsegment, segmentinfo); +} + +CW_CALLBACK CWGetOverlay1GroupInfo(CWPluginContext context, SInt32 whichgroup, CWOverlay1GroupInfo *groupinfo) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (!groupinfo) + return cwErrInvalidParameter; + return context->callbacks->cbGetOverlay1GroupInfo(context, whichgroup, groupinfo); +} + +CW_CALLBACK +CWGetOverlay1Info(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, CWOverlay1Info *overlayinfo) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (!overlayinfo) + return cwErrInvalidParameter; + return context->callbacks->cbGetOverlay1Info(context, whichgroup, whichoverlay, overlayinfo); +} + +CW_CALLBACK CWGetOverlay1FileInfo(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, SInt32 whichoverlayfile, + CWOverlay1FileInfo *fileinfo) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (!fileinfo) + return cwErrInvalidParameter; + return context->callbacks->cbGetOverlay1FileInfo(context, whichgroup, whichoverlay, whichoverlayfile, fileinfo); +} + +CW_CALLBACK CWReportMessage(CWPluginContext context, const CWMessageRef *msgRef, const char *line1, const char *line2, + short errorlevel, SInt32 errorNumber) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbReportMessage(context, msgRef, line1, line2, errorlevel, errorNumber); +} + +CW_CALLBACK CWAlert(CWPluginContext context, const char *msg1, const char *msg2, const char *msg3, const char *msg4) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbAlert(context, msg1, msg2, msg3, msg4); +} + +CW_CALLBACK CWShowStatus(CWPluginContext context, const char *line1, const char *line2) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbShowStatus(context, line1, line2); +} + +CW_CALLBACK CWUserBreak(CWPluginContext context) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbUserBreak(context); +} + +CW_CALLBACK CWGetNamedPreferences(CWPluginContext context, const char *prefsname, CWMemHandle *prefsdata) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + if (!prefsname) + return cwErrInvalidParameter; + if (!prefsdata) + return cwErrInvalidParameter; + return context->callbacks->cbGetNamedPreferences(context, prefsname, prefsdata); +} + +CW_CALLBACK CWStorePluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle prefsdata) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbStorePluginData(context, whichfile, type, prefsdata); +} + +CW_CALLBACK CWGetPluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle *prefsdata) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbGetPluginData(context, whichfile, type, prefsdata); +} + +CW_CALLBACK CWSetModDate(CWPluginContext context, const CWFileSpec *filespec, CWFileTime *moddate, Boolean isGenerated) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (!filespec) + return cwErrInvalidParameter; + return context->callbacks->cbSetModDate(context, filespec, moddate, isGenerated); +} + +CW_CALLBACK CWAddProjectEntry(CWPluginContext context, const CWFileSpec *fileSpec, Boolean isGenerated, + const CWNewProjectEntryInfo *projectEntryInfo, SInt32 *whichfile) { + if (IsVCSContext(context) || !ValidateContext(context)) + return cwErrInvalidParameter; + if (!fileSpec) + return cwErrInvalidParameter; + if (context->apiVersion < 8) + return cwErrRequestFailed; + return context->callbacks->cbAddProjectEntry(context, fileSpec, isGenerated, projectEntryInfo, whichfile); +} + +CW_CALLBACK CWCreateNewTextDocument(CWPluginContext context, const CWNewTextDocumentInfo *docinfo) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + if (!docinfo) + return cwErrInvalidParameter; + return context->callbacks->cbCreateNewTextDocument(context, docinfo); +} + +CW_CALLBACK CWAllocateMemory(CWPluginContext context, SInt32 size, Boolean isPermanent, void **ptr) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (!ptr) + return cwErrInvalidParameter; + return context->callbacks->cbAllocateMemory(context, size, isPermanent, ptr); +} + +CW_CALLBACK CWFreeMemory(CWPluginContext context, void *ptr, Boolean isPermanent) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (!ptr) + return cwNoErr; + return context->callbacks->cbFreeMemory(context, ptr, isPermanent); +} + +CW_CALLBACK CWAllocMemHandle(CWPluginContext context, SInt32 size, Boolean useTempMemory, CWMemHandle *handle) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (!handle) + return cwErrInvalidParameter; + return context->callbacks->cbAllocMemHandle(context, size, useTempMemory, handle); +} + +CW_CALLBACK CWFreeMemHandle(CWPluginContext context, CWMemHandle handle) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbFreeMemHandle(context, handle); +} + +CW_CALLBACK CWGetMemHandleSize(CWPluginContext context, CWMemHandle handle, SInt32 *size) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (!size) + return cwErrInvalidParameter; + return context->callbacks->cbGetMemHandleSize(context, handle, size); +} + +CW_CALLBACK CWResizeMemHandle(CWPluginContext context, CWMemHandle handle, SInt32 newSize) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbResizeMemHandle(context, handle, newSize); +} + +CW_CALLBACK CWLockMemHandle(CWPluginContext context, CWMemHandle handle, Boolean moveHi, void **ptr) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + if (!ptr) + return cwErrInvalidParameter; + return context->callbacks->cbLockMemHandle(context, handle, moveHi, ptr); +} + +CW_CALLBACK CWUnlockMemHandle(CWPluginContext context, CWMemHandle handle) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbUnlockMemHandle(context, handle); +} + +CW_CALLBACK CWDonePluginRequest(CWPluginContext, CWResult resultCode) { + return resultCode; +} + +CW_CALLBACK CWPreDialog(CWPluginContext context) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbPreDialog(context); +} + +CW_CALLBACK CWPostDialog(CWPluginContext context) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbPostDialog(context); +} + +CW_CALLBACK CWPreFileAction(CWPluginContext context, const CWFileSpec *theFile) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbPreFileAction(context, theFile); +} + +CW_CALLBACK CWPostFileAction(CWPluginContext context, const CWFileSpec *theFile) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbPostFileAction(context, theFile); +} + +CW_CALLBACK CWCheckoutLicense(CWPluginContext context, const char *featureName, const char *licenseVersion, SInt32 flags, void *reserved, SInt32 *cookie) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbCheckoutLicense(context, featureName, licenseVersion, flags, reserved, cookie); +} + +CW_CALLBACK CWCheckinLicense(CWPluginContext context, SInt32 cookie) { + if (!ValidateContext(context) && !ValidateInitTermContext(context)) + return cwErrInvalidParameter; + return context->callbacks->cbCheckinLicense(context, cookie); +} + +CW_CALLBACK CWResolveRelativePath(CWPluginContext context, const CWRelativePath *relativePath, CWFileSpec *fileSpec, Boolean create) { + if (!ValidateContext(context)) + return cwErrInvalidParameter; + if (relativePath == NULL) + return cwErrInvalidParameter; + if (fileSpec == NULL) + return cwErrInvalidParameter; + return context->callbacks->cbResolveRelativePath(context, relativePath, fileSpec, create); +} + +CW_CALLBACK CWMacOSErrToCWResult(CWPluginContext context, OSErr err) { + return OSErrtoCWResult(err); +} + +CWResult OSErrtoCWResult(OSErr err) { + switch (err) { + case noErr: return cwNoErr; + case userCanceledErr: return cwErrUserCanceled; + case paramErr: return cwErrInvalidParameter; + case memFullErr: return cwErrOutOfMemory; + case fnfErr: return cwErrFileNotFound; + default: return cwErrRequestFailed; + } +} + diff --git a/command_line/PluginLib/Src/Library/DropInCompilerLinkerPrivate.cpp b/command_line/PluginLib/Src/Library/DropInCompilerLinkerPrivate.cpp new file mode 100644 index 0000000..2c0a0c7 --- /dev/null +++ b/command_line/PluginLib/Src/Library/DropInCompilerLinkerPrivate.cpp @@ -0,0 +1,501 @@ +#include "plugin_internal.h" + +static CWCompilerLinkerContext *GetContext(CWPluginContext context) { + if (context && (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE)) + return static_cast(context); + else + return 0; +} + +CW_CALLBACK CWIsPrecompiling(CWPluginContext context, Boolean* isPrecompiling) { + CWCompilerLinkerContext *cl; + if (!isPrecompiling) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *isPrecompiling = cl->precompile; + return cwNoErr; +} + +CW_CALLBACK CWIsAutoPrecompiling(CWPluginContext context, Boolean* isAutoPrecompiling) { + CWCompilerLinkerContext *cl; + if (!isAutoPrecompiling) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *isAutoPrecompiling = cl->autoprecompile; + return cwNoErr; +} + +CW_CALLBACK CWIsPreprocessing(CWPluginContext context, Boolean* isPreprocessing) { + CWCompilerLinkerContext *cl; + if (!isPreprocessing) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *isPreprocessing = cl->preprocess; + return cwNoErr; +} + +CW_CALLBACK CWIsGeneratingDebugInfo(CWPluginContext context, Boolean* isGenerating) { + CWCompilerLinkerContext *cl; + if (!isGenerating) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *isGenerating = cl->debuginfo; + return cwNoErr; +} + +CW_CALLBACK CWIsCachingPrecompiledHeaders(CWPluginContext context, Boolean* isCaching) { + CWCompilerLinkerContext *cl; + if (!isCaching) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *isCaching = cl->cachingPCH; + return cwNoErr; +} + +CW_CALLBACK CWGetBrowseOptions(CWPluginContext context, CWBrowseOptions* browseOptions) { + CWCompilerLinkerContext *cl; + if (!browseOptions) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *browseOptions = cl->browseoptions; + return cwNoErr; +} + +CW_CALLBACK CWGetBuildSequenceNumber(CWPluginContext context, SInt32* sequenceNumber) { + CWCompilerLinkerContext *cl; + if (!sequenceNumber) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *sequenceNumber = cl->sequenceID; + return cwNoErr; +} + +CW_CALLBACK CWGetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) { + CWCompilerLinkerContext *cl; + if (!targetInfo) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion >= 10) { + *targetInfo = *cl->targetinfo; + } else if (cl->apiVersion >= 8) { + CWTargetInfo *ti = cl->targetinfo; + targetInfo->outputType = ti->outputType; + targetInfo->outfile = ti->outfile; + targetInfo->symfile = ti->symfile; + targetInfo->runfile = ti->runfile; + targetInfo->linkType = ti->linkType; + targetInfo->canRun = ti->canRun; + targetInfo->canDebug = ti->canDebug; + targetInfo->targetCPU = ti->targetCPU; + targetInfo->targetOS = ti->targetOS; +#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS + targetInfo->outfileCreator = ti->outfileCreator; + targetInfo->outfileType = ti->outfileType; + targetInfo->debuggerCreator = ti->debuggerCreator; + targetInfo->runHelperCreator = ti->runHelperCreator; +#endif + } else { + memset(targetInfo, 0, sizeof(CWTargetInfo)); + if (CWFileSpecNotEmpty(&cl->targetinfo_V7.outfile)) + targetInfo->outputType = linkOutputFile; + else + targetInfo->outputType = linkOutputNone; + targetInfo->outfile = cl->targetinfo_V7.outfile; + targetInfo->symfile = cl->targetinfo_V7.symfile; + targetInfo->runfile = cl->targetinfo_V7.outfile; + targetInfo->linkType = cl->targetinfo_V7.linkType; + targetInfo->canRun = cl->targetinfo_V7.canRun; + targetInfo->canDebug = cl->targetinfo_V7.canDebug; +#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS + targetInfo->debuggerCreator = cl->targetinfo_V7.debuggerCreator; + targetInfo->runHelperCreator = cl->targetinfo_V7.runHelperCreator; +#endif + } + return cwNoErr; +} + +CW_CALLBACK CWSetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) { + CWCompilerLinkerContext *cl; + if (!targetInfo) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion >= 10) { + *cl->targetinfo = *targetInfo; + } else if (cl->apiVersion >= 8) { + CWTargetInfo *ti = cl->targetinfo; + ti->outputType = targetInfo->outputType; + ti->outfile = targetInfo->outfile; + ti->symfile = targetInfo->symfile; + ti->runfile = targetInfo->runfile; + ti->linkType = targetInfo->linkType; + ti->canRun = targetInfo->canRun; + ti->canDebug = targetInfo->canDebug; + ti->targetCPU = targetInfo->targetCPU; + ti->targetOS = targetInfo->targetOS; +#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS + ti->outfileCreator = targetInfo->outfileCreator; + ti->outfileType = targetInfo->outfileType; + ti->debuggerCreator = targetInfo->debuggerCreator; + ti->runHelperCreator = targetInfo->runHelperCreator; +#endif + } else { + cl->targetinfo_V7.outfile = targetInfo->outfile; + cl->targetinfo_V7.symfile = targetInfo->symfile; + cl->targetinfo_V7.linkType = targetInfo->linkType; + cl->targetinfo_V7.canRun = targetInfo->canRun; + cl->targetinfo_V7.canDebug = targetInfo->canDebug; +#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS + cl->targetinfo_V7.useRunHelperApp = targetInfo->runHelperCreator != 0; + cl->targetinfo_V7.debuggerCreator = targetInfo->debuggerCreator; + cl->targetinfo_V7.runHelperCreator = targetInfo->runHelperCreator; +#endif + } + return cwNoErr; +} + +CW_CALLBACK CWGetMainFileNumber(CWPluginContext context, SInt32* fileNumber) { + CWCompilerLinkerContext *cl; + if (!fileNumber) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *fileNumber = cl->whichfile; + return cwNoErr; +} + +CW_CALLBACK CWGetMainFileID(CWPluginContext context, short* fileID) { + CWCompilerLinkerContext *cl; + if (!fileID) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *fileID = cl->fileID; + return cwNoErr; +} + +CW_CALLBACK CWGetMainFileSpec(CWPluginContext context, CWFileSpec* fileSpec) { + CWCompilerLinkerContext *cl; + if (!fileSpec) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *fileSpec = cl->sourcefile; + return cwNoErr; +} + +CW_CALLBACK CWGetMainFileText(CWPluginContext context, const char** text, SInt32* textLength) { + CWCompilerLinkerContext *cl; + if (!text) + return cwErrInvalidParameter; + if (!textLength) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + *text = cl->sourcetext; + *textLength = cl->sourcetextsize; + return cwNoErr; +} + +CW_CALLBACK CWLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle* objectdata) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbLoadObjectData(cl, whichfile, objectdata); +} + +CW_CALLBACK CWStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData* object) { + CWCompilerLinkerContext *cl; + if (!object) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbStoreObjectData(cl, whichfile, object); +} + +CW_CALLBACK CWFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbFreeObjectData(cl, whichfile, objectdata); +} + +CW_CALLBACK CWGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) { + CWCompilerLinkerContext *cl; + if (!fileSpec) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (context->apiVersion < 10) + return cwErrInvalidCallback; + return cl->callbacks->cbGetSuggestedObjectFileSpec(cl, whichfile, fileSpec); +} + +CW_CALLBACK CWGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) { + CWCompilerLinkerContext *cl; + if (!fileSpec) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (context->apiVersion < 10) + return cwErrInvalidCallback; + return cl->callbacks->cbGetStoredObjectFileSpec(cl, whichfile, fileSpec); +} + +CW_CALLBACK CWDisplayLines(CWPluginContext context, SInt32 nlines) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbDisplayLines(cl, nlines); +} + +CW_CALLBACK CWGetResourceFile(CWPluginContext context, CWFileSpec* filespec) { + CWCompilerLinkerContext *cl; + if (!filespec) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbGetResourceFile(cl, filespec); +} + +CW_CALLBACK CWPutResourceFile(CWPluginContext context, const char* prompt, const char* name, CWFileSpec* filespec) { + CWCompilerLinkerContext *cl; + if (!prompt) + return cwErrInvalidParameter; + if (!name) + return cwErrInvalidParameter; + if (!filespec) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbPutResourceFile(cl, prompt, name, filespec); +} + +CW_CALLBACK CWCachePrecompiledHeader(CWPluginContext context, const CWFileSpec* filespec, CWMemHandle pchhandle) { + CWCompilerLinkerContext *cl; + if (!filespec) + return cwErrInvalidParameter; + if (!pchhandle) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbCachePrecompiledHeader(cl, filespec, pchhandle); +} + +CW_CALLBACK CWGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *target) { + CWCompilerLinkerContext *cl; + if (!pchspec) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbGetPrecompiledHeaderSpec(cl, pchspec, target); +} + +CW_CALLBACK CWBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext* subContext) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbBeginSubCompile(cl, whichfile, subContext); +} + +CW_CALLBACK CWEndSubCompile(CWPluginContext subContext) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(subContext))) + return cwErrInvalidCallback; + return cl->callbacks->cbEndSubCompile(subContext); +} + +CW_CALLBACK CWLookUpUnit(CWPluginContext context, const char* name, Boolean isdependency, const void** unitdata, SInt32* unitdatalength) { + CWCompilerLinkerContext *cl; + if (!name) + return cwErrInvalidParameter; + if (!unitdata) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbLookUpUnit(cl, name, isdependency, unitdata, unitdatalength); +} + +CW_CALLBACK CWSBMfiles(CWPluginContext context, short libref) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbSBMfiles(cl, libref); +} + +CW_CALLBACK CWStoreUnit(CWPluginContext context, const char* unitname, CWMemHandle unitdata, CWDependencyTag dependencytag) { + CWCompilerLinkerContext *cl; + if (!unitname) + return cwErrInvalidParameter; + if (!unitdata) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbStoreUnit(cl, unitname, unitdata, dependencytag); +} + +CW_CALLBACK CWReleaseUnit(CWPluginContext context, void* unitdata) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbReleaseUnit(cl, unitdata); +} + +CW_CALLBACK CWUnitNameToFileName(CWPluginContext context, const char* unitname, char* filename) { + CWCompilerLinkerContext *cl; + if (!unitname) + return cwErrInvalidParameter; + if (!filename) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbUnitNameToFileName(cl, unitname, filename); +} + +CW_CALLBACK CWGetTargetStorage(CWPluginContext context, void** storage) { + CWCompilerLinkerContext *cl; + if (!storage) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion >= 8) { + *storage = cl->targetStorage; + return cwNoErr; + } else { + return cwErrRequestFailed; + } +} + +CW_CALLBACK CWSetTargetStorage(CWPluginContext context, void* storage) { + CWCompilerLinkerContext *cl; + if (!storage) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion >= 8) { + cl->targetStorage = storage; + return cwNoErr; + } else { + return cwErrRequestFailed; + } +} + +CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbOSErrorMessage(cl, msg, errorcode); +} + +CW_CALLBACK CWOSAlert(CWPluginContext context, const char* message, OSErr errorcode) { + CWCompilerLinkerContext *cl; + if (!message) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + return cl->callbacks->cbOSAlert(cl, message, errorcode); +} + +CW_CALLBACK CWGetModifiedFiles(CWPluginContext context, SInt32* modifiedFileCount, const SInt32** modifiedFiles) { + CWCompilerLinkerContext *cl; + if (!modifiedFileCount) + return cwErrInvalidParameter; + if (!modifiedFiles) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (context->apiVersion < 9) + return cwErrInvalidCallback; + return cl->callbacks->cbGetModifiedFiles(cl, modifiedFileCount, modifiedFiles); +} + +CW_CALLBACK CWGetCommandLineArgs(CWPluginContext context, const char** commandLineArgs) { + CWCompilerLinkerContext *cl; + if (!commandLineArgs) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion < 11) + return cwErrInvalidCallback; + if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) + return cwErrRequestFailed; + *commandLineArgs = cl->commandLineArgs; + return cwNoErr; +} + +CW_CALLBACK CWGetWorkingDirectory(CWPluginContext context, CWFileSpec* workingDirectorySpec) { + CWCompilerLinkerContext *cl; + if (!workingDirectorySpec) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion < 11) + return cwErrInvalidCallback; + if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) + return cwErrRequestFailed; + *workingDirectorySpec = *cl->workingDirectorySpec; + return cwNoErr; +} + +CW_CALLBACK CWGetEnvironmentVariableCount(CWPluginContext context, SInt32* count) { + CWCompilerLinkerContext *cl; + if (!count) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion < 11) + return cwErrInvalidCallback; + if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) + return cwErrRequestFailed; + *count = cl->numEnvironmentVariables; + return cwNoErr; +} + +CW_CALLBACK CWGetEnvironmentVariable(CWPluginContext context, SInt32 index, const char** name, const char** value) { + CWCompilerLinkerContext *cl; + if (!name) + return cwErrInvalidParameter; + if (!value) + return cwErrInvalidParameter; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion < 11) + return cwErrInvalidCallback; + if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) + return cwErrRequestFailed; + if (index < 0 || index >= cl->numEnvironmentVariables) + return cwErrInvalidParameter; + *name = cl->environmentVariables[index].name; + *value = cl->environmentVariables[index].value; + return cwNoErr; +} + +CW_CALLBACK CWGetFrameworkCount(CWPluginContext context, SInt32* frameworkCount) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion < 11) + return cwErrInvalidCallback; + if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkCount(cl, frameworkCount)) + return cwErrRequestFailed; + return cwNoErr; +} + +CW_CALLBACK CWGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo* frameworkInfo) { + CWCompilerLinkerContext *cl; + if (!(cl = GetContext(context))) + return cwErrInvalidCallback; + if (cl->apiVersion < 11) + return cwErrInvalidCallback; + if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkInfo(cl, whichFramework, frameworkInfo)) + return cwErrRequestFailed; + return cwNoErr; +} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c index f605817..ba38b17 100644 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c @@ -58,7 +58,7 @@ static PrefDataPanel stPrefPanels[] = { "CmdLine Linker Panel", &pCmdLineLinker, sizeof(pCmdLineLinker) }; -static int PreParse() { +static int PreParse(void) { setLinkerOutputFilename = 0; linkerOutputFilename[0] = 0; definesHandle = NULL; @@ -67,7 +67,7 @@ static int PreParse() { return 1; } -static int MidParse() { +static int MidParse(void) { const char *match; const char *env; @@ -85,7 +85,7 @@ static int MidParse() { return 1; } -static int PostParse() { +static int PostParse(void) { if (!SetupPragmas(irPragmas) || !SetupPragmas(warningPragmas)) return 0; @@ -132,6 +132,6 @@ static ParserTool parser = { &PostParse }; -int RegisterStaticParserToolInfo() { +int RegisterStaticParserToolInfo(void) { return SetParserToolInfo(&parser); } diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetOptimizer-ppc-mach.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetOptimizer-ppc-mach.c new file mode 100644 index 0000000..6c86356 --- /dev/null +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetOptimizer-ppc-mach.c @@ -0,0 +1,71 @@ +#include "parser.h" + +char schedule_ppc_default; + +int TargetSetOptFlags(short val, Boolean set) { + switch (val) { + case 'Pe': + pBackEnd.peephole = set; + break; + case 'Sn': + pBackEnd.schedule = 0; + break; + case 'Sh': + pBackEnd.schedule = set; + break; + case 'S?': + pBackEnd.processor = schedule_ppc_default; + break; + case 'SG': + pBackEnd.processor = schedule_ppc_default = PrefCPU_Generic; + break; + case 'S1': + pBackEnd.processor = schedule_ppc_default = PrefCPU_601; + break; + case 'S3': + pBackEnd.processor = schedule_ppc_default = PrefCPU_603; + break; + case 'S#': + pBackEnd.processor = schedule_ppc_default = PrefCPU_603e; + break; + case 'S4': + pBackEnd.processor = schedule_ppc_default = PrefCPU_604; + break; + case 'S%': + pBackEnd.processor = schedule_ppc_default = PrefCPU_604e; + break; + case 'S7': + pBackEnd.processor = schedule_ppc_default = PrefCPU_750; + break; + case 'SA': + pBackEnd.processor = schedule_ppc_default = PrefCPU_Altivec; + break; + default: + return 0; + } + + return 1; +} + +void TargetDisplayOptimizationOptions(Handle txt) { + PrefCPU p; + + if (!pBackEnd.schedule) { + HPrintF(txt, "\t- no instruction scheduling\n"); + } else { + HPrintF(txt, "\t- schedule for %s\n", + !(p = (PrefCPU) pBackEnd.processor) ? "generic PPC" : + (p == PrefCPU_601) ? "601" : + (p == PrefCPU_603) ? "603" : + (p == PrefCPU_603e) ? "603e" : + (p == PrefCPU_604) ? "604" : + (p == PrefCPU_604e) ? "604e" : + (p == PrefCPU_750) ? "750" : + (p == PrefCPU_Altivec) ? "Altivec" : + "???" + ); + } +} + +void TargetSetPragmaOptimizationsToUnspecified(void) { +} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c deleted file mode 100644 index db6165c..0000000 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c +++ /dev/null @@ -1,84 +0,0 @@ -#include "parser.h" - -// I'm making assumptions about the name of this file -// based on TargetWarningHelpers-ppc-ld.c existing in the linker - -PExtraWarningC pExtraWarningC = {0}; -Pragma warningPragmas[] = { - &pExtraWarningC.warn_largeargs, "warn_largeargs", 0, - &pExtraWarningC.warn_padding, "warn_padding", 0, - &pExtraWarningC.warn_resultnotused, "warn_resultnotused", 0, - &pExtraWarningC.warn_ptr_int_conv, "warn_ptr_int_conv", 0, - &pExtraWarningC.warn_no_side_effect, "warn_no_side_effect", 0, - 0, 0, 0 -}; - -int TargetSetWarningFlags(short val, Boolean set) { - switch (val) { - case 'Ip': pWarningC.warn_illpragma = set; break; - case 'Ed': pWarningC.warn_emptydecl = set; break; - case 'Pu': pWarningC.warn_possunwant = set; break; - case 'Uv': pWarningC.warn_unusedvar = set; break; - case 'Ua': pWarningC.warn_unusedarg = set; break; - case 'Ec': pWarningC.warn_extracomma = set; break; - case 'Pd': pWarningC.pedantic = set; break; - case 'Hv': pWarningC.warn_hidevirtual = set; break; - case 'Ic': pWarningC.warn_implicitconv = set; break; - case 'Ni': pWarningC.warn_notinlined = set; break; - case 'Sc': pWarningC.warn_structclass = set; break; - case 'Pa': pExtraWarningC.warn_padding = set ? PR_ON : PR_OFF; break; - case 'Nu': pExtraWarningC.warn_resultnotused = set ? PR_ON : PR_OFF; break; - case 'Se': pExtraWarningC.warn_no_side_effect = set ? PR_ON : PR_OFF; break; - case 'PI': pExtraWarningC.warn_ptr_int_conv = set ? PR_ON : PR_OFF; break; - case 'La': pExtraWarningC.warn_largeargs = set ? PR_ON : PR_OFF; break; - case 'We': pWarningC.warningerrors = set; break; - case 'Cp': pFrontEndC.checkprotos = set; break; - default: return 0; - } - - return 1; -} - -void TargetDisplayWarningOptions(Handle txt) { - HPrintF(txt, "C language warning options:\n"); - - if (pWarningC.warn_illpragma) - HPrintF(txt, "\t- illegal pragmas\n"); - if (pWarningC.warn_emptydecl) - HPrintF(txt, "\t- empty declarations\n"); - if (pWarningC.warn_possunwant) - HPrintF(txt, "\t- possible unwanted effects\n"); - if (pWarningC.warn_unusedvar) - HPrintF(txt, "\t- unused variables\n"); - if (pWarningC.warn_unusedarg) - HPrintF(txt, "\t- unused arguments\n"); - if (pWarningC.warn_extracomma) - HPrintF(txt, "\t- extra commas\n"); - if (pWarningC.pedantic) - HPrintF(txt, "\t- pedantic\n"); - if (pWarningC.warn_hidevirtual) - HPrintF(txt, "\t- hidden virtual functions\n"); - if (pWarningC.warn_implicitconv) - HPrintF(txt, "\t- implicit conversions\n"); - if (pWarningC.warn_notinlined) - HPrintF(txt, "\t- 'inline' not performed\n"); - if (pWarningC.warn_structclass) - HPrintF(txt, "\t- struct/class conflict\n"); - if (pExtraWarningC.warn_largeargs == 1) - HPrintF(txt, "\t- large args passed to unprototyped functions\n"); - if (pExtraWarningC.warn_padding == 1) - HPrintF(txt, "\t- padding added between struct members\n"); - if (pExtraWarningC.warn_resultnotused == 1) - HPrintF(txt, "\t- result of non-void function call not used\n"); - if (pExtraWarningC.warn_no_side_effect == 1) - HPrintF(txt, "\t- use of expressions as statements without side effects\n"); - if (pExtraWarningC.warn_ptr_int_conv == 1) - HPrintF(txt, "\t- implicit integer/pointer conversions\n"); - if (pFrontEndC.checkprotos) - HPrintF(txt, "\t- checking prototypes\n"); - - if (pWarningC.warningerrors) - HPrintF(txt, "\t- warnings are errors\n"); - else - HPrintF(txt, "\t- warnings are not errors\n"); -} diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c index 5965d11..912c21a 100644 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c @@ -246,7 +246,7 @@ static CompilerLinkerPluginCallbacks lk_cl_cb = { NULL }; -int RegisterStaticCompilerPlugin() { +int RegisterStaticCompilerPlugin(void) { return RegisterStaticCompilerLinkerPlugin(&plugin_cb, &plugin_cl_cb) && RegisterStaticCompilerLinkerPlugin(&lk_cb, &lk_cl_cb); } @@ -563,6 +563,6 @@ static const char *STR10100[] = { NULL }; -int RegisterCompilerResources() { +int RegisterCompilerResources(void) { return RegisterResource("Compiler Errors", 10000, STR10000) && RegisterResource("Compiler Strings", 10100, STR10100); } diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c index 484db0f..4eb55d5 100644 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c @@ -135,12 +135,12 @@ static CompilerLinkerPluginCallbacks machlibimport_cl_cb = { NULL }; -int RegisterStaticLibImporterPlugin() { +int RegisterStaticLibImporterPlugin(void) { return RegisterStaticCompilerLinkerPlugin(&machlibimport_cb, &machlibimport_cl_cb); } #include "compiler_and_linker/Plugin_Tools/MacOS_PPC/Lib_Importer_Mach/Resources/Errors.r" -int RegisterLibImporterResources() { +int RegisterLibImporterResources(void) { return RegisterResource("Mach-O Lib Importer Errors", 911, STR911); } diff --git a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c index 25a9f49..95dabf6 100644 --- a/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c +++ b/compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c @@ -1,11 +1,11 @@ #include "cmdline.h" // cc-mach-ppc.c -extern int RegisterStaticCompilerPlugin(); -extern int RegisterCompilerResources(); +extern int RegisterStaticCompilerPlugin(void); +extern int RegisterCompilerResources(void); // libimp-mach-ppc.c -extern int RegisterStaticLibImporterPlugin(); -extern int RegisterLibImporterResources(); +extern int RegisterStaticLibImporterPlugin(void); +extern int RegisterLibImporterResources(void); void GetStaticTarget(OSType *cpu, OSType *os) { *cpu = targetCPUPowerPC; @@ -21,11 +21,11 @@ void GetStaticParserPluginType(OSType *style) { *style = CWFOURCHAR('S','e','e','p'); } -int RegisterStaticTargetPlugins() { +int RegisterStaticTargetPlugins(void) { return RegisterStaticCompilerPlugin() && RegisterStaticLibImporterPlugin(); } -int RegisterStaticTargetResources() { +int RegisterStaticTargetResources(void) { OS_UseMacResourceForkInfo(1); return RegisterCompilerResources() && RegisterLibImporterResources(); } diff --git a/compiler_and_linker/FrontEnd/C/CPrep.c b/compiler_and_linker/FrontEnd/C/CPrep.c index 8392b44..7b6ece7 100644 --- a/compiler_and_linker/FrontEnd/C/CPrep.c +++ b/compiler_and_linker/FrontEnd/C/CPrep.c @@ -58,7 +58,7 @@ struct CompilerOption { char *name; short bits; } compileroptions[138] = { - "little_endian", OPT_FLAG_4000 | OPT_OFFSET(little_endian), + "little_endian", OPT_FLAG_4000 | OPT_OFFSET(littleendian), "longlong", OPT_OFFSET(longlong), "traceback", OPT_OFFSET(traceback), "disable_registers", OPT_OFFSET(disable_registers), @@ -71,7 +71,7 @@ struct CompilerOption { "optimizewithasm", OPT_OFFSET(optimizewithasm), "use_lmw_stmw", OPT_OFFSET(use_lmw_stmw), "no_register_save_helpers", OPT_OFFSET(no_register_save_helpers), - "ppc_opt_bclr_bcctr", OPT_OFFSET(ppc_opt_bclr_bcctr), + "ppc_opt_bclt_bctr", OPT_OFFSET(opt_bcc_lr_ctr), "misaligned_mem_access", OPT_OFFSET(misaligned_mem_access), "switch_tables", OPT_OFFSET(switch_tables), "prepare_compress", OPT_OFFSET(prepare_compress), @@ -81,29 +81,29 @@ struct CompilerOption { "ecplusplus", OPT_OFFSET(ecplusplus), "objective_c", OPT_OFFSET(objective_c), "objc_strict", OPT_OFFSET(objc_strict), - "ARM_conform", OPT_OFFSET(ARM_conform), - "ARM_scoping", OPT_OFFSET(ARM_scoping), - "require_prototypes", OPT_OFFSET(require_prototypes), + "ARM_conform", OPT_OFFSET(ARMconform), + "ARM_scoping", OPT_OFFSET(ARMscoping), + "require_prototypes", OPT_OFFSET(checkprotos), "trigraphs", OPT_OFFSET(trigraphs), - "only_std_keywords", OPT_OFFSET(only_std_keywords), + "only_std_keywords", OPT_OFFSET(onlystdkeywords), "enumsalwaysint", OPT_OFFSET(enumsalwaysint), - "ANSI_strict", OPT_OFFSET(ANSI_strict), + "ANSI_strict", OPT_OFFSET(ANSIstrict), "mpwc_relax", OPT_OFFSET(mpwc_relax), "mpwc_newline", OPT_OFFSET(mpwc_newline), "ignore_oldstyle", OPT_OFFSET(ignore_oldstyle), "cpp_extensions", OPT_OFFSET(cpp_extensions), "pointercast_lvalue", OPT_OFFSET(pointercast_lvalue), - "RTTI", OPT_OFFSET(useRTTI), + "RTTI", OPT_OFFSET(RTTI), "delete_exception", OPT_OFFSET(delete_exception), "oldalignment", OPT_OFFSET(oldalignment), "multibyteaware", OPT_OFFSET(multibyteaware), - "unsigned_char", OPT_OFFSET(unsignedchars), - "auto_inline", OPT_OFFSET(autoinline), + "unsigned_char", OPT_OFFSET(unsigned_char), + "auto_inline", OPT_OFFSET(auto_inline), "inline_bottom_up", OPT_OFFSET(inline_bottom_up), "defer_codegen", OPT_OFFSET(defer_codegen), "direct_to_som", OPT_OFFSET(direct_to_som), "SOMCheckEnvironment", OPT_OFFSET(som_env_check), - "SOMCallOptimization", OPT_OFFSET(som_call_opt), + "SOMCallOptimization", OPT_OFFSET(som_call_optimize), "bool", OPT_OFFSET(booltruefalse), "old_enum_mangler", OPT_OFFSET(old_enum_mangler), "longlong_enums", OPT_OFFSET(longlong_enums), @@ -144,11 +144,11 @@ struct CompilerOption { "optEH", OPT_OFFSET(optEH), "optEH2", OPT_OFFSET(optEH2), "new_mangler", OPT_OFFSET(new_mangler), - "microsoft_exceptions", OPT_OFFSET(microsoft), - "microsoft_RTTI", OPT_OFFSET(microsoft), + "microsoft_exceptions", OPT_OFFSET(microsoft_EH), + "microsoft_RTTI", OPT_OFFSET(microsoft_EH), "warning_errors", OPT_OFFSET(warningerrors), "extended_errorcheck", OPT_OFFSET(pedantic), - "check_header_flags", OPT_OFFSET(check_header_flags), + "check_header_flags", OPT_OFFSET(checkprecompflags), "supress_warnings", OPT_OFFSET(supress_warnings), "warn_illpragma", OPT_OFFSET(warn_illpragma), "warn_emptydecl", OPT_OFFSET(warn_emptydecl), @@ -165,40 +165,40 @@ struct CompilerOption { "warn_no_side_effect", OPT_OFFSET(warn_no_side_effect), "warn_resultnotused", OPT_OFFSET(warn_resultnotused), "warn_ptr_int_conv", OPT_OFFSET(warn_ptr_int_conv), - "align_array_members", OPT_OFFSET(align_array_members), + "align_array_members", OPT_OFFSET(alignarraymembers), "dont_reuse_strings", OPT_OFFSET(dont_reuse_strings), - "pool_strings", OPT_OFFSET(pool_strings), + "pool_strings", OPT_OFFSET(poolstrings), "explicit_zero_data", OPT_OFFSET(explicit_zero_data), "readonly_strings", OPT_OFFSET(readonly_strings), - "opt_common_subs", OPT_OFFSET(opt_common_subs), - "opt_loop_invariants", OPT_OFFSET(opt_loop_invariants), - "opt_propagation", OPT_OFFSET(opt_propagation), - "opt_unroll_loops", OPT_OFFSET(opt_unroll_loops), - "opt_lifetimes", OPT_OFFSET(opt_lifetimes), - "opt_strength_reduction", OPT_OFFSET(opt_strength_reduction), - "opt_strength_reduction_strict", OPT_OFFSET(opt_strength_reduction_strict), - "opt_dead_code", OPT_OFFSET(opt_dead_code), - "opt_dead_assignments", OPT_OFFSET(opt_dead_assignments), - "opt_vectorize_loops", OPT_OFFSET(opt_vectorize_loops), + "opt_common_subs", OPT_OFFSET(commonsubs), + "opt_loop_invariants", OPT_OFFSET(loopinvariants), + "opt_propagation", OPT_OFFSET(propagation), + "opt_unroll_loops", OPT_OFFSET(unrolling), + "opt_lifetimes", OPT_OFFSET(lifetimes), + "opt_strength_reduction", OPT_OFFSET(strengthreduction), + "opt_strength_reduction_strict", OPT_OFFSET(strengthreductionstrict), + "opt_dead_code", OPT_OFFSET(deadcode), + "opt_dead_assignments", OPT_OFFSET(deadstore), + "opt_vectorize_loops", OPT_OFFSET(vectorizeloops), "opt_pointer_analysis", OPT_OFFSET(opt_pointer_analysis), "exceptions", OPT_OFFSET(exceptions), - "dont_inline", OPT_OFFSET(dont_inline), - "always_inline", OPT_OFFSET(always_inline), - "optimize_for_size", OPT_OFFSET(optimize_for_size), + "dont_inline", OPT_OFFSET(dontinline), + "always_inline", OPT_OFFSET(alwaysinline), + "optimize_for_size", OPT_OFFSET(optimizesize), "peephole", OPT_OFFSET(peephole), - "global_optimizer", OPT_OFFSET(global_optimizer), - "side_effects", OPT_OFFSET(side_effects), - "internal", OPT_FLAG_2000 | OPT_OFFSET(internal), - "import", OPT_FLAG_2000 | OPT_OFFSET(import), - "export", OPT_FLAG_2000 | OPT_OFFSET(export), - "lib_export", OPT_FLAG_2000 | OPT_OFFSET(lib_export), + "global_optimizer", OPT_OFFSET(globaloptimizer), + "side_effects", OPT_OFFSET(sideeffects), + "internal", OPT_FLAG_2000 | OPT_OFFSET(cfm_internal), + "import", OPT_FLAG_2000 | OPT_OFFSET(cfm_import), + "export", OPT_FLAG_2000 | OPT_OFFSET(cfm_export), + "lib_export", OPT_FLAG_2000 | OPT_OFFSET(cfm_lib_export), "nosyminline", OPT_OFFSET(nosyminline), "force_active", OPT_OFFSET(force_active), - "sym", OPT_OFFSET(isGeneratingDebugInfo), + "sym", OPT_OFFSET(filesyminfo), NULL, 0 }; -CParams *cparamblkptr; +CompilerLinkerParamBlk *cparamblkptr; short tk; CInt64 tkintconst; Float tkfloatconst; @@ -274,7 +274,7 @@ static Macro trgtM; GList pplist; struct COptsPush { struct COptsPush *next; - COpts opts; + CompilerLinkerOptions opts; }; struct COptPush { struct COptPush *next; @@ -284,7 +284,7 @@ struct COptPush { }; static struct COptsPush *coptpushs; static struct COptPush *coptpush; -static COpts *coptssave; +static CompilerLinkerOptions *coptssave; static Boolean dofreeaheap; static GList mlist; static Handle ts_buffer; @@ -578,8 +578,8 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) { cannotopenerror(filename, 0); return 0; } - if (file_type == copts.pchType) { - if (cparamblkptr->isCachingPrecompiledHeaders) { + if (file_type == copts.headtype) { + if (cparamblkptr->caching_includes) { if (CWAllocMemHandle(cparamblkptr->context, file_size, 1, &cache_hnd) != cwNoErr) { if (CWAllocMemHandle(cparamblkptr->context, file_size, 0, &cache_hnd) != cwNoErr) { COS_FileClose(refnum); @@ -611,17 +611,17 @@ static Boolean setupfile(StringPtr filename, Boolean flag1, Boolean flag2) { } } } else { - if (!cparamblkptr->mainFileText) { - COS_FileGetFSSpecInfo(&cparamblkptr->mainFileSpec, &file_vrefnum, &file_dirid, file_filename); + if (!cparamblkptr->sourcetext) { + COS_FileGetFSSpecInfo(&cparamblkptr->sourcefile, &file_vrefnum, &file_dirid, file_filename); cannotopenerror(file_filename, 1); return 0; } - prepinfo.textfile = cparamblkptr->mainFileSpec; - prepinfo.textbuffer = (char *) cparamblkptr->mainFileText; - prepinfo.textlength = cparamblkptr->mainFileTextLength; - prepinfo.fileID = cparamblkptr->mainFileID; - prepinfo.recordbrowseinfo = cparamblkptr->field276; + prepinfo.textfile = cparamblkptr->sourcefile; + prepinfo.textbuffer = (char *) cparamblkptr->sourcetext; + prepinfo.textlength = cparamblkptr->sourcetextsize; + prepinfo.fileID = cparamblkptr->browserfileID; + prepinfo.recordbrowseinfo = cparamblkptr->recordbrowseinfo; } if (filesp >= 0) { @@ -1282,7 +1282,7 @@ void CPrep_SetSourceFile(FileOffsetInfo *foi) { if (foi->file) { if (foi->file == filestack[0]) { if (cprep_cursymfile) { - if (cparamblkptr->isPrecompiling != 1) + if (cparamblkptr->precompile != 1) ObjGen_SrcBreakName(NULL, 0, 0); cprep_cursymfile = NULL; } @@ -1290,7 +1290,7 @@ void CPrep_SetSourceFile(FileOffsetInfo *foi) { if (cprep_cursymfile != foi->file) { for (list = cprep_files; list; list = list->next) { if (foi->file == list->fileinfo) { - if (cparamblkptr->isPrecompiling != 1) + if (cparamblkptr->precompile != 1) ObjGen_SrcBreakName(list->fileinfo->nameNode, list->fileinfo->fileModDate, 0); cprep_cursymfile = foi->file; return; @@ -1301,7 +1301,7 @@ void CPrep_SetSourceFile(FileOffsetInfo *foi) { list->next = cprep_files; cprep_files = list; list->fileinfo = foi->file; - if (cparamblkptr->isPrecompiling != 1) + if (cparamblkptr->precompile != 1) ObjGen_SrcBreakName(list->fileinfo->nameNode, list->fileinfo->fileModDate, 1); cprep_cursymfile = foi->file; } @@ -1418,7 +1418,7 @@ void CPrep_GetPrepPos(CPrepFileInfo **file, SInt32 *ppos) { *ppos = pos - prep_file_start; } -UInt8 C_Compiler(CParams *param) { +UInt8 C_Compiler(CompilerLinkerParamBlk *param) { TStreamElement ts; UInt8 code; @@ -1438,7 +1438,7 @@ UInt8 C_Compiler(CParams *param) { linetick = COS_GetTicks() + 5; code = 0; copts.delete_exception = 1; - copts.som_call_opt = 1; + copts.som_call_optimize = 1; copts.template_patch = 1; copts.template_friends = 1; copts.simple_class_byval = 1; @@ -1464,7 +1464,7 @@ UInt8 C_Compiler(CParams *param) { InitNameHash(); setupprep(); CParser_Setup(); - SetupPrecompiler(cparamblkptr->isPrecompiling); + SetupPrecompiler(cparamblkptr->precompile); SetupAssembler(); ObjGen_Setup(); PointerAnalysis_Setup(); @@ -1474,12 +1474,12 @@ UInt8 C_Compiler(CParams *param) { if (copts.oldprefixname[0]) setupfile(copts.oldprefixname, 1, 0); - coptssave = galloc(sizeof(COpts)); + coptssave = galloc(sizeof(CompilerLinkerOptions)); *coptssave = copts; coptpushs = NULL; coptpush = NULL; - preprocessing_only = param->isPreprocessing; - if (param->isPreprocessing) + preprocessing_only = param->preprocess; + if (param->preprocess) CPrep_Preprocess(); else cparser(); @@ -1500,20 +1500,20 @@ UInt8 C_Compiler(CParams *param) { } if (!anyerrors) { - if (param->isPrecompiling == 1) { + if (param->precompile == 1) { CBrowse_Finish(param); PrecompilerWrite(); - } else if (!param->isPreprocessing) { + } else if (!param->preprocess) { ObjGen_Finish(); CBrowse_Finish(param); } code = 1; } - if (param->isPreprocessing) { - cparamblkptr->objectDataHandle = pplist.data; + if (param->preprocess) { + cparamblkptr->objectdata = pplist.data; pplist.data = NULL; - cparamblkptr->browseDataHandle = NULL; + cparamblkptr->browsedata = NULL; } } else { CWDisplayLines(param->context, lines); @@ -1529,7 +1529,7 @@ UInt8 C_Compiler(CParams *param) { CBrowse_Cleanup(param); } - param->objectdata.compiledlines = lines; + param->object.compiledlines = lines; if (cprep_nomem_exit) { CompilerGetCString(7, string); CWReportMessage(cparamblkptr->context, NULL, string, NULL, messagetypeError, 0); @@ -2003,7 +2003,7 @@ static void CPrep_Define(void) { } } - if (copts.ANSI_strict) + if (copts.ANSIstrict) CPrep_Error(CErrorStr117); AppendGListByte(&mlist, '#'); pos = ptr17; @@ -2076,7 +2076,7 @@ static void CPrep_Define(void) { macro->next = macrohashtable[macro->name->hashval]; macrohashtable[macro->name->hashval] = macro; - if (cparamblkptr->browseOptions.recordMacros && prep_file->recordbrowseinfo) { + if (cparamblkptr->browseoptions.recordMacros && prep_file->recordbrowseinfo) { CBrowse_NewMacro(macro, prep_file, gDirectiveStart, pos - prep_file_start + 1); } @@ -2143,7 +2143,7 @@ static Boolean CPrep_CheckTarget(void) { return 0; } - result = !strcmp(cparams.targetName, tkstring); + result = !strcmp(cparams.idetargetname, tkstring); if (!notendofline()) { CError_Error(CErrorStr112); @@ -2185,11 +2185,11 @@ static Boolean CPrep_CheckOption(void) { } if (!strcmp(tkidentifier->name, "scheduling")) { - result = copts.schedule_mode != 0; + result = copts.schedule_factor != 0; } else if (!strcmp(tkidentifier->name, "precompile")) { - result = cparamblkptr->isPrecompiling == 1; + result = cparamblkptr->precompile == 1; } else if (!strcmp(tkidentifier->name, "preprocess")) { - result = cparamblkptr->isPreprocessing; + result = cparamblkptr->preprocess; } else { for (option = compileroptions; option->name; option++) { if (!strcmp(tkidentifier->name, option->name)) { @@ -2813,19 +2813,19 @@ static void pragma_on_off_reset(UInt32 bits) { return; } if (flag && !strcmp(tkidentifier->name, "list")) { - if (cparamblkptr->isPreprocessing) { + if (cparamblkptr->preprocess) { skipendofline(); return; } macrocheck = 1; - if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(internal)) + if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(cfm_internal)) imex_flags = OBJECT_FLAGS_10; - else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(import)) + else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(cfm_import)) imex_flags = OBJECT_FLAGS_20; - else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(export)) + else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(cfm_export)) imex_flags = OBJECT_FLAGS_40; - else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(lib_export)) + else if ((bits & OPT_OFFSET_MASK) == OPT_OFFSET(cfm_lib_export)) imex_flags = OBJECT_FLAGS_60; else CError_FATAL(3610); @@ -2921,7 +2921,7 @@ static void CPrep_PragmaUnused(void) { NameSpaceObjectList *list; short t; - if (cparamblkptr->isPreprocessing) { + if (cparamblkptr->preprocess) { skipendofline(); return; } @@ -2994,7 +2994,7 @@ static void CPrep_PragmaInlineMaxSize(void) { if (notendofline() && plex() == '(' && notendofline()) { switch (plex()) { case TK_INTCONST: - copts.inline_max_size = CInt64_GetULong(&tkintconst); + copts.inlinemaxsize = CInt64_GetULong(&tkintconst); break; default: CPrep_Warning(CErrorStr186); @@ -3019,7 +3019,7 @@ static void CPrep_PragmaInlineMaxTotalSize(void) { if (notendofline() && plex() == '(' && notendofline()) { switch (plex()) { case TK_INTCONST: - copts.inline_max_total_size = CInt64_GetULong(&tkintconst); + copts.inlinemaxtotalsize = CInt64_GetULong(&tkintconst); break; default: CPrep_Warning(CErrorStr186); @@ -3061,7 +3061,7 @@ static void pragma_segment(void) { if (!i || i >= 255) CPrep_Warning(CErrorStr186); - copts.forcedSegment = GetHashNameNodeExport(name); + copts.cursegmentname = GetHashNameNodeExport(name); ObjGen_SegmentName(); } else { if (copts.warn_illpragma) @@ -3072,22 +3072,22 @@ static void pragma_segment(void) { static void pragma_options(void) { if (notendofline() && plex() == TK_IDENTIFIER && !strcmp(tkidentifier->name, "align") && notendofline() && plex() == '=' && notendofline() && plex() == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "reset")) { - CPrep_PopOption(OPT_OFFSET(align_mode)); + CPrep_PopOption(OPT_OFFSET(structalignment)); goto done; } else if (!strcmp(tkidentifier->name, "native")) { - CPrep_PushOption(OPT_OFFSET(align_mode), AlignMode2_PPC); + CPrep_PushOption(OPT_OFFSET(structalignment), AlignMode2_PPC); goto done; } else if (!strcmp(tkidentifier->name, "mac68k")) { - CPrep_PushOption(OPT_OFFSET(align_mode), AlignMode0_Mac68k); + CPrep_PushOption(OPT_OFFSET(structalignment), AlignMode0_Mac68k); goto done; } else if (!strcmp(tkidentifier->name, "mac68k4byte")) { - CPrep_PushOption(OPT_OFFSET(align_mode), AlignMode1_Mac68k4byte); + CPrep_PushOption(OPT_OFFSET(structalignment), AlignMode1_Mac68k4byte); goto done; } else if (!strcmp(tkidentifier->name, "power")) { - CPrep_PushOption(OPT_OFFSET(align_mode), AlignMode2_PPC); + CPrep_PushOption(OPT_OFFSET(structalignment), AlignMode2_PPC); goto done; } else if (!strcmp(tkidentifier->name, "packed")) { - CPrep_PushOption(OPT_OFFSET(align_mode), AlignMode8_Packed); + CPrep_PushOption(OPT_OFFSET(structalignment), AlignMode8_Packed); goto done; } } @@ -3127,7 +3127,7 @@ static void pragma_pop(void) { static void pragma_overload(void) { Object *obj; - if (cparamblkptr->isPreprocessing) { + if (cparamblkptr->preprocess) { skipendofline(); return; } @@ -3192,7 +3192,7 @@ static void pragma_opt_unroll_count(void) { if (t == TK_INTCONST) { lv = CInt64_GetULong(&tkintconst); if (lv >= 0 && lv <= 127) { - CPrep_PushOption(OPT_OFFSET(loop_unroll_count), lv); + CPrep_PushOption(OPT_OFFSET(unrollfactor), lv); CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { @@ -3200,7 +3200,7 @@ static void pragma_opt_unroll_count(void) { skipendofline(); } } else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) { - CPrep_PopOption(OPT_OFFSET(loop_unroll_count)); + CPrep_PopOption(OPT_OFFSET(unrollfactor)); CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { @@ -3223,7 +3223,7 @@ static void pragma_opt_unroll_instr_count(void) { if (t == TK_INTCONST) { lv = CInt64_GetULong(&tkintconst); if (lv >= 0 && lv <= 127) { - CPrep_PushOption(OPT_OFFSET(loop_unroll_size_threshold), lv); + CPrep_PushOption(OPT_OFFSET(unrollinstrfactor), lv); CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { @@ -3231,7 +3231,7 @@ static void pragma_opt_unroll_instr_count(void) { skipendofline(); } } else if (t == TK_IDENTIFIER && !strcmp(tkidentifier->name, "reset")) { - CPrep_PopOption(OPT_OFFSET(loop_unroll_size_threshold)); + CPrep_PopOption(OPT_OFFSET(unrollinstrfactor)); CodeGen_UpdateOptimizerOptions(); CodeGen_UpdateBackEndOptions(); } else { @@ -3254,7 +3254,7 @@ static void pragma_pack(void) { if (notendofline() && plex() == '(') { macrocheck = 1; if (notendofline() && ((t = plex()) == ')')) { - copts.align_mode = coptssave->align_mode; + copts.structalignment = coptssave->structalignment; } else { did_push = did_pop = 0; do { @@ -3263,14 +3263,14 @@ static void pragma_pack(void) { if (cprep_packstackp) { cprep_packstackp--; cprep_packstack[cprep_packstackp].identifier = NULL; - cprep_packstack[cprep_packstackp].align_mode = copts.align_mode; + cprep_packstack[cprep_packstackp].align_mode = copts.structalignment; did_push = 1; } else { CPrep_Warning(CErrorStr186); } } else if (!strcmp(tkidentifier->name, "pop")) { if (cprep_packstackp < 128) { - copts.align_mode = cprep_packstack[cprep_packstackp].align_mode; + copts.structalignment = cprep_packstack[cprep_packstackp].align_mode; cprep_packstackp++; did_pop = 1; } else { @@ -3285,7 +3285,7 @@ static void pragma_pack(void) { break; } if (i < 128) { - copts.align_mode = cprep_packstack[i].align_mode; + copts.structalignment = cprep_packstack[i].align_mode; cprep_packstackp = i + 1; } else { CPrep_Warning(CErrorStr186); @@ -3300,22 +3300,22 @@ static void pragma_pack(void) { if (t == TK_INTCONST) { switch (CInt64_GetULong(&tkintconst)) { case 0: - copts.align_mode = coptssave->align_mode; + copts.structalignment = coptssave->structalignment; break; case 1: - copts.align_mode = AlignMode3_1Byte; + copts.structalignment = AlignMode3_1Byte; break; case 2: - copts.align_mode = AlignMode4_2Byte; + copts.structalignment = AlignMode4_2Byte; break; case 4: - copts.align_mode = AlignMode5_4Byte; + copts.structalignment = AlignMode5_4Byte; break; case 8: - copts.align_mode = AlignMode6_8Byte; + copts.structalignment = AlignMode6_8Byte; break; case 16: - copts.align_mode = AlignMode7_16Byte; + copts.structalignment = AlignMode7_16Byte; break; default: if (copts.warn_illpragma) @@ -4098,7 +4098,7 @@ static void prepelse(void) { return; } - if (!copts.ANSI_strict) + if (!copts.ANSIstrict) skipendofline(); else goendofline(); @@ -4127,7 +4127,7 @@ static void prependif(void) { } macrocheck = 0; - if (!copts.ANSI_strict) + if (!copts.ANSIstrict) skipendofline(); else goendofline(); @@ -4264,7 +4264,7 @@ void preprocessor(void) { macrocheck = 1; return; } - if (!copts.ANSI_strict) { + if (!copts.ANSIstrict) { if (!strcmp("warning", tkidentifier->name)) { CPrep_Warning(CErrorStr337); skipendofline(); @@ -4307,7 +4307,7 @@ void preprocessor(void) { prependif(); return; } - if (copts.objective_c || !copts.ANSI_strict) { + if (copts.objective_c || !copts.ANSIstrict) { if (!strcmp("import", tkidentifier->name)) { prepinclude(1); macrocheck = 1; diff --git a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c index 4c36aab..6d66b9d 100644 --- a/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c +++ b/compiler_and_linker/FrontEnd/C/CPrepTokenizer.c @@ -81,7 +81,7 @@ loop: } } if (tokenstacklevel <= 0) { - if (p[0] == '/' && (!copts.ANSI_strict || copts.cplusplus || copts.c9x)) { + if (p[0] == '/' && (!copts.ANSIstrict || copts.cplusplus || copts.c9x)) { spaceskip = 1; nextcharpos = (char *) CPrep_SkipNewComment(p + 1); return CPrep_SkipNewCommentChar; @@ -224,7 +224,7 @@ loop: p += 2; } } - if (p[0] == '/' && (!copts.ANSI_strict || copts.cplusplus)) { + if (p[0] == '/' && (!copts.ANSIstrict || copts.cplusplus)) { spaceskip = 1; pos = (char *) CPrep_SkipNewComment(p + 1); return CPrep_SkipNewCommentChar; @@ -676,7 +676,7 @@ static short intsuffix(short token, Boolean flag) { break; case 'i': case 'I': - if (copts.cpp_extensions && !copts.ANSI_strict && copts.longlong) { + if (copts.cpp_extensions && !copts.ANSIstrict && copts.longlong) { pos = nextcharpos; t = prepcurchar(); if (t == '6') { @@ -745,7 +745,7 @@ static short floatsuffix(short token) { break; case 'd': case 'D': - if (!copts.ANSI_strict) { + if (!copts.ANSIstrict) { pos = nextcharpos; token = *pos; whichtype = IT_DOUBLE; @@ -1001,7 +1001,7 @@ void skipendofline(void) { } } - if (*p == '/' && (!copts.ANSI_strict || copts.cplusplus)) { + if (*p == '/' && (!copts.ANSIstrict || copts.cplusplus)) { // EOL comment pos = (char *) CPrep_SkipNewComment(p + 1); if (CPrep_SkipNewCommentChar == '\r') @@ -1133,7 +1133,7 @@ static short tapos(short _t) { CError_FATAL(1386); } } else { - if (copts.unsignedchars) + if (copts.unsigned_char) t &= 0xFF; CInt64_SetLong(&tkintconst, t); tksize = copts.cplusplus ? IT_SCHAR : IT_INT; @@ -1556,7 +1556,7 @@ static short tzero(short t) { if (pos == p) CError_Error(CErrorStr105); pos = p; - } else if (!copts.ANSI_strict && (ch == 'b' || ch == 'B')) { + } else if (!copts.ANSIstrict && (ch == 'b' || ch == 'B')) { p = CInt64_ScanBinString(&tkintconst, pos, &failed); if (pos == p) CError_Error(CErrorStr105); @@ -1691,7 +1691,7 @@ static short tchra(void) { return 0; if (!strcmp("auto", tkidentifier->name)) return TK_AUTO; - if ((copts.cplusplus || !copts.only_std_keywords) && !strcmp("asm", tkidentifier->name)) + if ((copts.cplusplus || !copts.onlystdkeywords) && !strcmp("asm", tkidentifier->name)) return TK_ASM; if (copts.cplusplus && !in_assembler && !preprocessing_only) { if (!strcmp("and", tkidentifier->name)) @@ -1845,7 +1845,7 @@ static short tchri(void) { if (copts.cplusplus || copts.c9x) { if (!strcmp("inline", tkidentifier->name)) return TK_INLINE; - } else if (!copts.only_std_keywords) { + } else if (!copts.onlystdkeywords) { if (!strcmp("inline", tkidentifier->name)) return TK_INLINE; } @@ -1933,7 +1933,7 @@ static short tchrp(short t) { pos = ReadIdentifier(pos - 1); if (macrocheck && macrotest()) return 0; - if (!copts.only_std_keywords && !strcmp("pascal", tkidentifier->name)) + if (!copts.onlystdkeywords && !strcmp("pascal", tkidentifier->name)) return TK_PASCAL; if (copts.cplusplus && t == 'p') { if (!strcmp("private", tkidentifier->name)) diff --git a/compiler_and_linker/unsorted/CABI.c b/compiler_and_linker/unsorted/CABI.c index 853a053..d607104 100644 --- a/compiler_and_linker/unsorted/CABI.c +++ b/compiler_and_linker/unsorted/CABI.c @@ -451,7 +451,7 @@ static void CABI_AllocateVTable(DeclE *decle, TypeClass *tclass) { } void CABI_LayoutClass(DeclE *decle, TypeClass *tclass) { - char saveAlignMode = copts.align_mode; + char saveAlignMode = copts.structalignment; tclass->size = 0; if (!tclass->sominfo) { @@ -465,7 +465,7 @@ void CABI_LayoutClass(DeclE *decle, TypeClass *tclass) { if (tclass->flags & CLASS_FLAGS_20) CABI_AllocateVirtualBases(decle, tclass); } else { - copts.align_mode = AlignMode2_PPC; + copts.structalignment = AlignMode2_PPC; CABI_AllocateMembers(decle, tclass); } @@ -479,7 +479,7 @@ void CABI_LayoutClass(DeclE *decle, TypeClass *tclass) { tclass->flags |= CLASS_FLAGS_2; - copts.align_mode = saveAlignMode; + copts.structalignment = saveAlignMode; } void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *func) { @@ -505,8 +505,8 @@ void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *func) { CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_SetupNewFuncArgs(func, TYPE_FUNC(func->type)->args); @@ -555,7 +555,7 @@ void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *func) { CFunc_Gen(&firstStmt, func, 0); CScope_RestoreScope(&savedScope); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; func->u.func.defargdata = NULL; } @@ -747,11 +747,11 @@ SInt32 CABI_GetCtorOffsetOffset(TypeClass *tclass, TypeClass *baseclass) { size -= baseSize; } - saveAlignMode = copts.align_mode; + saveAlignMode = copts.structalignment; if (tclass->eflags & CLASS_EFLAGS_F0) - copts.align_mode = ((tclass->eflags & CLASS_EFLAGS_F0) >> 4) - 1; + copts.structalignment = ((tclass->eflags & CLASS_EFLAGS_F0) >> 4) - 1; size += CMach_MemberAlignValue(TYPE(&stunsignedlong), size); - copts.align_mode = saveAlignMode; + copts.structalignment = saveAlignMode; return size; } @@ -1179,8 +1179,8 @@ void CABI_MakeDefaultConstructor(TypeClass *tclass, Object *func) { CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_SetupNewFuncArgs(func, TYPE_FUNC(func->type)->args); @@ -1199,7 +1199,7 @@ void CABI_MakeDefaultConstructor(TypeClass *tclass, Object *func) { CFunc_Gen(&firstStmt, func, 0); CScope_RestoreScope(&savedScope); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } static ENode *CABI_AssignObject(TypeClass *tclass, ENode *expr1, ENode *expr2) { @@ -1550,8 +1550,8 @@ void CABI_MakeDefaultCopyConstructor(TypeClass *tclass, Object *func) { CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_SetupNewFuncArgs(func, TYPE_FUNC(func->type)->args); @@ -1570,7 +1570,7 @@ void CABI_MakeDefaultCopyConstructor(TypeClass *tclass, Object *func) { CFunc_Gen(&firstStmt, func, 0); CScope_RestoreScope(&savedScope); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } void CABI_MakeDefaultAssignmentOperator(TypeClass *tclass, Object *func) { @@ -1592,8 +1592,8 @@ void CABI_MakeDefaultAssignmentOperator(TypeClass *tclass, Object *func) { CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_SetupNewFuncArgs(func, TYPE_FUNC(func->type)->args); @@ -1628,7 +1628,7 @@ void CABI_MakeDefaultAssignmentOperator(TypeClass *tclass, Object *func) { CFunc_Gen(&firstStmt, func, 0); CScope_RestoreScope(&savedScope); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } static Statement *CABI_DestroyMembers(Statement *stmt, ObjMemberVar *ivars, TypeClass *tclass) { @@ -1862,8 +1862,8 @@ void CABI_MakeDefaultDestructor(TypeClass *tclass, Object *func) { CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_SetupNewFuncArgs(func, TYPE_FUNC(func->type)->args); @@ -1879,7 +1879,7 @@ void CABI_MakeDefaultDestructor(TypeClass *tclass, Object *func) { CFunc_Gen(&firstStmt, func, 0); CScope_RestoreScope(&savedScope); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } static void CABI_CreateLayeredDestructor(TypeClass *tclass, Object *obj1, Object *func, CABIDestroyMode mode) { @@ -1894,8 +1894,8 @@ static void CABI_CreateLayeredDestructor(TypeClass *tclass, Object *obj1, Object CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_SetupNewFuncArgs(func, TYPE_FUNC(func->type)->args); @@ -1911,7 +1911,7 @@ static void CABI_CreateLayeredDestructor(TypeClass *tclass, Object *obj1, Object CFunc_Gen(&firstStmt, func, 0); CScope_RestoreScope(&savedScope); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } void CABI_MakeLayeredDestructor(TypeClass *tclass, Object *func) { diff --git a/compiler_and_linker/unsorted/CBrowse.c b/compiler_and_linker/unsorted/CBrowse.c index 1e12b91..9bc65b9 100644 --- a/compiler_and_linker/unsorted/CBrowse.c +++ b/compiler_and_linker/unsorted/CBrowse.c @@ -106,12 +106,12 @@ typedef struct BrowseHeader { // forward decls static void RecordUndefinedMemberFunctions(void); -void CBrowse_Setup(CParams *params) { +void CBrowse_Setup(CompilerLinkerParamBlk *params) { BrowseHeader hdr; CError_ASSERT(123, params != NULL); - params->objectdata.browsedata = NULL; + params->object.browsedata = NULL; InitGList(&gBrowseData, 0x10000); InitGList(&gMemberFuncList, 1024); @@ -130,7 +130,7 @@ void CBrowse_Setup(CParams *params) { AppendGListData(&gBrowseData, &hdr, sizeof(hdr)); } -void CBrowse_Finish(CParams *params) { +void CBrowse_Finish(CompilerLinkerParamBlk *params) { CWMemHandle hnd; CError_ASSERT(151, params != NULL); @@ -142,13 +142,13 @@ void CBrowse_Finish(CParams *params) { COS_ResizeHandle(gBrowseData.data, gBrowseData.size); if (CWSecretAttachHandle(params->context, gBrowseData.data, &hnd) == cwNoErr) { - params->objectdata.browsedata = hnd; + params->object.browsedata = hnd; gBrowseData.data = NULL; } } } -void CBrowse_Cleanup(CParams *params) { +void CBrowse_Cleanup(CompilerLinkerParamBlk *params) { FreeGList(&gBrowseData); FreeGList(&gClassData); FreeGList(&gMemberFuncList); diff --git a/compiler_and_linker/unsorted/CClass.c b/compiler_and_linker/unsorted/CClass.c index 7123a93..86ba7a9 100644 --- a/compiler_and_linker/unsorted/CClass.c +++ b/compiler_and_linker/unsorted/CClass.c @@ -1765,7 +1765,7 @@ void CClass_ClassAction(TypeClass *tclass) { CClass_AllocVTable(tclass); memclrw(vtable_object_data, vtable_data_size); - if (copts.useRTTI && !(tclass->flags & (CLASS_FLAGS_10 | CLASS_FLAGS_2000))) + if (copts.RTTI && !(tclass->flags & (CLASS_FLAGS_10 | CLASS_FLAGS_2000))) vtable_object_links = CRTTI_ConstructVTableHeaders(tclass, vtable_object_data, vtable_object_links); CError_ASSERT(2492, tclass->vtable->object->type->size == tclass->vtable->size); @@ -1779,7 +1779,7 @@ void CClass_MakeStaticActionClass(TypeClass *tclass) { tclass->vtable->object->qual |= Q_20000; if (!(tclass->vtable->object->flags & OBJECT_FLAGS_2)) { CParser_NewCallBackAction(tclass->vtable->object, tclass); - } else if (cparamblkptr->isPrecompiling != 1) { + } else if (cparamblkptr->precompile != 1) { CParser_NewClassAction(tclass); } } @@ -1800,7 +1800,7 @@ void CClass_MemberDef(Object *obj, TypeClass *tclass) { CError_Error(CErrorStr280); tclass->action = CLASS_ACTION_0; CClass_MakeStaticActionClass(tclass); - } else if (cparamblkptr->isPrecompiling != 1) { + } else if (cparamblkptr->precompile != 1) { CParser_NewClassAction(tclass); } } diff --git a/compiler_and_linker/unsorted/CCompiler.c b/compiler_and_linker/unsorted/CCompiler.c index 1bac511..06d518f 100644 --- a/compiler_and_linker/unsorted/CCompiler.c +++ b/compiler_and_linker/unsorted/CCompiler.c @@ -13,7 +13,7 @@ Boolean systemHandles; static Boolean using_license_manager; Boolean crippled; SInt32 license_cookie; -CParams cparams; +CompilerLinkerParamBlk cparams; static void get_extension(ConstStringPtr src, char *dst) { int ep; @@ -33,86 +33,86 @@ static int setup_param_block(CWPluginContext context) { static char target_name[128]; CWTargetInfo tinfo; - memset(&cparams, 0, sizeof(CParams)); + memset(&cparams, 0, sizeof(CompilerLinkerParamBlk)); cparams.context = context; - if (CWGetPluginRequest(context, &cparams.pluginRequest) != cwNoErr) + if (CWGetPluginRequest(context, &cparams.request) != cwNoErr) return 0; - if (CWGetAPIVersion(context, &cparams.apiVersion) != cwNoErr) + if (CWGetAPIVersion(context, &cparams.version) != cwNoErr) return 0; - if (CWGetProjectFile(context, &cparams.projectFile) != cwNoErr) + if (CWGetProjectFile(context, &cparams.targetfile) != cwNoErr) return 0; - if (CWGetProjectFileCount(context, &cparams.projectFileCount) != cwNoErr) + if (CWGetProjectFileCount(context, &cparams.numfiles) != cwNoErr) return 0; - if (CWGetMainFileNumber(context, &cparams.mainFileNumber) != cwNoErr) + if (CWGetMainFileNumber(context, &cparams.whichfile) != cwNoErr) return 0; - if (CWGetMainFileSpec(context, &cparams.mainFileSpec) != cwNoErr) + if (CWGetMainFileSpec(context, &cparams.sourcefile) != cwNoErr) return 0; - if (CWGetMainFileText(context, &cparams.mainFileText, &cparams.mainFileTextLength) != cwNoErr) + if (CWGetMainFileText(context, &cparams.sourcetext, &cparams.sourcetextsize) != cwNoErr) return 0; - if (CWIsPrecompiling(context, &cparams.isPrecompiling) != cwNoErr) + if (CWIsPrecompiling(context, &cparams.precompile) != cwNoErr) return 0; - if (CWIsAutoPrecompiling(context, &cparams.isAutoPrecompiling) != cwNoErr) + if (CWIsAutoPrecompiling(context, &cparams.autoprecompile) != cwNoErr) return 0; - if (CWIsPreprocessing(context, &cparams.isPreprocessing) != cwNoErr) + if (CWIsPreprocessing(context, &cparams.preprocess) != cwNoErr) return 0; - if (CWIsGeneratingDebugInfo(context, &cparams.isGeneratingDebugInfo) != cwNoErr) + if (CWIsGeneratingDebugInfo(context, &cparams.SYMinfo) != cwNoErr) return 0; - if (CWIsCachingPrecompiledHeaders(context, &cparams.isCachingPrecompiledHeaders) != cwNoErr) + if (CWIsCachingPrecompiledHeaders(context, &cparams.caching_includes) != cwNoErr) return 0; - if (CWGetBrowseOptions(context, &cparams.browseOptions) != cwNoErr) + if (CWGetBrowseOptions(context, &cparams.browseoptions) != cwNoErr) return 0; - cparams.field276 = cparams.isPreprocessing == 0; - if (CWGetMainFileID(context, &cparams.mainFileID) != cwNoErr) + cparams.recordbrowseinfo = cparams.preprocess == 0; + if (CWGetMainFileID(context, &cparams.browserfileID) != cwNoErr) return 0; if (CWGetTargetInfo(context, &tinfo) != cwNoErr) return 0; cparams.targetOS = tinfo.targetOS; cparams.targetCPU = tinfo.targetCPU; - cparams.targetName = target_name; + cparams.idetargetname = target_name; return CWGetTargetName(context, target_name, sizeof(target_name)) == cwNoErr; } static short store_compile_results(void) { CWResult result; - if (cparams.objectDataHandle) - CWSecretAttachHandle(cparams.context, cparams.objectDataHandle, &cparams.objectdata.objectdata); - if (cparams.browseDataHandle) - CWSecretAttachHandle(cparams.context, cparams.browseDataHandle, &cparams.objectdata.browsedata); + if (cparams.objectdata) + CWSecretAttachHandle(cparams.context, cparams.objectdata, &cparams.object.objectdata); + if (cparams.browsedata) + CWSecretAttachHandle(cparams.context, cparams.browsedata, &cparams.object.browsedata); - if (cparams.isPreprocessing) { - if (cparams.objectdata.objectdata) { + if (cparams.preprocess) { + if (cparams.object.objectdata) { CWNewTextDocumentInfo docinfo; memset(&docinfo, 0, sizeof(CWNewTextDocumentInfo)); - docinfo.text = cparams.objectdata.objectdata; - cparams.objectdata.objectdata = NULL; + docinfo.text = cparams.object.objectdata; + cparams.object.objectdata = NULL; result = CWCreateNewTextDocument(cparams.context, &docinfo); } } else { - result = CWStoreObjectData(cparams.context, cparams.mainFileNumber, &cparams.objectdata); + result = CWStoreObjectData(cparams.context, cparams.whichfile, &cparams.object); } return result; } -static void initialize_compiler_options(CParams *params) { +static void initialize_compiler_options(CompilerLinkerParamBlk *params) { static PFrontEndC pFrontEnd; PWarningC pWarningC; PGlobalOptimizer pGlobalOptimizer; Handle prefsdata; char extension[256]; - memclrw(&copts, sizeof(COpts)); + memclrw(&copts, sizeof(CompilerLinkerOptions)); CWSecretGetNamedPreferences(cparams.context, "C/C++ Compiler", &prefsdata); pFrontEnd = *((PFrontEndC *) *prefsdata); - copts.little_endian = 0; + copts.littleendian = 0; copts.cplusplus = 1; copts.objective_c = pFrontEnd.objective_c; - get_extension(params->mainFileSpec.name, extension); + get_extension(params->sourcefile.name, extension); if (!strcmp(extension, ".c") || !strcmp(extension, ".h") || !strcmp(extension, ".pch")) { copts.cplusplus = pFrontEnd.cplusplus; } else if (!strcmp(extension, ".m")) { @@ -123,34 +123,34 @@ static void initialize_compiler_options(CParams *params) { copts.objective_c = 1; } - copts.require_prototypes = pFrontEnd.checkprotos; - copts.ARM_conform = pFrontEnd.arm; - copts.ARM_scoping = pFrontEnd.arm; + copts.checkprotos = pFrontEnd.checkprotos; + copts.ARMconform = pFrontEnd.arm; + copts.ARMscoping = pFrontEnd.arm; copts.trigraphs = pFrontEnd.trigraphs; - copts.only_std_keywords = pFrontEnd.onlystdkeywords; + copts.onlystdkeywords = pFrontEnd.onlystdkeywords; copts.enumsalwaysint = pFrontEnd.enumsalwaysint; copts.mpwc_relax = pFrontEnd.mpwpointerstyle; - copts.ANSI_strict = pFrontEnd.ansistrict; + copts.ANSIstrict = pFrontEnd.ansistrict; copts.mpwc_newline = pFrontEnd.mpwcnewline; copts.exceptions = pFrontEnd.enableexceptions; copts.dont_reuse_strings = pFrontEnd.dontreusestrings; - copts.pool_strings = pFrontEnd.poolstrings; - copts.dont_inline = pFrontEnd.dontinline; - copts.useRTTI = pFrontEnd.useRTTI; + copts.poolstrings = pFrontEnd.poolstrings; + copts.dontinline = pFrontEnd.dontinline; + copts.RTTI = pFrontEnd.useRTTI; copts.oldprefixname = pFrontEnd.oldprefixname; copts.multibyteaware = pFrontEnd.multibyteaware; - copts.unsignedchars = pFrontEnd.unsignedchars; - copts.autoinline = pFrontEnd.autoinline; + copts.unsigned_char = pFrontEnd.unsignedchars; + copts.auto_inline = pFrontEnd.autoinline; copts.direct_to_som = pFrontEnd.direct_to_som; copts.som_env_check = pFrontEnd.som_env_check; copts.booltruefalse = pFrontEnd.booltruefalse; - copts.always_inline = pFrontEnd.alwaysinline; + copts.alwaysinline = pFrontEnd.alwaysinline; copts.inlinelevel = pFrontEnd.inlinelevel; copts.wchar_type = pFrontEnd.wchar_type; copts.ecplusplus = pFrontEnd.ecplusplus; copts.defer_codegen = pFrontEnd.defer_codegen; - copts.inline_max_size = 512; - copts.inline_max_total_size = 100000; + copts.inlinemaxsize = 512; + copts.inlinemaxtotalsize = 100000; CWSecretGetNamedPreferences(cparams.context, "C/C++ Warnings", &prefsdata); pWarningC = *((PWarningC *) *prefsdata); @@ -172,15 +172,15 @@ static void initialize_compiler_options(CParams *params) { pGlobalOptimizer = *((PGlobalOptimizer *) *prefsdata); copts.optimizationlevel = pGlobalOptimizer.optimizationlevel; - copts.optimize_for_size = (Boolean) (pGlobalOptimizer.optfor == 1); + copts.optimizesize = (Boolean) (pGlobalOptimizer.optfor == 1); copts.crippled = crippled; - copts.loop_unroll_count = 8; - copts.loop_unroll_size_threshold = 100; - copts.isGeneratingDebugInfo = params->isGeneratingDebugInfo; - copts.pchCreator = CWFOURCHAR('C','W','I','E'); - copts.pchType = CWFOURCHAR('M','M','C','H'); - copts.text = CWFOURCHAR('T','E','X','T'); + copts.unrollfactor = 8; + copts.unrollinstrfactor = 100; + copts.filesyminfo = params->SYMinfo; + copts.appltype = CWFOURCHAR('C', 'W', 'I', 'E'); + copts.headtype = CWFOURCHAR('M', 'M', 'C', 'H'); + copts.texttype = CWFOURCHAR('T','E','X','T'); } static void GetLicense(void) { diff --git a/compiler_and_linker/unsorted/CDecl.c b/compiler_and_linker/unsorted/CDecl.c index 789c6d8..7aee542 100644 --- a/compiler_and_linker/unsorted/CDecl.c +++ b/compiler_and_linker/unsorted/CDecl.c @@ -436,7 +436,7 @@ static void scandirectdecl1(DeclInfo *declinfo) { CError_Error(CErrorStr124); len = cint64_one; } else if (CInt64_IsZero(&len)) { - if (!copts.ANSI_strict && declinfo->x50) { + if (!copts.ANSIstrict && declinfo->x50) { flag = 1; } else { CError_Error(CErrorStr124); @@ -1595,7 +1595,7 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) { const UInt32 mask = Q_ALIGNED_MASK | Q_REFERENCE | Q_PASCAL | Q_VOLATILE | Q_CONST; if (!is_typesame(objt->type, declinfo->thetype) || (objt->qual & mask) != (declinfo->qual & mask)) { CError_Error(CErrorStr249, declinfo->name->name, objt->type, objt->qual, declinfo->thetype, declinfo->qual); - } else if (!copts.cplusplus && (copts.pedantic || copts.ANSI_strict)) { + } else if (!copts.cplusplus && (copts.pedantic || copts.ANSIstrict)) { if (copts.pedantic) CError_Warning(CErrorStr122, declinfo->name->name); else @@ -1626,7 +1626,7 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) { } } - if (cparamblkptr->browseOptions.recordTypedefs && declinfo->file->recordbrowseinfo) + if (cparamblkptr->browseoptions.recordTypedefs && declinfo->file->recordbrowseinfo) CBrowse_NewTypedef(nspace, declinfo->name, declinfo->file, declinfo->file2, declinfo->x60, CPrep_BrowserFileOffset()); } @@ -1742,7 +1742,7 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) CTemplTool_IsTemplateArgumentDependentType(declinfo->thetype)) CTemplClass_RegisterObjectDef(TEMPL_CLASS(nspace->theclass), OBJ_BASE(obj)); - if (flag && nspace->theclass && cparamblkptr->browseOptions.recordClasses) + if (flag && nspace->theclass && cparamblkptr->browseoptions.recordClasses) CBrowse_AddClassMemberData(obj, CPrep_BrowserTokenOffset(&member_fileoffset) + 1, CPrep_BrowserFileOffset()); } @@ -1790,9 +1790,9 @@ Boolean CDecl_FunctionDeclarator(DeclInfo *declinfo, NameSpace *nspace, Boolean } if (obj->nspace == cscope_root && !strcmp(obj->name->name, "main")) { - if (obj->sclass == TK_STATIC || (copts.ANSI_strict && TYPE_FUNC(obj->type)->functype != (Type *) &stsignedint)) + if (obj->sclass == TK_STATIC || (copts.ANSIstrict && TYPE_FUNC(obj->type)->functype != (Type *) &stsignedint)) CError_Error(CErrorStr334); - } else if (copts.require_prototypes && (pflag || declinfo->x64)) { + } else if (copts.checkprotos && (pflag || declinfo->x64)) { if (obj->sclass != TK_STATIC && !(obj->qual & Q_INLINE) && !obj->nspace->is_unnamed) CError_Warning(CErrorStr178); } @@ -2214,7 +2214,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { } if (copts.enumsalwaysint) { - if (copts.ANSI_strict) { + if (copts.ANSIstrict) { if (!CInt64_IsInRange(val, stsignedint.size)) CError_Error(CErrorStr154); } else { @@ -2236,7 +2236,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { break; basetype = TYPE(CDecl_FindSignedType(8)); if (basetype->size != 8) { - if (!copts.ANSI_strict && CInt64_IsInRange(maximum, 4) && CInt64_IsInURange(minimum, 4)) + if (!copts.ANSIstrict && CInt64_IsInRange(maximum, 4) && CInt64_IsInURange(minimum, 4)) break; if (overflowed) CError_Error(CErrorStr154); @@ -2288,7 +2288,7 @@ static TypeEnum *CDecl_OldParseEnumList(TypeEnum *tenum, HashNameNode *name) { tenum->enumlist = oec; } - if (cparamblkptr->browseOptions.recordEnums) { + if (cparamblkptr->browseoptions.recordEnums) { CPrepFileInfo *f = CPrep_BrowserCurrentFile(); if (f->recordbrowseinfo) { CBrowse_NewEnumConstant(cscope_current, oec->name, f, fileinfo, offset, CPrep_BrowserFileOffset()); @@ -2376,7 +2376,7 @@ void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum) { if (CInt64_IsInRange(maximum, r26->size) && CInt64_IsInRange(minimum, r26->size)) break; - if (r26->size == stsignedlong.size && !copts.ANSI_strict && CInt64_IsInRange(minimum, r26->size) && CInt64_IsInURange(maximum, r26->size)) + if (r26->size == stsignedlong.size && !copts.ANSIstrict && CInt64_IsInRange(minimum, r26->size) && CInt64_IsInURange(maximum, r26->size)) break; } while (1); } else { @@ -2432,7 +2432,7 @@ static Type *CDecl_FindUnderlyingType(short size, CInt64 *a, CInt64 *b) { return TYPE(&stsignedlong); if (size <= stsignedlonglong.size && copts.longlong && copts.longlong_enums && CInt64_IsInRange(*a, stsignedlonglong.size) && CInt64_IsInRange(*b, stsignedlonglong.size)) return TYPE(&stsignedlonglong); - if (!copts.ANSI_strict && size <= stsignedlong.size && CInt64_IsInRange(*a, stsignedlong.size) && CInt64_IsInURange(*b, stunsignedlong.size)) + if (!copts.ANSIstrict && size <= stsignedlong.size && CInt64_IsInRange(*a, stsignedlong.size) && CInt64_IsInURange(*b, stunsignedlong.size)) return TYPE(&stsignedlong); } @@ -2560,7 +2560,7 @@ static TypeEnum *CDecl_ParseEnumList(TypeEnum *tenum, HashNameNode *name) { if (!has_template_value) { if (copts.enumsalwaysint) { - if (!CInt64_IsInRange(val, stsignedint.size) && (copts.ANSI_strict || !CInt64_IsInURange(val, stunsignedint.size))) + if (!CInt64_IsInRange(val, stsignedint.size) && (copts.ANSIstrict || !CInt64_IsInURange(val, stunsignedint.size))) overflowed = 1; basetype = TYPE(&stsignedint); } else if (CInt64_IsNegative(&val) && !is_unsigned(basetype)) { @@ -2601,7 +2601,7 @@ static TypeEnum *CDecl_ParseEnumList(TypeEnum *tenum, HashNameNode *name) { tenum->enumlist = oec; } - if (cparamblkptr->browseOptions.recordEnums) { + if (cparamblkptr->browseoptions.recordEnums) { CPrepFileInfo *f = CPrep_BrowserCurrentFile(); if (f->recordbrowseinfo) { CBrowse_NewEnumConstant(cscope_current, oec->name, f, fileinfo, offset, CPrep_BrowserFileOffset()); @@ -2651,7 +2651,7 @@ void scanenum(DeclInfo *declinfo) { declinfo->thetype = TYPE(CDecl_ParseEnumList(NULL, name)); } - if (cparamblkptr->browseOptions.recordEnums && declinfo->file->recordbrowseinfo) + if (cparamblkptr->browseoptions.recordEnums && declinfo->file->recordbrowseinfo) CBrowse_NewEnum( cscope_current, TYPE_ENUM(declinfo->thetype)->enumname, @@ -2716,7 +2716,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) { return; } - if ((!copts.ANSI_strict || copts.c9x) && !bde->declinfo2.thetype->size && IS_TYPE_ARRAY(bde->declinfo2.thetype)) { + if ((!copts.ANSIstrict || copts.c9x) && !bde->declinfo2.thetype->size && IS_TYPE_ARRAY(bde->declinfo2.thetype)) { if (bde->declinfo2.storageclass != TK_STATIC && bde->declinfo2.storageclass != TK_TYPEDEF) { type = TYPE_POINTER(bde->declinfo2.thetype)->target; while (IS_TYPE_ARRAY(type)) @@ -2749,7 +2749,7 @@ void CDecl_ScanStructDeclarator(BigDeclInfo *bde) { goto fuckup; CError_Error(CErrorStr138); bde->declinfo2.thetype = TYPE(&stunsignedint); - } else if (copts.ANSI_strict && !copts.cplusplus) { + } else if (copts.ANSIstrict && !copts.cplusplus) { if (bde->declinfo2.thetype != TYPE(&stsignedint) && bde->declinfo2.thetype != TYPE(&stunsignedint)) { CError_Error(CErrorStr138); bde->declinfo2.thetype = TYPE(&stunsignedint); @@ -2981,7 +2981,7 @@ static SInt32 scanstructdeclarationlist(TypeStruct *tstruct, Boolean flag) { break; tk = lex(); } - } else if (!copts.ANSI_strict && IS_TYPE_STRUCT(bde.declinfo.thetype)) { + } else if (!copts.ANSIstrict && IS_TYPE_STRUCT(bde.declinfo.thetype)) { member = galloc(sizeof(StructMember)); memclrw(member, sizeof(StructMember)); member->type = bde.declinfo.thetype; @@ -3084,7 +3084,7 @@ void scanstruct(DeclInfo *declinfo, short structtype) { type = (Type *) CDecl_DefineStruct(NULL, structtype); } - if ((add_to_browse = cparamblkptr->browseOptions.recordClasses && declinfo->file->recordbrowseinfo)) + if ((add_to_browse = cparamblkptr->browseoptions.recordClasses && declinfo->file->recordbrowseinfo)) CBrowse_BeginStruct(declinfo, TYPE_STRUCT(type), &gl); typecopy = *TYPE_STRUCT(type); @@ -3254,7 +3254,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d InlineFunctionObject(obj, NULL); } - if (cparamblkptr->browseOptions.recordClasses) + if (cparamblkptr->browseoptions.recordClasses) CBrowse_AddClassMemberFunction(obj, CPrep_BrowserTokenOffset(&member_fileoffset) + 1, CPrep_BrowserFileOffset()); } @@ -3516,7 +3516,7 @@ static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclas CScope_AddObject(tclass->nspace, name, OBJ_BASE(ivar)); if ((tclass->flags & CLASS_FLAGS_100) && CTemplTool_IsTemplateArgumentDependentType(type)) CTemplClass_RegisterObjectDef(TEMPL_CLASS(tclass), OBJ_BASE(ivar)); - if (cparamblkptr->browseOptions.recordClasses) + if (cparamblkptr->browseoptions.recordClasses) CBrowse_AddClassMemberVar(ivar, CPrep_BrowserTokenOffset(&member_fileoffset) + 1, CPrep_BrowserFileOffset()); } @@ -4082,7 +4082,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t tk = lex(); break; case TK_PROTECTED: - if (!copts.ARM_conform) { + if (!copts.ARMconform) { access = ACCESSPROTECTED; tk = lex(); } @@ -4809,16 +4809,16 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class TEMPL_CLASS_INST(tclass)->is_specialized = 1; } - CError_ASSERT(6853, copts.align_mode >= 0 && copts.align_mode <= 14); + CError_ASSERT(6853, copts.structalignment >= 0 && copts.structalignment <= 14); - tclass->eflags |= (UInt8) ((copts.align_mode + 1) << 4); + tclass->eflags |= (UInt8) ((copts.structalignment + 1) << 4); if (tk == ':') CDecl_ParseBaseClassList(tclass, mode, is_templ); CScope_SetClassDefScope(tclass, &scopesave); if (tk == '{') { tk = lex(); - if ((add_to_browse = cparamblkptr->browseOptions.recordClasses && declinfo->file->recordbrowseinfo)) { + if ((add_to_browse = cparamblkptr->browseoptions.recordClasses && declinfo->file->recordbrowseinfo)) { offsetsave = member_fileoffset; CBrowse_BeginClass(declinfo, &gl); } diff --git a/compiler_and_linker/unsorted/CExpr.c b/compiler_and_linker/unsorted/CExpr.c index 8deb0ed..64002a9 100644 --- a/compiler_and_linker/unsorted/CExpr.c +++ b/compiler_and_linker/unsorted/CExpr.c @@ -1241,7 +1241,7 @@ static ENode *CExpr_ParseNameResultExpr(CScopeParseResult *pr, ENode *expr, Bool return nullnode(); } - if (copts.require_prototypes) + if (copts.checkprotos) CError_Error(CErrorStr178); tfunc = galloc(sizeof(TypeFunc)); @@ -2645,7 +2645,7 @@ ENode *unary_expression(void) { return CExpr_ParseAlignof(); case TK_LOGICAL_AND: - if (copts.ANSI_strict) + if (copts.ANSIstrict) break; if ((tk = lex()) != TK_IDENTIFIER) { @@ -3027,7 +3027,7 @@ ENode *cast_expression(void) { return tmp; } - if (tk == '{' && (!copts.ANSI_strict || copts.c9x) && !IS_TYPE_VECTOR(di.thetype)) + if (tk == '{' && (!copts.ANSIstrict || copts.c9x) && !IS_TYPE_VECTOR(di.thetype)) return CInit_AutoObject(NULL, di.thetype, di.qual); expr = cast_expression(); @@ -4349,7 +4349,7 @@ static ENode *conditional_expression(void) { else tk = lex(); - expr2 = (copts.cplusplus && !copts.ARM_conform) ? assignment_expression() : conditional_expression(); + expr2 = (copts.cplusplus && !copts.ARMconform) ? assignment_expression() : conditional_expression(); if (is_templdep_cond || IS_TYPE_TEMPLDEPEXPR(expr1->rtype) || IS_TYPE_TEMPLDEPEXPR(expr2->rtype)) { result = CExpr_NewENode(ECOND); diff --git a/compiler_and_linker/unsorted/CExpr2.c b/compiler_and_linker/unsorted/CExpr2.c index 609cd43..c770edc 100644 --- a/compiler_and_linker/unsorted/CExpr2.c +++ b/compiler_and_linker/unsorted/CExpr2.c @@ -824,7 +824,7 @@ ENode *CExpr_LValue(ENode *expr, Boolean flag1, Boolean flag2) { loop: switch (expr->type) { case ETYPCON: - if (copts.pointercast_lvalue || !copts.ANSI_strict) { + if (copts.pointercast_lvalue || !copts.ANSIstrict) { if (expr->rtype->type == TYPEPOINTER && expr->data.monadic->rtype->type == TYPEPOINTER) { switch (expr->data.monadic->type) { case EINDIRECT: @@ -2583,7 +2583,7 @@ ENode *CExpr_GenericFuncCall(BClassList *path, ENode *funcexpr, Boolean flag1, O objexpr = CSOM_MethodAccess(pathcopy, obj, flag1); } else { if (obj->datatype == DVFUNC) { - if (flag1 || (!copts._59 && !had_alias && funcexpr && CExpr_IsStaticType(funcexpr))) + if (flag1 || (!copts.always_vdispatch && !had_alias && funcexpr && CExpr_IsStaticType(funcexpr))) objexpr->flags |= ENODE_FLAG_80; } funcexpr = CExpr_GetClassAccessNode(path, buildpath, funcexpr, obj, access, flag4); diff --git a/compiler_and_linker/unsorted/CFunc.c b/compiler_and_linker/unsorted/CFunc.c index 63a2493..647977a 100644 --- a/compiler_and_linker/unsorted/CFunc.c +++ b/compiler_and_linker/unsorted/CFunc.c @@ -165,7 +165,7 @@ void CFunc_SetupLocalVarInfo(Object *obj) { obj->u.var.info->func = cscope_currentfunc; if (obj->sclass == TK_REGISTER) { - if (!copts.optimize_for_size) + if (!copts.optimizesize) obj->u.var.info->usage = 100; else obj->u.var.info->usage = 5; @@ -318,7 +318,7 @@ static FuncArg *parameter_list(DeclInfo *declinfo) { while (1) { if (tk == TK_ELLIPSIS) { if (flag26) { - if (!copts.cplusplus && copts.ANSI_strict) + if (!copts.cplusplus && copts.ANSIstrict) CError_Warning(CErrorStr127); args = &elipsis; } else { @@ -907,7 +907,7 @@ static void scancase(DeclThing *thing) { tk = lex(); min = CExpr_IntConstConvert(thing->switchinfo->x8, thing->switchinfo->x8, CExpr_IntegralConstExpr()); - if (!copts.ANSI_strict && tk == TK_ELLIPSIS) { + if (!copts.ANSIstrict && tk == TK_ELLIPSIS) { tk = lex(); max = CExpr_IntConstConvert(thing->switchinfo->x8, thing->switchinfo->x8, CExpr_IntegralConstExpr()); if (CInt64_Greater(min, max)) @@ -1676,7 +1676,7 @@ static void statement(DeclThing *thing) { else tk = lex(); - if (copts.cplusplus && !copts.ARM_scoping && isdeclaration(1, 0, 0, '=')) { + if (copts.cplusplus && !copts.ARMscoping && isdeclaration(1, 0, 0, '=')) { block = CFunc_NewDeclBlock(); expr = CFunc_ParseLocalDeclarationList(0, 1, 0, 0); if (CScope_IsEmptyNameSpace(cscope_current)) { @@ -1730,7 +1730,7 @@ static void statement(DeclThing *thing) { case TK_GOTO: if ((tk = lex()) != TK_IDENTIFIER) { - if (tk == '*' && !copts.ANSI_strict) { + if (tk == '*' && !copts.ANSIstrict) { tk = lex(); stmt = CFunc_AppendStatement(ST_GOTOEXPR); stmt->expr = expression(); @@ -1793,7 +1793,7 @@ static void statement(DeclThing *thing) { expr = expression(); CExpr_CheckUnusedExpression(expr); } else { - if (!copts.ARM_scoping) + if (!copts.ARMscoping) block = CFunc_NewDeclBlock(); expr = CFunc_ParseLocalDeclarationList(0, 1, 1, 0); if (block && CScope_IsEmptyNameSpace(cscope_current)) { @@ -1816,7 +1816,7 @@ static void statement(DeclThing *thing) { } if ((tk = lex()) != ';') { - if (copts.cplusplus && !copts.ARM_scoping && isdeclaration(1, 0, 0, '=')) { + if (copts.cplusplus && !copts.ARMscoping && isdeclaration(1, 0, 0, '=')) { if (!block) block = CFunc_NewDeclBlock(); expr = CFunc_ParseLocalDeclarationList(0, 1, 0, 0); @@ -1975,7 +1975,7 @@ static void statement(DeclThing *thing) { else tk = lex(); - if (copts.cplusplus && !copts.ARM_scoping && isdeclaration(1, 0, 0, '=')) { + if (copts.cplusplus && !copts.ARMscoping && isdeclaration(1, 0, 0, '=')) { block = CFunc_NewDeclBlock(); expr = CFunc_ParseLocalDeclarationList(0, 1, 0, 0); if (CScope_IsEmptyNameSpace(cscope_current)) { @@ -2043,7 +2043,7 @@ static void statement(DeclThing *thing) { else tk = lex(); - if (copts.cplusplus && !copts.ARM_scoping && isdeclaration(1, 0, 0, '=')) { + if (copts.cplusplus && !copts.ARMscoping && isdeclaration(1, 0, 0, '=')) { block = CFunc_NewDeclBlock(); expr = CFunc_ParseLocalDeclarationList(0, 1, 0, 0); if (CScope_IsEmptyNameSpace(cscope_current)) { @@ -2111,7 +2111,7 @@ static void statement(DeclThing *thing) { return; case TK_ASM: - if (copts.cplusplus || !copts.ANSI_strict) { + if (copts.cplusplus || !copts.ANSIstrict) { tk = lex(); volatileasm = 0; @@ -2319,7 +2319,7 @@ void CFunc_SetupNewFuncArgs(Object *func, FuncArg *args) { TPTR_QUAL(obj->type) = Q_REFERENCE | Q_RESTRICT; } - if (obj->name == no_name_node && copts.ANSI_strict && !copts.cplusplus && !(func->qual & Q_80000)) + if (obj->name == no_name_node && copts.ANSIstrict && !copts.cplusplus && !(func->qual & Q_80000)) CError_Error(CErrorStr127); if (newlist) { @@ -2933,7 +2933,7 @@ void CFunc_ParseFuncDef(Object *func, DeclInfo *di, TypeClass *tclass, Boolean i if (di->x45 && (func->qual & Q_ASM)) CError_Error(CErrorStr176); - if (cparamblkptr->isPrecompiling == 1 && !(func->qual & Q_INLINE)) + if (cparamblkptr->precompile == 1 && !(func->qual & Q_INLINE)) CError_ErrorTerm(CErrorStr180); if (di->x49) @@ -3077,7 +3077,7 @@ void InitExpr_Register(ENode *expr, Object *object) { InitExpr *scan; if ( - cparamblkptr->isPrecompiling == 1 && + cparamblkptr->precompile == 1 && object->sclass != TK_STATIC && !(object->qual & (Q_20000 | Q_OVERLOAD)) ) @@ -3112,14 +3112,14 @@ void CFunc_GenerateDummyFunction(Object *func) { if (!anyerrors) { nspace = CFunc_FuncGenSetup(&firstStmt, NULL); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_CodeCleanup(&firstStmt); CFunc_Gen(&firstStmt, func, 0); cscope_current = nspace->parent; - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } } @@ -3129,7 +3129,7 @@ void CFunc_GenerateSingleExprFunc(Object *func, ENode *expr) { Statement firstStmt; Statement *stmt; - if (cparamblkptr->isPrecompiling == 1) { + if (cparamblkptr->precompile == 1) { CError_Error(CErrorStr180); return; } @@ -3137,8 +3137,8 @@ void CFunc_GenerateSingleExprFunc(Object *func, ENode *expr) { if (!anyerrors) { nspace = CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; stmt = CFunc_AppendStatement(ST_EXPRESSION); stmt->expr = expr; @@ -3147,7 +3147,7 @@ void CFunc_GenerateSingleExprFunc(Object *func, ENode *expr) { CInline_GenFunc(&firstStmt, func, 0); cscope_current = nspace->parent; - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } } @@ -3161,7 +3161,7 @@ void CFunc_GenerateDummyCtorFunc(Object *func, Object *real_ctor) { Statement firstStmt; Statement *stmt; - if (cparamblkptr->isPrecompiling == 1) { + if (cparamblkptr->precompile == 1) { CError_Error(CErrorStr180); return; } @@ -3171,8 +3171,8 @@ void CFunc_GenerateDummyCtorFunc(Object *func, Object *real_ctor) { nspace = CFunc_FuncGenSetup(&firstStmt, func); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; CFunc_SetupNewFuncArgs(func, TYPE_FUNC(func->type)->args); @@ -3219,6 +3219,6 @@ void CFunc_GenerateDummyCtorFunc(Object *func, Object *real_ctor) { cscope_current = nspace->parent; cscope_currentfunc = NULL; - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } } diff --git a/compiler_and_linker/unsorted/CInit.c b/compiler_and_linker/unsorted/CInit.c index 180f098..76b96c2 100644 --- a/compiler_and_linker/unsorted/CInit.c +++ b/compiler_and_linker/unsorted/CInit.c @@ -586,7 +586,7 @@ static void CInit_InitTypeInt(CInit_Stuff *s, ENode *expr, TypeIntegral *tint, U if (IS_TYPE_INT(expr->rtype)) { if (ENODE_IS(expr, EINTCONST)) { CMach_InitIntMem(TYPE(tint), expr->data.intval, s->buffer + s->size); - } else if (ENODE_IS(expr, ETYPCON) && IS_TYPE_POINTER_ONLY(expr->data.monadic->rtype) && expr->rtype->size == 4 && (copts.cplusplus || !copts.ANSI_strict)) { + } else if (ENODE_IS(expr, ETYPCON) && IS_TYPE_POINTER_ONLY(expr->data.monadic->rtype) && expr->rtype->size == 4 && (copts.cplusplus || !copts.ANSIstrict)) { CInit_InitTypePointer(s, expr->data.monadic, TYPE_POINTER(expr->data.monadic->rtype), qual); } else { CInit_InitNonConst(s, TYPE(tint), expr); @@ -636,7 +636,7 @@ static void CInit_SetBitfield(TypeBitfield *tbitfield, UInt8 *buffer, CInt64 val int pos; int step; - if (copts.little_endian) { + if (copts.littleendian) { pos = tbitfield->unkA; step = 1; } else { @@ -645,7 +645,7 @@ static void CInit_SetBitfield(TypeBitfield *tbitfield, UInt8 *buffer, CInt64 val } for (i = 0; i < tbitfield->unkB; i++) { if (CInt64_GetULong(&val) & 1) { - if (copts.little_endian) { + if (copts.littleendian) { buffer[pos >> 3] |= 1 << (pos & 7); } else { buffer[pos >> 3] |= 0x80 >> (pos & 7); @@ -1430,7 +1430,7 @@ static void CInit_ExprPointer(TypePointer *tptr, ENode *expr) { static void CInit_ExprInt(TypeIntegral *tint, ENode *expr) { if (ENODE_IS(expr, EINTCONST)) { CMach_InitIntMem(TYPE(tint), expr->data.intval, cinit_initinfo->buffer + cinit_initinfo->expr_offset); - } else if (ENODE_IS(expr, ETYPCON) && IS_TYPE_POINTER_ONLY(expr->data.monadic->rtype) && expr->rtype->size == 4 && (copts.cplusplus || !copts.ANSI_strict)) { + } else if (ENODE_IS(expr, ETYPCON) && IS_TYPE_POINTER_ONLY(expr->data.monadic->rtype) && expr->rtype->size == 4 && (copts.cplusplus || !copts.ANSIstrict)) { CInit_ExprPointer(TYPE_POINTER(expr->data.monadic->rtype), expr->data.monadic); } else if (cinit_initinfo->expr_cb) { cinit_initinfo->expr_cb(TYPE(tint), expr, 0); @@ -2976,13 +2976,13 @@ void CInit_RewriteString(ENode *expr, Boolean flag) { PooledString *str; Boolean is_wide; - if (cparamblkptr->isPrecompiling == 1) + if (cparamblkptr->precompile == 1) CError_Error(CErrorStr180); CError_ASSERT(4220, expr->rtype->type == TYPEPOINTER); is_wide = TYPE_POINTER(expr->rtype)->target->size != 1; - if (copts.pool_strings) { + if (copts.poolstrings) { if (is_wide) str = CInit_DeclarePooledWString(expr->data.string.data, expr->data.string.size); else @@ -3047,14 +3047,14 @@ static void declaredata(Object *obj, void *data, OLinkList *list, SInt32 size, B qual = obj->qual; - if (cparamblkptr->isPrecompiling == 1) { + if (cparamblkptr->precompile == 1) { PreComp_StaticData(obj, data, list, size); } else { obj->flags |= OBJECT_FLAGS_4; if (!fatalerrors) { for (scan = list; scan; scan = scan->next) CInline_ObjectAddrRef(scan->obj); - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) CPrep_SetSourceFile(&cparser_fileoffset); if (is_readonly) ObjGen_DeclareReadOnlyData(obj, data, list, size); diff --git a/compiler_and_linker/unsorted/CInline.c b/compiler_and_linker/unsorted/CInline.c index 4cd3c4b..1afbde8 100644 --- a/compiler_and_linker/unsorted/CInline.c +++ b/compiler_and_linker/unsorted/CInline.c @@ -1709,7 +1709,7 @@ static Boolean CInline_InlineFunctionCheck(ENode *expr) { (object->datatype == DFUNC || (object->datatype == DVFUNC && (expr->flags & ENODE_FLAG_80))) ) { - if (copts.always_inline) + if (copts.alwaysinline) return 1; if (copts.inline_bottom_up) { @@ -2809,7 +2809,7 @@ static void CInline_ExportCheck(ENode *expr) { expr = expr->data.funccall.funcref; if ( copts.warn_notinlined && - !copts.dont_inline && + !copts.dontinline && ENODE_IS(expr, EOBJREF) && (expr->data.objref->qual & Q_INLINE) && expr->data.objref->datatype != DINLINEFUNC && @@ -2853,10 +2853,10 @@ static void CInline_ExportCheck(ENode *expr) { static void CInline_Expand(Statement *stmt) { Statement *scan; - if (!copts.dont_inline && copts.inlinelevel >= 0) { + if (!copts.dontinline && copts.inlinelevel >= 0) { if (copts.inline_bottom_up) { - inline_max_size = copts.inline_max_size; - while (inline_max_size > 1 && EstimateExpandedSizeOfFunction(stmt) > copts.inline_max_total_size) + inline_max_size = copts.inlinemaxsize; + while (inline_max_size > 1 && EstimateExpandedSizeOfFunction(stmt) > copts.inlinemaxtotalsize) inline_max_size >>= 1; } @@ -2891,7 +2891,7 @@ static void CInline_Expand(Statement *stmt) { if (!copts.inline_bottom_up && !any_inline_expanded) break; - if (!copts.always_inline || copts.inline_bottom_up) { + if (!copts.alwaysinline || copts.inline_bottom_up) { if (copts.inlinelevel == 0) { if (copts.inline_bottom_up) { if ((cinline_level + 1) >= 8) @@ -3150,7 +3150,7 @@ void CInline_PackIFunctionData(CI_FuncData *funcdata, Statement *stmt, Object *o funcdata->can_inline = CInline_CanInline(object, stmt->next); - if (copts.isGeneratingDebugInfo) { + if (copts.filesyminfo) { funcdata->fileoffset = cparser_fileoffset; funcdata->fileoffset.is_inline = 1; funcdata->symdecloffset = symdecloffset; @@ -3415,28 +3415,28 @@ static void CInline_GenIFunctionCode(Object *object, CI_FuncData *func, UInt8 un CScopeSave saveScope; Statement firstStmt; - if (cparamblkptr->isPrecompiling != 1 && func) { + if (cparamblkptr->precompile != 1 && func) { ObjGen_SetupSym(); CScope_SetFunctionScope(object, &saveScope); CFunc_FuncGenSetup(&firstStmt, object); CInline_UnpackIFunctionData(object, func, &firstStmt); - saveDebugInfo = copts.isGeneratingDebugInfo; + saveDebugInfo = copts.filesyminfo; if (copts.nosyminline || (!symdecloffset && !symdeclend)) - copts.isGeneratingDebugInfo = 0; + copts.filesyminfo = 0; expanding_function = object; recursive_inline = 0; CInline_Expand(&firstStmt); if (!anyerrors) { - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) CPrep_SetSourceFile(&cparser_fileoffset); CodeGen_Generator(&firstStmt, object, unk, 0); } CScope_RestoreScope(&saveScope); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } } @@ -3902,8 +3902,8 @@ void CInline_GenFunc(Statement *stmt, Object *object, UInt8 unk) { flag30 = 0; if (!(object->qual & Q_INLINE)) { if ( - copts.autoinline && - !copts.dont_inline && + copts.auto_inline && + !copts.dontinline && CInline_CanInline(object, stmt->next) && CInline_IsSmallFunction(object, stmt->next) ) @@ -3962,7 +3962,7 @@ void CInline_GenFunc(Statement *stmt, Object *object, UInt8 unk) { recursive_inline = 0; CInline_Expand(stmt); - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) CPrep_SetSourceFile(&cparser_fileoffset); if (!anyerrors) @@ -4175,8 +4175,8 @@ void CInline_Finish(void) { } while (doMore); nspace = CFunc_FuncGenSetup(&firstStmt, NULL); - saveDebugInfo = copts.isGeneratingDebugInfo; - copts.isGeneratingDebugInfo = 0; + saveDebugInfo = copts.filesyminfo; + copts.filesyminfo = 0; init = init_expressions; while (init) { @@ -4196,11 +4196,11 @@ void CInline_Finish(void) { CInline_Expand(&firstStmt); if (!anyerrors) { - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) CPrep_SetSourceFile(&cparser_fileoffset); CodeGen_Generator(&firstStmt, NULL, 0, 1); } cscope_current = nspace->parent; - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; } diff --git a/compiler_and_linker/unsorted/CMachine.c b/compiler_and_linker/unsorted/CMachine.c index 59344d7..9eebdfe 100644 --- a/compiler_and_linker/unsorted/CMachine.c +++ b/compiler_and_linker/unsorted/CMachine.c @@ -175,12 +175,12 @@ SInt32 CMach_ArgumentAlignment(Type *type) { UInt8 save_oldalignment; SInt32 align; - save_align_mode = copts.align_mode; + save_align_mode = copts.structalignment; save_oldalignment = copts.oldalignment; - copts.align_mode = AlignMode2_PPC; + copts.structalignment = AlignMode2_PPC; copts.oldalignment = 0; align = CMach_GetQualifiedTypeAlign(type, 0); - copts.align_mode = save_align_mode; + copts.structalignment = save_align_mode; copts.oldalignment = save_oldalignment; if (type->type == TYPESTRUCT && !TYPE_STRUCT(type)->members && TYPE_STRUCT(type)->align > align) @@ -218,7 +218,7 @@ SInt32 CMach_AllocationAlignment(Type *type, UInt32 qual) { if (copts.optimizationlevel > 0) { if (type->type == TYPEARRAY || (type->type == TYPESTRUCT && (TYPE_STRUCT(type)->stype < STRUCT_TYPE_4 || TYPE_STRUCT(type)->stype > STRUCT_TYPE_E)) || type->type == TYPECLASS || (type->type == TYPEMEMBERPOINTER && (UInt32) type->size == 12)) { - return (copts.some_alignment > align) ? copts.some_alignment : align; + return (copts.min_struct_alignment > align) ? copts.min_struct_alignment : align; } } @@ -844,7 +844,7 @@ static SInt16 CMach_GetQualifiedStructAlign(const TypeStruct *tstruct, Boolean f if (tstruct->stype >= STRUCT_TYPE_4 && tstruct->stype <= STRUCT_TYPE_E) return 16; - switch (copts.align_mode) { + switch (copts.structalignment) { case AlignMode3_1Byte: case AlignMode8_Packed: return 1; @@ -858,7 +858,7 @@ static SInt16 CMach_GetQualifiedStructAlign(const TypeStruct *tstruct, Boolean f return 1; best = 1; - switch (copts.align_mode) { + switch (copts.structalignment) { default: CError_FATAL(1026); case AlignMode4_2Byte: @@ -928,7 +928,7 @@ static SInt16 CMach_GetQualifiedClassAlign(TypeClass *tclass, Boolean flag) { SInt32 align; Boolean isFirst; - switch (copts.align_mode) { + switch (copts.structalignment) { case AlignMode3_1Byte: case AlignMode8_Packed: return 1; @@ -940,7 +940,7 @@ static SInt16 CMach_GetQualifiedClassAlign(TypeClass *tclass, Boolean flag) { if (tclass->size <= 1) return 1; best = 1; - switch (copts.align_mode) { + switch (copts.structalignment) { default: CError_FATAL(1149); case AlignMode4_2Byte: @@ -1011,7 +1011,7 @@ SInt16 CMach_GetClassAlign(TypeClass *tclass) { } static SInt16 CMach_GetWinTypeAlign(Type *type) { - int packoffs = copts.align_mode - 3; + int packoffs = copts.structalignment - 3; SInt32 align = cmach_packsize[packoffs]; if (type->size < align) align = type->size; @@ -1019,7 +1019,7 @@ static SInt16 CMach_GetWinTypeAlign(Type *type) { } static SInt16 CMach_GetWinMinimizeAlign(SInt16 align) { - int packoffs = copts.align_mode - 3; + int packoffs = copts.structalignment - 3; SInt16 minimum = cmach_packsize[packoffs]; if (minimum < align) align = minimum; @@ -1033,7 +1033,7 @@ static SInt16 CMach_GetQualifiedTypeAlign(Type *type, Boolean flag) { if (type->type == TYPESTRUCT && TYPE_STRUCT(type)->stype >= STRUCT_TYPE_4 && TYPE_STRUCT(type)->stype <= STRUCT_TYPE_E) return 16; - switch (copts.align_mode) { + switch (copts.structalignment) { case AlignMode3_1Byte: case AlignMode8_Packed: return 1; @@ -1063,13 +1063,13 @@ restart: return 1; if (copts.oldalignment && type->size == 8) return 8; - if (copts.align_mode != AlignMode0_Mac68k && type->size >= 4) + if (copts.structalignment != AlignMode0_Mac68k && type->size >= 4) return 4; return 2; case TYPEFLOAT: if (isWin) return CMach_GetWinTypeAlign(type); - switch (copts.align_mode) { + switch (copts.structalignment) { case AlignMode0_Mac68k: return 2; case AlignMode1_Mac68k4byte: @@ -1085,19 +1085,19 @@ restart: case TYPEPOINTER: if (isWin) return CMach_GetWinTypeAlign(type); - if (copts.align_mode == AlignMode0_Mac68k) + if (copts.structalignment == AlignMode0_Mac68k) return 2; else return 4; case TYPEARRAY: - if (copts.align_array_members) { + if (copts.alignarraymembers) { if (isWin) return CMach_GetWinTypeAlign(type); if (type->size == 1) return 1; - if (copts.align_mode == AlignMode0_Mac68k || type->size <= 2) + if (copts.structalignment == AlignMode0_Mac68k || type->size <= 2) return 2; - if (copts.align_mode == AlignMode1_Mac68k4byte || type->size < 8) + if (copts.structalignment == AlignMode1_Mac68k4byte || type->size < 8) return 4; align = CMach_GetQualifiedTypeAlign(TYPE_POINTER(type)->target, flag); if (align > 4) @@ -1151,7 +1151,7 @@ static SInt16 CMach_GetMemberAlignment(Type *type, SInt32 var, Boolean flag) { if (IS_TYPE_VECTOR(type) && align < 16) align = 16; - switch (copts.align_mode) { + switch (copts.structalignment) { case AlignMode8_Packed: align = 1; break; @@ -1238,7 +1238,7 @@ SInt32 CMach_StructLayoutBitfield(TypeBitfield *tbitfield, UInt32 qual) { required_alignment = 2; break; case 4: - if (copts.align_mode != AlignMode0_Mac68k && copts.align_mode != AlignMode4_2Byte) + if (copts.structalignment != AlignMode0_Mac68k && copts.structalignment != AlignMode4_2Byte) required_alignment = 4; else required_alignment = 2; @@ -1249,7 +1249,7 @@ SInt32 CMach_StructLayoutBitfield(TypeBitfield *tbitfield, UInt32 qual) { CError_FATAL(1620); } - switch (copts.align_mode) { + switch (copts.structalignment) { case AlignMode3_1Byte: case AlignMode8_Packed: required_alignment = 0; @@ -1322,7 +1322,7 @@ Boolean CMach_PassResultInHiddenArg(Type *type) { } char *CMach_GetCPU(void) { - switch (copts.cpu) { + switch (copts.processor) { case CPU_PPC401: return "__PPC401__"; case CPU_PPC403: return "__PPC403__"; case CPU_PPC505: return "__PPC505__"; diff --git a/compiler_and_linker/unsorted/CObjC.c b/compiler_and_linker/unsorted/CObjC.c index 7d761c5..4af8b09 100644 --- a/compiler_and_linker/unsorted/CObjC.c +++ b/compiler_and_linker/unsorted/CObjC.c @@ -1449,7 +1449,7 @@ static void CObjC_EncodeType(Type *type, UInt32 qual, Boolean flag) { AppendGListByte(&name_mangle_list, 'C'); return; case IT_CHAR: - AppendGListByte(&name_mangle_list, copts.unsignedchars ? 'C' : 'c'); + AppendGListByte(&name_mangle_list, copts.unsigned_char ? 'C' : 'c'); return; case IT_UCHAR: AppendGListByte(&name_mangle_list, 'C'); diff --git a/compiler_and_linker/unsorted/COptimizer.c b/compiler_and_linker/unsorted/COptimizer.c index a8fb93b..f7614ed 100644 --- a/compiler_and_linker/unsorted/COptimizer.c +++ b/compiler_and_linker/unsorted/COptimizer.c @@ -186,7 +186,7 @@ static short cse_cost(COptCSE *cse) { return cse_objectcost(cse->expr->data.monadic->data.objref); cost = 1; - if (!copts.optimize_for_size) { + if (!copts.optimizesize) { if (ENODE_IS3(cse->expr, EMUL, EDIV, EMODULO)) cost = 2; } @@ -1195,7 +1195,7 @@ static void BasicBlockAnalyze(Statement *stmt) { SwitchCase *swcase; setbytes = 2 * ((localcount - 1) / 16) + 2; - if (copts.global_optimizer) { + if (copts.globaloptimizer) { setbytes += 32; extravars = 0; } @@ -1561,8 +1561,8 @@ void SetVarUsage(Object *obj, Boolean noregister) { if (obj->datatype == DLOCAL || obj->datatype == DNONLAZYPTR) { vi = obj->u.var.info; vi->used = 1; - if (!copts.global_optimizer) { - if (copts.optimize_for_size) + if (!copts.globaloptimizer) { + if (copts.optimizesize) vi->usage++; else vi->usage += curstmtvalue; @@ -1817,7 +1817,7 @@ void COpt_SimpleOptimizer(Object *obj, Statement *stmt) { Statement *COpt_Optimizer(Object *obj, Statement *stmt) { copt_isleaffunction = 1; - if (copts.global_optimizer) + if (copts.globaloptimizer) stmt = IRO_Optimizer(obj, stmt); static_for_inlines = 0; diff --git a/compiler_and_linker/unsorted/CParser.c b/compiler_and_linker/unsorted/CParser.c index 214061d..075932e 100644 --- a/compiler_and_linker/unsorted/CParser.c +++ b/compiler_and_linker/unsorted/CParser.c @@ -72,7 +72,7 @@ Object *Xthrw_func; Object *Xicth_func; Object *Xecth_func; Object *Xunex_func; -COpts copts; +CompilerLinkerOptions copts; GList name_mangle_list; HashNameNode *no_name_node; HashNameNode *temp_argument_name; @@ -375,7 +375,7 @@ void CParser_Setup(void) { CParser_SetUniqueID(1); dont_set_references = 0; - copts.side_effects = 1; + copts.sideeffects = 1; cparser_classactions = NULL; name_obj_check = NULL; callbackactions = NULL; @@ -603,7 +603,7 @@ HashNameNode *CParser_AppendUniqueNameFile(char *prefix) { i++; } - COS_FileGetFSSpecInfo(&cparamblkptr->mainFileSpec, NULL, NULL, filename); + COS_FileGetFSSpecInfo(&cparamblkptr->sourcefile, NULL, NULL, filename); src = (char *) &filename[1]; len = filename[0]; for (j = 0; j < len && i < 255; j++, i++) { @@ -630,7 +630,7 @@ static HashNameNode *CParser_GetUnnamedNameSpaceName(void) { strcpy(buf, "@unnamed@"); dst = buf + strlen(buf); - COS_FileGetFSSpecInfo(&cparamblkptr->mainFileSpec, NULL, NULL, filename); + COS_FileGetFSSpecInfo(&cparamblkptr->sourcefile, NULL, NULL, filename); src = (char *) &filename[1]; len = filename[0]; for (i = 0; i < len && dst < &buf[254]; i++) { @@ -657,18 +657,18 @@ static void CParser_SetCFMFlags(Object *object, DeclInfo *declinfo) { object->flags |= declinfo->exportflags; if (object->datatype == DDATA) { - if (copts.export) + if (copts.cfm_export) object->flags |= OBJECT_FLAGS_40; - if (copts.internal) + if (copts.cfm_internal) object->flags |= OBJECT_FLAGS_10; - } else if (copts.internal) { + } else if (copts.cfm_internal) { object->flags |= OBJECT_FLAGS_10; } else { - if (copts.import) + if (copts.cfm_import) object->flags |= OBJECT_FLAGS_20; - if (copts.export) + if (copts.cfm_export) object->flags |= OBJECT_FLAGS_40; - if (copts.lib_export) + if (copts.cfm_lib_export) object->flags |= OBJECT_FLAGS_20 | OBJECT_FLAGS_40; } } @@ -1350,14 +1350,14 @@ Boolean is_unsigned(Type *type) { type = TYPE_ENUM(type)->enumtype; if ( - (type == TYPE(&stunsignedchar)) || - (type == TYPE(&stunsignedshort)) || - (type == TYPE(&stunsignedint)) || - (type == TYPE(&stunsignedlong)) || - (type == TYPE(&stunsignedlonglong)) || - (type == TYPE(&stbool)) || - (copts.unsignedchars && (type == TYPE(&stchar))) || - (type->type == TYPEPOINTER)) + (type == TYPE(&stunsignedchar)) || + (type == TYPE(&stunsignedshort)) || + (type == TYPE(&stunsignedint)) || + (type == TYPE(&stunsignedlong)) || + (type == TYPE(&stunsignedlonglong)) || + (type == TYPE(&stbool)) || + (copts.unsigned_char && (type == TYPE(&stchar))) || + (type->type == TYPEPOINTER)) return 1; return 0; @@ -3458,7 +3458,7 @@ void cparser(void) { CParser_ParseDeclaration(&di); } while (tk && (tk = lex())); } else { - if (!copts.cplusplus && copts.ANSI_strict) + if (!copts.cplusplus && copts.ANSIstrict) CError_Error(CErrorStr102); } @@ -3466,13 +3466,13 @@ void cparser(void) { copts.defer_codegen = 0; CParser_GlobalCleanup(1); - if (cparamblkptr->isPrecompiling != 1) { + if (cparamblkptr->precompile != 1) { CInline_Finish(); CParser_GlobalCleanup(1); } CClass_GenThunks(); - if (cparamblkptr->isPrecompiling != 1) + if (cparamblkptr->precompile != 1) CObjC_GenerateModule(); CSOM_Cleanup(); diff --git a/compiler_and_linker/unsorted/CPrec.c b/compiler_and_linker/unsorted/CPrec.c index 75608bf..78a36b6 100644 --- a/compiler_and_linker/unsorted/CPrec.c +++ b/compiler_and_linker/unsorted/CPrec.c @@ -3087,7 +3087,7 @@ static OSErr CPrec_WriteFile(void) { cprec_header->magic = 0xBEEFFACE; cprec_header->version = 1047; cprec_header->target = 2; - cprec_header->check_header_flags = copts.check_header_flags; + cprec_header->check_header_flags = copts.checkprecompflags; cprec_header->cplusplus = copts.cplusplus; cprec_header->uniqueID = CParser_GetUniqueID(); cprec_header->cobjc_selrefcount = cobjc_selrefcount; @@ -3158,10 +3158,10 @@ void PrecompilerWrite(void) { char str[128]; FSSpec spec; - spec = cparamblkptr->mainFileSpec; + spec = cparamblkptr->sourcefile; if (CWGetPrecompiledHeaderSpec(cparamblkptr->context, &spec, precomp_target_str) == cwNoErr) { strindex = 3; - err = COS_FileNew(&spec, &cprec_refnum, copts.pchCreator, copts.pchType); + err = COS_FileNew(&spec, &cprec_refnum, copts.appltype, copts.headtype); if (err == noErr) { strindex = 4; err = CPrec_WriteFile(); @@ -3433,7 +3433,7 @@ void PrecompilerRead(short refnum, void *buffer) { if (cprec_header->target != 2) CError_ErrorTerm(CErrorStr223); - copts.check_header_flags = cprec_header->check_header_flags; + copts.checkprecompflags = cprec_header->check_header_flags; CPrec_ReadRawBuffer(); CPrec_RelocateRawBuffer(); @@ -3477,6 +3477,6 @@ void PrecompilerRead(short refnum, void *buffer) { CPrep_InsertSpecialMacros(); - if (cparamblkptr->isPrecompiling != 1) + if (cparamblkptr->precompile != 1) CPrec_DefineStaticData(); } diff --git a/compiler_and_linker/unsorted/CRTTI.c b/compiler_and_linker/unsorted/CRTTI.c index cc036fb..7b4ef5d 100644 --- a/compiler_and_linker/unsorted/CRTTI.c +++ b/compiler_and_linker/unsorted/CRTTI.c @@ -397,7 +397,7 @@ ENode *CRTTI_ParseTypeID(void) { Type *typeinfoType; UInt32 qual; - if (!copts.useRTTI) + if (!copts.RTTI) CError_Warning(CErrorStr257); typeinfoType = CRTTI_FindTypeInfoType(); @@ -661,7 +661,7 @@ static ENode *CRTTI_UniversalCast(ENode *expr, Type *type, UInt32 qual, UInt8 mo } if (isSimpleCast) { - if (needsTypcon && ENODE_IS(expr, EINDIRECT) && (copts.pointercast_lvalue || !copts.ANSI_strict)) + if (needsTypcon && ENODE_IS(expr, EINDIRECT) && (copts.pointercast_lvalue || !copts.ANSIstrict)) expr = makemonadicnode(expr, ETYPCON); expr->rtype = type; @@ -687,7 +687,7 @@ ENode *CRTTI_Parse_dynamic_cast(void) { if (!expr) return nullnode(); - if (!copts.useRTTI) + if (!copts.RTTI) CError_Warning(CErrorStr257); CRTTI_ConstCastCheck(expr->rtype, expr->flags, di.thetype, di.qual); diff --git a/compiler_and_linker/unsorted/CSOM.c b/compiler_and_linker/unsorted/CSOM.c index f0b1537..bd1a75e 100644 --- a/compiler_and_linker/unsorted/CSOM.c +++ b/compiler_and_linker/unsorted/CSOM.c @@ -165,7 +165,7 @@ void CSOM_Setup(Boolean flag) { void CSOM_Cleanup(void) { CSOMStub *stub; - if (cparamblkptr->isPrecompiling != 1) { + if (cparamblkptr->precompile != 1) { for (stub = csom_stubs; stub; stub = stub->next) { switch (stub->x10) { case 0: @@ -1604,7 +1604,7 @@ ENode *CSOM_New(TypeClass *tclass) { } } - if (!copts.som_env_check || !copts.som_call_opt) { + if (!copts.som_env_check || !copts.som_call_optimize) { newFunc = CSOM_FindRTFunc("somNewObjectInstance", "ppll"); if (!newFunc) return nullnode(); @@ -1621,7 +1621,7 @@ ENode *CSOM_New(TypeClass *tclass) { ); expr->rtype = CDecl_NewPointerType(TYPE(tclass)); - if (copts.som_env_check && !copts.som_call_opt) { + if (copts.som_env_check && !copts.som_call_optimize) { ENode *tempExpr; ENode *checkExpr; ENode *notExpr; @@ -1830,7 +1830,7 @@ ENode *CSOM_EnvCheck(ENode *funccall, ENodeList *checkArg) { *expr27 = *arg2->node; } - if (copts.som_call_opt) { + if (copts.som_call_optimize) { funccall = makediadicnode(funccall, funccallexpr(rt_som_check, expr27, NULL, NULL, NULL), ECOMMA); if (expr26) funccall = makediadicnode(funccall, expr26, ECOMMA); @@ -2059,7 +2059,7 @@ ENode *CSOM_MethodAccess(BClassList *path, Object *func, Boolean flag) { expr->flags |= ENODE_FLAG_10; } else { CSOM_FindIntroClassOffset(tclass2, func, &tclass3, &offset); - if (copts.som_call_opt && CSOM_CanUseGlueCall(TYPE_FUNC(func->type))) + if (copts.som_call_optimize && CSOM_CanUseGlueCall(TYPE_FUNC(func->type))) return CSOM_SOMGlueCall(tclass3, offset, func); expr = create_objectrefnode(tclass3->sominfo->classdataobject); diff --git a/compiler_and_linker/unsorted/CTemplateClass.c b/compiler_and_linker/unsorted/CTemplateClass.c index e180159..45d07b8 100644 --- a/compiler_and_linker/unsorted/CTemplateClass.c +++ b/compiler_and_linker/unsorted/CTemplateClass.c @@ -281,7 +281,7 @@ TemplateMember *CTemplClass_DefineMember(TemplClass *tmclass, Object *object, Fi static void CTemplClass_ParseBody(TemplClass *templ, short mode, SInt32 *offset) { DeclInfo di; - templ->align = copts.align_mode; + templ->align = copts.structalignment; memclrw(&di, sizeof(di)); di.file = CPrep_BrowserCurrentFile(); @@ -794,7 +794,7 @@ TemplClass *CTemplClass_DefineNestedClass(TemplClass *parent, HashNameNode *name CDecl_DefineClass(parent->theclass.nspace, name, TYPE_CLASS(templ), mode, 0, 1); templ->theclass.flags = CLASS_FLAGS_100; - templ->align = copts.align_mode; + templ->align = copts.structalignment; action = galloc(sizeof(TemplateAction)); memclrw(action, sizeof(TemplateAction)); @@ -1614,10 +1614,10 @@ Boolean CTempl_InstantiateTemplateClass(TypeClass *tclass) { declE.x8 = templ->lex_order_count; declE.xC = templ->flags & TEMPLCLASS_FLAGS_1; - saveAlignMode = copts.align_mode; - copts.align_mode = templ->align; + saveAlignMode = copts.structalignment; + copts.structalignment = templ->align; CDecl_CompleteClass(&declE, TYPE_CLASS(inst)); - copts.align_mode = saveAlignMode; + copts.structalignment = saveAlignMode; if (templ->theclass.align > inst->theclass.align) { inst->theclass.align = templ->theclass.align; diff --git a/compiler_and_linker/unsorted/CTemplateNew.c b/compiler_and_linker/unsorted/CTemplateNew.c index ddda594..fdbf194 100644 --- a/compiler_and_linker/unsorted/CTemplateNew.c +++ b/compiler_and_linker/unsorted/CTemplateNew.c @@ -953,7 +953,7 @@ static void CTempl_ParseTemplateFunction(TemplateFunction *templ, TypeClass *tcl templ->srcfile = file; templ->startoffset = *startOffset; templ->endoffset = offset + 1; - if (cparamblkptr->browseOptions.recordTemplates && file->recordbrowseinfo) + if (cparamblkptr->browseoptions.recordTemplates && file->recordbrowseinfo) CBrowse_NewTemplateFunc(templ); } @@ -1643,15 +1643,15 @@ Boolean CTempl_GenFuncInstance(TemplateFunction *templ, TemplFuncInstance *inst, CPrep_StreamInsert(&templ->stream, &streamState); - saveDebugInfo = copts.isGeneratingDebugInfo; + saveDebugInfo = copts.filesyminfo; if (copts.nosyminline || !templ->deftoken.tokenfile) - copts.isGeneratingDebugInfo = 0; + copts.filesyminfo = 0; CError_ASSERT(2112, (tk = lex()) == '{' || tk == ':' || tk == TK_TRY); symdecltoken = *CPrep_CurStreamElement(); - if (copts.isGeneratingDebugInfo) { + if (copts.filesyminfo) { CPrep_NewFileOffsetInfo(&cparser_fileoffset, &templ->deftoken); symdecloffset = cparser_fileoffset.tokenline; } @@ -1680,7 +1680,7 @@ Boolean CTempl_GenFuncInstance(TemplateFunction *templ, TemplFuncInstance *inst, CTemplTool_PopInstance(&stack); CPrep_StreamRemove(&templ->stream, &streamState); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; if (di.file->recordbrowseinfo) CBrowse_NewFunction(inst->object, di.file, di.file2, di.x60, templ->endoffset); @@ -1713,8 +1713,8 @@ void CTempl_InstantiateMember(TemplClass *templ, TemplClassInst *inst, TemplateM symdecltoken = *CPrep_CurStreamElement(); - saveDebugInfo = copts.isGeneratingDebugInfo; - if (copts.isGeneratingDebugInfo) { + saveDebugInfo = copts.filesyminfo; + if (copts.filesyminfo) { CPrep_NewFileOffsetInfo(&cparser_fileoffset, &symdecltoken); symdecloffset = cparser_fileoffset.tokenline; } @@ -1746,7 +1746,7 @@ void CTempl_InstantiateMember(TemplClass *templ, TemplClassInst *inst, TemplateM CTemplTool_PopInstance(&stack); CTemplTool_RemoveTemplateArgumentNameSpace(nspace, inst, &savedScope); CPrep_StreamRemove(&tmemb->stream, &savedState); - copts.isGeneratingDebugInfo = saveDebugInfo; + copts.filesyminfo = saveDebugInfo; gForceSourceLoc = saveSourceLoc; } diff --git a/compiler_and_linker/unsorted/CodeGen.c b/compiler_and_linker/unsorted/CodeGen.c index d5ba07f..4fb0b30 100644 --- a/compiler_and_linker/unsorted/CodeGen.c +++ b/compiler_and_linker/unsorted/CodeGen.c @@ -217,7 +217,7 @@ static void retain_argument_register(Object *obj, short reg) { if (type->size <= 4) { retain_register(obj, RegClass_GPR, reg); } else if (reg < GPRLimit) { - if (copts.little_endian) + if (copts.littleendian) retain_GPR_pair(obj, reg, reg + 1); else retain_GPR_pair(obj, reg + 1, reg); @@ -519,7 +519,7 @@ void move_assigned_argument(Object *obj, short reg) { if (reg) { if (vi->reg) { if (TYPE_IS_8BYTES(type)) { - if (copts.little_endian) { + if (copts.littleendian) { if (vi->reg != reg) emitpcode(PC_MR, vi->reg, reg); if (reg < GPRLimit) { @@ -872,7 +872,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B setheaperror(CodeGen_heaperror); } - if (cparamblkptr->isPrecompiling == 1) + if (cparamblkptr->precompile == 1) CError_Error(CErrorStr180); if (!func) { @@ -928,7 +928,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B allocate_locals(); process_arguments(move_assigned_argument, has_varargs); - if (copts.schedule_mode || copts.altivec_model) + if (copts.schedule_factor || copts.altivec_model) branch_label(makepclabel()); load_TOC_pointers(); @@ -1032,7 +1032,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B else pclistblocks(CMangler_GetLinkName(func)->name, "INITIAL CODE"); - if (copts.schedule_mode == 2) { + if (copts.schedule_factor == 2) { if (copts.peephole) peepholemergeblocks(func, 0); if (copts.debuglisting) @@ -1045,7 +1045,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B } if (copts.peephole) { - if (copts.schedule_mode == 0 && copts.optimizationlevel > 1) + if (copts.schedule_factor == 0 && copts.optimizationlevel > 1) peepholemergeblocks(func, 0); peepholeoptimizeforward(func); if (copts.debuglisting) @@ -1073,7 +1073,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B pclistblocks(CMangler_GetLinkName(func)->name, "AFTER GENERATING EPILOGUE, PROLOGUE"); if (copts.peephole) { - if (copts.schedule_mode) { + if (copts.schedule_factor) { peepholemergeblocks(func, 1); if (copts.debuglisting) pclistblocks(CMangler_GetLinkName(func)->name, "AFTER MERGING EPILOGUE, PROLOGUE"); @@ -1083,7 +1083,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B pclistblocks(CMangler_GetLinkName(func)->name, "AFTER PEEPHOLE OPTIMIZATION"); } - if (copts.schedule_mode) { + if (copts.schedule_factor) { if (copts.debuglisting) pclistblocks_start_scheduler(CMangler_GetLinkName(func)->name, "BEFORE SCHEDULING"); scheduleinstructions(1); @@ -1125,7 +1125,7 @@ void CodeGen_GenVDispatchThunk(Object *thunkobj, Object *obj, SInt32 a, SInt32 b Boolean save_traceback; char reg; - save_debug = copts.isGeneratingDebugInfo; + save_debug = copts.filesyminfo; save_peephole = copts.peephole; save_traceback = copts.traceback; @@ -1161,11 +1161,11 @@ void CodeGen_GenVDispatchThunk(Object *thunkobj, Object *obj, SInt32 a, SInt32 b emitpcode(PC_B, 0, obj); - copts.isGeneratingDebugInfo = 0; + copts.filesyminfo = 0; copts.peephole = 0; copts.traceback = 0; assemblefunction(thunkobj, NULL); - copts.isGeneratingDebugInfo = save_debug; + copts.filesyminfo = save_debug; copts.peephole = save_peephole; copts.traceback = save_traceback; } @@ -1231,7 +1231,7 @@ void CodeGen_SOMStub(Object *a, Object *b, Object *c, SInt32 offset) { Object *tmp; Operand opnd; - save_debug = copts.isGeneratingDebugInfo; + save_debug = copts.filesyminfo; save_peephole = copts.peephole; save_traceback = copts.traceback; @@ -1264,11 +1264,11 @@ void CodeGen_SOMStub(Object *a, Object *b, Object *c, SInt32 offset) { load_store_register(PC_LWZ, 12, 12, NULL, (short) offset); emitpcode(PC_B, 0, b); - copts.isGeneratingDebugInfo = 0; + copts.filesyminfo = 0; copts.peephole = 0; copts.traceback = 0; assemblefunction(a, NULL); - copts.isGeneratingDebugInfo = save_debug; + copts.filesyminfo = save_debug; copts.peephole = save_peephole; copts.traceback = save_traceback; } @@ -1295,7 +1295,7 @@ static void CodeGen_EOLCheck(void) { static void schedule_for(int what) { CPrep_PushOption(OPT_OFFSET(schedule_cpu), what); - if (copts.schedule_mode == 0) + if (copts.schedule_factor == 0) CPrep_PushOption(OPT_OFFSET(schedule_mode), 2); } @@ -1467,12 +1467,12 @@ void CodeGen_ParsePragma(HashNameNode *name) { return; } - if (!strcmp(name->name, "ppc_unroll_speculative")) { + if (!strcmp(name->name, "unroll_speculative")) { if (plex() == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "off")) { - copts.ppc_unroll_speculative = 0; + copts.unroll_speculative = 0; } else if (!strcmp(tkidentifier->name, "on")) { - copts.ppc_unroll_speculative = 1; + copts.unroll_speculative = 1; } else { CError_Error(CErrorStr186); return; @@ -1484,19 +1484,19 @@ void CodeGen_ParsePragma(HashNameNode *name) { return; } - if (!strcmp(name->name, "ppc_unroll_instructions_limit")) { + if (!strcmp(name->name, "unroll_instr_limit")) { t = plex(); if (t == TK_INTCONST) { - copts.ppc_unroll_instructions_limit = CInt64_GetULong(&tkintconst); - if (copts.ppc_unroll_instructions_limit < 0) { - copts.ppc_unroll_instructions_limit = 0; + copts.unroll_instr_limit = CInt64_GetULong(&tkintconst); + if (copts.unroll_instr_limit < 0) { + copts.unroll_instr_limit = 0; CError_Error(CErrorStr186); } } else if (t == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "off")) { - copts.ppc_unroll_instructions_limit = 0; + copts.unroll_instr_limit = 0; } else if (!strcmp(tkidentifier->name, "on")) { - copts.ppc_unroll_instructions_limit = 70; + copts.unroll_instr_limit = 70; } else { CError_Error(CErrorStr186); return; @@ -1539,19 +1539,19 @@ void CodeGen_ParsePragma(HashNameNode *name) { return; } - if (!strcmp(name->name, "ppc_unroll_factor_limit")) { + if (!strcmp(name->name, "unroll_factor_limit")) { t = plex(); if (t == TK_INTCONST) { - copts.ppc_unroll_factor_limit = CInt64_GetULong(&tkintconst); - if (copts.ppc_unroll_factor_limit < 0) { - copts.ppc_unroll_factor_limit = 0; + copts.unroll_factor_limit = CInt64_GetULong(&tkintconst); + if (copts.unroll_factor_limit < 0) { + copts.unroll_factor_limit = 0; CError_Error(CErrorStr186); } } else if (t == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "off")) { - copts.ppc_unroll_factor_limit = 0; + copts.unroll_factor_limit = 0; } else if (!strcmp(tkidentifier->name, "on")) { - copts.ppc_unroll_factor_limit = 10; + copts.unroll_factor_limit = 10; } else { CError_Error(CErrorStr186); return; @@ -1637,67 +1637,67 @@ void CodeGen_ParsePragma(HashNameNode *name) { if (t == TK_INTCONST) { switch (CInt64_GetULong(&tkintconst)) { case 401: - copts.cpu = 0; + copts.processor = 0; break; case 403: - copts.cpu = 1; + copts.processor = 1; break; case 505: - copts.cpu = 2; + copts.processor = 2; break; case 509: - copts.cpu = 3; + copts.processor = 3; break; case 555: - copts.cpu = 4; + copts.processor = 4; break; case 556: - copts.cpu = 25; + copts.processor = 25; break; case 565: - copts.cpu = 26; + copts.processor = 26; break; case 601: - copts.cpu = 5; + copts.processor = 5; break; case 602: - copts.cpu = 6; + copts.processor = 6; break; case 8240: - copts.cpu = 18; + copts.processor = 18; break; case 8260: - copts.cpu = 19; + copts.processor = 19; break; case 603: - copts.cpu = 7; + copts.processor = 7; break; case 604: - copts.cpu = 9; + copts.processor = 9; break; case 740: - copts.cpu = 11; + copts.processor = 11; break; case 750: - copts.cpu = 12; + copts.processor = 12; break; case 801: - copts.cpu = 13; + copts.processor = 13; break; case 821: - copts.cpu = 14; + copts.processor = 14; break; case 823: - copts.cpu = 15; + copts.processor = 15; break; case 850: - copts.cpu = 16; + copts.processor = 16; break; case 860: - copts.cpu = 17; + copts.processor = 17; break; case 7400: - copts.cpu = 21; + copts.processor = 21; break; default: PPCError_Warning(208); @@ -1706,15 +1706,15 @@ void CodeGen_ParsePragma(HashNameNode *name) { } } else if (t == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "generic")) - copts.cpu = 20; + copts.processor = 20; else if (!strcmp(tkidentifier->name, "603e")) - copts.cpu = 8; + copts.processor = 8; else if (!strcmp(tkidentifier->name, "604e")) - copts.cpu = 10; + copts.processor = 10; else if (!strcmp(tkidentifier->name, "PPC603e")) - copts.cpu = 8; + copts.processor = 8; else if (!strcmp(tkidentifier->name, "PPC604e")) - copts.cpu = 10; + copts.processor = 10; else PPCError_Warning(208); } else { @@ -1889,7 +1889,7 @@ void CodeGen_UpdateObject(Object *object) { } void CodeGen_UpdateBackEndOptions(void) { - copts.global_optimizer = 1; + copts.globaloptimizer = 1; } SInt32 CodeGen_objc_method_self_offset(ObjCMethod *meth) { @@ -2360,10 +2360,10 @@ void CodeGen_InsertSpecialMacros(void) { if (!copts.codegen_dynamic) CPrep_InsertSpecialMacro(&dynM, "__STATIC__"); - if (copts.oldalignment && copts.align_mode == AlignMode2_PPC) + if (copts.oldalignment && copts.structalignment == AlignMode2_PPC) CPrep_InsertSpecialMacro(&alignM, "__NATURAL_ALIGNMENT__"); - if (!copts.ANSI_strict) + if (!copts.ANSIstrict) CPrep_InsertSpecialMacro(&ppcM, "ppc"); } @@ -2397,7 +2397,7 @@ char *CodeGen_ExpandSpecialMacro(Macro *macro) { if (macro == &_machM) return "1"; if (macro == &archM) return "ppc"; if (macro == &dynM) return "1"; - if (!copts.ANSI_strict && macro == &ppcM) return "1"; + if (!copts.ANSIstrict && macro == &ppcM) return "1"; if (macro == &_ppc_M) return "1"; CError_FATAL(4801); diff --git a/compiler_and_linker/unsorted/CodeGenOptPPC.c b/compiler_and_linker/unsorted/CodeGenOptPPC.c index 4964435..cdf34e7 100644 --- a/compiler_and_linker/unsorted/CodeGenOptPPC.c +++ b/compiler_and_linker/unsorted/CodeGenOptPPC.c @@ -26,11 +26,11 @@ void CodeGen_InitBackEndOptions(void) { CWSecretGetNamedPreferences(cparams.context, "PPC Mach-O Linker", &handle); pmol = *((PMachOLinker *) *handle); - copts.code_alignment = 16; + copts.function_align = 16; copts.misaligned_mem_access = 1; copts.switch_tables = 1; copts.prepare_compress = 0; - copts.some_alignment = 4; + copts.min_struct_alignment = 4; copts.altivec_model = 0; copts.altivec_vrsave = 1; copts.codegen_pic = pb.pic; @@ -41,61 +41,61 @@ void CodeGen_InitBackEndOptions(void) { copts.no_implicit_templates = 0; copts.absolutepath = pmol.symfullpath; copts.x06 = pmol.exports; - copts.schedule_mode = 2; + copts.schedule_factor = 2; copts.altivec_model = pb.altivec; copts.readonly_strings = pb.readonlystrings; if (pb.schedule) - copts.schedule_mode = 2; + copts.schedule_factor = 2; else - copts.schedule_mode = 0; + copts.schedule_factor = 0; switch (pb.processor) { case 1: - copts.cpu = CPU_PPC601; - copts.schedule_cpu = 1; + copts.processor = CPU_PPC601; + copts.scheduling = 1; break; case 2: - copts.cpu = CPU_PPC603; - copts.schedule_cpu = 2; + copts.processor = CPU_PPC603; + copts.scheduling = 2; break; case 3: - copts.cpu = CPU_PPC603e; - copts.schedule_cpu = 5; + copts.processor = CPU_PPC603e; + copts.scheduling = 5; break; case 4: - copts.cpu = CPU_PPC604; - copts.schedule_cpu = 3; + copts.processor = CPU_PPC604; + copts.scheduling = 3; break; case 5: - copts.cpu = CPU_PPC604e; - copts.schedule_cpu = 6; + copts.processor = CPU_PPC604e; + copts.scheduling = 6; break; case 6: - copts.cpu = CPU_PPC750; - copts.schedule_cpu = 4; + copts.processor = CPU_PPC750; + copts.scheduling = 4; break; case 7: - copts.cpu = CPU_PPC7400; - copts.schedule_cpu = 7; + copts.processor = CPU_PPC7400; + copts.scheduling = 7; break; case 8: - copts.cpu = CPU_PPC7450; - copts.schedule_cpu = 10; + copts.processor = CPU_PPC7450; + copts.scheduling = 10; break; default: - copts.cpu = CPU_Generic; - copts.schedule_cpu = 8; + copts.processor = CPU_Generic; + copts.scheduling = 8; break; } copts.peephole = pb.peephole; - copts.align_mode = pb.structalignment; + copts.structalignment = pb.structalignment; copts.profile = pb.profiler; copts.fp_contract = pb.fpcontract; copts.traceback = pb.tracebacktables > 0; copts.x1D = pb.tracebacktables == 2; - copts.x1E = 0; - if (pb.processorspecific && copts.cpu >= CPU_PPC603) + copts.gen_isel = 0; + if (pb.processorspecific && copts.processor >= CPU_PPC603) copts.gen_fsel = 10; else copts.gen_fsel = 0; @@ -103,16 +103,16 @@ void CodeGen_InitBackEndOptions(void) { copts.altivec_vrsave = 1; else copts.altivec_vrsave = 0; - copts.ppc_unroll_speculative = 1; - copts.ppc_unroll_instructions_limit = 70; - copts.ppc_unroll_factor_limit = 10; - copts.ppc_opt_bclr_bcctr = 1; + copts.unroll_speculative = 1; + copts.unroll_instr_limit = 70; + copts.unroll_factor_limit = 10; + copts.opt_bcc_lr_ctr = 1; copts.use_lmw_stmw = 1; if (copts.optimizationlevel > 2) copts.optimizewithasm = 1; else copts.optimizewithasm = 0; - copts.opt_strength_reduction_strict = 1; + copts.strengthreductionstrict = 1; } void Test_Version_Numbers(void) { diff --git a/compiler_and_linker/unsorted/FuncLevelAsmPPC.c b/compiler_and_linker/unsorted/FuncLevelAsmPPC.c index 5cdab02..dead030 100644 --- a/compiler_and_linker/unsorted/FuncLevelAsmPPC.c +++ b/compiler_and_linker/unsorted/FuncLevelAsmPPC.c @@ -42,7 +42,7 @@ void setup_assembly_argument(Object *obj, short reg) { short regLo; short regHi; if (reg < 10) { - if (copts.little_endian) { + if (copts.littleendian) { regLo = reg; regHi = reg + 1; } else { @@ -198,7 +198,7 @@ void Assembler(Object *func) { if (fatalerrors) return; - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) CPrep_SetSourceFile(&cparser_fileoffset); sm_section = SECT_TEXT; @@ -372,7 +372,7 @@ void Assembler(Object *func) { func->section = sm_section; - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) symdeclend = CPrep_GetFileOffsetInfo(&cparser_fileoffset); copts.peephole = 0; diff --git a/compiler_and_linker/unsorted/FunctionCalls.c b/compiler_and_linker/unsorted/FunctionCalls.c index e746989..898d567 100644 --- a/compiler_and_linker/unsorted/FunctionCalls.c +++ b/compiler_and_linker/unsorted/FunctionCalls.c @@ -183,7 +183,7 @@ static ArgInfo *analyze_arguments(ENode *funcref, ENodeList *arg_expr, FuncArg * } else if (TYPE_IS_8BYTES(type)) { if (gpr_counter <= 10) { info->flags |= AIF_PassInGPR; - if (copts.little_endian) { + if (copts.littleendian) { info->gpr = gpr_counter; info->gprHi = gpr_counter + 1; } else { @@ -335,7 +335,7 @@ static void pass_in_register(ArgInfo *info) { if (!info->evaluated) GEN_NODE_TO_REG(info->expr, info->gpr, info->gprHi, &info->opnd); coerce_to_register_pair(&info->opnd, type, info->gpr, info->gprHi); - if (copts.little_endian) { + if (copts.littleendian) { if (info->gprHi > 10) { load_store_register( PC_STW, info->opnd.regHi, 1, diff --git a/compiler_and_linker/unsorted/GenStabs.c b/compiler_and_linker/unsorted/GenStabs.c index 4dfe371..2db276f 100644 --- a/compiler_and_linker/unsorted/GenStabs.c +++ b/compiler_and_linker/unsorted/GenStabs.c @@ -746,7 +746,7 @@ static int StabTypeID(Type *type) { } if (IS_TYPE_INT(TPTR_TARGET(type))) { if (TYPE_INTEGRAL(TPTR_TARGET(type))->integral == IT_CHAR) { - id = copts.unsignedchars ? StabType_UCharPtr : StabType_CharPtr; + id = copts.unsigned_char ? StabType_UCharPtr : StabType_CharPtr; break; } if (TYPE_INTEGRAL(TPTR_TARGET(type))->integral == IT_UCHAR) { @@ -865,7 +865,7 @@ static void output_stab_string(SInt32 (*func)(char *, SInt16, UInt32), SInt16 de static void output_default_types(void) { Output_LSYM_Stab("int:t(0,1)=r(0,1);0020000000000;0017777777777;", 0, 0); - if (copts.unsignedchars) + if (copts.unsigned_char) Output_LSYM_Stab("char:t(0,2)=r(0,2);0;255;", 0, 0); else Output_LSYM_Stab("char:t(0,2)=r(0,2);-128;127;", 0, 0); diff --git a/compiler_and_linker/unsorted/GlobalOptimizer.c b/compiler_and_linker/unsorted/GlobalOptimizer.c index f600322..3a6d3af 100644 --- a/compiler_and_linker/unsorted/GlobalOptimizer.c +++ b/compiler_and_linker/unsorted/GlobalOptimizer.c @@ -26,7 +26,7 @@ static void optimizelevel2(Object *func) { static void optimizelevel3(Object *func) { if (copts.peephole) { - if (copts.schedule_mode == 0 && copts.optimizationlevel > 1) + if (copts.schedule_factor == 0 && copts.optimizationlevel > 1) peepholemergeblocks(func, 0); peepholeoptimizeforward(func); @@ -84,7 +84,7 @@ static void optimizelevel3(Object *func) { } if (copts.peephole) { - if (copts.schedule_mode == 0 && copts.optimizationlevel > 1) + if (copts.schedule_factor == 0 && copts.optimizationlevel > 1) peepholemergeblocks(func, 0); peepholeoptimizeforward(func); @@ -102,7 +102,7 @@ static void optimizelevel3(Object *func) { static void optimizelevel4(Object *func) { if (copts.peephole) { - if (copts.schedule_mode == 0 && copts.optimizationlevel > 1) + if (copts.schedule_factor == 0 && copts.optimizationlevel > 1) peepholemergeblocks(func, 0); peepholeoptimizeforward(func); @@ -172,7 +172,7 @@ static void optimizelevel4(Object *func) { } if (copts.peephole) { - if (copts.schedule_mode == 0 && copts.optimizationlevel > 1) + if (copts.schedule_factor == 0 && copts.optimizationlevel > 1) peepholemergeblocks(func, 0); peepholeoptimizeforward(func); diff --git a/compiler_and_linker/unsorted/InlineAsmPPC.c b/compiler_and_linker/unsorted/InlineAsmPPC.c index 606b6af..9da367a 100644 --- a/compiler_and_linker/unsorted/InlineAsmPPC.c +++ b/compiler_and_linker/unsorted/InlineAsmPPC.c @@ -1512,7 +1512,7 @@ void InlineAsm_InitializePPC(void) { supports_hardware_fpu = 1; assembledinstructions = 0; - switch (copts.cpu) { + switch (copts.processor) { case CPU_PPC401: cpu = CPUMask_401; break; case CPU_PPC403: cpu = CPUMask_403; break; case CPU_PPC505: cpu = CPUMask_50x; break; @@ -1697,7 +1697,7 @@ void InlineAsm_ProcessDirective(SInt32 directive) { stmt = CFunc_AppendStatement(ST_ASM); stmt->expr = NULL; stmt->expr = (ENode *) InlineAsm_CreateFrFree(); - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) stmt->sourceoffset = CPrep_GetFileOffsetInfo(&cparser_fileoffset); else stmt->sourceoffset = -1; @@ -1820,7 +1820,7 @@ void InlineAsm_ScanAssemblyInstruction(void) { stmt = CFunc_AppendStatement(ST_ASM); stmt->expr = NULL; - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) stmt->sourceoffset = CPrep_GetFileOffsetInfo(&cparser_fileoffset); else stmt->sourceoffset = -1; diff --git a/compiler_and_linker/unsorted/InstrSelection.c b/compiler_and_linker/unsorted/InstrSelection.c index e49437f..359c980 100644 --- a/compiler_and_linker/unsorted/InstrSelection.c +++ b/compiler_and_linker/unsorted/InstrSelection.c @@ -534,7 +534,7 @@ void gen_DIV(ENode *expr, short outputReg, short outputRegHi, Operand *output) { if (is_unsigned(type)) { if (ENODE_IS(right, EINTCONST) && (tmp = ispowerof2(right->data.intval.lo))) { shift_right_immediate(left, type, tmp, outputReg, output); - } else if (!copts.optimize_for_size && ENODE_IS(right, EINTCONST) && right->data.intval.lo != 1) { + } else if (!copts.optimizesize && ENODE_IS(right, EINTCONST) && right->data.intval.lo != 1) { SInt32 value; int tmpreg1; int tmpreg2; @@ -590,7 +590,7 @@ void gen_DIV(ENode *expr, short outputReg, short outputRegHi, Operand *output) { signed_divide_by_power_of_2(left, tmp, 0, outputReg, output); } else if (ENODE_IS(right, EINTCONST) && (tmp = ispowerof2(-right->data.intval.lo))) { signed_divide_by_power_of_2(left, tmp, 1, outputReg, output); - } else if (!copts.optimize_for_size && ENODE_IS(right, EINTCONST) && (value = right->data.intval.lo) != 1u && value != -1) { + } else if (!copts.optimizesize && ENODE_IS(right, EINTCONST) && (value = right->data.intval.lo) != 1u && value != -1) { int tmpreg2; int tmpreg3; int tmpreg1; @@ -664,7 +664,7 @@ void gen_MODULO(ENode *expr, short outputReg, short outputRegHi, Operand *output shift_and_mask(left, 0, 32 - tmp, 31, outputReg, output); else signed_mod_by_power_of_2(left, tmp, 0, outputReg, output); - } else if (!copts.optimize_for_size && ENODE_IS(right, EINTCONST) && (value = right->data.intval.lo) != 1u && value != -1) { + } else if (!copts.optimizesize && ENODE_IS(right, EINTCONST) && (value = right->data.intval.lo) != 1u && value != -1) { GEN_NODE(left, &op1); ENSURE_GPR(&op1, left->rtype, 0); @@ -2463,7 +2463,7 @@ static void signed_divide_by_power_of_2(ENode *expr, int shift, int negate, shor memclrw(&op, sizeof(Operand)); GEN_NODE_TO_GPR(expr, &op, expr->rtype, 0); - if (!copts.optimize_for_size && shift == 1) { + if (!copts.optimizesize && shift == 1) { tmpreg1 = ALLOC_GPR(); emitpcode(PC_RLWINM, tmpreg1, op.reg, 1, 31, 31); tmpreg2 = ALLOC_GPR(); @@ -3054,7 +3054,7 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) { } if (IS_INT_CONST_ZERO(right)) { - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_ADDIC, tmpReg, op1.reg, -1); finalReg = outputReg ? outputReg : ALLOC_GPR(); @@ -3072,7 +3072,7 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) { return; } - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_SUBF, tmpReg, op1.reg, op2.reg); tmpReg2 = ALLOC_GPR(); @@ -3109,7 +3109,7 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) { case ELESSEQU: if (is_unsigned(left->rtype)) { - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_LI, tmpReg, -1); tmpReg2 = ALLOC_GPR(); @@ -3184,7 +3184,7 @@ void gen_condition_gpr(ENode *cond, Operand *output, short outputReg) { output->optype = OpndType_GPR; output->reg = finalReg; } else { - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_SUBFC, tmpReg, op2.reg, op1.reg); tmpReg2 = ALLOC_GPR(); @@ -3368,7 +3368,7 @@ void gen_negated_condition_gpr(ENode *cond, Operand *output, short outputReg) { } if (IS_INT_CONST_ZERO(right)) { - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_ADDIC, tmpReg, op1.reg, -1); finalReg = outputReg ? outputReg : ALLOC_GPR(); @@ -3386,7 +3386,7 @@ void gen_negated_condition_gpr(ENode *cond, Operand *output, short outputReg) { return; } - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_SUBF, tmpReg, op2.reg, op1.reg); tmpReg2 = ALLOC_GPR(); @@ -3459,7 +3459,7 @@ void gen_negated_condition_gpr(ENode *cond, Operand *output, short outputReg) { } if (IS_INT_CONST_ZERO(right)) { - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_SUBFIC, tmpReg, op1.reg, 0); finalReg = outputReg ? outputReg : ALLOC_GPR(); @@ -3477,7 +3477,7 @@ void gen_negated_condition_gpr(ENode *cond, Operand *output, short outputReg) { return; } - if (copts.optimize_for_size) { + if (copts.optimizesize) { tmpReg = ALLOC_GPR(); emitpcode(PC_SUBF, tmpReg, op2.reg, op1.reg); tmpReg2 = ALLOC_GPR(); diff --git a/compiler_and_linker/unsorted/IrOptimizer.c b/compiler_and_linker/unsorted/IrOptimizer.c index 0be1e1e..87be84c 100644 --- a/compiler_and_linker/unsorted/IrOptimizer.c +++ b/compiler_and_linker/unsorted/IrOptimizer.c @@ -172,7 +172,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { if (!DisableDueToAsm && copts.optimizationlevel > 0 && copts.opt_pointer_analysis && func) { IRO_AnalyzePointers(func); - if (copts.opt_propagation && IRO_EvaluateDefinitePointers(func)) { + if (copts.propagation && IRO_EvaluateDefinitePointers(func)) { IRO_UpdateFlagsOnInts(); IRO_UpdateVars(); IRO_DumpAfterPhase("IRO_EvaluateDefinitePointers", 0); @@ -202,7 +202,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { } if (!DisableDueToAsm && copts.optimizationlevel > 0) { - passCount = copts._B4 ? 2 : 1; + passCount = copts.multiplepasses ? 2 : 1; IRO_CPFirstTime = 1; for (pass = 0; pass < passCount; pass++) { IRO_Dump("*****************\n"); @@ -213,7 +213,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { IRO_ScalarizeClassDataMembers(); IRO_DumpAfterPhase("IRO_ScalarizeClassDataMembers", 0); - if (copts.opt_propagation) { + if (copts.propagation) { IRO_CopyAndConstantPropagation(); IRO_CPFirstTime = 0; IRO_ExpressionPropagation(); @@ -226,8 +226,8 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { IRO_DumpAfterPhase("IRO_ExpressionPropagation", 0); - if (copts.opt_dead_assignments || copts.opt_propagation) - IRO_UseDef(copts.opt_dead_assignments, copts.opt_propagation); + if (copts.deadstore || copts.propagation) + IRO_UseDef(copts.deadstore, copts.propagation); IRO_DumpAfterPhase("after IRO_UseDef", 0); IRO_UpdateVars(); @@ -246,7 +246,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { IRO_RenumberInts(); } - if (copts.opt_unroll_loops && !copts.optimize_for_size && pass == 0) { + if (copts.unrolling && !copts.optimizesize && pass == 0) { IRO_DumpAfterPhase("Before IRO_LoopUnroller", 0); IRO_LoopUnroller(); IRO_DumpAfterPhase("After IRO_LoopUnroller", 0); @@ -255,7 +255,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { VectorPhaseCalledFromUnroll = 0; - if (pass == 0 && (copts.opt_loop_invariants || copts.opt_strength_reduction)) { + if (pass == 0 && (copts.loopinvariants || copts.strengthreduction)) { IRO_DumpAfterPhase("Before IRO_FindLoops", 0); IRO_FindLoops(); LoopOptimizerRun = 1; @@ -263,7 +263,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { } IRO_DumpAfterPhase("After IRO_FindLoops", 0); - if (copts.opt_propagation) { + if (copts.propagation) { IRO_CopyAndConstantPropagation(); IRO_ConstantFolding(); IRO_EvaluateConditionals(); @@ -271,10 +271,10 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { IRO_DumpAfterPhase("Second pass:IRO_CopyAndConstantPropagation, IRO_ConstantFolding, IRO_EvaluateConditionals", 0); - if (copts.opt_common_subs) + if (copts.commonsubs) IRO_FindExpressions(NULL, 0); - if (copts.opt_common_subs) { + if (copts.commonsubs) { IRO_ComputeAvail(); IRO_CommonSubs(); } @@ -288,7 +288,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { do { IRO_UpdateFlagsOnInts(); - if (copts.opt_dead_code) + if (copts.deadcode) IRO_RemoveUnreachable(); IRO_DumpAfterPhase("IRO_RemoveUnreachable", 0); @@ -301,7 +301,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { changed2 |= IRO_DoJumpChaining(); IRO_DumpAfterPhase("IRO_DoJumpChaining", 0); - if (copts.opt_propagation) { + if (copts.propagation) { IRO_RenumberInts(); IRO_DumpAfterPhase("Before IRO_CopyAndConstantPropagation", 0); changed2 |= IRO_CopyAndConstantPropagation(); @@ -309,8 +309,8 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { IRO_ConstantFolding(); } - if (copts.opt_dead_assignments || copts.opt_propagation) - changed2 |= IRO_UseDef(copts.opt_dead_assignments, copts.opt_propagation); + if (copts.deadstore || copts.propagation) + changed2 |= IRO_UseDef(copts.deadstore, copts.propagation); IRO_DumpAfterPhase("IRO_UseDef", 0); changed2 |= IRO_EvaluateConditionals(); @@ -318,7 +318,7 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { } while (changed2); } - if (copts.opt_lifetimes) { + if (copts.lifetimes) { IRO_UseDef(0, 0); IRO_SplitLifetimes(); } @@ -382,20 +382,20 @@ void CodeGen_UpdateOptimizerOptions(void) { Boolean flag; flag = copts.optimizationlevel >= 1; - copts.opt_dead_code = flag; + copts.deadcode = flag; flag = copts.optimizationlevel >= 2; - copts.opt_propagation = flag; - copts.opt_common_subs = flag; + copts.propagation = flag; + copts.commonsubs = flag; flag = copts.optimizationlevel >= 3; - copts.opt_vectorize_loops = flag; - copts.opt_unroll_loops = flag; - copts.opt_dead_assignments = flag; - copts.opt_lifetimes = flag; - copts.opt_strength_reduction = flag; - copts.opt_loop_invariants = flag; + copts.vectorizeloops = flag; + copts.unrolling = flag; + copts.deadstore = flag; + copts.lifetimes = flag; + copts.strengthreduction = flag; + copts.loopinvariants = flag; flag = copts.optimizationlevel >= 4; - copts._B4 = flag; + copts.multiplepasses = flag; } diff --git a/compiler_and_linker/unsorted/IroExprRegeneration.c b/compiler_and_linker/unsorted/IroExprRegeneration.c index 074510b..f63622a 100644 --- a/compiler_and_linker/unsorted/IroExprRegeneration.c +++ b/compiler_and_linker/unsorted/IroExprRegeneration.c @@ -1321,7 +1321,7 @@ static Boolean GeneratePossibleCondAss(IRONode *fnode) { r23 = fnode->last->type == IROLinearIf; r20 = fnode->last->u.diadic.right; r19flag = 0; - if (r28 && copts.opt_common_subs && IRO_IsSubableExpression(r20)) + if (r28 && copts.commonsubs && IRO_IsSubableExpression(r20)) r19flag = 1; if (r19flag) { @@ -1344,7 +1344,7 @@ static Boolean GeneratePossibleCondAss(IRONode *fnode) { r19flag = 1; } - if (r19flag && !copts.opt_common_subs) + if (r19flag && !copts.commonsubs) return 0; } diff --git a/compiler_and_linker/unsorted/IroLoop.c b/compiler_and_linker/unsorted/IroLoop.c index 50c835f..d6ec5f0 100644 --- a/compiler_and_linker/unsorted/IroLoop.c +++ b/compiler_and_linker/unsorted/IroLoop.c @@ -407,7 +407,7 @@ static int Reducable(IROLinear *nd, IROLinear **resultNd1, IROLinear **resultNd2 if (!*resultVar || (*resultVar)->xA != 2) return 0; - if (copts.ANSI_strict || copts.opt_strength_reduction_strict) { + if (copts.ANSIstrict || copts.strengthreductionstrict) { Type *type = (*resultVar)->object->type; if (IRO_IsUnsignedType(type) && type->size < stunsignedlong.size) return 0; @@ -1278,17 +1278,17 @@ static void MyHandleLoop_Vector(IRONode *fnode) { } } - if (copts.opt_loop_invariants || copts.opt_strength_reduction) { + if (copts.loopinvariants || copts.strengthreduction) { MoveInvarianceInAddressExpr(); IRO_DumpAfterPhase("MoveInvarianceInAddressExpr", 0); IRO_FindExpressions(InLoop, 1); IRO_DumpExprs(); } - if (copts.opt_loop_invariants) + if (copts.loopinvariants) UnmarkSubexpressionsOfInvariantExpressions(); - if (!copts.optimize_for_size && copts.opt_strength_reduction) { + if (!copts.optimizesize && copts.strengthreduction) { for (expr = IRO_FirstExpr; expr; expr = expr->next) { if ( !(expr->x0 & 4) && @@ -1306,7 +1306,7 @@ static void MyHandleLoop_Vector(IRONode *fnode) { } } - if (!copts.optimize_for_size && copts.opt_strength_reduction) { + if (!copts.optimizesize && copts.strengthreduction) { RisList = NULL; for (expr = IRO_FirstExpr; expr; expr = exprnext) { exprnext = expr->next; @@ -1355,7 +1355,7 @@ static void MyHandleLoop_Vector(IRONode *fnode) { expr = IRO_FirstExpr; removedExprs = NULL; - if (copts.opt_loop_invariants) { + if (copts.loopinvariants) { while (expr) { exprnext = expr->next; flag24 = 0; @@ -1461,14 +1461,14 @@ static void MyHandleLoop_Motion(IRONode *fnode) { } } - if (copts.opt_loop_invariants || copts.opt_strength_reduction) { + if (copts.loopinvariants || copts.strengthreduction) { MoveInvarianceInAddressExpr(); IRO_DumpAfterPhase("MoveInvarianceInAddressExpr", 0); IRO_FindExpressions(InLoop, 0); IRO_DumpExprs(); } - if (copts.opt_loop_invariants) + if (copts.loopinvariants) UnmarkSubexpressionsOfInvariantExpressions(); checkflag = 1; diff --git a/compiler_and_linker/unsorted/IroPointerAnalysis.c b/compiler_and_linker/unsorted/IroPointerAnalysis.c index 45e4fe5..4fcb8d3 100644 --- a/compiler_and_linker/unsorted/IroPointerAnalysis.c +++ b/compiler_and_linker/unsorted/IroPointerAnalysis.c @@ -5161,7 +5161,7 @@ void PointerAnalysis_GetFunctionDependencies(Object *proc, IROLinear *funccall, } void PointerAnalysis_PragmaMode(void) { - if (cparamblkptr->isPreprocessing) { + if (cparamblkptr->preprocess) { skipendofline(); return; } diff --git a/compiler_and_linker/unsorted/IroUnrollLoop.c b/compiler_and_linker/unsorted/IroUnrollLoop.c index 5bbe490..45b774e 100644 --- a/compiler_and_linker/unsorted/IroUnrollLoop.c +++ b/compiler_and_linker/unsorted/IroUnrollLoop.c @@ -112,7 +112,7 @@ static void IRO_FindLoops_Unroll(void) { listfnode = list->fnode; IRO_Dump("IRO_FindLoops_Unroll:Found loop with header %d\n", listfnode->index); IRO_DumpBits("Loop includes: ", InLoop); - LoopUnroll(copts.loop_unroll_count, listfnode); + LoopUnroll(copts.unrollfactor, listfnode); IRO_UpdateFlagsOnInts(); } } @@ -1329,7 +1329,7 @@ static int IsLoopUnrollable(IROLoop *loop) { } } - if (loop->sizeBySomeMeasurement > copts.loop_unroll_size_threshold) { + if (loop->sizeBySomeMeasurement > copts.unrollinstrfactor) { IRO_Dump("IsLoopUnrollable:No because loop size greater than threshold\n"); return 0; } diff --git a/compiler_and_linker/unsorted/LoopOptimization.c b/compiler_and_linker/unsorted/LoopOptimization.c index 9db7c53..b2aef1e 100644 --- a/compiler_and_linker/unsorted/LoopOptimization.c +++ b/compiler_and_linker/unsorted/LoopOptimization.c @@ -188,8 +188,8 @@ static void unrollloop(Loop *loop) { PCode *firstInstr; PCode *nextInstr; - for (factor = copts.ppc_unroll_factor_limit; factor > 1; factor--) { - if ((loop->iterationCount % factor) == 0 && (loop->bodySize - 2) * factor <= copts.ppc_unroll_instructions_limit) + for (factor = copts.unroll_factor_limit; factor > 1; factor--) { + if ((loop->iterationCount % factor) == 0 && (loop->bodySize - 2) * factor <= copts.unroll_instr_limit) break; } @@ -339,8 +339,8 @@ static void unrollloopconditional(Loop *loop) { outputBlockCount = 0; instructionCount = 0; - for (factor = copts.ppc_unroll_factor_limit; factor > 1; factor--) { - if ((loop->iterationCount % factor) == 0 && (loop->bodySize - 2) * factor <= copts.ppc_unroll_instructions_limit) + for (factor = copts.unroll_factor_limit; factor > 1; factor--) { + if ((loop->iterationCount % factor) == 0 && (loop->bodySize - 2) * factor <= copts.unroll_instr_limit) break; } @@ -547,9 +547,9 @@ static void unrollunknownBDNZ(Loop *loop) { return; factor = 128; - while (factor > copts.ppc_unroll_factor_limit) + while (factor > copts.unroll_factor_limit) factor >>= 1; - while (factor > 1 && (loop->bodySize - 2) * factor > copts.ppc_unroll_instructions_limit) + while (factor > 1 && (loop->bodySize - 2) * factor > copts.unroll_instr_limit) factor >>= 1; if (factor < 2) @@ -1175,7 +1175,7 @@ static void optimizeloop(Loop *loop) { if (loop->isKnownCountingLoop) { if (loop->iterationCount > 0) { skiplooptest(loop); - if (!copts.optimize_for_size && !loop->x4D && !loop->x57) { + if (!copts.optimizesize && !loop->x4D && !loop->x57) { if (loop->x4F) unrollloop(loop); else if (!loop->x4E) @@ -1193,7 +1193,7 @@ static void optimizeloop(Loop *loop) { optimizedloops = 1; } else if (loop->isUnknownCountingLoop && !loop->x4E && !loop->x4D) { rewriteunknownloopwithBDNZ(loop); - if (copts.ppc_unroll_speculative && !copts.optimize_for_size) { + if (copts.unroll_speculative && !copts.optimizesize) { if (loop->x4F && !loop->x57 && !loop->x52) unrollunknownBDNZ(loop); } diff --git a/compiler_and_linker/unsorted/MachO.c b/compiler_and_linker/unsorted/MachO.c index 1fb2d05..6a8f364 100644 --- a/compiler_and_linker/unsorted/MachO.c +++ b/compiler_and_linker/unsorted/MachO.c @@ -679,10 +679,10 @@ void MachO_Finish(void) { COS_ResizeHandle(ObjFile.data, ObjFile.size); - cparamblkptr->objectDataHandle = ObjFile.data; - cparamblkptr->objectdata.codesize = CodeSize; - cparamblkptr->objectdata.udatasize = UdataSize; - cparamblkptr->objectdata.idatasize = IdataSize; + cparamblkptr->objectdata = ObjFile.data; + cparamblkptr->object.codesize = CodeSize; + cparamblkptr->object.udatasize = UdataSize; + cparamblkptr->object.idatasize = IdataSize; } void MachO_Cleanup(void) { diff --git a/compiler_and_linker/unsorted/ObjGenMachO.c b/compiler_and_linker/unsorted/ObjGenMachO.c index 97f5997..10ce456 100644 --- a/compiler_and_linker/unsorted/ObjGenMachO.c +++ b/compiler_and_linker/unsorted/ObjGenMachO.c @@ -655,7 +655,7 @@ void ObjGen_Finish(void) { UInt32 opMask; UInt32 argMask; - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) GenStab_SourceFile(""); CInit_DeclarePooledStrings(); @@ -1036,7 +1036,7 @@ static void definedatasymbol(Object *object, MachOSection *section, SInt32 value flag = ObjGen_DeclareSymbol(object, section, value); ObjGen_GetHashNodeRelocID(object, section, 0); - if (flag && copts.isGeneratingDebugInfo) + if (flag && copts.filesyminfo) GenStab_Var(object); if (object->toc) patchuplazyptr(object); @@ -1210,11 +1210,11 @@ void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag) { char buf1[1024]; char buf2[1024]; - if (copts.isGeneratingDebugInfo) { + if (copts.filesyminfo) { if (name) strncpy(buf1, name->name, sizeof(buf1)); else - COS_FileGetPathName(buf1, &cparamblkptr->mainFileSpec, &fileModDate); + COS_FileGetPathName(buf1, &cparamblkptr->sourcefile, &fileModDate); if (name && copts.absolutepath) ptr = buf1 + strlen(buf1); @@ -1712,17 +1712,17 @@ void ObjGen_DeclareTracebackTable(Object *tableobj, void *data, SInt32 size) { } void ObjGen_DeclareSymInfo(void) { - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) SymContainedVars(); } void ObjGen_Line(UInt32 line, UInt32 offset) { - if (copts.isGeneratingDebugInfo && line) + if (copts.filesyminfo && line) GenStab_Line(line, offset + last_base_offset[last_function_sect_id]); } void ObjGen_OutputDebugInfo(Object *funcobj) { - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) GenStab_Function(funcobj, CMangler_GetLinkName(funcobj)->id); } diff --git a/compiler_and_linker/unsorted/PCodeAssembly.c b/compiler_and_linker/unsorted/PCodeAssembly.c index 0455d77..cd3f376 100644 --- a/compiler_and_linker/unsorted/PCodeAssembly.c +++ b/compiler_and_linker/unsorted/PCodeAssembly.c @@ -1349,7 +1349,7 @@ SInt32 optimizefinalbranches(SInt32 codesize) { instr->args[2].data.label.label = target->args[0].data.label.label; changed = 1; } - } else if (copts.ppc_opt_bclr_bcctr) { + } else if (copts.opt_bcc_lr_ctr) { if (target->op == PC_BLR) { if (instr->op == PC_BT) instr->op = PC_BTLR; @@ -1425,7 +1425,7 @@ SInt32 optimizefinalbranches(SInt32 codesize) { instr->args[3].data.label.label = target->args[0].data.label.label; changed = 1; } - } else if (copts.ppc_opt_bclr_bcctr) { + } else if (copts.opt_bcc_lr_ctr) { if (target->op == PC_BLR) { instr->op = PC_BCLR; instr->argCount = 3; @@ -1556,7 +1556,7 @@ SInt32 assemblefunction(Object *func, EntryPoint *entrypoints) { codesize = pccomputeoffsets(); } - if (copts.code_alignment > 4) + if (copts.function_align > 4) codesize = insert_align_nops(func, codesize); tbsize = 0; @@ -1573,7 +1573,7 @@ SInt32 assemblefunction(Object *func, EntryPoint *entrypoints) { codebase = gl->size; AppendGListNoData(gl, codesize + tbsize); - if (copts.isGeneratingDebugInfo) { + if (copts.filesyminfo) { ObjGen_SymFunc(func); ObjGen_Line(functionbodyoffset, 0); ObjGen_DeclareSymInfo(); @@ -1590,7 +1590,7 @@ SInt32 assemblefunction(Object *func, EntryPoint *entrypoints) { for (block = pcbasicblocks; block; block = block->nextBlock) { for (offset2 = block->codeOffset, instr = block->firstPCode; instr; instr = instr->nextPCode, offset2 += 4) { - if (copts.isGeneratingDebugInfo && instr->sourceoffset != -1) + if (copts.filesyminfo && instr->sourceoffset != -1) ObjGen_Line(instr->sourceoffset, offset2); *((UInt32 *) (*gl->data + codebase + offset2)) = assemblepcode(instr, offset2, &wop); @@ -1600,7 +1600,7 @@ SInt32 assemblefunction(Object *func, EntryPoint *entrypoints) { } } - if (copts.isGeneratingDebugInfo) + if (copts.filesyminfo) ObjGenMach_SymFuncEnd(func, codesize); if (copts.traceback) diff --git a/compiler_and_linker/unsorted/PCodeListing.c b/compiler_and_linker/unsorted/PCodeListing.c index 6e87241..485d52d 100644 --- a/compiler_and_linker/unsorted/PCodeListing.c +++ b/compiler_and_linker/unsorted/PCodeListing.c @@ -81,7 +81,7 @@ static void pclistblock(PCodeBlock *block, char *format, UInt32 vecSize) { fprintf(pcfile, "}\n\n"); - cpu = copts.schedule_cpu; + cpu = copts.scheduling; if (cpu == 10) { mi = &machine7450; } else if (copts.altivec_model != 0 || cpu == 7) { diff --git a/compiler_and_linker/unsorted/Peephole.c b/compiler_and_linker/unsorted/Peephole.c index 3a63bff..151e448 100644 --- a/compiler_and_linker/unsorted/Peephole.c +++ b/compiler_and_linker/unsorted/Peephole.c @@ -1449,7 +1449,7 @@ static int MR_ADDI(PCode *instr, UInt32 *masks) { int prevFlag = 0; int nextFlag = 0; - if (copts.cpu == CPU_PPC603e) { + if (copts.processor == CPU_PPC603e) { if (prev) prevFlag = (prev->flags & fOpTypeMask) == fOpTypeGPR; if (next) diff --git a/compiler_and_linker/unsorted/RegisterInfo.c b/compiler_and_linker/unsorted/RegisterInfo.c index 9365d11..72aa09c 100644 --- a/compiler_and_linker/unsorted/RegisterInfo.c +++ b/compiler_and_linker/unsorted/RegisterInfo.c @@ -346,7 +346,7 @@ int is_nonvolatile_register(RegClass rclass, int reg) { } void init_endian(void) { - if (copts.little_endian) { + if (copts.littleendian) { high_offset = 4; low_offset = 0; high_reg = 4; diff --git a/compiler_and_linker/unsorted/Scheduler.c b/compiler_and_linker/unsorted/Scheduler.c index 791ba28..23b580f 100644 --- a/compiler_and_linker/unsorted/Scheduler.c +++ b/compiler_and_linker/unsorted/Scheduler.c @@ -464,7 +464,7 @@ void scheduleinstructions(Boolean flag) { PCodeBlock *block; int cpu; - cpu = copts.schedule_cpu; + cpu = copts.scheduling; if (cpu == 10) { MI = &machine7450; } else if (copts.altivec_model != 0 || cpu == 7) { @@ -534,7 +534,7 @@ int is_dependent(PCode *a, PCode *b, char rclass) { int uses_vpermute_unit(PCode *instr) { int cpu; - cpu = copts.schedule_cpu; + cpu = copts.scheduling; if (cpu == 10) return machine7450.uses_vpermute_unit(instr); if (copts.altivec_model != 0 || cpu == 7) diff --git a/compiler_and_linker/unsorted/SpillCode.c b/compiler_and_linker/unsorted/SpillCode.c index 477d391..69e7e43 100644 --- a/compiler_and_linker/unsorted/SpillCode.c +++ b/compiler_and_linker/unsorted/SpillCode.c @@ -26,7 +26,7 @@ void estimatespillcosts(void) { int weight; for (block = pcbasicblocks; block; block = block->nextBlock) { - if (copts.optimize_for_size) + if (copts.optimizesize) weight = 1; else weight = block->loopWeight; @@ -37,7 +37,7 @@ void estimatespillcosts(void) { while (i--) { if (PC_OP_IS_READ_ANY_REGISTER(op, coloring_class)) { node = interferencegraph[op->data.reg.reg]; - if (node->instr8 || copts.optimize_for_size) + if (node->instr8 || copts.optimizesize) node->spillCost += weight; else node->spillCost += weight * 2; diff --git a/compiler_and_linker/unsorted/StackFrame.c b/compiler_and_linker/unsorted/StackFrame.c index e9feb2e..6fa4524 100644 --- a/compiler_and_linker/unsorted/StackFrame.c +++ b/compiler_and_linker/unsorted/StackFrame.c @@ -588,7 +588,7 @@ static void save_nonvolatile_GPRs(int reg, SInt32 offset) { o = offset + non_volatile_save_offset[RegClass_GPR]; if (!use_helper_function(RegClass_GPR)) { - if (copts.use_lmw_stmw && ((used_nonvolatile_registers[RegClass_GPR] > 4) || (copts.optimize_for_size && (used_nonvolatile_registers[RegClass_GPR] > 1)))) { + if (copts.use_lmw_stmw && ((used_nonvolatile_registers[RegClass_GPR] > 4) || (copts.optimizesize && (used_nonvolatile_registers[RegClass_GPR] > 1)))) { emitpcode(PC_STMW, used_nonvolatile_registers[RegClass_GPR] - 1, 32 - used_nonvolatile_registers[RegClass_GPR], reg, 0, o); } else { for (i = 1; i <= used_nonvolatile_registers[RegClass_GPR]; i++) { @@ -608,7 +608,7 @@ static void restore_nonvolatile_GPRs(int reg, SInt32 offset) { o = offset + non_volatile_save_offset[RegClass_GPR]; if (!use_helper_function(RegClass_GPR)) { - if (copts.use_lmw_stmw && ((used_nonvolatile_registers[RegClass_GPR] > 4) || (copts.optimize_for_size && (used_nonvolatile_registers[RegClass_GPR] > 1)))) { + if (copts.use_lmw_stmw && ((used_nonvolatile_registers[RegClass_GPR] > 4) || (copts.optimizesize && (used_nonvolatile_registers[RegClass_GPR] > 1)))) { emitpcode(PC_LMW, used_nonvolatile_registers[RegClass_GPR] - 1, 32 - used_nonvolatile_registers[RegClass_GPR], reg, 0, o); setpcodeflags(fIsVolatile); } else { @@ -876,7 +876,7 @@ void assign_arguments_to_memory(Object *func, UInt8 mysteryFlag, Boolean hasVara } obj->u.var.uid = pos; Registers_GetVarInfo(obj)->flags = (Registers_GetVarInfo(obj)->flags & ~VarInfoFlag1) | VarInfoFlag1; - if (!copts.little_endian && (IS_TYPE_INT(obj->type) || IS_TYPE_ENUM(obj->type)) && obj->type->size < 4) + if (!copts.littleendian && (IS_TYPE_INT(obj->type) || IS_TYPE_ENUM(obj->type)) && obj->type->size < 4) obj->u.var.uid += 4 - obj->type->size; pos += type->size; pos = ALIGN(pos, 4); @@ -1089,11 +1089,11 @@ static Boolean use_helper_function(char rclass) { case RegClass_GPR: if (copts.use_lmw_stmw) return 0; - return (used_nonvolatile_registers[RegClass_GPR] > 4) || (copts.optimize_for_size && used_nonvolatile_registers[RegClass_GPR] > 2); + return (used_nonvolatile_registers[RegClass_GPR] > 4) || (copts.optimizesize && used_nonvolatile_registers[RegClass_GPR] > 2); case RegClass_FPR: - return (used_nonvolatile_registers[RegClass_FPR] > 3) || (copts.optimize_for_size && used_nonvolatile_registers[RegClass_FPR] > 2); + return (used_nonvolatile_registers[RegClass_FPR] > 3) || (copts.optimizesize && used_nonvolatile_registers[RegClass_FPR] > 2); case RegClass_VR: - return (used_nonvolatile_registers[RegClass_VR] > 3) || (copts.optimize_for_size && used_nonvolatile_registers[RegClass_VR] > 2); + return (used_nonvolatile_registers[RegClass_VR] > 3) || (copts.optimizesize && used_nonvolatile_registers[RegClass_VR] > 2); default: CError_FATAL(2862); return 0; diff --git a/compiler_and_linker/unsorted/StructMoves.c b/compiler_and_linker/unsorted/StructMoves.c index a07ef03..7c28b88 100644 --- a/compiler_and_linker/unsorted/StructMoves.c +++ b/compiler_and_linker/unsorted/StructMoves.c @@ -388,7 +388,7 @@ void move_block(Operand *dst, Operand *src, SInt32 len, SInt32 align) { move_block_via_load_store(&myDst, src, len, align); else if (len == 8 && align == 8) move_block_via_load_store(&myDst, src, len, align); - else if (len <= 16 || (copts.optimize_for_size == 0 && len <= 64)) + else if (len <= 16 || (copts.optimizesize == 0 && len <= 64)) move_block_via_load_store_sequence(&myDst, src, len, align); else move_block_via_inline_loop(&myDst, src, len, align); diff --git a/compiler_and_linker/unsorted/TOC.c b/compiler_and_linker/unsorted/TOC.c index 3fde61b..daa6464 100644 --- a/compiler_and_linker/unsorted/TOC.c +++ b/compiler_and_linker/unsorted/TOC.c @@ -147,7 +147,7 @@ void createNonLazyPointer(Object *obj) { void referenceIndirectPointer(Object *obj) { VarInfo *vi = obj->toc->u.toc.info; vi->used = 1; - vi->usage += copts.optimize_for_size ? 1 : curstmtvalue; + vi->usage += copts.optimizesize ? 1 : curstmtvalue; } Object *createIndirect(Object *obj, Boolean flag1, Boolean flag2) { @@ -317,7 +317,7 @@ static Object *CreatePooledFloatConst(Type *type, Float *data, SInt32 *pOffset) buffer = galloc(8u); CMach_InitFloatMem(type, *data, buffer); - if (cparamblkptr->isPrecompiling == 1) + if (cparamblkptr->precompile == 1) CError_Error(CErrorStr180); for (entry = doubleconstpool; entry; entry = entry->next) { @@ -365,7 +365,7 @@ static Object *CreatePooledFloatConst(Type *type, Float *data, SInt32 *pOffset) buffer = galloc(4u); CMach_InitFloatMem(type, *data, buffer); - if (cparamblkptr->isPrecompiling == 1) + if (cparamblkptr->precompile == 1) CError_Error(CErrorStr180); for (entry = floatconstpool; entry; entry = entry->next) { @@ -441,7 +441,7 @@ static void RewriteVectorConst(ENode *expr) { CMach_InitVectorMem(expr->rtype, expr->data.vector128val, data, 1); - if (cparamblkptr->isPrecompiling == 1) + if (cparamblkptr->precompile == 1) CError_Error(CErrorStr180); for (entry = vectorconstpool; entry; entry = entry->next) { @@ -1391,7 +1391,7 @@ Boolean TOC_use_isel(ENode *expr, Boolean flag) { if (flag) opt = 10; else - opt = copts.x1E; + opt = copts.gen_isel; if (!opt) return 0; if (!copts.peephole) return 0; @@ -2232,7 +2232,7 @@ Object *createstaticinitobject(void) { TypeFunc *tfunc; Object *obj; - COS_FileGetFSSpecInfo(&cparamblkptr->mainFileSpec, NULL, NULL, fname); + COS_FileGetFSSpecInfo(&cparamblkptr->sourcefile, NULL, NULL, fname); sprintf(buf, "__sinit_%*.*s", -fname[0], fname[0], &fname[1]); for (p = &buf[1]; *p; p++) { if (*p == '.') diff --git a/includes/compiler/CBrowse.h b/includes/compiler/CBrowse.h index cbca85d..388888d 100644 --- a/includes/compiler/CBrowse.h +++ b/includes/compiler/CBrowse.h @@ -7,9 +7,9 @@ extern Boolean gUseTokenStreamSource; extern Boolean gForceSourceLoc; extern Boolean gUseNameTable; -extern void CBrowse_Setup(CParams *params); -extern void CBrowse_Finish(CParams *params); -extern void CBrowse_Cleanup(CParams *params); +extern void CBrowse_Setup(CompilerLinkerParamBlk *params); +extern void CBrowse_Finish(CompilerLinkerParamBlk *params); +extern void CBrowse_Cleanup(CompilerLinkerParamBlk *params); extern void CBrowse_BeginClass(DeclInfo *di, GList *gl); extern void CBrowse_AddClassMemberVar(ObjMemberVar *ivar, SInt32 startOffset, SInt32 endOffset); extern void CBrowse_AddClassMemberFunction(Object *object, SInt32 startOffset, SInt32 endOffset); diff --git a/includes/compiler/CCompiler.h b/includes/compiler/CCompiler.h index 92b483c..daa1020 100644 --- a/includes/compiler/CCompiler.h +++ b/includes/compiler/CCompiler.h @@ -6,7 +6,7 @@ extern Boolean systemHandles; extern Boolean crippled; extern SInt32 license_cookie; -extern CParams cparams; +extern CompilerLinkerParamBlk cparams; extern CWPLUGIN_ENTRY(MWC_main)(CWPluginContext context); extern void PrintProgressFunction(const char *str); diff --git a/includes/compiler/CParser.h b/includes/compiler/CParser.h index 7312e33..65d046a 100644 --- a/includes/compiler/CParser.h +++ b/includes/compiler/CParser.h @@ -53,82 +53,81 @@ enum { }; -// not sure how many of these are char and how many are unsigned char or Boolean -typedef struct COpts { - Boolean little_endian; +typedef struct CompilerLinkerOptions { + Boolean littleendian; Boolean codegen_dynamic; Boolean codegen_pic; Boolean no_common; Boolean no_implicit_templates; Boolean absolutepath; // determines the path written to debug info char x06; // linker/objgen related - short cpu; - char schedule_cpu; - char schedule_mode; // may be an enum?? + short processor; + char scheduling; + char schedule_factor; SInt32 debuglisting; Boolean profile; Boolean traceback; Boolean disable_registers; Boolean fp_contract; Boolean no_register_save_helpers; - Boolean ppc_unroll_speculative; - short ppc_unroll_instructions_limit; - short ppc_unroll_factor_limit; + Boolean unroll_speculative; + short unroll_instr_limit; + short unroll_factor_limit; Boolean altivec_model; UInt8 altivec_vrsave; - UInt8 code_alignment; + UInt8 function_align; UInt8 x1D; - UInt8 x1E; // some register used in TOC_use_isel + UInt8 gen_isel; UInt8 gen_fsel; - Boolean ppc_opt_bclr_bcctr; + Boolean opt_bcc_lr_ctr; Boolean use_lmw_stmw; char report_heap_info; Boolean misaligned_mem_access; Boolean switch_tables; - char prepare_compress; - char some_alignment; // used in CMach_AllocationAlignment + Boolean prepare_compress; + char min_struct_alignment; // used in CMach_AllocationAlignment Boolean asmsemicolcomment; Boolean asmpoundcomment; StringPtr oldprefixname; short inlinelevel; - int inline_max_size; - int inline_max_total_size; + int inlinemaxsize; + int inlinemaxtotalsize; Boolean inline_bottom_up; Boolean cplusplus; Boolean ecplusplus; Boolean objective_c; Boolean objc_strict; - Boolean ARM_conform; - Boolean ARM_scoping; - Boolean require_prototypes; + Boolean ARMconform; + Boolean ARMscoping; + Boolean checkprotos; Boolean trigraphs; - Boolean only_std_keywords; + Boolean onlystdkeywords; Boolean enumsalwaysint; - Boolean ANSI_strict; + Boolean ANSIstrict; Boolean mpwc_relax; Boolean mpwc_newline; Boolean ignore_oldstyle; Boolean cpp_extensions; Boolean pointercast_lvalue; - Boolean useRTTI; + Boolean RTTI; Boolean delete_exception; - char _4B; + Boolean test_dummy; Boolean oldalignment; - Boolean unsignedchars; + Boolean unsigned_char; Boolean multibyteaware; - Boolean autoinline; + Boolean auto_inline; Boolean defer_codegen; Boolean direct_to_som; Boolean som_env_check; - Boolean som_call_opt; + Boolean som_call_optimize; Boolean booltruefalse; - char old_enum_mangler; + Boolean old_enum_mangler; Boolean longlong; Boolean longlong_enums; - char no_tfuncinline; - Boolean _59; + Boolean no_tfuncinline; + Boolean always_vdispatch; Boolean flat_include; - char syspath_once; + Boolean syspath_once; Boolean always_import; Boolean simple_class_byval; Boolean wchar_type; @@ -136,16 +135,16 @@ typedef struct COpts { Boolean vbase_abi_v2; Boolean def_inherited; Boolean template_patch; - char template_friends; + Boolean template_friends; Boolean faster_pch_gen; Boolean array_new_delete; Boolean dollar_identifiers; - char def_inline_tfuncs; + Boolean def_inline_tfuncs; Boolean arg_dep_lookup; Boolean simple_prepdump; Boolean line_prepdump; Boolean fullpath_prepdump; - char old_mtemplparser; + Boolean old_mtemplparser; Boolean suppress_init_code; Boolean reverse_bitfields; Boolean c9x; @@ -153,20 +152,20 @@ typedef struct COpts { Boolean no_static_dtors; Boolean longlong_prepeval; Boolean const_strings; - char dumpir; + Boolean dumpir; Boolean experimental; Boolean gcc_extensions; - char stdc_fp_contract; - char stdc_fenv_access; - char stdc_cx_limitedr; + Boolean stdc_fp_contract; + Boolean stdc_fenv_access; + Boolean stdc_cx_limitedr; Boolean old_argmatch; Boolean optEH; Boolean optEH2; Boolean new_mangler; - char microsoft; + Boolean microsoft_EH; Boolean warningerrors; Boolean pedantic; - Boolean check_header_flags; + Boolean checkprecompflags; Boolean supress_warnings; Boolean warn_illpragma; Boolean warn_emptydecl; @@ -183,51 +182,51 @@ typedef struct COpts { Boolean warn_no_side_effect; Boolean warn_resultnotused; Boolean warn_ptr_int_conv; - char align_mode; - Boolean align_array_members; + char structalignment; + Boolean alignarraymembers; Boolean dont_reuse_strings; - Boolean pool_strings; + Boolean poolstrings; Boolean explicit_zero_data; Boolean readonly_strings; Boolean exceptions; - char _99; - Boolean dont_inline; - Boolean always_inline; + Boolean dddummy; + Boolean dontinline; + Boolean alwaysinline; Boolean peephole; - Boolean global_optimizer; - char side_effects; - Boolean internal; - Boolean import; - Boolean export; - Boolean lib_export; + Boolean globaloptimizer; + Boolean sideeffects; + Boolean cfm_internal; + Boolean cfm_import; + Boolean cfm_export; + Boolean cfm_lib_export; Boolean nosyminline; - char force_active; + Boolean force_active; char optimizationlevel; - Boolean optimize_for_size; + Boolean optimizesize; Boolean optimizewithasm; Boolean crippled; - Boolean opt_common_subs; - Boolean opt_loop_invariants; - Boolean opt_propagation; - Boolean opt_dead_assignments; - Boolean opt_strength_reduction; - Boolean opt_strength_reduction_strict; - Boolean opt_dead_code; - Boolean opt_lifetimes; - char _B1; // unused? - Boolean opt_unroll_loops; - char opt_vectorize_loops; - Boolean _B4; // amount of IRO passes? + Boolean commonsubs; + Boolean loopinvariants; + Boolean propagation; + Boolean deadstore; + Boolean strengthreduction; + Boolean strengthreductionstrict; + Boolean deadcode; + Boolean lifetimes; + Boolean logopts; + Boolean unrolling; + Boolean vectorizeloops; + Boolean multiplepasses; Boolean opt_pointer_analysis; - unsigned char opt_pointer_analysis_mode; - char loop_unroll_count; - char loop_unroll_size_threshold; - Boolean isGeneratingDebugInfo; - CWDataType pchCreator; - CWDataType pchType; - CWDataType text; - HashNameNode *forcedSegment; // when set by #pragma segment -} COpts; + UInt8 opt_pointer_analysis_mode; + char unrollfactor; + char unrollinstrfactor; + Boolean filesyminfo; + CWDataType appltype; + CWDataType headtype; + CWDataType texttype; + HashNameNode *cursegmentname; // when set by #pragma segment +} CompilerLinkerOptions; typedef struct ParserTryBlock { struct ParserTryBlock *next; @@ -290,7 +289,7 @@ extern Object *Xthrw_func; extern Object *Xicth_func; extern Object *Xecth_func; extern Object *Xunex_func; -extern COpts copts; +extern CompilerLinkerOptions copts; extern struct GList name_mangle_list; extern HashNameNode *no_name_node; extern HashNameNode *temp_argument_name; diff --git a/includes/compiler/CPrep.h b/includes/compiler/CPrep.h index 02d5a76..5fc972c 100644 --- a/includes/compiler/CPrep.h +++ b/includes/compiler/CPrep.h @@ -25,7 +25,7 @@ typedef struct TokenStack { } TokenStack; //#define OPT_OFFSET(optname) ((short) (((char *) (&copts.optname)) - ((char *) &copts))) -#define OPT_OFFSET(optname) ((UInt16) ( &((COpts *)0)->optname )) +#define OPT_OFFSET(optname) ((UInt16) ( &((CompilerLinkerOptions *)0)->optname )) enum { OPT_OFFSET_MASK = 0x1FFF, OPT_FLAG_2000 = 0x2000, @@ -33,7 +33,7 @@ enum { OPT_FLAG_8000 = 0x8000 }; -extern CParams *cparamblkptr; +extern CompilerLinkerParamBlk *cparamblkptr; extern short tk; extern CInt64 tkintconst; extern Float tkfloatconst; @@ -112,7 +112,7 @@ extern SInt32 CPrep_GetFileOffsetInfo(FileOffsetInfo *foi); extern void CPrep_GetFileOffsetInfo2(FileOffsetInfo *foi, SInt32 *pLine, HashNameNode **pName); extern void CPrep_ResetFileInfo(FileOffsetInfo *foi); extern void CPrep_GetPrepPos(CPrepFileInfo **file, SInt32 *ppos); -extern UInt8 C_Compiler(CParams *param); +extern UInt8 C_Compiler(CompilerLinkerParamBlk *param); extern void poptokenseq(void); extern void foundnl(void); extern void newline(void); diff --git a/includes/compiler/common.h b/includes/compiler/common.h index 0b8aaa7..156e5c4 100644 --- a/includes/compiler/common.h +++ b/includes/compiler/common.h @@ -112,7 +112,7 @@ typedef struct BClassList BClassList; typedef struct CI_FuncData CI_FuncData; typedef struct CLabel CLabel; typedef struct ClassList ClassList; -typedef struct CParams CParams; +typedef struct CompilerLinkerParamBlk CompilerLinkerParamBlk; typedef struct CPrepFileInfo CPrepFileInfo; typedef struct CScopeSave CScopeSave; typedef struct DeclE DeclE; @@ -296,30 +296,30 @@ typedef enum RegClass { #ifdef __MWERKS__ #pragma options align=mac68k #endif -struct CParams { +struct CompilerLinkerParamBlk { 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; + 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; CWDataType targetOS; CWDataType targetCPU; - char *targetName; + char *idetargetname; }; #define FITS_IN_SHORT(value) ( (value) == ((short) (value)) ) diff --git a/includes/cw_common.h b/includes/cw_common.h index eb016f1..0be94bb 100644 --- a/includes/cw_common.h +++ b/includes/cw_common.h @@ -32,8 +32,8 @@ typedef struct BasePluginCallbacks { typedef struct CompilerLinkerPluginCallbacks { CWPLUGIN_ENTRY (*GetTargetList)(const struct CWTargetList **targetList); CWPLUGIN_ENTRY (*GetDefaultMappingList)(const CWExtMapList **mappings); - CWPLUGIN_ENTRY (*Unmangle)(); - CWPLUGIN_ENTRY (*BrSymbolEntryPoint)(); + CWPLUGIN_ENTRY (*Unmangle)(CWUnmangleInfo *unmangleInfo); + CWPLUGIN_ENTRY (*BrSymbolEntryPoint)(CWCompilerBrSymbolInfo *symbolInfo); CWPLUGIN_ENTRY (*GetObjectFlags)(const CWObjectFlags **objectFlags); CWPLUGIN_ENTRY (*WriteObjectFile)(const FSSpec *srcfss, const FSSpec *outfss, OSType creator, OSType type, Handle data); } CompilerLinkerPluginCallbacks; diff --git a/includes/plugin.h b/includes/plugin.h index 3341c82..6fad976 100644 --- a/includes/plugin.h +++ b/includes/plugin.h @@ -203,7 +203,7 @@ struct CWParserCallbacks { #ifdef __cplusplus extern "C" { #endif -CW_CALLBACK CWCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr); +CW_CALLBACK CWCheckoutLicense(CWPluginContext context, const char *featureName, const char *licenseVersion, SInt32 flags, void *reserved, SInt32 *cookie); CW_CALLBACK CWCheckinLicense(CWPluginContext context, SInt32 cookie); CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode); @@ -214,7 +214,7 @@ CW_CALLBACK CWSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, CW_CALLBACK CWSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle); CW_CALLBACK CWSecretGetNamedPreferences(CWPluginContext context, const char *prefsname, Handle *prefsdata); -CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **buildDate, const char **buildTime); +CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **bdate, const char **btime); CW_CALLBACK CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **args); CW_CALLBACK CWParserGetTargetInfo(CWPluginContext context, CWDataType *cpu, CWDataType *os); CW_CALLBACK CWParserGetToolInfo(CWPluginContext context, const ToolVersionInfo **toolVersionInfo); diff --git a/osx_build.sh b/osx_build.sh index 17523c1..56d31c2 100755 --- a/osx_build.sh +++ b/osx_build.sh @@ -5,207 +5,212 @@ export MWCIncludes=/usr/include MWC_FLAGS="-c -g -opt l=4,noschedule,speed -enum min -Iincludes -Isdk_hdrs -w all,nounused,nonotinlined -wchar_t on -bool off -Cpp_exceptions off -maxwarnings 10" -#~/bin/mwccppc $MWC_FLAGS -o objs/CLCompilerLinkerDropin_V10.o command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp -#~/bin/mwccppc $MWC_FLAGS -o objs/CLDropinCallbacks_V10.o command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp -#~/bin/mwccppc $MWC_FLAGS -o objs/CLParserCallbacks_V1.o command_line/CmdLine/Src/Callbacks/CLParserCallbacks_V1.cpp -# -#~/bin/mwccppc $MWC_FLAGS -o objs/CLStaticMain.o command_line/CmdLine/Src/Clients/CLStaticMain.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ClientGlue.o command_line/CmdLine/Src/Clients/ClientGlue.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/CLErrors.o command_line/CmdLine/Src/Envir/CLErrors.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLIO.o command_line/CmdLine/Src/Envir/CLIO.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/ErrMgr.o command_line/CmdLine/Src/MacEmul/ErrMgr.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Files.o command_line/CmdLine/Src/MacEmul/Files.c -#~/bin/mwccppc $MWC_FLAGS -o objs/LowMem.o command_line/CmdLine/Src/MacEmul/LowMem.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Memory.o command_line/CmdLine/Src/MacEmul/Memory.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Resources.o command_line/CmdLine/Src/MacEmul/Resources.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ResourceStrings.o command_line/CmdLine/Src/MacEmul/ResourceStrings.c -#~/bin/mwccppc $MWC_FLAGS -o objs/TextUtils.o command_line/CmdLine/Src/MacEmul/TextUtils.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/FileHandles.o command_line/CmdLine/Src/OSLib/FileHandles.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Generic.o command_line/CmdLine/Src/OSLib/Generic.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MacFileTypes.o command_line/CmdLine/Src/OSLib/MacFileTypes.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MacSpecs.o command_line/CmdLine/Src/OSLib/MacSpecs.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MemUtils.o command_line/CmdLine/Src/OSLib/MemUtils.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Posix.o command_line/CmdLine/Src/OSLib/Posix.c -#~/bin/mwccppc $MWC_FLAGS -o objs/StringExtras.o command_line/CmdLine/Src/OSLib/StringExtras.c -#~/bin/mwccppc $MWC_FLAGS -o objs/StringUtils.o command_line/CmdLine/Src/OSLib/StringUtils.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/CLPlugins.o command_line/CmdLine/Src/Plugins/CLPlugins.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/CLAccessPaths.o command_line/CmdLine/Src/Project/CLAccessPaths.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLFiles.o command_line/CmdLine/Src/Project/CLFiles.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLOverlays.o command_line/CmdLine/Src/Project/CLOverlays.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLProj.o command_line/CmdLine/Src/Project/CLProj.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLSegs.o command_line/CmdLine/Src/Project/CLSegs.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/CLBrowser.o command_line/CmdLine/Src/CLBrowser.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLDependencies.o command_line/CmdLine/Src/CLDependencies.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLFileOps.o command_line/CmdLine/Src/CLFileOps.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLIncludeFileCache.o command_line/CmdLine/Src/CLIncludeFileCache.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLLicenses.o command_line/CmdLine/Src/CLLicenses.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLLoadAndCache.o command_line/CmdLine/Src/CLLoadAndCache.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLMain.o command_line/CmdLine/Src/CLMain.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLPluginRequests.o command_line/CmdLine/Src/CLPluginRequests.cpp -#~/bin/mwccppc $MWC_FLAGS -o objs/CLPrefs.o command_line/CmdLine/Src/CLPrefs.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLTarg.o command_line/CmdLine/Src/CLTarg.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLToolExec.o command_line/CmdLine/Src/CLToolExec.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CLWriteObjectFile.o command_line/CmdLine/Src/CLWriteObjectFile.c -#~/bin/mwccppc $MWC_FLAGS -o objs/uFileTypeMappings.o command_line/CmdLine/Src/uFileTypeMappings.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/ParserGlue-mach-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c -~/bin/mwccppc $MWC_FLAGS -o objs/TargetWarningHelpers-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetWarningHelpers-ppc-cc.c -# +# CmdLine +~/bin/mwccppc $MWC_FLAGS -o objs/CLCompilerLinkerDropin_V10.o command_line/CmdLine/Src/Callbacks/CLCompilerLinkerDropin_V10.cpp +~/bin/mwccppc $MWC_FLAGS -o objs/CLDropinCallbacks_V10.o command_line/CmdLine/Src/Callbacks/CLDropinCallbacks_V10.cpp +~/bin/mwccppc $MWC_FLAGS -o objs/CLParserCallbacks_V1.o command_line/CmdLine/Src/Callbacks/CLParserCallbacks_V1.cpp + +~/bin/mwccppc $MWC_FLAGS -o objs/CLStaticMain.o command_line/CmdLine/Src/Clients/CLStaticMain.c +~/bin/mwccppc $MWC_FLAGS -o objs/ClientGlue.o command_line/CmdLine/Src/Clients/ClientGlue.c + +~/bin/mwccppc $MWC_FLAGS -o objs/CLErrors.o command_line/CmdLine/Src/Envir/CLErrors.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLIO.o command_line/CmdLine/Src/Envir/CLIO.c + +~/bin/mwccppc $MWC_FLAGS -o objs/ErrMgr.o command_line/CmdLine/Src/MacEmul/ErrMgr.c +~/bin/mwccppc $MWC_FLAGS -o objs/Files.o command_line/CmdLine/Src/MacEmul/Files.c +~/bin/mwccppc $MWC_FLAGS -o objs/LowMem.o command_line/CmdLine/Src/MacEmul/LowMem.c +~/bin/mwccppc $MWC_FLAGS -o objs/Memory.o command_line/CmdLine/Src/MacEmul/Memory.c +~/bin/mwccppc $MWC_FLAGS -o objs/Resources.o command_line/CmdLine/Src/MacEmul/Resources.c +~/bin/mwccppc $MWC_FLAGS -o objs/ResourceStrings.o command_line/CmdLine/Src/MacEmul/ResourceStrings.c +~/bin/mwccppc $MWC_FLAGS -o objs/TextUtils.o command_line/CmdLine/Src/MacEmul/TextUtils.c + +~/bin/mwccppc $MWC_FLAGS -o objs/FileHandles.o command_line/CmdLine/Src/OSLib/FileHandles.c +~/bin/mwccppc $MWC_FLAGS -o objs/Generic.o command_line/CmdLine/Src/OSLib/Generic.c +~/bin/mwccppc $MWC_FLAGS -o objs/MacFileTypes.o command_line/CmdLine/Src/OSLib/MacFileTypes.c +~/bin/mwccppc $MWC_FLAGS -o objs/MacSpecs.o command_line/CmdLine/Src/OSLib/MacSpecs.c +~/bin/mwccppc $MWC_FLAGS -o objs/MemUtils.o command_line/CmdLine/Src/OSLib/MemUtils.c +~/bin/mwccppc $MWC_FLAGS -o objs/Posix.o command_line/CmdLine/Src/OSLib/Posix.c +~/bin/mwccppc $MWC_FLAGS -o objs/StringExtras.o command_line/CmdLine/Src/OSLib/StringExtras.c +~/bin/mwccppc $MWC_FLAGS -o objs/StringUtils.o command_line/CmdLine/Src/OSLib/StringUtils.c + +~/bin/mwccppc $MWC_FLAGS -o objs/CLPlugins.o command_line/CmdLine/Src/Plugins/CLPlugins.c + +~/bin/mwccppc $MWC_FLAGS -o objs/CLAccessPaths.o command_line/CmdLine/Src/Project/CLAccessPaths.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLFiles.o command_line/CmdLine/Src/Project/CLFiles.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLOverlays.o command_line/CmdLine/Src/Project/CLOverlays.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLProj.o command_line/CmdLine/Src/Project/CLProj.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLSegs.o command_line/CmdLine/Src/Project/CLSegs.c + +~/bin/mwccppc $MWC_FLAGS -o objs/CLBrowser.o command_line/CmdLine/Src/CLBrowser.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLDependencies.o command_line/CmdLine/Src/CLDependencies.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLFileOps.o command_line/CmdLine/Src/CLFileOps.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLFileTypes.o command_line/CmdLine/Src/CLFileTypes.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLIncludeFileCache.o command_line/CmdLine/Src/CLIncludeFileCache.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLLicenses.o command_line/CmdLine/Src/CLLicenses.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLLoadAndCache.o command_line/CmdLine/Src/CLLoadAndCache.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLMain.o command_line/CmdLine/Src/CLMain.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLPluginRequests.o command_line/CmdLine/Src/CLPluginRequests.cpp +~/bin/mwccppc $MWC_FLAGS -o objs/CLPrefs.o command_line/CmdLine/Src/CLPrefs.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLTarg.o command_line/CmdLine/Src/CLTarg.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLToolExec.o command_line/CmdLine/Src/CLToolExec.c +~/bin/mwccppc $MWC_FLAGS -o objs/CLWriteObjectFile.o command_line/CmdLine/Src/CLWriteObjectFile.c + +~/bin/mwccppc $MWC_FLAGS -o objs/ParserGlue-mach-ppc-cc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/ParserGlue-mach-ppc-cc.c +~/bin/mwccppc $MWC_FLAGS -o objs/TargetOptimizer-ppc-mach.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Options/Glue/TargetOptimizer-ppc-mach.c + ~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/cc-mach-ppc.c ~/bin/mwccppc $MWC_FLAGS -o objs/libimp-mach-ppc.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Plugin/libimp-mach-ppc.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc-mw.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c -# + +~/bin/mwccppc $MWC_FLAGS -o objs/cc-mach-ppc-mw.o compiler_and_linker/CmdLine_Tools/MacOS_PPC/Tools_PPC/Src/Static/cc-mach-ppc-mw.c + ~/bin/mwccppc $MWC_FLAGS -o objs/CPrep.o compiler_and_linker/FrontEnd/C/CPrep.c ~/bin/mwccppc $MWC_FLAGS -o objs/CPrepTokenizer.o compiler_and_linker/FrontEnd/C/CPrepTokenizer.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CScope.o compiler_and_linker/FrontEnd/C/CScope.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/CompilerTools.o compiler_and_linker/FrontEnd/Common/CompilerTools.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/AddPropagation.o compiler_and_linker/unsorted/AddPropagation.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Alias.o compiler_and_linker/unsorted/Alias.c -#~/bin/mwccppc $MWC_FLAGS -o objs/BitVectors.o compiler_and_linker/unsorted/BitVectors.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CABI.o compiler_and_linker/unsorted/CABI.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CBrowse.o compiler_and_linker/unsorted/CBrowse.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CClass.o compiler_and_linker/unsorted/CClass.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CCompiler.o compiler_and_linker/unsorted/CCompiler.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CDecl.o compiler_and_linker/unsorted/CDecl.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CError.o compiler_and_linker/unsorted/CError.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CException.o compiler_and_linker/unsorted/CException.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CExpr.o compiler_and_linker/unsorted/CExpr.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CExpr2.o compiler_and_linker/unsorted/CExpr2.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CExprConvMatch.o compiler_and_linker/unsorted/CExprConvMatch.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CFunc.o compiler_and_linker/unsorted/CFunc.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CInit.o compiler_and_linker/unsorted/CInit.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CInline.o compiler_and_linker/unsorted/CInline.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CInt64.o compiler_and_linker/unsorted/CInt64.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CIRTransform.o compiler_and_linker/unsorted/CIRTransform.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CMachine.o compiler_and_linker/unsorted/CMachine.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CMangler.o compiler_and_linker/unsorted/CMangler.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CObjC.o compiler_and_linker/unsorted/CObjC.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CObjCModern.o compiler_and_linker/unsorted/CObjCModern.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CodeGen.o compiler_and_linker/unsorted/CodeGen.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CodeGenOptPPC.o compiler_and_linker/unsorted/CodeGenOptPPC.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CodeMotion.o compiler_and_linker/unsorted/CodeMotion.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Coloring.o compiler_and_linker/unsorted/Coloring.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ConstantPropagation.o compiler_and_linker/unsorted/ConstantPropagation.c -#~/bin/mwccppc $MWC_FLAGS -o objs/COptimizer.o compiler_and_linker/unsorted/COptimizer.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CopyPropagation.o compiler_and_linker/unsorted/CopyPropagation.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CParser.o compiler_and_linker/unsorted/CParser.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CPrec.o compiler_and_linker/unsorted/CPrec.c +~/bin/mwccppc $MWC_FLAGS -o objs/CScope.o compiler_and_linker/FrontEnd/C/CScope.c + +~/bin/mwccppc $MWC_FLAGS -o objs/CompilerTools.o compiler_and_linker/FrontEnd/Common/CompilerTools.c + +~/bin/mwccppc $MWC_FLAGS -o objs/AddPropagation.o compiler_and_linker/unsorted/AddPropagation.c +~/bin/mwccppc $MWC_FLAGS -o objs/Alias.o compiler_and_linker/unsorted/Alias.c +~/bin/mwccppc $MWC_FLAGS -o objs/BitVectors.o compiler_and_linker/unsorted/BitVectors.c +~/bin/mwccppc $MWC_FLAGS -o objs/CABI.o compiler_and_linker/unsorted/CABI.c +~/bin/mwccppc $MWC_FLAGS -o objs/CBrowse.o compiler_and_linker/unsorted/CBrowse.c +~/bin/mwccppc $MWC_FLAGS -o objs/CClass.o compiler_and_linker/unsorted/CClass.c +~/bin/mwccppc $MWC_FLAGS -o objs/CCompiler.o compiler_and_linker/unsorted/CCompiler.c +~/bin/mwccppc $MWC_FLAGS -o objs/CDecl.o compiler_and_linker/unsorted/CDecl.c +~/bin/mwccppc $MWC_FLAGS -o objs/CError.o compiler_and_linker/unsorted/CError.c +~/bin/mwccppc $MWC_FLAGS -o objs/CException.o compiler_and_linker/unsorted/CException.c +~/bin/mwccppc $MWC_FLAGS -o objs/CExpr.o compiler_and_linker/unsorted/CExpr.c +~/bin/mwccppc $MWC_FLAGS -o objs/CExpr2.o compiler_and_linker/unsorted/CExpr2.c +~/bin/mwccppc $MWC_FLAGS -o objs/CExprConvMatch.o compiler_and_linker/unsorted/CExprConvMatch.c +~/bin/mwccppc $MWC_FLAGS -o objs/CFunc.o compiler_and_linker/unsorted/CFunc.c +~/bin/mwccppc $MWC_FLAGS -o objs/CInit.o compiler_and_linker/unsorted/CInit.c +~/bin/mwccppc $MWC_FLAGS -o objs/CInline.o compiler_and_linker/unsorted/CInline.c +~/bin/mwccppc $MWC_FLAGS -o objs/CInt64.o compiler_and_linker/unsorted/CInt64.c +~/bin/mwccppc $MWC_FLAGS -o objs/CIRTransform.o compiler_and_linker/unsorted/CIRTransform.c +~/bin/mwccppc $MWC_FLAGS -o objs/CMachine.o compiler_and_linker/unsorted/CMachine.c +~/bin/mwccppc $MWC_FLAGS -o objs/CMangler.o compiler_and_linker/unsorted/CMangler.c +~/bin/mwccppc $MWC_FLAGS -o objs/CObjC.o compiler_and_linker/unsorted/CObjC.c +~/bin/mwccppc $MWC_FLAGS -o objs/CObjCModern.o compiler_and_linker/unsorted/CObjCModern.c +~/bin/mwccppc $MWC_FLAGS -o objs/CodeGen.o compiler_and_linker/unsorted/CodeGen.c +~/bin/mwccppc $MWC_FLAGS -o objs/CodeGenOptPPC.o compiler_and_linker/unsorted/CodeGenOptPPC.c +~/bin/mwccppc $MWC_FLAGS -o objs/CodeMotion.o compiler_and_linker/unsorted/CodeMotion.c +~/bin/mwccppc $MWC_FLAGS -o objs/Coloring.o compiler_and_linker/unsorted/Coloring.c +~/bin/mwccppc $MWC_FLAGS -o objs/ConstantPropagation.o compiler_and_linker/unsorted/ConstantPropagation.c +~/bin/mwccppc $MWC_FLAGS -o objs/COptimizer.o compiler_and_linker/unsorted/COptimizer.c +~/bin/mwccppc $MWC_FLAGS -o objs/CopyPropagation.o compiler_and_linker/unsorted/CopyPropagation.c +~/bin/mwccppc $MWC_FLAGS -o objs/CParser.o compiler_and_linker/unsorted/CParser.c +~/bin/mwccppc $MWC_FLAGS -o objs/CPrec.o compiler_and_linker/unsorted/CPrec.c ~/bin/mwccppc $MWC_FLAGS -o objs/CPreprocess.o compiler_and_linker/unsorted/CPreprocess.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CRTTI.o compiler_and_linker/unsorted/CRTTI.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CSOM.o compiler_and_linker/unsorted/CSOM.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateClass.o compiler_and_linker/unsorted/CTemplateClass.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateFunc.o compiler_and_linker/unsorted/CTemplateFunc.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateNew.o compiler_and_linker/unsorted/CTemplateNew.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateTools.o compiler_and_linker/unsorted/CTemplateTools.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Exceptions.o compiler_and_linker/unsorted/Exceptions.c -#~/bin/mwccppc $MWC_FLAGS -o objs/FuncLevelAsmPPC.o compiler_and_linker/unsorted/FuncLevelAsmPPC.c -#~/bin/mwccppc $MWC_FLAGS -o objs/FunctionCalls.o compiler_and_linker/unsorted/FunctionCalls.c -#~/bin/mwccppc $MWC_FLAGS -o objs/GCCInlineAsm.o compiler_and_linker/unsorted/GCCInlineAsm.c -#~/bin/mwccppc $MWC_FLAGS -o objs/GenStabs.o compiler_and_linker/unsorted/GenStabs.c -#~/bin/mwccppc $MWC_FLAGS -o objs/GlobalOptimizer.o compiler_and_linker/unsorted/GlobalOptimizer.c -#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsm.o compiler_and_linker/unsorted/InlineAsm.c -#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmMnemonicsPPC.o compiler_and_linker/unsorted/InlineAsmMnemonicsPPC.c -#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmPPC.o compiler_and_linker/unsorted/InlineAsmPPC.c -#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmRegisters.o compiler_and_linker/unsorted/InlineAsmRegisters.c -#~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmRegistersPPC.o compiler_and_linker/unsorted/InlineAsmRegistersPPC.c -#~/bin/mwccppc $MWC_FLAGS -o objs/InstrSelection.o compiler_and_linker/unsorted/InstrSelection.c -#~/bin/mwccppc $MWC_FLAGS -o objs/InterferenceGraph.o compiler_and_linker/unsorted/InterferenceGraph.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Intrinsics.o compiler_and_linker/unsorted/Intrinsics.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroBitVect.o compiler_and_linker/unsorted/IroBitVect.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroCSE.o compiler_and_linker/unsorted/IroCSE.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroDump.o compiler_and_linker/unsorted/IroDump.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroEmptyLoop.o compiler_and_linker/unsorted/IroEmptyLoop.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroEval.o compiler_and_linker/unsorted/IroEval.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroExprRegeneration.o compiler_and_linker/unsorted/IroExprRegeneration.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroFlowgraph.o compiler_and_linker/unsorted/IroFlowgraph.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroJump.o compiler_and_linker/unsorted/IroJump.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroLinearForm.o compiler_and_linker/unsorted/IroLinearForm.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroLoop.o compiler_and_linker/unsorted/IroLoop.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroMalloc.o compiler_and_linker/unsorted/IroMalloc.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroPointerAnalysis.o compiler_and_linker/unsorted/IroPointerAnalysis.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroPropagate.o compiler_and_linker/unsorted/IroPropagate.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IrOptimizer.o compiler_and_linker/unsorted/IrOptimizer.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroRangePropagation.o compiler_and_linker/unsorted/IroRangePropagation.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroSubable.o compiler_and_linker/unsorted/IroSubable.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroTransform.o compiler_and_linker/unsorted/IroTransform.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroUnrollLoop.o compiler_and_linker/unsorted/IroUnrollLoop.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IROUseDef.o compiler_and_linker/unsorted/IROUseDef.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroUtil.o compiler_and_linker/unsorted/IroUtil.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IroVars.o compiler_and_linker/unsorted/IroVars.c -#~/bin/mwccppc $MWC_FLAGS -o objs/LiveVariables.o compiler_and_linker/unsorted/LiveVariables.c -#~/bin/mwccppc $MWC_FLAGS -o objs/LoadDeletion.o compiler_and_linker/unsorted/LoadDeletion.c -#~/bin/mwccppc $MWC_FLAGS -o objs/LoopDetection.o compiler_and_linker/unsorted/LoopDetection.c -#~/bin/mwccppc $MWC_FLAGS -o objs/LoopOptimization.o compiler_and_linker/unsorted/LoopOptimization.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachO.o compiler_and_linker/unsorted/MachO.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation601.o compiler_and_linker/unsorted/MachineSimulation601.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation603.o compiler_and_linker/unsorted/MachineSimulation603.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation603e.o compiler_and_linker/unsorted/MachineSimulation603e.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation604.o compiler_and_linker/unsorted/MachineSimulation604.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation7400.o compiler_and_linker/unsorted/MachineSimulation7400.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation750.o compiler_and_linker/unsorted/MachineSimulation750.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation821.o compiler_and_linker/unsorted/MachineSimulation821.c -#~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulationAltiVec.o compiler_and_linker/unsorted/MachineSimulationAltiVec.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ObjGenMachO.o compiler_and_linker/unsorted/ObjGenMachO.c -#~/bin/mwccppc $MWC_FLAGS -o objs/OpcodeInfo.o compiler_and_linker/unsorted/OpcodeInfo.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Operands.o compiler_and_linker/unsorted/Operands.c -#~/bin/mwccppc $MWC_FLAGS -o objs/PCode.o compiler_and_linker/unsorted/PCode.c -#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeAssembly.o compiler_and_linker/unsorted/PCodeAssembly.c -#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeInfo.o compiler_and_linker/unsorted/PCodeInfo.c -#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeListing.o compiler_and_linker/unsorted/PCodeListing.c -#~/bin/mwccppc $MWC_FLAGS -o objs/PCodeUtilities.o compiler_and_linker/unsorted/PCodeUtilities.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Peephole.o compiler_and_linker/unsorted/Peephole.c -#~/bin/mwccppc $MWC_FLAGS -o objs/PPCError.o compiler_and_linker/unsorted/PPCError.c -#~/bin/mwccppc $MWC_FLAGS -o objs/RegisterInfo.o compiler_and_linker/unsorted/RegisterInfo.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Registers.o compiler_and_linker/unsorted/Registers.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ScanFloat.o compiler_and_linker/unsorted/ScanFloat.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Scheduler.o compiler_and_linker/unsorted/Scheduler.c -#~/bin/mwccppc $MWC_FLAGS -o objs/SpillCode.o compiler_and_linker/unsorted/SpillCode.c -#~/bin/mwccppc $MWC_FLAGS -o objs/StackFrame.o compiler_and_linker/unsorted/StackFrame.c -#~/bin/mwccppc $MWC_FLAGS -o objs/StrengthReduction.o compiler_and_linker/unsorted/StrengthReduction.c -#~/bin/mwccppc $MWC_FLAGS -o objs/StructMoves.o compiler_and_linker/unsorted/StructMoves.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Switch.o compiler_and_linker/unsorted/Switch.c -#~/bin/mwccppc $MWC_FLAGS -o objs/TOC.o compiler_and_linker/unsorted/TOC.c -#~/bin/mwccppc $MWC_FLAGS -o objs/uDump.o compiler_and_linker/unsorted/uDump.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Unmangle.o compiler_and_linker/unsorted/Unmangle.c -#~/bin/mwccppc $MWC_FLAGS -o objs/UseDefChains.o compiler_and_linker/unsorted/UseDefChains.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ValueNumbering.o compiler_and_linker/unsorted/ValueNumbering.c -#~/bin/mwccppc $MWC_FLAGS -o objs/VectorArraysToRegs.o compiler_and_linker/unsorted/VectorArraysToRegs.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/Arguments.o unsorted/Arguments.c -#~/bin/mwccppc $MWC_FLAGS -o objs/CmdLineBuildDate.o unsorted/CmdLineBuildDate.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Help.o unsorted/Help.c -#~/bin/mwccppc $MWC_FLAGS -o objs/IO.o unsorted/IO.c -#~/bin/mwccppc $MWC_FLAGS -o objs/OptimizerHelpers.o unsorted/OptimizerHelpers.c -~/bin/mwccppc $MWC_FLAGS -o objs/Option.o unsorted/Option.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Parameter.o unsorted/Parameter.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ParserErrors.o unsorted/ParserErrors.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ParserFace.o unsorted/ParserFace.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ParserHelpers.o unsorted/ParserHelpers.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ParserHelpers-cc.o unsorted/ParserHelpers-cc.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Projects.o unsorted/Projects.c -#~/bin/mwccppc $MWC_FLAGS -o objs/StaticParserGlue.o unsorted/StaticParserGlue.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Targets.o unsorted/Targets.c -~/bin/mwccppc $MWC_FLAGS -o objs/TargetOptimizer-ppc-mach.o unsorted/TargetOptimizer-ppc-mach.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers.o unsorted/ToolHelpers.c -#~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers-cc.o unsorted/ToolHelpers-cc.c -#~/bin/mwccppc $MWC_FLAGS -o objs/uContext1.o unsorted/uContext1.cpp -#~/bin/mwccppc $MWC_FLAGS -o objs/uContextCL.o unsorted/uContextCL.cpp -#~/bin/mwccppc $MWC_FLAGS -o objs/uContextParser.o unsorted/uContextParser.cpp -#~/bin/mwccppc $MWC_FLAGS -o objs/uContextSecret.o unsorted/uContextSecret.cpp -#~/bin/mwccppc $MWC_FLAGS -o objs/uCOS.o unsorted/uCOS.c -#~/bin/mwccppc $MWC_FLAGS -o objs/uLibImporter.o unsorted/uLibImporter.c -#~/bin/mwccppc $MWC_FLAGS -o objs/Utils.o unsorted/Utils.c -# -#~/bin/mwccppc $MWC_FLAGS -o objs/WarningHelpers.o command_line/C++_Parser/Src/Library/WarningHelpers.c +~/bin/mwccppc $MWC_FLAGS -o objs/CRTTI.o compiler_and_linker/unsorted/CRTTI.c +~/bin/mwccppc $MWC_FLAGS -o objs/CSOM.o compiler_and_linker/unsorted/CSOM.c +~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateClass.o compiler_and_linker/unsorted/CTemplateClass.c +~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateFunc.o compiler_and_linker/unsorted/CTemplateFunc.c +~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateNew.o compiler_and_linker/unsorted/CTemplateNew.c +~/bin/mwccppc $MWC_FLAGS -o objs/CTemplateTools.o compiler_and_linker/unsorted/CTemplateTools.c +~/bin/mwccppc $MWC_FLAGS -o objs/Exceptions.o compiler_and_linker/unsorted/Exceptions.c +~/bin/mwccppc $MWC_FLAGS -o objs/FuncLevelAsmPPC.o compiler_and_linker/unsorted/FuncLevelAsmPPC.c +~/bin/mwccppc $MWC_FLAGS -o objs/FunctionCalls.o compiler_and_linker/unsorted/FunctionCalls.c +~/bin/mwccppc $MWC_FLAGS -o objs/GCCInlineAsm.o compiler_and_linker/unsorted/GCCInlineAsm.c +~/bin/mwccppc $MWC_FLAGS -o objs/GenStabs.o compiler_and_linker/unsorted/GenStabs.c +~/bin/mwccppc $MWC_FLAGS -o objs/GlobalOptimizer.o compiler_and_linker/unsorted/GlobalOptimizer.c +~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsm.o compiler_and_linker/unsorted/InlineAsm.c +~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmMnemonicsPPC.o compiler_and_linker/unsorted/InlineAsmMnemonicsPPC.c +~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmPPC.o compiler_and_linker/unsorted/InlineAsmPPC.c +~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmRegisters.o compiler_and_linker/unsorted/InlineAsmRegisters.c +~/bin/mwccppc $MWC_FLAGS -o objs/InlineAsmRegistersPPC.o compiler_and_linker/unsorted/InlineAsmRegistersPPC.c +~/bin/mwccppc $MWC_FLAGS -o objs/InstrSelection.o compiler_and_linker/unsorted/InstrSelection.c +~/bin/mwccppc $MWC_FLAGS -o objs/InterferenceGraph.o compiler_and_linker/unsorted/InterferenceGraph.c +~/bin/mwccppc $MWC_FLAGS -o objs/Intrinsics.o compiler_and_linker/unsorted/Intrinsics.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroBitVect.o compiler_and_linker/unsorted/IroBitVect.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroCSE.o compiler_and_linker/unsorted/IroCSE.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroDump.o compiler_and_linker/unsorted/IroDump.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroEmptyLoop.o compiler_and_linker/unsorted/IroEmptyLoop.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroEval.o compiler_and_linker/unsorted/IroEval.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroExprRegeneration.o compiler_and_linker/unsorted/IroExprRegeneration.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroFlowgraph.o compiler_and_linker/unsorted/IroFlowgraph.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroJump.o compiler_and_linker/unsorted/IroJump.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroLinearForm.o compiler_and_linker/unsorted/IroLinearForm.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroLoop.o compiler_and_linker/unsorted/IroLoop.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroMalloc.o compiler_and_linker/unsorted/IroMalloc.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroPointerAnalysis.o compiler_and_linker/unsorted/IroPointerAnalysis.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroPropagate.o compiler_and_linker/unsorted/IroPropagate.c +~/bin/mwccppc $MWC_FLAGS -o objs/IrOptimizer.o compiler_and_linker/unsorted/IrOptimizer.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroRangePropagation.o compiler_and_linker/unsorted/IroRangePropagation.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroSubable.o compiler_and_linker/unsorted/IroSubable.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroTransform.o compiler_and_linker/unsorted/IroTransform.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroUnrollLoop.o compiler_and_linker/unsorted/IroUnrollLoop.c +~/bin/mwccppc $MWC_FLAGS -o objs/IROUseDef.o compiler_and_linker/unsorted/IROUseDef.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroUtil.o compiler_and_linker/unsorted/IroUtil.c +~/bin/mwccppc $MWC_FLAGS -o objs/IroVars.o compiler_and_linker/unsorted/IroVars.c +~/bin/mwccppc $MWC_FLAGS -o objs/LiveVariables.o compiler_and_linker/unsorted/LiveVariables.c +~/bin/mwccppc $MWC_FLAGS -o objs/LoadDeletion.o compiler_and_linker/unsorted/LoadDeletion.c +~/bin/mwccppc $MWC_FLAGS -o objs/LoopDetection.o compiler_and_linker/unsorted/LoopDetection.c +~/bin/mwccppc $MWC_FLAGS -o objs/LoopOptimization.o compiler_and_linker/unsorted/LoopOptimization.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachO.o compiler_and_linker/unsorted/MachO.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation601.o compiler_and_linker/unsorted/MachineSimulation601.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation603.o compiler_and_linker/unsorted/MachineSimulation603.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation603e.o compiler_and_linker/unsorted/MachineSimulation603e.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation604.o compiler_and_linker/unsorted/MachineSimulation604.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation7400.o compiler_and_linker/unsorted/MachineSimulation7400.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation750.o compiler_and_linker/unsorted/MachineSimulation750.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulation821.o compiler_and_linker/unsorted/MachineSimulation821.c +~/bin/mwccppc $MWC_FLAGS -o objs/MachineSimulationAltiVec.o compiler_and_linker/unsorted/MachineSimulationAltiVec.c +~/bin/mwccppc $MWC_FLAGS -o objs/ObjGenMachO.o compiler_and_linker/unsorted/ObjGenMachO.c +~/bin/mwccppc $MWC_FLAGS -o objs/OpcodeInfo.o compiler_and_linker/unsorted/OpcodeInfo.c +~/bin/mwccppc $MWC_FLAGS -o objs/Operands.o compiler_and_linker/unsorted/Operands.c +~/bin/mwccppc $MWC_FLAGS -o objs/PCode.o compiler_and_linker/unsorted/PCode.c +~/bin/mwccppc $MWC_FLAGS -o objs/PCodeAssembly.o compiler_and_linker/unsorted/PCodeAssembly.c +~/bin/mwccppc $MWC_FLAGS -o objs/PCodeInfo.o compiler_and_linker/unsorted/PCodeInfo.c +~/bin/mwccppc $MWC_FLAGS -o objs/PCodeListing.o compiler_and_linker/unsorted/PCodeListing.c +~/bin/mwccppc $MWC_FLAGS -o objs/PCodeUtilities.o compiler_and_linker/unsorted/PCodeUtilities.c +~/bin/mwccppc $MWC_FLAGS -o objs/Peephole.o compiler_and_linker/unsorted/Peephole.c +~/bin/mwccppc $MWC_FLAGS -o objs/PPCError.o compiler_and_linker/unsorted/PPCError.c +~/bin/mwccppc $MWC_FLAGS -o objs/RegisterInfo.o compiler_and_linker/unsorted/RegisterInfo.c +~/bin/mwccppc $MWC_FLAGS -o objs/Registers.o compiler_and_linker/unsorted/Registers.c +~/bin/mwccppc $MWC_FLAGS -o objs/ScanFloat.o compiler_and_linker/unsorted/ScanFloat.c +~/bin/mwccppc $MWC_FLAGS -o objs/Scheduler.o compiler_and_linker/unsorted/Scheduler.c +~/bin/mwccppc $MWC_FLAGS -o objs/SpillCode.o compiler_and_linker/unsorted/SpillCode.c +~/bin/mwccppc $MWC_FLAGS -o objs/StackFrame.o compiler_and_linker/unsorted/StackFrame.c +~/bin/mwccppc $MWC_FLAGS -o objs/StrengthReduction.o compiler_and_linker/unsorted/StrengthReduction.c +~/bin/mwccppc $MWC_FLAGS -o objs/StructMoves.o compiler_and_linker/unsorted/StructMoves.c +~/bin/mwccppc $MWC_FLAGS -o objs/Switch.o compiler_and_linker/unsorted/Switch.c +~/bin/mwccppc $MWC_FLAGS -o objs/TOC.o compiler_and_linker/unsorted/TOC.c +~/bin/mwccppc $MWC_FLAGS -o objs/uDump.o compiler_and_linker/unsorted/uDump.c +~/bin/mwccppc $MWC_FLAGS -o objs/Unmangle.o compiler_and_linker/unsorted/Unmangle.c +~/bin/mwccppc $MWC_FLAGS -o objs/UseDefChains.o compiler_and_linker/unsorted/UseDefChains.c +~/bin/mwccppc $MWC_FLAGS -o objs/ValueNumbering.o compiler_and_linker/unsorted/ValueNumbering.c +~/bin/mwccppc $MWC_FLAGS -o objs/VectorArraysToRegs.o compiler_and_linker/unsorted/VectorArraysToRegs.c + +~/bin/mwccppc $MWC_FLAGS -o objs/CmdLineBuildDate.o unsorted/CmdLineBuildDate.c +~/bin/mwccppc $MWC_FLAGS -o objs/uLibImporter.o unsorted/uLibImporter.c + +# C++_Parser +~/bin/mwccppc $MWC_FLAGS -o objs/Arguments.o command_line/C++_Parser/Src/Library/Arguments.c +~/bin/mwccppc $MWC_FLAGS -o objs/Help.o command_line/C++_Parser/Src/Library/Help.c +~/bin/mwccppc $MWC_FLAGS -o objs/IO.o command_line/C++_Parser/Src/Library/IO.c +~/bin/mwccppc $MWC_FLAGS -o objs/Option.o command_line/C++_Parser/Src/Library/Option.c +~/bin/mwccppc $MWC_FLAGS -o objs/Parameter.o command_line/C++_Parser/Src/Library/Parameter.c +~/bin/mwccppc $MWC_FLAGS -o objs/ParserErrors.o command_line/C++_Parser/Src/Library/ParserErrors.c +~/bin/mwccppc $MWC_FLAGS -o objs/ParserFace.o command_line/C++_Parser/Src/Library/ParserFace.c +~/bin/mwccppc $MWC_FLAGS -o objs/ParserHelpers.o command_line/C++_Parser/Src/Library/ParserHelpers.c +~/bin/mwccppc $MWC_FLAGS -o objs/ParserHelpers-cc.o command_line/C++_Parser/Src/Library/ParserHelpers-cc.c +~/bin/mwccppc $MWC_FLAGS -o objs/Projects.o command_line/C++_Parser/Src/Library/Projects.c +~/bin/mwccppc $MWC_FLAGS -o objs/StaticParserGlue.o command_line/C++_Parser/Src/Library/StaticParserGlue.c +~/bin/mwccppc $MWC_FLAGS -o objs/Targets.o command_line/C++_Parser/Src/Library/Targets.c +~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers.o command_line/C++_Parser/Src/Library/ToolHelpers.c +~/bin/mwccppc $MWC_FLAGS -o objs/ToolHelpers-cc.o command_line/C++_Parser/Src/Library/ToolHelpers-cc.c +~/bin/mwccppc $MWC_FLAGS -o objs/Utils.o command_line/C++_Parser/Src/Library/Utils.c + +~/bin/mwccppc $MWC_FLAGS -o objs/OptimizerHelpers.o command_line/C++_Parser/Src/Library/OptimizerHelpers.c +~/bin/mwccppc $MWC_FLAGS -o objs/StdTargetWarningHelpers-cc.o command_line/C++_Parser/Src/Library/StdTargetWarningHelpers-cc.c +~/bin/mwccppc $MWC_FLAGS -o objs/WarningHelpers.o command_line/C++_Parser/Src/Library/WarningHelpers.c + +~/bin/mwccppc $MWC_FLAGS -o objs/COSToolsCLT.o command_line/PluginLib/Src/Internal/COSToolsCLT.c +~/bin/mwccppc $MWC_FLAGS -o objs/CWSecretPluginCallbacks.o command_line/PluginLib/Src/Internal/CWSecretPluginCallbacks.cpp + +~/bin/mwccppc $MWC_FLAGS -o objs/CWParserPluginsPrivate.o command_line/PluginLib/Src/Library/CWParserPluginsPrivate.cpp +~/bin/mwccppc $MWC_FLAGS -o objs/CWPluginsPrivate.o command_line/PluginLib/Src/Library/CWPluginsPrivate.cpp +~/bin/mwccppc $MWC_FLAGS -o objs/DropInCompilerLinkerPrivate.o command_line/PluginLib/Src/Library/DropInCompilerLinkerPrivate.cpp ld /usr/lib/crt1.o \ objs/CLStaticMain.o \ @@ -235,7 +240,7 @@ ld /usr/lib/crt1.o \ objs/Memory.o \ objs/Files.o \ objs/TextUtils.o \ - objs/uFileTypeMappings.o \ + objs/CLFileTypes.o \ objs/CLFiles.o \ objs/CLOverlays.o \ objs/CLSegs.o \ @@ -255,7 +260,7 @@ ld /usr/lib/crt1.o \ objs/libimp-mach-ppc.o \ objs/TargetOptimizer-ppc-mach.o \ objs/OptimizerHelpers.o \ - objs/TargetWarningHelpers-ppc-cc.o \ + objs/StdTargetWarningHelpers-cc.o \ objs/WarningHelpers.o \ \ objs/CCompiler.o \ @@ -389,11 +394,11 @@ ld /usr/lib/crt1.o \ objs/Utils.o \ objs/Parameter.o \ objs/Help.o \ - objs/uContext1.o \ - objs/uContextCL.o \ - objs/uContextSecret.o \ - objs/uCOS.o \ - objs/uContextParser.o \ + objs/CWPluginsPrivate.o \ + objs/DropInCompilerLinkerPrivate.o \ + objs/CWSecretPluginCallbacks.o \ + objs/COSToolsCLT.o \ + objs/CWParserPluginsPrivate.o \ objs/uLibImporter.o \ objs/CmdLineBuildDate.o \ \ diff --git a/unsorted/Arguments.c b/unsorted/Arguments.c deleted file mode 100644 index 631f282..0000000 --- a/unsorted/Arguments.c +++ /dev/null @@ -1,590 +0,0 @@ -#include "parser.h" - -char compat; -char *MAINOPTCHAR; -char *FIRSTARGCHAR; -char *SEPOPTSTR; -char SEPOPTCHAR; -char SEP1; -char SEP2; -char SEP3; -char RESPFILECHAR; -char *RESPFILESTR; -static ArgToken *argtoks; -static int numargtoks; -static int maxargtoks; -unsigned char parserDebug; -static unsigned char in_response_file; -static int margc; -static int margind; -static char **margv; -static OSFileHandle respfilehandle; -static char *respfile; -static char *respfilestart; -static unsigned long respfilesize; -static int scantok; -anon0_50 linkargs; -anon0_50 prelinkargs; -anon0_50 postlinkargs; - -static void Arg_AddToken(short val, char *text); -static void Arg_Setup(int argc, char **argv); -static void Arg_SkipRespFileWS(); -static unsigned char Arg_OpenRespFile(const char *name); -static void Arg_CloseRespFile(); -static char *Arg_GetRespFileToken(); -static char *Arg_GetNext(unsigned char allow_resp); -static unsigned char Arg_GotMore(); -static void Arg_Parse(); -static void Arg_GrowArgs(anon0_50 *ta); -static void Arg_GrowArg(anon0_50 *ta, char *txt); - -static void Arg_AddToken(short val, char *text) { - ArgToken *cur; - ArgToken *prev; - ArgToken *pprev; - ArgToken *ppprev; - ArgToken *pppprev; - - if (numargtoks > 0) - prev = &argtoks[numargtoks - 1]; - else - prev = 0; - - if (prev && prev->val == ATK_ARG && prev->text[0] == 0) { - pppprev = ppprev = pprev = 0; - if (numargtoks > 3) - pppprev = &argtoks[numargtoks - 4]; - if (numargtoks > 2) - ppprev = &argtoks[numargtoks - 3]; - if (numargtoks > 1) - pprev = &argtoks[numargtoks - 2]; - - if (pprev) { - if ((int) val == ATK_ARG_END && (pprev->val == ATK_COMMA || pprev->val == ATK_EQUALS) && (ppprev->val != ATK_ARG || pppprev->val != ATK_OPTION)) { - if (parserDebug) - printf("Coalescing args with '%s'\n", Arg_GetTokenName(pprev)); - val = pprev->val; - numargtoks -= 2; - } else if (pprev->val == ATK_ARG_END && ((int) val == ATK_COMMA || (int) val == ATK_EQUALS)) { - if (parserDebug) - printf("Coalescing args, removing '%s'\n", Arg_GetTokenName(pprev)); - numargtoks -= 2; - } - } - } - - if (numargtoks >= maxargtoks) { - argtoks = (ArgToken *) xrealloc("argument list", argtoks, sizeof(ArgToken) * (maxargtoks + 16)); - maxargtoks += 16; - } - - cur = &argtoks[numargtoks]; - cur->val = val; - if (text) - cur->text = xstrdup(text); - else - cur->text = 0; - numargtoks++; -} - -static void Arg_Setup(int argc, char **argv) { - in_response_file = 0; - respfile = 0; - margc = argc; - margv = argv; - margind = 1; -} - -static void Arg_SkipRespFileWS(void) { -restart: - while (respfile[0] && isspace(respfile[0])) - ++respfile; - - if (respfile[0] == '\\' && respfile[1] == '#') { - ++respfile; - return; - } - - if (respfile[0] == '#') { - if ((respfile > respfilestart) ? (respfile[-1] != '\\') : 1) { - while (respfile[0] && respfile[0] != 10 && respfile[0] != 13) - ++respfile; - - while (respfile[0] == 13 || respfile[0] == 10) - ++respfile; - - goto restart; - } - } -} - -static unsigned char Arg_OpenRespFile(const char *name) { - struct OSSpec spec; - int err; - - if ( - (err = OS_MakeFileSpec(name, &spec)) - || (err = OS_NewFileHandle(&spec, 0, 0, &respfilehandle)) - || (err = OS_AppendHandle(&respfilehandle.hand, "", 1)) - || (err = OS_LockFileHandle(&respfilehandle, &respfile, &respfilesize)) - ) { - CLPOSAlert(CLPStr74, (short) err, "response ", name); - return 0; - } else { - respfilestart = respfile; - Arg_SkipRespFileWS(); - in_response_file = 1; - return 1; - } -} - -static void Arg_CloseRespFile(void) { - in_response_file = 0; - OS_FreeFileHandle(&respfilehandle); -} - -static char *Arg_GetRespFileToken(void) { - char *start; - char *ptr; - int quoting; - - quoting = 0; - if (respfile[0] == 0) - return 0; - - start = ptr = respfile; - while (respfile[0]) { - if (!quoting && isspace(respfile[0])) - break; - - if (respfile[0] == '"') { - quoting = !quoting; - respfile++; - } else if (respfile[0] == '\\' && respfile[1] == '"') { - *ptr = '"'; - respfile += 2; - ptr++; - } else { - *(ptr++) = *(respfile++); - } - } - - if (respfile[0]) - Arg_SkipRespFileWS(); - *ptr = 0; - return start; -} - -static char *Arg_GetNext(unsigned char allow_resp) { - char *ret; - int rfclen; - char *rfcequ; - -restart: - if (!in_response_file) { - rfclen = 1; - ret = margv[margind++]; - if (ret[0] == '\\' && ret[1] == RESPFILECHAR) { - ret++; - } else if (allow_resp) { - if (ret[0] == RESPFILECHAR || (RESPFILESTR[0] && !ustrncmp(ret, RESPFILESTR, rfclen = strlen(RESPFILESTR))) && ret[rfclen]) { - rfcequ = strchr(ret + rfclen, '='); - if (rfcequ) - rfclen = (rfcequ + 1) - ret; - if (Arg_OpenRespFile(ret + rfclen)) - goto restart; - ret = 0; - } - } - } else { - ret = Arg_GetRespFileToken(); - if (!ret) { - Arg_CloseRespFile(); - goto restart; - } - } - - if (parserDebug) - fprintf(stderr, "Got arg = '%s'\n", ret ? ret : ""); - - return ret; -} - -static unsigned char Arg_GotMore(void) { - if (!in_response_file) - return margind < margc; - else if (respfile[0]) - return 1; - else - return margind < margc; -} - -static void Arg_Parse(void) { - unsigned char isOpt; - unsigned char isList; - char *arg; - char *argstart; - char buffer[4096]; - char *bufptr; - char ch; - - isOpt = 0; - isList = 0; - while (Arg_GotMore()) { - argstart = arg = Arg_GetNext(1); - if (!arg) - break; - - bufptr = buffer; - buffer[0] = 0; - isList = 0; - - if (arg[0] && arg[1] && strchr(MAINOPTCHAR, arg[0])) { - if (isOpt) - Arg_AddToken(ATK_ARG_END, 0); - buffer[0] = arg[1]; - buffer[1] = 0; - isOpt = 1; - isList = 0; - bufptr++; - arg += 2; - } else { - isOpt = 0; - } - - while (arg && arg[0]) { - ch = arg[0]; - if (arg[0] == '\\' && (arg[1] == SEP1 || arg[1] == SEP2 || arg[1] == SEP3)) { - ch = 0x80 | *(++arg); - } else if (compat == 1 && arg[0] == ':' && arg[1] == '\\') { - ch |= 0x80; - } - - if (ch != SEP1 && ch != SEP2 && ch != SEP3) { - if ((ch & 0x7F) == SEP1 || (ch & 0x7F) == SEP2 || (ch & 0x7F) == SEP3) - ch &= 0x7F; - *(bufptr++) = ch; - if (bufptr >= &buffer[sizeof(buffer)]) { - CLPReportError(CLPStr2, argstart, argstart + strlen(argstart) - 15, sizeof(buffer)); - } - *bufptr = 0; - } else { - if (isOpt) { - Arg_AddToken(ATK_OPTION, buffer); - Arg_AddToken(ATK_ARG, buffer); - } else { - Arg_AddToken(ATK_ARG, buffer); - } - - Arg_AddToken( - (unsigned char) ((ch == ',') ? ATK_COMMA : (((ch == '=') || (ch == SEP3)) ? ATK_EQUALS : ATK_END)), - 0 - ); - - bufptr = buffer; - buffer[0] = 0; - - if (ch == SEP1 || ch == SEP2 || ch == SEP3) - isOpt = 0; - isList = 1; - } - - arg++; - } - - // 1799C8 - if (isOpt && bufptr > &buffer[0]) { - Arg_AddToken(ATK_OPTION, buffer + (isList && strchr(MAINOPTCHAR, buffer[0]))); - Arg_AddToken(ATK_ARG, buffer + (isList && strchr(MAINOPTCHAR, buffer[0])) + 1); - } else { - Arg_AddToken(ATK_ARG, buffer); - Arg_AddToken(ATK_ARG_END, 0); - } - } - - if (isOpt || isList) - Arg_AddToken(ATK_ARG_END, 0); - Arg_AddToken(ATK_END, 0); -} - -enum { - COMPAT_0, - COMPAT_1, - COMPAT_2 -}; - -void Arg_Init(int theargc, char **theargv) { - int p; - int x; - - maxargtoks = 0; - numargtoks = 0; - parserDebug = 0; - if (theargc > 1 && !strcmp(theargv[1], "--parser-debug")) { - parserDebug = 1; - memmove(&theargv[1], &theargv[2], sizeof(char *) * (theargc - 1)); - theargc--; - } - - if ((int) compat == COMPAT_0) { - MAINOPTCHAR = "-"; - FIRSTARGCHAR = "="; - SEPOPTSTR = " "; - SEP1 = ','; - SEP2 = '='; - SEP3 = '='; - RESPFILECHAR = '@'; - RESPFILESTR = ""; - } else if ((int) compat == COMPAT_1) { - MAINOPTCHAR = "/-"; - FIRSTARGCHAR = ":"; - SEPOPTSTR = ":"; - SEP1 = ','; - SEP2 = '='; - SEP3 = ':'; - RESPFILECHAR = '@'; - RESPFILESTR = ""; - } else if ((int) compat == COMPAT_2) { - if (!MAINOPTCHAR) - MAINOPTCHAR = "-"; - if (!FIRSTARGCHAR) - FIRSTARGCHAR = "="; - if (!SEPOPTSTR) - SEPOPTSTR = " "; - if (!SEP1) - SEP1 = ','; - if (!SEP2) - SEP2 = '='; - if (!SEP3) - SEP3 = '='; - if (!RESPFILECHAR) - RESPFILECHAR = '@'; - if (!RESPFILESTR) - RESPFILESTR = ""; - } else { - CLPFatalError("Unknown parser compatibility type (%d)\n", (int) compat); - } - - if (parserDebug) { - printf("Incoming arguments: \n"); - for (p = 0; p < theargc; p++) { - printf("[%s] ", theargv[p]); - } - printf("\n"); - } - - Arg_Setup(theargc, theargv); - Arg_Parse(); - Arg_Reset(); - - if (parserDebug) { - for (x = 0; x < numargtoks; x++) { - printf("TOKEN: '%s'\n", Arg_GetTokenName(&argtoks[x])); - } - } -} - -void Arg_Terminate(void) { - ArgToken *cur; - - while (numargtoks > 0) { - cur = &argtoks[--numargtoks]; - if (cur->text) - free(cur->text); - } - - if (maxargtoks) - free(argtoks); - maxargtoks = 0; -} - -void Arg_Reset(void) { - scantok = 0; -} - -void Arg_Stop(ArgToken *where) { - ArgToken *cur; - - while (&argtoks[numargtoks] > where) { - cur = &argtoks[--numargtoks]; - if (cur->text) - free(cur->text); - cur->val = ATK_END; - cur->text = 0; - } - - argtoks[numargtoks++].val = ATK_ARG_END; - argtoks[numargtoks++].val = ATK_END; - scantok = numargtoks - 2; -} - -ArgToken *Arg_PeekToken(void) { - if (scantok >= numargtoks) - return 0; - else - return &argtoks[scantok]; -} - -ArgToken *Arg_UsedToken(void) { - if (scantok < numargtoks) - scantok++; - return Arg_PeekToken(); -} - -int Arg_IsEmpty(void) { - ArgToken *tok; - - tok = Arg_PeekToken(); - return (tok == 0 || tok->val == ATK_END); -} - -ArgToken *Arg_GetToken(void) { - ArgToken *ret; - - ret = Arg_PeekToken(); - if (ret) - scantok++; - return ret; -} - -ArgToken *Arg_UndoToken(void) { - if (scantok > 0) { - scantok--; - return Arg_PeekToken(); - } else { - return 0; - } -} - -const char *Arg_GetTokenName(ArgToken *tok) { - if ((int) tok->val == ATK_ARG) - return tok->text; - - return - ((int) tok->val == ATK_OPTION) ? "option" : - ((int) tok->val == ATK_COMMA) ? "comma" : - (((int) compat == COMPAT_1 && (int) tok->val == ATK_EQUALS)) ? "colon or equals" : - (((int) compat != COMPAT_1 && (int) tok->val == ATK_EQUALS)) ? "equals" : - ((int) tok->val == ATK_ARG_END) ? "end of argument" : - ((int) tok->val == ATK_END) ? "end of command line" : - ""; -} - -const char *Arg_GetTokenText(ArgToken *tok, char *buffer, int maxlen, unsigned char warn) { - const char *ptr; - char *bptr; - int curlen; - - bptr = buffer; - curlen = 0; - if (tok->val == ATK_ARG || tok->val == ATK_OPTION) - ptr = tok->text; - else - ptr = Arg_GetTokenName(tok); - - while (*ptr && curlen++ < maxlen) { - *(bptr++) = *(ptr++); - } - - if (curlen < maxlen) { - bptr[0] = 0; - } else { - bptr[-1] = 0; - if (warn) - CLPReportWarning(CLPStr56, buffer, ptr + strlen(ptr) - ((maxlen <= 32) ? maxlen : 32), maxlen); - } - - return buffer; -} - -static void Arg_GrowArgs(anon0_50 *ta) { - int len; - - if (!ta->argv || (ta->argc + 1) >= ta->nargv) { - len = ta->nargv; - ta->nargv = len + 16; - ta->argv = xrealloc("argument list", ta->argv, sizeof(char *) * (ta->nargv + 1)); - while (len <= ta->nargv) { - ta->argv[len++] = 0; - } - } - - ta->argc++; -} - -static void Arg_GrowArg(anon0_50 *ta, char *txt) { - char **ptr; - int ptrlen; - - ptr = &ta->argv[ta->argc]; - - if (*ptr == 0) { - *ptr = xstrdup(txt); - } else { - ptrlen = strlen(*ptr); - *ptr = xrealloc("command line", *ptr, ptrlen + strlen(txt) + 1); - strcpy(*ptr + ptrlen, txt); - } -} - -void Arg_InitToolArgs(anon0_50 *ta) { - ta->argc = 0; - ta->nargv = 0; - ta->argv = 0; - Arg_GrowArgs(ta); -} - -void Arg_AddToToolArgs(anon0_50 *ta, short tokval, char *toktxt) { - switch (tokval) { - case ATK_END: - Arg_FinishToolArgs(ta); - break; - case ATK_ARG_END: - if (ta->argv && ta->argv[ta->argc]) - Arg_GrowArgs(ta); - break; - case ATK_ARG: - Arg_GrowArg(ta, toktxt); - break; - case ATK_OPTION: - Arg_GrowArg(ta, "-"); - break; - case ATK_EQUALS: - Arg_GrowArg(ta, "="); - break; - case ATK_COMMA: - Arg_GrowArg(ta, ","); - break; - default: - CLPFatalError(__FILE__, 787, "Unknown token (%d)", tokval); - break; - } -} - -void Arg_FinishToolArgs(anon0_50 *ta) { - Arg_GrowArgs(ta); - ta->argv[ta->argc] = 0; -} - -void Arg_ToolArgsForPlugin(anon0_50 *ta, struct CWCommandLineArgs *args) { - args->argc = 1; - args->argv = ta->argv; - - while (args->argv[args->argc]) - args->argc++; - - args->envp = 0; -} - -void Arg_FreeToolArgs(anon0_50 *ta) { - int x; - - if (ta->argv) { - for (x = 1; x < ta->argc; x++) { - if (ta->argv[x]) - free(ta->argv[x]); - } - free(ta->argv); - } -} diff --git a/unsorted/Help.c b/unsorted/Help.c deleted file mode 100644 index 74849a1..0000000 --- a/unsorted/Help.c +++ /dev/null @@ -1,561 +0,0 @@ -#include "parser.h" - -typedef struct _Side { - short offset; - short width; - char buffer[1024]; - short bptr; - short blen; - short indent; - short vrow; - short vcol; - Boolean atEOL; - Boolean impInd; -} Side; - -short helpExtras; -Boolean showedHelp; -Side left; -Side right; -Side all; -char **helptext; -static char outLine[256]; - -static void Help_Output(Side *left, Side *right); -static void Help_OutputSingle(Side *all); -static void Help_Flush(void); - -static void Side_Init(Side *s, short offset, short width) { - memset(s, 0, sizeof(Side)); - s->offset = offset; - s->width = width; -} - -static void Side_Print(Side *s, const char *format, ...) { - char c; - char *text; - char buffer[1024]; - va_list args; - - va_start(args, format); - vsprintf(buffer, format, args); - va_end(args); - - text = buffer; - while (*text) { - if (s->blen < 1024) { - c = *(text++); - if (c == '~' && *text == '~') { - c = *MAINOPTCHAR; - text++; - } - - s->buffer[(s->bptr + s->blen) & 1023] = c; - s->blen++; - } else { - if (s == &left) - Help_Output(&left, &right); - else - Help_OutputSingle(&all); - } - } -} - -static void Side_NewLine(Side *s) { - Side_Print(s, "\n"); -} - -static void Side_Indent(Side *s, short how) { - if ((s->width - s->indent - how) > (parseopts.ioCols / 8)) - s->indent += how; - else if ((s->width - s->indent - 1) > (parseopts.ioCols / 10)) - s->indent++; -} - -static void Side_Outdent(Side *s, short how) { - if ((s->width - s->indent) < (parseopts.ioCols / 8)) - s->indent++; - else if (s->indent >= how) - s->indent -= how; -} - -static unsigned char isBreaker(char c) { - return (c == 10) || (c == 13) || (c == 32) || (c == 9) || (c == 8) || (c == '|'); -} - -static void Side_DumpLine(Side *s) { - short col; - short len; - short afterspace; - short eol; - short ind; - char c; - - eol = 0; - ind = 0; - col = s->offset + s->indent; - s->vcol = s->indent; - len = 0; - afterspace = s->width - s->indent; - - while (s->blen > 0 && s->vcol < s->width && !eol && !ind) { - c = s->buffer[s->bptr]; - outLine[col + len] = c; - s->vcol++; - len++; - - if (isBreaker(c)) { - afterspace = len; - eol = (c == '\n') || (c == '\r'); - eol += (c == '\r'); - ind = (c == '\b') || (c == '\t'); - ind += (c == '\b'); - } - - s->bptr = (s->bptr + 1) & 1023; - s->blen--; - } - - if (s->blen || eol || ind) { - s->blen += len - afterspace; - s->bptr = (s->bptr - (len - afterspace)) & 1023; - if (eol || ind) { - len++; - afterspace--; - } - - while (len > afterspace) { - outLine[col + --len] = ' '; - } - } - - s->vcol = 0; - s->vrow++; - s->atEOL = (eol == 1) || ind || !s->blen; - if ((s->atEOL || ind) && s->impInd) { - Side_Outdent(s, parseopts.ioCols / 40); - s->impInd = 0; - } - if (ind) { - if (ind == 1) - Side_Indent(s, parseopts.ioCols / 25); - else - Side_Outdent(s, parseopts.ioCols / 25); - } else if (!s->atEOL && s != &all && !s->impInd) { - Side_Indent(s, parseopts.ioCols / 40); - s->impInd = 1; - } -} - -static void Help_PrintLine(void) { - HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, outLine); -} - -static void Help_Output(Side *left, Side *right) { - while (left->blen || right->blen) { - memset(outLine, ' ', parseopts.ioCols); - outLine[left->offset + left->width + 1] = '#'; - if (left->atEOL && right->atEOL) - left->atEOL = right->atEOL = 0; - if (!left->atEOL) - Side_DumpLine(left); - if (!right->atEOL) - Side_DumpLine(right); - Help_PrintLine(); - } -} - -static void Help_OutputSingle(Side *all) { - while (all->blen) { - memset(outLine, ' ', parseopts.ioCols); - if (all->atEOL) - all->atEOL = 0; - if (!all->atEOL) - Side_DumpLine(all); - Help_PrintLine(); - } -} - -static void Help_Flush(void) { - Help_Output(&left, &right); -} - -static void Help_NewLine(void) { - Side_NewLine(&left); - Side_NewLine(&right); -} - -int Help_Option(struct OptionList *lst, struct Option *opt, int subprint, const char *keyword) { - char pfbuf[512]; - char slflags; - int listFlags; - Boolean allNoArgs; - PARAM_T *lastparam; - Boolean print; - Boolean printMe; - - if (!opt->names[0] && !(lst->flags & LISTFLAGS_4)) - return 0; - - if (keyword && keyword[0] && !strstr(opt->names, keyword) && (!opt->help || !strstr(opt->help, keyword))) - return 0; - - if ((opt->avail & OTF_SECRET) && !(parseopts.helpFlags & HELPFLAGS_SECRET)) - return 0; - - if ((opt->avail & OTF_OBSOLETE) && !(parseopts.helpFlags & HELPFLAGS_OBSOLETE)) - return 0; - - if ((opt->avail & OTF_DEPRECATED) && !(parseopts.helpFlags & HELPFLAGS_DEPRECATED)) - return 0; - - if ((opt->avail & OTF_IGNORED) && !(parseopts.helpFlags & HELPFLAGS_IGNORED)) - return 0; - - if ((opt->avail & OTF_MEANINGLESS) && !(parseopts.helpFlags & HELPFLAGS_MEANINGLESS)) - return 0; - - if (!(parseopts.helpFlags & HELPFLAGS_NORMAL) && !(opt->avail & OTF_ALL_HIDDEN_BY_DEFAULT)) - return 0; - - if (opt->help || (opt->avail & OTF_HAS_SUB_OPTIONS)) { - allNoArgs = 1; - lastparam = 0; - if (parseopts.helpFlags & HELPFLAGS_SPACES) - Help_NewLine(); - if ((opt->avail & OTF_GLOBAL) && !subprint) - Side_Print(&right, "global; "); - if (compat != 1 && (opt->avail & OTF_CASED)) - Side_Print(&right, "cased; "); - - slflags = (subprint == 0) ? SLFLAGS_1 : SLFLAGS_2; - switch (opt->avail & OTF_SLFLAGS_MASK) { - case OTF_SLFLAGS_8: - slflags = slflags | SLFLAGS_8; - break; - case OTF_SLFLAGS_10: - slflags = slflags | SLFLAGS_10; - break; - case OTF_SLFLAGS_20: - slflags = slflags | SLFLAGS_20; - break; - } - if (opt->avail & OTF_STICKY) - slflags = slflags | SLFLAGS_40; - - Utils_SpellList(opt->names[0] ? opt->names : "...", pfbuf, slflags); - Side_Print(&left, pfbuf); - - if (opt->avail & OTF_OBSOLETE) - Side_Print(&right, "obsolete;\r"); - if (opt->avail & OTF_COMPATIBILITY) - Side_Print(&right, "compatibility;\r"); - if (opt->avail & OTF_IGNORED) - Side_Print(&right, "ignored;\r"); - - listFlags = ((lst->flags & LISTFLAGS_COMPILER) ? OTF_TOOL_COMPILER : 0) | ((lst->flags & LISTFLAGS_LINKER) ? OTF_TOOL_LINKER : 0) | ((lst->flags & LISTFLAGS_DISASSEMBLER) ? OTF_TOOL_DISASSEMBLER : 0); - if (!Option_ForThisTool(opt) || Option_AlsoPassedFromThisTool(opt) || listFlags != Option_ThisTool()) { - print = 0; - printMe = 1; - if ((opt->avail & OTF_TOOL_MASK) != (unsigned int) listFlags) - print = 1; - if (Option_ForThisTool(opt) && Option_AlsoPassedFromThisTool(opt)) - printMe = 0; - - if (print) { - char opttool[64] = ""; // stack 0x44 - if ((opt->avail & OTF_TOOL_MASK) == (unsigned int) OTF_TOOL_MASK) { - strcat(opttool, "all tools"); - } else { - if (Option_ForTool(opt, OTF_TOOL_COMPILER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_COMPILER) || printMe)) { - strcat(opttool, "this tool"); - } - if (Option_ForTool(opt, OTF_TOOL_LINKER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_LINKER) || printMe)) { - if (opttool[0]) - strcat(opttool, ", "); - strcat(opttool, "linker"); - } - if (Option_ForTool(opt, OTF_TOOL_DISASSEMBLER) && ((Option_ThisTool() != (unsigned int) OTF_TOOL_DISASSEMBLER) || printMe)) { - if (opttool[0]) - strcat(opttool, ", "); - strcat(opttool, "disassembler"); - } - if (!Option_ForTool(opt, OTF_TOOL_MASK)) - strcat(opttool, "another tool"); - } - - if (printMe || !Option_ForThisTool(opt)) { - Side_Print(&right, "for %s;\r", opttool); - } else if (parseopts.passingArgs) { - Side_Print(&right, "passed to %s;\r", opttool); - } - } - } - - if (opt->avail & OTF_WARNING) - Side_Print(&right, "warning:\r"); - - if (opt->avail & OTF_DEPRECATED) - Side_Print(&right, "deprecated;\rinstead use "); - else if (opt->avail & OTF_SUBSTITUTED) - Side_Print(&right, "substituted with "); - - if (opt->help) - Side_Print(&right, "%s", opt->help); - - if (opt->param && !(opt->avail & OTF_IGNORED)) { - PARAM_T *scan = opt->param; - PARAM_T *firstparam = 0; - const char *desc; - const char *help; - const char *defaul; - while (scan) { - if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_1) { - if (!firstparam) - firstparam = scan; - - allNoArgs = 0; - Param_DescHelp(scan, &desc, &help, &defaul); - if (desc) { - if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { - if (SEPOPTSTR[0] == ' ') { - Side_Print(&left, (scan != firstparam) ? "[," : subprint ? "[=" : " ["); - } else { - Side_Print(&left, "[%s", (scan != firstparam) ? "," : subprint ? "=" : SEPOPTSTR); - } - } else { - Side_Print(&left, (scan != firstparam) ? "," : subprint ? "=" : ((opt->avail & OTF_STICKY) && !strchr(opt->names, '|')) ? "" : SEPOPTSTR); - } - Side_Print(&left, "%s", desc); - if (((scan->flags & PARAMFLAGS_3) == PARAMFLAGS_2) && scan->which != PARAMWHICH_Setting && scan->which != PARAMWHICH_IfArg) { - Side_Print(&left, "]"); - } - if (help) { - if ((scan->flags & PARAMFLAGS_3) != PARAMFLAGS_2) - Side_Print(&right, "; for '%s', %s", desc, help); - else - Side_Print(&right, "; if parameter specified, %s", help); - } - if (defaul && !(opt->avail & OTF_HIDE_DEFAULT)) { - if (firstparam == scan) - Side_Print(&right, "; default is %s", defaul); - else - Side_Print(&right, ",%s", defaul); - } - } - } - lastparam = scan; - scan = scan->next; - } - - if (allNoArgs && !(opt->avail & OTF_HIDE_DEFAULT)) { - PARAM_T *scan = opt->param; - Boolean isdefault = scan ? 1 : 0; - while (scan && isdefault) { - isdefault &= Param_Compare(scan); - scan = scan->next; - } - - if (isdefault) - Side_Print(&right, "; default"); - } - } - - if (opt->avail & OTF_MEANINGLESS) - Side_Print(&right, "; meaningless for this target"); - - if ((opt->avail & OTF_HAS_SUB_OPTIONS) && opt->sub) { - if (!allNoArgs) { - Side_Print( - &left, - "%s", - (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? ((lastparam->flags & PARAMFLAGS_8) ? "[=" : "[,") : ((lastparam->flags & PARAMFLAGS_8) ? "=" : ",") - ); - } else if (!(opt->avail & OTF_STICKY)) { - if (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) { - if (SEPOPTSTR[0] == ' ') - Side_Print(&left, subprint ? "[=" : " ["); - else - Side_Print(&left, "[%s", subprint ? "=" : SEPOPTSTR); - } else { - Side_Print(&left, "%c", subprint ? '=' : SEPOPTSTR[0]); - } - } else { - if (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) { - Side_Print(&left, subprint ? "[" : (SEPOPTSTR[0] == ' ') ? " [" : "["); - } - } - - Side_Print( - &left, - "%s%s%s", - opt->sub->help ? opt->sub->help : "keyword", - (opt->sub->flags & PARAMFLAGS_1) ? "" : "[,...]", - (opt->avail & OTF_SUB_OPTIONS_OPTIONAL) ? "]" : "" - ); - - Side_Print(&left, "\t"); - Side_Print(&right, "\t"); - Help_Options(opt->sub, 1, ""); - Side_Print(&right, "\b"); - Side_Print(&left, "\b"); - } else { - Side_Print(&left, "\n"); - Side_Print(&right, "\n"); - } - } - - Help_Flush(); - return 1; -} - -void Help_Options(struct OptionList *lst, int subprint, const char *keyword) { - Option **opts; - int toolflags; - Boolean show; - - opts = lst->list; - toolflags = 0; - if (Option_ThisTool() == OTF_TOOL_COMPILER) { - toolflags |= LISTFLAGS_COMPILER; - } else { - toolflags |= LISTFLAGS_LINKER; - } - - // review me maybe? - if (!subprint && (parseopts.helpFlags & HELPFLAGS_TOOL)) { - if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_THIS && (lst->flags & LISTFLAGS_TOOL_MASK) && !(lst->flags & toolflags)) - return; - if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_OTHER && (((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) toolflags) || ((lst->flags & LISTFLAGS_TOOL_MASK) == (unsigned int) LISTFLAGS_NONE))) - return; - } - - if (lst->help && !subprint && opts[0]) { - Help_Line('-'); - Side_Print(&all, "%s", lst->help); - Help_OutputSingle(&all); - Help_Line('-'); - } - - while (*opts) { - show = 0; - if (!(parseopts.helpFlags & HELPFLAGS_TOOL)) { - if (((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) && (parseopts.passingArgs ? (Option_ForTool(*opts, OTF_TOOL_LINKER) || Option_ForTool(*opts, OTF_TOOL_DISASSEMBLER)) : 1) && Option_ForThisTool(*opts)) - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_BOTH) == HELPFLAGS_TOOL_BOTH) { - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_THIS) && Option_ForThisTool(*opts)) { - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && !Option_ForThisTool(*opts)) { - show = 1; - } else if ((parseopts.helpFlags & HELPFLAGS_TOOL_OTHER) && Option_ForTool(*opts, ~Option_ThisTool() & OTF_TOOL_MASK)) { - show = 1; - } - - if (show) - Help_Option(lst, *opts, subprint, keyword); - - ++opts; - } - - if (subprint && (parseopts.helpFlags & HELPFLAGS_SPACES)) - Help_NewLine(); - Help_Flush(); - if (!subprint) - HPrintF(helptext, "\n"); -} - -void Help_Usage(void) { - Side_Print( - &all, - "\tGuide to help:\b" - "\tWhen an option is specified as '~~xxx | yy[y] | zzz', then either '~~xxx', '~~yy', '~~yyy', or '~~zzz' matches the option.\b" - "\tAn option given as '~~[no]xxx' may be given as '~~xxx' or '~~noxxx'; '~~noxxx' reverses the meaning of the option.\b" - ); - Help_OutputSingle(&all); - - Side_Print( - &all, - "\tFor most options, the option and the parameters are separated by a %sspace. When the option's name is '~~xxx+', however, the parameter must directly follow the option, without the '+' (as in '~~xxx45').\b", - (compat != 1) ? "" : "colon or " - ); - Side_Print( - &all, - "\tA parameter included in brackets '[]' is optional. An ellipsis '...' indicates that the previous type of parameter may be repeated as a list.\b" - ); - Help_OutputSingle(&all); - - Side_Print( - &all, - "\t%s-- \"compatability\" indicates that the option is borrowed from another vendor's tool and may only approximate its counterpart.\r" - "-- \"global\" indicates that the option has an effect over the entire command line and is parsed before any other options. When several global options are specified, they are interpreted in order.\r" - "-- \"deprecated\" indicates that the option will be eliminated in the future and should not be used any longer. An alternative form is supplied.\r", - (compat != 1) ? "-- \"cased\" indicates that the option is case-sensitive. By default, no options are case-sensitive.\r" : ""); - Help_OutputSingle(&all); - - Side_Print( - &all, - "-- \"ignored\" means the option will be accepted but has no effect on the tool.\r" - "-- \"meaningless\" means the option is accepted but probably has no meaning for the target OS.\r" - "-- \"obsolete\" means the option was once deprecated and is now gone.\r" - "-- \"substituted\" means the option has the same effect as another. This points out a preferred form and prevents confusion when similar options appear in the help.\r" - "-- \"default\" in the help text indicates that the given value or variation of an option will be used unless otherwise overridden. \b" - ); - Help_OutputSingle(&all); - - Side_Print( - &all, - "\tThe symbols ',' %s separate options and parameters unconditionally; to include one of these symbols in a parameter or filename, escape it (e.g., as '\\,' in mwcc file.c\\,v).\b\n", - (compat != 1) ? "and '='" : ", ':', and '='" - ); - Help_OutputSingle(&all); - - if (parseopts.passingArgs && pTool->TYPE == CWDROPINCOMPILERTYPE) - Side_Print( - &all, - "\tThis tool calls the linker (unless a compiler option such as ~~c prevents it) and understands linker options -- use '~~help tool=other' to see them. Options marked \"passed to linker\" are used by the compiler and the linker; options marked \"for linker\" are used only by the linker. When using the compiler and linker separately, you must pass the common options to both.\b\n" - ); - Help_OutputSingle(&all); -} - -void Help_Null(void) { - Side_Print(&all, - "%s [options, filenames...]\n\nExecute '%s %shelp' for more information.", - OS_GetFileNamePtr(parseopts.args->argv[0]), - OS_GetFileNamePtr(parseopts.args->argv[0]), - MAINOPTCHAR - ); - Help_OutputSingle(&all); -} - -void Help_Init(void) { - short lb; - short le; - short rb; - short re; - - if (!(helptext = NewHandle(0))) { - fprintf(stderr, "\n*** Out of memory\n"); - exit(-23); - } - - lb = parseopts.ioCols / 40; - le = (parseopts.ioCols / 3) + lb; - rb = le + 3 + ((parseopts.ioCols / 60) & ~1); - re = parseopts.ioCols - 1; - Side_Init(&left, lb, le - lb); - Side_Init(&right, rb, re - rb); - Side_Init(&all, 0, re); -} - -void Help_Line(char ch) { - char line[256]; - memset(line, ch, 255); - line[255] = 0; - HPrintF(helptext, "%.*s\n", parseopts.ioCols - 1, line); -} - -void Help_Term(void) { - ShowTextHandle(0, helptext); - DisposeHandle(helptext); -} diff --git a/unsorted/IO.c b/unsorted/IO.c deleted file mode 100644 index 36d809b..0000000 --- a/unsorted/IO.c +++ /dev/null @@ -1,83 +0,0 @@ -#include "parser.h" - -void ShowTextHandle(const char *description, Handle text) { - CWMemHandle mh; - - if (!text) - return; - - if (description) - CLPStatus(71, description); - CWSecretAttachHandle(parseopts.context, text, &mh); - CWParserDisplayTextHandle(parseopts.context, description, mh); -} - -void ShowVersion(Boolean decorate) { - char *vplugin; - char *valtplugin; - const char *bdate; - const char *btime; - Handle txt; - int x; - - vplugin = 0; - valtplugin = 0; - if (parseopts.printedVersion) - return; - - txt = NewHandle(0); - if (!txt) { - fprintf(stderr, "\n*** Out of memory\n"); - exit(-23); - } - - for (x = 0; x < parseopts.numPlugins; x++) { - if (parseopts.plugins[x].plugintype == CWDROPINDRIVERTYPE) continue; - if (parseopts.plugins[x].plugintype == CWDROPINPARSERTYPE) continue; - - if (pTool->TYPE == parseopts.plugins[x].plugintype) { - if (!vplugin && pTool->LANG == parseopts.plugins[x].language) - vplugin = parseopts.plugins[x].version; - else - valtplugin = parseopts.plugins[x].version; - } - } - - CWParserGetBuildDate(parseopts.context, &bdate, &btime); - HPrintF(txt, "\n"); - if (parseopts.toolVersion) { - HPrintF( - txt, - "%s.\n%s, %s\nAll rights reserved.\n%s\n", - pTool->toolInfo, - parseopts.toolVersion->copyright, - parseopts.toolVersion->company, - parseopts.toolVersion->version - ); - } else { - HPrintF( - txt, - "%s.\nCopyright (c)%s Metrowerks, Inc.\nAll rights reserved.\n%s\n", - pTool->toolInfo, - pTool->copyright, - vplugin ? vplugin : valtplugin ? valtplugin : "" - ); - } - - HPrintF(txt, "Runtime Built: %s %s\n", bdate, btime); - HPrintF(txt, "\n"); - - if (decorate) { - HPrintF( - txt, - "Please enter '%s %chelp' for information about options.\n\n", - OS_GetFileNamePtr(parseopts.args->argv[0]), - MAINOPTCHAR[0] - ); - } - - ShowTextHandle(0, txt); - DisposeHandle(txt); - - parseopts.printedVersion = 1; -} diff --git a/unsorted/OptimizerHelpers.c b/unsorted/OptimizerHelpers.c deleted file mode 100644 index 4085363..0000000 --- a/unsorted/OptimizerHelpers.c +++ /dev/null @@ -1,166 +0,0 @@ -#include "parser.h" - -Boolean setOldOptimizerOptions; - -typedef struct { - Boolean commonsubs; - Boolean loopinvariants; - Boolean propagation; - Boolean deadstore; - Boolean strengthreduction; - Boolean deadcode; - Boolean lifetimes; -} PIROptimizer; // assumed name - -static PIROptimizer pIrOptimizer = {0}; - -Pragma irPragmas[] = { - &pIrOptimizer.commonsubs, "opt_common_subs", 0, - &pIrOptimizer.loopinvariants, "opt_loop_invariants", 0, - &pIrOptimizer.propagation, "opt_propagation", 0, - &pIrOptimizer.deadstore, "opt_dead_assignments", 0, - &pIrOptimizer.deadcode, "opt_dead_code", 0, - &pIrOptimizer.strengthreduction, "opt_strength_reduction", 0, - &pIrOptimizer.lifetimes, "opt_lifetimes", 0, - 0, 0, 0 -}; - -int SetPragmaOptimizationsToUnspecified(const char *opt, void *, const char *, int) { - if (setOldOptimizerOptions) - Option_Warning(CLPStr62); - - memset(&pIrOptimizer, 0, sizeof(pIrOptimizer)); - TargetSetPragmaOptimizationsToUnspecified(); - return 1; -} - -int SetOptFlags(const char *opt, void *str, const char *, int flags) { - // this is very similar to ToolHelper - // might also fail to match - unsigned char *ptr; - Boolean set; - Boolean no; - UInt16 flag; - - ptr = (unsigned char *) str; - no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3); - set = (Boolean) (no ^ 1); - - while (*ptr) { - if (*ptr == '+') { - set = !no; - } else if (*ptr == '-') { - set = no; - } else if (*ptr == '|') { - set = (Boolean) (no ^ 1); - } else { - flag = (ptr[0] << 8) | ptr[1]; - - if ((flag >= 'G0' && flag <= 'G4') || (flag == 'Gs') || (flag == 'Gp')) - SetPragmaOptimizationsToUnspecified(opt, NULL, NULL, 0); - - switch (flag) { - case 'Cs': - pIrOptimizer.commonsubs = set ? 1 : 2; - setOldOptimizerOptions = 1; - break; - case 'Li': - pIrOptimizer.loopinvariants = set ? 1 : 2; - setOldOptimizerOptions = 1; - break; - case 'Pr': - pIrOptimizer.propagation = set ? 1 : 2; - setOldOptimizerOptions = 1; - break; - case 'Ds': - pIrOptimizer.deadstore = set ? 1 : 2; - setOldOptimizerOptions = 1; - break; - case 'Sr': - pIrOptimizer.strengthreduction = set ? 1 : 2; - setOldOptimizerOptions = 1; - break; - case 'Dc': - pIrOptimizer.deadcode = set ? 1 : 2; - setOldOptimizerOptions = 1; - break; - case 'Lt': - pIrOptimizer.lifetimes = set ? 1 : 2; - setOldOptimizerOptions = 1; - break; - case 'G0': - pGlobalOptimizer.optimizationlevel = set ? 0 : 0; - break; - case 'G1': - pGlobalOptimizer.optimizationlevel = set ? 1 : 0; - break; - case 'G2': - pGlobalOptimizer.optimizationlevel = set ? 2 : 0; - break; - case 'G3': - pGlobalOptimizer.optimizationlevel = set ? 3 : 0; - break; - case 'G4': - pGlobalOptimizer.optimizationlevel = set ? 4 : 0; - break; - case 'Gs': - pGlobalOptimizer.optfor = set ? 1 : 0; - break; - case 'Gp': - pGlobalOptimizer.optfor = set ? 0 : 1; - break; - default: - if (!TargetSetOptFlags(flag, set)) - CLPFatalError("Bad optimizer settings in %s (%c%c)\n", str, ptr[0], ptr[1]); - } - - ++ptr; - } - - ++ptr; - } - - return 1; -} - -int DisplayOptimizationOptions(const char *, void *, const char *, int) { - SInt32 oldsize; - Handle h; - - h = NewHandle(0); - if (!h) - exit(-23); - - HPrintF(h, "\t- global optimizer level %d\n", pGlobalOptimizer.optimizationlevel); - HPrintF(h, "\t- global optimize for %s\n", (pGlobalOptimizer.optfor == 0) ? "speed" : "size"); - - oldsize = GetHandleSize(h); - if (pIrOptimizer.commonsubs) - HPrintF(h, "\t- common subexpression elimination %s\n", (pIrOptimizer.commonsubs == 1) ? "on" : "off"); - if (pIrOptimizer.loopinvariants) - HPrintF(h, "\t- loop invariants %s\n", (pIrOptimizer.loopinvariants == 1) ? "on" : "off"); - if (pIrOptimizer.commonsubs) - HPrintF(h, "\t- constant propagation %s\n", (pIrOptimizer.propagation == 1) ? "on" : "off"); - if (pIrOptimizer.deadstore) - HPrintF(h, "\t- dead store elimination %s\n", (pIrOptimizer.deadstore == 1) ? "on" : "off"); - if (pIrOptimizer.deadcode) - HPrintF(h, "\t- dead code elimination %s\n", (pIrOptimizer.deadcode == 1) ? "on" : "off"); - if (pIrOptimizer.strengthreduction) - HPrintF(h, "\t- strength reduction %s\n", (pIrOptimizer.strengthreduction == 1) ? "on" : "off"); - if (pIrOptimizer.lifetimes) - HPrintF(h, "\t- variable lifetimes %s\n", (pIrOptimizer.lifetimes == 1) ? "on" : "off"); - - if (oldsize == GetHandleSize(h)) - HPrintF(h, "\t- no extra global optimizations\n"); - - HPrintF(h, "Backend-specific optimizer options:\n"); - - oldsize = GetHandleSize(h); - TargetDisplayOptimizationOptions(h); - if (oldsize == GetHandleSize(h)) - HPrintF(h, "\t- no extra backend-specific optimizations\n"); - - ShowTextHandle(NULL, h); - DisposeHandle(h); - return 1; -} diff --git a/unsorted/Option.c b/unsorted/Option.c deleted file mode 100644 index 2a53f38..0000000 --- a/unsorted/Option.c +++ /dev/null @@ -1,1136 +0,0 @@ -#include "parser.h" - -#define MAXSTACK 8 - -static OptionList *optionlists[32]; -int numoptionlists; -static OptionList internalset; -static OptionList legalset; -int numinternalset; -int numlegalset; -int maxlegalset; -char curopt[1024]; -Opt48 oStack[8]; -int oStackPtr; - -enum { - ARGFLAG_1 = 1, - ARGFLAG_2 = 2, - ARGFLAG_4 = 4, - ARGFLAG_8 = 8, - ARGFLAG_10 = 0x10, - ARGFLAG_20 = 0x20, - ARGFLAG_40 = 0x40, - ARGFLAG_80 = 0x80 -}; - -enum { - ARGSPELLFLAG_1 = 1, - ARGSPELLFLAG_2 = 2, - ARGSPELLFLAG_4 = 4, - ARGSPELLFLAG_8 = 8, - ARGSPELLFLAG_10 = 0x10, - ARGSPELLFLAG_20 = 0x20, - ARGSPELLFLAG_40 = 0x40, - ARGSPELLFLAG_80 = 0x80 -}; - -enum { - OPTSPELLFLAG_1 = 1, - OPTSPELLFLAG_2 = 2, - OPTSPELLFLAG_4 = 4, - OPTSPELLFLAG_8 = 8, - OPTSPELLFLAG_10 = 0x10, - OPTSPELLFLAG_20 = 0x20, - OPTSPELLFLAG_40 = 0x40, - OPTSPELLFLAG_80 = 0x80 -}; - -static void Option_PushList(OptionList *lst) { - Args_Push(1, lst, 0); -} - -static void Option_PushOpt(Option *opt, const char *optname) { - char *cpy; - short flags = ARGFLAG_2; - if (opt && (opt->avail & OTF_STICKY)) { - if (Utils_CompareOptionString(opt->names, optname, opt->avail & OTF_CASED, OTF_STICKY)) { - flags |= ARGFLAG_80; - } - } - cpy = xstrdup(optname); - Args_Push(flags, opt, cpy); -} - -static void Option_PopOpt(char *optname) { - Opt48 *os = Args_Pop(ARGFLAG_2); - if (optname) - strcpy(optname, os->e.o.curopt); - free(os->e.o.curopt); -} - -static void Option_PopList(void) { - Args_Pop(ARGFLAG_1); -} - -void Args_InitStack(void) { - oStackPtr = 0; -} -int Args_StackSize(void) { - return oStackPtr; -} - -void Args_Push(short flags, void *first, void *second) { - OS_ASSERT(104, oStackPtr 0) { - short prev = - (flags & ARGFLAG_1) ? ARGFLAG_2 : - (flags & ARGFLAG_2) ? ARGFLAG_1 : - (flags & ARGFLAG_4) ? ARGFLAG_2 : -1; - OS_ASSERT(111, oStack[oStackPtr-1].flags & prev); - } - - oStack[oStackPtr].e.v.first = first; - oStack[oStackPtr].e.v.second = second; - oStack[oStackPtr].flags = flags; - oStackPtr++; -} - -Opt48 *Args_Pop(short flags) { - OS_ASSERT(122, oStackPtr>0); - --oStackPtr; - OS_ASSERT(124, oStack[oStackPtr].flags & flags); - return &oStack[oStackPtr]; -} - -void Args_SpellStack(char *buffer, short flags) { - char *bptr; - Opt48 *os; - int sp; - int level; - - bptr = buffer; - sp = 0; - level = 0; - os = &oStack[sp]; - - while (sp < oStackPtr) { - if (!flags || !(os->flags & ARGFLAG_20)) { - if (os->flags & ARGFLAG_4) { - Opt48 *po = os - 1; - if (!(os[-1].flags & ARGFLAG_40)) { - if ((level == 1 || level == 2) && !(po->flags & ARGFLAG_80)) - *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; - os[-1].flags |= ARGFLAG_40; - } else if (level == 2) { - *(bptr++) = ','; - } else if (level == 3) { - *(bptr++) = '='; - } - strcpy(bptr, os->e.param); - bptr += strlen(bptr); - } else if (os->flags & ARGFLAG_2) { - if (level == 1) { - *(bptr++) = MAINOPTCHAR[0]; - } else if (level == 2) { - Opt48 *po = os - 2; - if (!(os[-1].flags & ARGFLAG_40) && !(po->flags & ARGFLAG_80)) - *(bptr++) = (flags & ARGSPELLFLAG_20) ? '\n' : ' '; - } - - if (os[-1].flags & ARGFLAG_40) { - if (level == 2) { - if (flags & ARGSPELLFLAG_20) - *(bptr++) = ','; - else - *(bptr++) = ' '; - } - } else { - if (level == 3) { - *(bptr++) = '='; - } - } - - os[-1].flags |= ARGFLAG_40; - strcpy(bptr, os->e.o.curopt); - bptr += strlen(bptr); - } - - if (flags & ARGSPELLFLAG_20) - os->flags |= ARGFLAG_20; - } - - if (os->flags & ARGFLAG_1) - level++; - - ++sp; - ++os; - } -} - -void Args_AddToToolArgs(anon0_50 *ta) { - char buffer[4096]; - char *nptr; - - Args_SpellStack(buffer, ARGSPELLFLAG_20); - nptr = strchr(buffer, '\n'); - if (nptr) { - *(nptr++) = 0; - Arg_AddToToolArgs(ta, 2, buffer); - Arg_AddToToolArgs(ta, 1, 0); - } else { - nptr = buffer; - } - Arg_AddToToolArgs(ta, 2, nptr); -} - -void Options_Init(void) { - numoptionlists = 0; - maxlegalset = 0; - numlegalset = 0; - numinternalset = 0; - - if (legalset.list) - free(legalset.list); - if (internalset.list) - free(internalset.list); - - legalset.list = 0; - legalset.flags = - ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | - ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | - ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); - internalset.list = 0; - internalset.flags = - ((Option_ThisTool() & OTF_TOOL_COMPILER) ? LISTFLAGS_COMPILER : 0) | - ((Option_ThisTool() & OTF_TOOL_LINKER) ? LISTFLAGS_LINKER : 0) | - ((Option_ThisTool() & OTF_TOOL_DISASSEMBLER) ? LISTFLAGS_DISASSEMBLER : 0); - - Args_InitStack(); -} - -OptionList *Options_GetOptions(void) { - return &legalset; -} - -void Options_SortOptions(void) { - int r; - - if (numinternalset > 0) { - legalset.list = (Option **) xrealloc("options", legalset.list, sizeof(Option *) * (numinternalset + 1)); - for (r = 0; r < numinternalset; r++) { - if (internalset.list[r]->avail & (OTF_STICKY | OTF_CASED)) - legalset.list[numlegalset++] = internalset.list[r]; - } - for (r = 0; r < numinternalset; r++) { - if (!(internalset.list[r]->avail & (OTF_STICKY | OTF_CASED))) - legalset.list[numlegalset++] = internalset.list[r]; - } - legalset.list[numlegalset] = 0; - - if (internalset.list) - free(internalset.list); - internalset.list = 0; - numinternalset = 0; - } -} - -static void Options_AddOption(Option *opt) { - if (numinternalset >= maxlegalset) { - maxlegalset += 32; - internalset.list = (Option **) xrealloc("options", internalset.list, sizeof(Option *) * (maxlegalset + 1)); - } - - internalset.list[numinternalset++] = opt; - internalset.list[numinternalset] = 0; -} - -int Options_AddList(OptionList *optlst) { - Option **ptr; - - if (numoptionlists >= 32) - CLPFatalError("Too many option lists defined!"); - - optionlists[numoptionlists++] = optlst; - for (ptr = optlst->list; *ptr; ptr++) - Options_AddOption(*ptr); - - return 1; -} - -int Options_AddLists(OptionList **optlst) { - int ret = 1; - OptionList **ptr; - - for (ptr = optlst; *ptr; ptr++) { - ret = Options_AddList(*ptr); - if (!ret) - return ret; - } - - return ret; -} - -static void Options_Reset(OptionList *optlst) { - Option **os; - - os = optlst->list; - if (os) { - for (; *os; os++) { - (*os)->avail &= ~(OTF_INTERNAL_ALREADY_SEEN | OTF_INTERNAL_SEEN_CONFLICTED); - } - } -} - -static void Option_SpellList(char *buffer, OptionList *conflicts, int flags) { - Option **scan; - Boolean first; - int total; - char tmp[256]; - Option **next; - int slflags; - - scan = conflicts->list; - first = 1; - total = 0; - 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]) { - if (!first) - buffer += sprintf(buffer, ", "); - if (first) - first = 0; - - if (total > 1) { - while (*next && (((*next)->avail & (((parseopts.helpFlags & HELPFLAGS_SECRET) ? 0 : OTF_SECRET) | ((parseopts.helpFlags & HELPFLAGS_DEPRECATED) ? 0 : OTF_DEPRECATED) | OTF_SUBSTITUTED)) || !(*next)->names[0])) { - ++next; - } - - if (!*next) - buffer += sprintf(buffer, "or "); - } - - slflags = (flags & OPTSPELLFLAG_2) ? SLFLAGS_2 : SLFLAGS_1; - switch ((*scan)->avail & OTF_SLFLAGS_MASK) { - case OTF_SLFLAGS_8: - slflags |= SLFLAGS_8; - break; - case OTF_SLFLAGS_20: - slflags |= SLFLAGS_20; - break; - case OTF_SLFLAGS_10: - slflags |= SLFLAGS_10; - break; - } - - Utils_SpellList((*scan)->names, tmp, slflags); - total++; - buffer += sprintf(buffer, "%s", tmp); - - if ((*scan)->avail & OTF_HAS_SUB_OPTIONS) - buffer += sprintf(buffer, " ..."); - } - scan++; - } -} - -int Option_ForTool(Option *opt, int which) { - return !which || (opt->avail & which); -} - -int Option_ThisTool(void) { - return (pTool->TYPE == CWDROPINCOMPILERTYPE) ? OTF_TOOL_COMPILER : OTF_TOOL_LINKER; -} - -int Option_ForThisTool(Option *opt) { - return !Option_ForTool(opt, OTF_TOOL_MASK) || Option_ForTool(opt, Option_ThisTool()); -} - -int Option_AlsoPassedToTool(Option *opt, int which) { - return Option_ForThisTool(opt) && Option_ForTool(opt, which); -} - -int Option_AlsoPassedFromThisTool(Option *opt) { - return Option_ForThisTool(opt) && Option_ForTool(opt, ~Option_ThisTool() & OTF_TOOL_MASK); -} - -static Boolean Option_ContinuesThisLevel(int level, ArgToken *tok) { - ArgToken *tmp; - int ret; // not in stabs but i think this exists - - if (level == 1) { - return (tok->val == ATK_ARG_END) || (tok->val == ATK_OPTION) || (tok->val == ATK_ARG); - } else if (level == 2) { - tmp = Arg_UsedToken(); - ret = (tok->val == ATK_COMMA && tmp->val != ATK_OPTION) || (tok->val == ATK_ARG && tmp->val != ATK_ARG_END); - Arg_UndoToken(); - return ret; - } else if (level == 3) { - return (tok->val == ATK_EQUALS) || (tok->val == ATK_ARG); - } else { - return 0; - } -} - -static short endingStack[5][3] = { - ATK_END, ATK_END, ATK_END, - ATK_ARG_END, ATK_COMMA, ATK_OPTION, - ATK_COMMA, ATK_END, ATK_END, - ATK_EQUALS, ATK_END, ATK_END, - ATK_END, ATK_END, ATK_END -}; -static Boolean Option_IsEndingThisLevel(int level, ArgToken *tok) { - ArgToken *tmp; - - if (!tok) - 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) { - if (!tok) - return 1; - - while (level > 0) { - if (Option_IsEndingThisLevel(level - 1, tok)) - return 1; - level--; - } - - return 0; -} - -int Option_Parse(Option *opt, int oflags) { - 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 & OTF_INTERNAL_ALREADY_SEEN) && (opt->avail & OTF_ONLY_ONCE)) { - Option_Warning(CLPStr30_OptionShouldNotBeSpecifiedMultipleTimes); - } else if (opt->avail & OTF_HAS_CONFLICTS) { - cscan = opt->conflicts->list; - while (*cscan && (*cscan == opt || !((*cscan)->avail & OTF_INTERNAL_ALREADY_SEEN))) { - ++cscan; - } - - if (*cscan && *cscan != opt) { - (*cscan)->avail &= ~OTF_INTERNAL_ALREADY_SEEN; - Option_SpellList(errstr, opt->conflicts, oflags); - if (opt->conflicts->help) - Option_Warning(CLPStr32_OptionOverridesEffectWithHelp, (*cscan)->names, errstr, opt->conflicts->help); - else - Option_Warning(CLPStr31_OptionOverridesEffect, (*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_ARG_END, 0); - Args_AddToToolArgs(&linkargs); - } - - if (!(flags & PFLAGS_1)) { - if (opt->avail & OTF_OBSOLETE) { - if (opt->help) - Option_Error(CLPStr22_OptionObsoleteWithHelp, opt->help); - else - Option_Error(CLPStr21_OptionObsolete); - flags |= PFLAGS_1; - } - - if (opt->avail & OTF_IGNORED) { - if (!(opt->avail & (OTF_WARNING | OTF_MEANINGLESS))) { - if (opt->help) - Option_Warning(CLPStr27_OptionIgnoredWithText, opt->help); - else - Option_Warning(CLPStr26_OptionIgnored); - } - flags |= PFLAGS_1; - } else if (opt->avail & OTF_SUBSTITUTED) { - Option_Warning(CLPStr23_OptionXSubstitutedWithX, curopt, opt->help); - } else if (opt->avail & OTF_DEPRECATED) { - if (opt->help) - Option_Warning(CLPStr25_OptionDeprecatedWithHelp, opt->help); - else - Option_Warning(CLPStr24_OptionDeprecated); - } - - if (opt->avail & OTF_WARNING) - Option_Warning(CLPStr28_WarningText, opt->help); - if (opt->avail & OTF_MEANINGLESS) - Option_Warning(CLPStr29_OptionHasNoEffect); - } - - opt->avail |= OTF_INTERNAL_ALREADY_SEEN; - if (opt->avail & OTF_HAS_CONFLICTS) { - scan = opt->conflicts->list; - opt->avail |= OTF_INTERNAL_SEEN_CONFLICTED; - while (*scan) { - (*scan)->avail |= OTF_INTERNAL_SEEN_CONFLICTED; - scan++; - } - } - } else { - flags |= PFLAGS_1; - } - - goingtosubparse = opt->avail & OTF_HAS_SUB_OPTIONS; - if (opt->param) { - ret = Params_Parse(opt->param, flags | (goingtosubparse ? PFLAGS_20 : 0)); - } else { - tok = Arg_PeekToken(); - if (tok && tok->val == ATK_EQUALS) - 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 & OTF_SUB_OPTIONS_OPTIONAL) ? OFLAGS_4 : 0) - ); - } - - if (pushed) - Option_PopOpt(curopt); - - if (Option_ThisTool() == OTF_TOOL_COMPILER && !subparse) - Arg_AddToToolArgs(&linkargs, ATK_ARG_END, 0); - - return ret; -} - -static int Option_MatchString(char *list, char *str, int flags, int *result) { - 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) { - 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 & OTF_STICKY) == OTF_STICKY) { - 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 & OTF_STICKY) { - matched = Utils_CompareOptionString((*os)->names, curopt, (*os)->avail & OTF_CASED, 2); - if (matched) - stickyflags |= OTF_STICKY; - } else { - matched = 0; - } - - if (matched) - stickyopt = *os; - - ++os; - } - } - - *flags = stickyflags; - return stickyopt; -} - -static int Options_DoParse(OptionList *search, int flags) { - // 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 *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_OPTION)) || ((mystery_r31 == 2) && (token_r18->val == ATK_ARG) && (token_r18->text[0] || search->flags & LISTFLAGS_4)) || ((mystery_r31 == 3) && (token_r18->val == ATK_EQUALS)); - // 950 17CFD4 - if ((mystery_r31 == 3) && isOpt) { - token_r18 = Arg_UsedToken(); - isOpt = token_r18 && (token_r18->val == ATK_ARG); - 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_OPTION) - 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(CLPStr34_ArgumentsExpected, 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_EQUALS) - 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_ALLOW_UNKNOWNS) { - if (!(flags & OFLAGS_1)) { - Option_SpellList(curparam, search, flags); - Option_Warning(CLPStr20_UnknownOptionX_ExpectedOneOfX, token_r18->text, curparam); - } - Arg_UsedToken(); - parsedany = 1; - } else { - // 1090 - Option_SpellList(curparam, search, flags); - Option_Error(CLPStr20_UnknownOptionX_ExpectedOneOfX, token_r18->text, curparam); - failed = 1; - haderrors++; - } - } else { - // 1099 - if ((search->flags & LISTFLAGS_ALLOW_UNKNOWNS) || parseopts.ignoreUnknown) { - // 1101 - if (!(flags & OFLAGS_1)) - Option_Warning(CLPStr19_UnknownOptionX, token_r18->text); - Arg_UsedToken(); - Arg_GetToken(); - parsedany = 1; - } else { - // 1115 - Option_Error(CLPStr19_UnknownOptionX, 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_ARG)) { - // 1142 - opttok = 0; - curopt[0] = 0; - opt = Option_Lookup(search, 0, &matchflags); - strcpy(curopt, token_r18->text); - if (!opt) { - Option_Warning(CLPStr33_NoDefaultHandlerSetUpForX_Ignoring, curopt); - failed = 1; - } else { - if (!(flags & OFLAGS_1)) { - haderrors = Option_Parse(opt, flags) == 0; - } else { - parseopts.possibleFiles++; - haderrors = 0; - } - parsedany++; - 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(CLPStr34_ArgumentsExpected, 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_ARG) && (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(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); - Option_PopOpt(0); - } else { - CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, 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_OPTION)) { - // 1280 - if (opttok) { - Option_PushOpt(0, opttok->text); - if (tok->val == ATK_ARG) - Param_Error(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); - else - Param_Error(CLPStr35_TokenXNotExpected, Arg_GetTokenName(prev)); - Option_PopOpt(opttok->text); - } else if (tok->val == ATK_ARG) { - // 1292 - CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); - } else { - // 1294 - CLPReportError(CLPStr35_TokenXNotExpected, 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_ARG) - Param_Error(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); - else - Param_Error(CLPStr35_TokenXNotExpected, Arg_GetTokenName(tok)); - Option_PopOpt(opttok->text); - } else if (tok->val == ATK_ARG) { - CLPReportError(CLPStr36_UnexpectedAdditionalArgumentX, Arg_GetTokenName(tok)); - } else { - CLPReportError(CLPStr35_TokenXNotExpected, Arg_GetTokenName(tok)); - } - haderrors++; - failed++; - } - } - } // else: 1323 - - if (haderrors || failed) { - while (!Option_IsEndingLevel(mystery_r31, tok)) - tok = Arg_GetToken(); - if (!tok) - tok = Arg_UndoToken(); - OS_ASSERT(1335, 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) { - // options: r30 - // flags: r31 - int ret; // r31 - char savecuropt[64]; // stack 0x3C - - Options_Reset(options); - Option_PushList(options); - - if (!(flags & 2)) { - ret = Options_DoParse(options, flags); - if (Option_ThisTool() == OTF_TOOL_COMPILER) - Arg_AddToToolArgs(&linkargs, 1, 0); - } else { - strcpy(savecuropt, curopt); - ret = Options_DoParse(options, flags); - strcpy(curopt, savecuropt); - } - - Option_PopList(); - return ret; -} - -int Option_ParseDefaultOption(OptionList *options) { - // options: r31 - int ret; // r31 - Option *dopt; // r0 - int matchflags; // 0x3C - - Options_Reset(options); - Option_PushList(options); - - strcpy(curopt, "defaultoptions"); - dopt = Option_Lookup(options, 0, &matchflags); - if (!dopt) { - CLPFatalError("Default options not defined"); - ret = 1; - } else { - ret = Option_Parse(dopt, 0); - } - - Option_PopList(); - return ret; -} - -void Option_ParamError(short id, va_list ap) { - char buf[4096]; - - CLPGetErrorString(id, buf); - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - CLPReportError_V(buf, ap); -} - -void Option_ParamWarning(short id, va_list ap) { - char buf[1024]; - - CLPGetErrorString(id, buf); - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - CLPReportWarning_V(buf, ap); -} - -void Option_OptionError(short id, va_list ap) { - char buf[1024]; - - CLPGetErrorString(id, buf); - if (Args_StackSize() >= 2) { - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - } - CLPReportError_V(buf, ap); -} - -void Option_OptionWarning(short id, va_list ap) { - char buf[1024]; - - CLPGetErrorString(id, buf); - if (Args_StackSize() >= 2) { - sprintf(&buf[strlen(buf)], "\nwhile parsing option '"); - Args_SpellStack(&buf[strlen(buf)], 0); - sprintf(&buf[strlen(buf)], "'"); - } - CLPReportWarning_V(buf, ap); -} - -void Option_Error(short id, ...) { - va_list va; - va_start(va, id); - Option_OptionError(id, va); - va_end(va); -} - -void Option_Warning(short id, ...) { - va_list va; - va_start(va, id); - Option_OptionWarning(id, va); - va_end(va); -} - -int Options_Help(const char *keyword) { - // keyword: r31 - int scan; // r26 - OptionList *lst; // r25 - - Help_Init(); - - if (parseopts.helpFlags & HELPFLAGS_USAGE) { - ShowVersion(1); - Help_Line('='); - Help_Usage(); - } else { - ShowVersion(1); - for (scan = 0; scan < numoptionlists; scan++) { - if ((lst = optionlists[scan])) { - if (parseopts.helpFlags & HELPFLAGS_8000) { - if (keyword && keyword[0] && lst->help && strstr(lst->help, keyword)) - Help_Options(lst, 0, ""); - } else { - Help_Options(lst, 0, keyword); - } - } - } - } - - Help_Term(); - return 1; -} - -int Option_Help(const char *opt) { - // opt: r31 - Option *find; // r29 - int matchflags; // stack 0x3C - int ret; // r29 - - find = 0; - Option_PushList(Options_GetOptions()); - Option_PushOpt(0, "help"); - if (opt[0] == MAINOPTCHAR[0]) - strcpy(curopt, opt + 1); - else - strcpy(curopt, opt); - - if (!curopt[1]) - find = Option_Lookup(Options_GetOptions(), 0x700002, &matchflags); - if (!find) - find = Option_Lookup(Options_GetOptions(), 0x700000, &matchflags); - - if (find) { - Help_Init(); - if (!Help_Option(Options_GetOptions(), find, 0, "")) - CLPReportWarning(CLPStr38_NoHelpAvailableForOptionX, opt); - Help_Term(); - ret = 1; - } else { - Option_Error(CLPStr19_UnknownOptionX, opt); - ret = 0; - } - - Option_PopOpt(curopt); - Option_PopList(); - return ret; -} - -int Options_DisplayHelp(void) { - if (parseopts.helpFlags & HELPFLAGS_1) - return Option_Help(parseopts.helpKey); - else - return Options_Help(parseopts.helpKey); -} diff --git a/unsorted/Parameter.c b/unsorted/Parameter.c deleted file mode 100644 index 31669e1..0000000 --- a/unsorted/Parameter.c +++ /dev/null @@ -1,1145 +0,0 @@ -#include "parser.h" - -char curparam[4096]; -char *descparam = &curparam[0]; -char *helpparam = &curparam[1024]; -char *defaultparam = &curparam[2048]; - -#define copy_8(dst, src) \ -do { \ -((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ -} while (0) - -#define copy_16(dst, src) \ -do { \ -((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ -((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ -} while (0) - -#define copy_32(dst, src) \ -do { \ -((unsigned char *) (dst))[0] = ((unsigned char *) (src))[0]; \ -((unsigned char *) (dst))[1] = ((unsigned char *) (src))[1]; \ -((unsigned char *) (dst))[2] = ((unsigned char *) (src))[2]; \ -((unsigned char *) (dst))[3] = ((unsigned char *) (src))[3]; \ -} while (0) - -#define inline_write_32(dst, val) do { \ -union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ -copy_32(_arg.bytes, val); \ -_val.lg = _arg.lg; \ -copy_32(dst, _val.bytes); \ -} while (0) - -#define inline_write_16(dst, val) do { \ -union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ -copy_16(_arg.bytes, val); \ -_val.sh = _arg.sh; \ -copy_16(dst, _val.bytes); \ -} while (0) - -#define inline_write_8(ptr, val) copy_8(ptr, val) - -#define inline_andor_32(dst, and, or) do { \ -union {unsigned char bytes[4]; unsigned long lg;} _val, _arg, _arg2; \ -copy_32(_val.bytes, dst); \ -copy_32(_arg.bytes, and); \ -copy_32(_arg2.bytes, or); \ -_val.lg = (_val.lg & ~_arg.lg) | _arg2.lg; \ -copy_32(dst, _val.bytes); \ -} while(0) - -#define inline_andor_16(dst, and, or) do { \ -union {unsigned char bytes[2]; unsigned short sh;} _val, _arg, _arg2; \ -copy_16(_val.bytes, dst); \ -copy_16(_arg.bytes, and); \ -copy_16(_arg2.bytes, or); \ -_val.sh = (_val.sh & ~_arg.sh) | _arg2.sh; \ -copy_16(dst, _val.bytes); \ -} while(0) - -#define inline_andor_8(dst, and, or) do { \ -((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] & ~((unsigned char *) (and))[0]) | ((unsigned char *) (or))[0]; \ -} while(0) - -#define inline_xor_32(dst, arg) do { \ -union {unsigned char bytes[4]; unsigned long lg;} _val, _arg; \ -copy_32(_val.bytes, dst); \ -copy_32(_arg.bytes, arg); \ -_val.lg = _val.lg ^ _arg.lg; \ -copy_32(dst, _val.bytes); \ -} while(0) - -#define inline_xor_16(dst, arg) do { \ -union {unsigned char bytes[2]; unsigned short sh;} _val, _arg; \ -copy_16(_val.bytes, dst); \ -copy_16(_arg.bytes, arg); \ -_val.sh = _val.sh ^ _arg.sh; \ -copy_16(dst, _val.bytes); \ -} while(0) - -#define inline_xor_8(dst, arg) do { \ -((unsigned char *) (dst))[0] = (((unsigned char *) (dst))[0] ^ ((unsigned char *) (arg))[0]); \ -} while(0) - -// forward declaration -static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec); -static int Param_Parse(PARAM_T *param, const char *cparam, int flags); - -static int Param_None(PARAM_T *p, const char *pstr, int flags) { - return 1; -} - -static void DescHelpParam_None(PARAM_T *p, const char **desc, const char **help, const char **defaul) { - *desc = 0; - *help = 0; - *defaul = 0; -} - -static int CompareParam_None(PARAM_T *p) { - return 0; -} - -static void DescHelpParam_Number(NUM_T *p, const char **desc, const char **help, const char **defaul) { - unsigned long value; - unsigned char value8; - unsigned short value16; - - value = 0; - *desc = 0; - if (p->myname) - *desc = p->myname; - - if (p->size == 1) { - if (!*desc) - *desc = "byte"; - if (p->num) copy_8(&value8, p->num); - value = value8; - } else if (p->size == 2) { - if (!*desc) - *desc = "short"; - if (p->num) copy_16(&value16, p->num); - value = value16; - } else if (p->size == 4) { - if (!*desc) - *desc = "long"; - if (p->num) copy_32(&value, p->num); - } - - if (p->size == 4) { - if (p->lo != p->hi) - sprintf(helpparam, "range 0x%x - 0x%x", p->lo, p->hi); - *help = helpparam; - if (value <= 0x10000) - sprintf(defaultparam, "%u", value); - else - sprintf(defaultparam, "0x%x", value); - *defaul = defaultparam; - } else { - if (p->lo != p->hi) - sprintf(helpparam, "range %u - %u", p->lo, p->hi); - *help = helpparam; - sprintf(defaultparam, "%u", value); - *defaul = defaultparam; - } - - if (!p->num) - *defaul = 0; - if (p->lo == p->hi) - *help = 0; -} - -static int CompareParam_Number(NUM_T *p) { - return 0; -} - -static int Param_Number(NUM_T *p, const char *pstr, int flags) { - unsigned long val; - unsigned long lo; - unsigned long hi; - const char *opstr; - - val = 0; - opstr = pstr; - if (!pstr[0]) { - Param_Error(5, "", pstr); - return 0; - } - - if (((*pstr == '0') && my_tolower(pstr[1]) == 'x') || (*pstr == '$')) { - // 218 - if (pstr[0] == '$') - pstr += 1; - else - pstr += 2; - - while (*pstr) { - if (!my_isxdigit(*pstr)) { - Param_Error(5, "hexadecimal ", opstr); - return 0; - } - - if (val > 0xFFFFFFF) { - Param_Error(4, opstr); - return 0; - } - - val = (val << 4) | (my_isdigit(*pstr) ? (*pstr - '0') : (my_tolower(*pstr) - 'a' + 10)); - ++pstr; - } - } else if (pstr[0] == '0') { - pstr += 1; - - while (*pstr) { - if (*pstr < '0' || *pstr >= '8') { - Param_Error(5, "octal ", opstr); - return 0; - } - - if (val > 0x1FFFFFFF) { - Param_Error(4, opstr); - return 0; - } - - val = (val << 3) | (*pstr - '0'); - ++pstr; - } - } else { - while (*pstr) { - if (!my_isdigit(*pstr)) { - Param_Error(5, "decimal ", opstr); - return 0; - } - - if (val > 0x19999999) { - Param_Error(4, opstr); - return 0; - } - - val = (val * 10) + (*pstr - '0'); - ++pstr; - } - } - - if (p->lo == p->hi) { - if (p->size == 1) { - lo = 0; - hi = 0xFF; - } else if (p->size == 2) { - lo = 0; - hi = 0xFFFF; - } else { - lo = 0; - hi = 0xFFFFFFFF; - } - } else { - lo = p->lo; - hi = p->hi; - } - - if (!p->fit && (val < lo || val > hi)) { - Param_Error(6, val, lo, hi); - return 0; - } - - if (val < lo) { - Param_Warning(7, val, lo, hi, lo); - val = lo; - } else if (val > hi) { - Param_Warning(7, val, lo, hi, hi); - val = hi; - } - - if (p->size == 1) { - unsigned char val8 = val; - inline_write_8(p->num, &val8); - } - - if (p->size == 2) { - unsigned short val16 = val; - inline_write_16(p->num, &val16); - } else if (p->size == 4) { - unsigned long val32 = val; - inline_write_32(p->num, &val32); - } - - return 1; -} - -static void DescHelpParam_FTypeCreator(FTYPE_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else if (p->iscreator) - *desc = "creator"; - else - *desc = "type"; - - if (!p->fc) { - *defaul = 0; - } else { - unsigned long tmp; - unsigned char *ptr; - - ptr = (unsigned char *) defaultparam; - tmp = *p->fc; - ptr[0] = '\''; - ptr[1] = tmp & 0xFF; - ptr[2] = (tmp >> 8) & 0xFF; - ptr[3] = (tmp >> 16) & 0xFF; - ptr[4] = (tmp >> 24) & 0xFF; - ptr[5] = '\''; - ptr[6] = 0; - *defaul = defaultparam; - } -} - -static int CompareParam_FTypeCreator(FTYPE_T *p) { - return 0; -} - -static int Param_FTypeCreator(FTYPE_T *p, const char *pstr, int flags) { - char x[4] = " "; - int cnt; - const char *opstr; - - cnt = 0; - opstr = pstr; - while (*pstr && cnt < 4) { - x[cnt++] = *(pstr++); - } - - if (*pstr) { - Param_Error(8, opstr); - return 0; - } - - inline_write_32(p->fc, &x); - return 1; -} - -static void DescHelpParam_String(STRING_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else - *desc = "string"; - - if (!p->str) { - *help = 0; - *defaul = 0; - } else { - sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); - *help = helpparam; - - if (*p->str) { - sprintf(defaultparam, "'%s'", p->str); - *defaul = defaultparam; - } else { - *defaul = "none"; - } - } -} - -static int CompareParam_String(STRING_T *p) { - return 0; -} - -static int Param_String(STRING_T *p, const char *pstr, int flags) { - int len; - - len = strlen(pstr); - strncpy(p->str, pstr, p->maxlen - 1); - if (p->pstring) - c2pstr(p->str); - - if (len > p->maxlen) { - Param_Error(9, pstr, pstr + len - 5, p->maxlen - 1); - return 0; - } - - return 1; -} - -static void DescHelpParam_ID_or_SYM(STRING_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else if (p->which == PARAMWHICH_Id) - *desc = "identifier"; - else - *desc = "symbol"; - - if (!p->str) { - *help = *defaul = 0; - } else { - sprintf(helpparam, "maximum length %d chars", p->maxlen - 1); - *help = helpparam; - - if (*p->str) { - sprintf(defaultparam, "'%s'", p->str); - *defaul = defaultparam; - } else { - *defaul = "none"; - } - } -} - -static int CompareParam_ID_or_SYM(STRING_T *p) { - return 0; -} - -static int Param_ID_or_SYM(STRING_T *p, const char *pstr, int flags) { - const char *ptr; - const char *x; - - if (Param_String(p, pstr, flags)) { - if (p->which == PARAMWHICH_Id) { - x = "$_"; - } else if (p->which == PARAMWHICH_Sym) { - x = "_.$@?#"; - } - - for (ptr = pstr; *ptr; ++ptr) { - if (ptr == pstr && my_isdigit(*ptr)) - Param_Warning(10, pstr); - - if (!my_isalnum(*ptr) && !strchr(x, *ptr)) - Param_Warning(11, pstr, *ptr); - } - - return 1; - } else { - return 0; - } -} - -static void DescHelpParam_OnOff(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { - unsigned char def; - - if (p->myname) - *desc = p->myname; - else - *desc = "on|off"; - - *help = 0; - if (!p->var) { - *defaul = 0; - } else { - if (p->var) - *((unsigned char *) &def) = *((unsigned char *) p->var); - if (def) - *defaul = "on"; - else - *defaul = "off"; - } -} - -static int CompareParam_OnOff(ONOFF_T *p) { - return 0; -} - -static int Param_OnOff(ONOFF_T *p, const char *pstr, int flags) { - Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; - - if (!ustrcmp(pstr, "on")) { - *(p->var) = mytrue; - } else if (!ustrcmp(pstr, "off")) { - *(p->var) = mytrue == 0; - } else { - Param_Error(12, pstr); - return 0; - } - - return 1; -} - -static void DescHelpParam_OffOn(ONOFF_T *p, const char **desc, const char **help, const char **defaul) { - unsigned char def; - - if (p->myname) - *desc = p->myname; - else - *desc = "off|on"; - - *help = 0; - if (!p->var) { - *defaul = 0; - } else { - if (p->var) - *((unsigned char *) &def) = *((unsigned char *) p->var); - if (!def) - *defaul = "on"; - else - *defaul = "off"; - } -} - -static int CompareParam_OffOn(OFFON_T *p) { - return 0; -} - -static int Param_OffOn(OFFON_T *p, const char *pstr, int flags) { - Boolean mytrue = (flags & PARAMPARSEFLAGS_8) == 0; - - if (!ustrcmp(pstr, "off")) { - *(p->var) = mytrue; - } else if (!ustrcmp(pstr, "on")) { - *(p->var) = mytrue == 0; - } else { - Param_Error(12, pstr); - return 0; - } - - return 1; -} - -static void DescHelpParam_FilePath(FILEPATH_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else - *desc = "filepath"; - - *help = 0; - *defaul = p->defaultstr; -} - -static int CompareParam_FilePath(FILEPATH_T *p) { - return 0; -} - -static int Param_FilePath(FILEPATH_T *p, const char *pstr, int flags) { - int err; - OSSpec spec; - char canon[256]; - int clen; - - if (!pstr[0]) { - ((unsigned char *) p->filename)[0] = 0; - return 1; - } - - err = OS_MakeFileSpec(pstr, &spec); - if (err) { - Param_Error(18, pstr, OS_GetErrText(err)); - return 0; - } - - OS_SpecToString(&spec, canon, sizeof(canon)); - if (p->fflags & 1) { - c2pstrcpy(p->filename, canon); - } else { - clen = strlen(canon); - if (clen > p->maxlen) { - Param_Error(13, canon + clen - 32, canon); - return 0; - } - strcpy(p->filename, canon); - } - - return 1; -} - -static void DescHelpParam_Mask(MASK_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_Mask(MASK_T *p) { - if (p->size == 1) { - unsigned char or8 = p->ormask, and8 = p->andmask, val8; - if (p->num) copy_8(&val8, p->num); - return ((val8 & ~and8) | or8) == val8; - } else if (p->size == 2) { - unsigned short or16 = p->ormask, and16 = p->andmask, val16; - if (p->num) copy_16(&val16, p->num); - return ((val16 & ~and16) | or16) == val16; - } else { - unsigned long or32 = p->ormask, and32 = p->andmask, val32; - if (p->num) copy_32(&val32, p->num); - return ((val32 & ~and32) | or32) == val32; - } -} - -static int Param_Mask(MASK_T *p, const char *pstr, int flags) { - if (p->size == 1) { - unsigned char or8 = p->ormask, and8 = p->andmask, tmp8; - if (flags & PARAMPARSEFLAGS_8) { - tmp8 = and8; - and8 = and8 | or8; - or8 = tmp8; - } - inline_andor_8(p->num, &and8, &or8); - } else if (p->size == 2) { - unsigned short or16 = p->ormask, and16 = p->andmask, tmp16; - if (flags & PARAMPARSEFLAGS_8) { - tmp16 = and16; - and16 = and16 | or16; - or16 = tmp16; - } - inline_andor_16(p->num, &and16, &or16); - } else { - unsigned long or32 = p->ormask, and32 = p->andmask, tmp32; - if (flags & PARAMPARSEFLAGS_8) { - tmp32 = and32; - and32 = and32 | or32; - or32 = tmp32; - } - inline_andor_32(p->num, &and32, &or32); - } - return 1; -} - -static void DescHelpParam_Toggle(TOGGLE_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_Toggle(TOGGLE_T *p) { - if (p->size == 1) { - unsigned char mask8, val8; - mask8 = (unsigned char) p->mask; - if (p->num) copy_8(&val8, p->num); - return (val8 ^ mask8) == val8; - } else if (p->size == 2) { - unsigned short mask16, val16; - mask16 = (unsigned short) p->mask; - if (p->num) copy_16(&val16, p->num); - return (val16 ^ mask16) == val16; - } else { - unsigned long mask32, val32; - mask32 = p->mask; - if (p->num) copy_16(&val32, p->num); // BUG ALERT - return (val32 ^ mask32) == val32; - } -} - -static int Param_Toggle(TOGGLE_T *p, const char *pstr, int flags) { - if (p->size == 1) { - unsigned char val8; - val8 = (unsigned char) p->mask; - inline_xor_8(p->num, &val8); - } else if (p->size == 2) { - unsigned short val16; - val16 = (unsigned short) p->mask; - inline_xor_16(p->num, &val16); - } else { - inline_xor_32(p->num, &p->mask); - } - return 1; -} - -static void DescHelpParam_Set(SET_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_Set(SET_T *p) { - if (p->size == 1) { - unsigned char set8, val8; - set8 = (unsigned char) p->value; - if (p->num) copy_8(&val8, p->num); - return set8 == val8; - } else if (p->size == 2) { - unsigned short set16, val16; - set16 = (unsigned short) p->value; - if (p->num) copy_16(&val16, p->num); - return set16 == val16; - } else { - unsigned long set32, val32; - set32 = p->value; - if (p->num) copy_32(&val32, p->num); - return set32 == val32; - } -} - -static int Param_Set(SET_T *p, const char *pstr, int flags) { - if (p->size == 1) { - unsigned char val8; - val8 = (unsigned char) p->value; - if ((flags & PARAMPARSEFLAGS_8) && val8 <= 1) - val8 = (val8 == 0); - inline_write_8(p->num, &val8); - } else if (p->size == 2) { - unsigned short val16; - val16 = (unsigned short) p->value; - if ((flags & PARAMPARSEFLAGS_8) && val16 <= 1) - val16 = (val16 == 0); - inline_write_16(p->num, &val16); - } else { - unsigned long val32; - val32 = p->value; - if ((flags & PARAMPARSEFLAGS_8) && val32 <= 1) - val32 = (val32 == 0); - inline_write_32(p->num, &val32); - } - return 1; -} - -static void DescHelpParam_SetString(SETSTRING_T *p, const char **desc, const char **help, const char **defaul) { - *help = 0; - *desc = 0; - *defaul = 0; -} - -static int CompareParam_SetString(SETSTRING_T *p, int flags) { - if (p->pstring) - return pstrcmp((const unsigned char *) p->var, (const unsigned char *) p->value) == 0; - else - return strcmp(p->var, p->value) == 0; -} - -static int Param_SetString(SETSTRING_T *p, const char *pstr, int flags) { - if (p->pstring) - memcpy(p->var, p->value, p->value[0]); - else - strcpy(p->var, p->value); - return 1; -} - -static void DescHelpParam_Generic(GENERIC_T *p, const char **desc, const char **help, const char **defaul) { - if (p->myname) - *desc = p->myname; - else if ((p->flags & PARAMFLAGS_3) != 1) - *desc = "xxx"; - else - *desc = 0; - *help = p->help; - *defaul = 0; -} - -static int CompareParam_Generic(GENERIC_T *p) { - return 0; -} - -static int Param_Generic(GENERIC_T *p, const char *pstr, int flags) { - return p->parse(curopt, p->var, pstr, flags); -} - -static void DescHelpParam_Setting(SETTING_T *p, const char **desc, const char **help, const char **defaul) { - char *dptr = descparam; - - dptr += sprintf(dptr, "%s", p->myname ? p->myname : "var"); - if ((p->flags & PARAMFLAGS_3) != 1) { - sprintf(dptr, - "%s=%s%s", - (p->flags & PARAMFLAGS_2) ? "[" : "", - p->valuename ? p->valuename : "...", - (p->flags & PARAMFLAGS_2) ? "]" : "" - ); - } - *desc = descparam; - *help = 0; - *defaul = 0; -} - -static int CompareParam_Setting(SETTING_T *p) { - return 0; -} - -static int Param_Setting(SETTING_T *p, const char *pstr, int flags) { - char savevar[256]; - const char *vstr; - ArgToken *tok; - Boolean equals = 0; - - if (!pstr) { - Param_Error(40); - return 0; - } - - strncpy(savevar, pstr, sizeof(savevar)); - tok = Arg_PeekToken(); - if (tok && tok->val == ATK_EQUALS) { - Arg_UsedToken(); - equals = 1; - if (!Param_GetArgument((PARAM_T *) p, &vstr, flags)) - return 0; - } else { - vstr = 0; - } - - if (!vstr && equals) - vstr = ""; - - return p->parse(savevar, vstr); -} - -static void DescHelpParam_IfArg(IFARG_T *p, const char **desc, const char **help, const char **defaul) { - const char *d1 = 0; - const char *d2 = 0; - const char *h1 = 0; - const char *h2 = 0; - const char *df1 = 0; - const char *df2 = 0; - char desclocal[1024]; - char *dptr = desclocal; - char helplocal[1024]; - char *hptr = helplocal; - const char *ind; - - desclocal[0] = 0; - helplocal[0] = 0; - - if (p->parg) - Param_DescHelp(p->parg, &d1, &h1, &df1); - if (p->pnone) - Param_DescHelp(p->pnone, &d2, &h2, &df2); - - if (p->helpa && p->helpn) { - if (df1) - hptr += sprintf(hptr, "%s (default is %s), else %s", p->helpa, df1, p->helpn); - else - hptr += sprintf(hptr, "%s, else %s", p->helpa, p->helpn); - } else if (p->helpa) { - hptr += sprintf(hptr, "%s", p->helpa); - if (df1) - hptr += sprintf(hptr, "; default is %s", df1); - } else if (p->helpn) { - hptr += sprintf(hptr, "nothing, else %s", p->helpn); - } - - if (d1) { - if (p->myname) { - dptr += sprintf(dptr, "[%s]", p->myname ? p->myname: "param"); - } else if (h1) { - ind = strchr(d1, '\n'); - if (!ind) - ind = d1 + strlen(d1); - dptr += sprintf(dptr, "[%.*s]", ind - d1, d1); - } else { - dptr += sprintf(dptr, "[%s]", d1); - d1 = 0; - } - } - - if (h1 || h2) { - dptr += sprintf(dptr, "\n\t"); - hptr += sprintf(hptr, "\n\t"); - if (h1) { - if (d1) - dptr += sprintf(dptr, "%s", d1); - if (h1) - hptr += sprintf(hptr, "%s", h1); - if (h2) { - dptr += sprintf(dptr, "\b\t"); - hptr += sprintf(hptr, "\b\t"); - } - } - if (h2) { - if (d2) - dptr += sprintf(dptr, "%s", d2); - else - dptr += sprintf(dptr, "(if blank)"); - if (h2) - hptr += sprintf(hptr, "%s", h2); - dptr += sprintf(dptr, "\n"); - hptr += sprintf(hptr, "\n"); - } - dptr += sprintf(dptr, "\b"); - hptr += sprintf(hptr, "\b"); - } - - if (dptr != desclocal) { - strcpy(descparam, desclocal); - *desc = descparam; - } else { - *desc = 0; - } - - if (hptr != helplocal) { - strcpy(helpparam, helplocal); - *help = helpparam; - } else { - *help = 0; - } - - *defaul = 0; -} - -static int CompareParam_IfArg(IFARG_T *p) { - return 0; -} - -static int Param_IfArg(IFARG_T *p, const char *pstr, int flags) { - if (pstr) - return Param_Parse(p->parg, pstr, flags); - else if (p->pnone) - return Param_Parse(p->pnone, pstr, flags); - else - return 1; -} - -typedef int (*PARSE_FUNC)(PARAM_T *, const char *, int); -PARSE_FUNC ParamParsers[16] = { - (PARSE_FUNC) &Param_None, - (PARSE_FUNC) &Param_FTypeCreator, - (PARSE_FUNC) &Param_FilePath, - (PARSE_FUNC) &Param_Number, - (PARSE_FUNC) &Param_String, - (PARSE_FUNC) &Param_ID_or_SYM, - (PARSE_FUNC) &Param_ID_or_SYM, - (PARSE_FUNC) &Param_OnOff, - (PARSE_FUNC) &Param_OffOn, - (PARSE_FUNC) &Param_Mask, - (PARSE_FUNC) &Param_Toggle, - (PARSE_FUNC) &Param_Set, - (PARSE_FUNC) &Param_SetString, - (PARSE_FUNC) &Param_Generic, - (PARSE_FUNC) &Param_IfArg, - (PARSE_FUNC) &Param_Setting -}; - -static int Param_Parse(PARAM_T *param, const char *cparam, int flags) { - if (!param) - CLPFatalError("PARAM_T is NULL"); - - if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { - return ParamParsers[param->which](param, cparam, flags); - } else { - CLPFatalError("Unhandled PARAM_T (%d)", param->which); - return 0; - } -} - -typedef void (*DESC_HELP_FUNC)(PARAM_T *, const char **, const char **, const char **); -DESC_HELP_FUNC DescHelpParams[16] = { - (DESC_HELP_FUNC) &DescHelpParam_None, - (DESC_HELP_FUNC) &DescHelpParam_FTypeCreator, - (DESC_HELP_FUNC) &DescHelpParam_FilePath, - (DESC_HELP_FUNC) &DescHelpParam_Number, - (DESC_HELP_FUNC) &DescHelpParam_String, - (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, - (DESC_HELP_FUNC) &DescHelpParam_ID_or_SYM, - (DESC_HELP_FUNC) &DescHelpParam_OnOff, - (DESC_HELP_FUNC) &DescHelpParam_OffOn, - (DESC_HELP_FUNC) &DescHelpParam_Mask, - (DESC_HELP_FUNC) &DescHelpParam_Toggle, - (DESC_HELP_FUNC) &DescHelpParam_Set, - (DESC_HELP_FUNC) &DescHelpParam_SetString, - (DESC_HELP_FUNC) &DescHelpParam_Generic, - (DESC_HELP_FUNC) &DescHelpParam_IfArg, - (DESC_HELP_FUNC) &DescHelpParam_Setting -}; -void Param_DescHelp(PARAM_T *param, const char **desc, const char **help, const char **defaul) { - *desc = 0; - *help = 0; - *defaul = 0; - - if (!param) { - CLPFatalError("PARAM_T is NULL"); - return; - } - - if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { - DescHelpParams[param->which](param, desc, help, defaul); - } else { - CLPFatalError("Unhandled PARAM_T (%d)", param->which); - } -} - -typedef int (*COMPARE_FUNC)(PARAM_T *); -COMPARE_FUNC CompareParams[16] = { - (COMPARE_FUNC) &CompareParam_None, - (COMPARE_FUNC) &CompareParam_FTypeCreator, - (COMPARE_FUNC) &CompareParam_FilePath, - (COMPARE_FUNC) &CompareParam_Number, - (COMPARE_FUNC) &CompareParam_String, - (COMPARE_FUNC) &CompareParam_ID_or_SYM, - (COMPARE_FUNC) &CompareParam_ID_or_SYM, - (COMPARE_FUNC) &CompareParam_OnOff, - (COMPARE_FUNC) &CompareParam_OffOn, - (COMPARE_FUNC) &CompareParam_Mask, - (COMPARE_FUNC) &CompareParam_Toggle, - (COMPARE_FUNC) &CompareParam_Set, - (COMPARE_FUNC) &CompareParam_SetString, - (COMPARE_FUNC) &CompareParam_Generic, - (COMPARE_FUNC) &CompareParam_IfArg, - (COMPARE_FUNC) &CompareParam_Setting -}; -int Param_Compare(PARAM_T *param) { - if (!param) - CLPFatalError("PARAM_T is NULL"); - - if (param->which >= PARAMWHICH_None && param->which < PARAMWHICH_MAX) { - return CompareParams[param->which](param); - } else { - CLPFatalError("Unhandled PARAM_T (%d)", param->which); - return 0; - } -} - -static void Param_PushParam(const char *param) { - Args_Push(4, (void *) param, 0); -} - -static void Param_PopParam(void) { - Args_Pop(4); -} - -static Boolean Param_IsNonTextFile(const char *fname, Boolean warn) { - OSSpec tmp; - CWDataType mactype; - Boolean isfile; - - if (!OS_MakeSpec(fname, &tmp, &isfile)) { - if (isfile) { - if (!OS_Status(&tmp)) { - if (!OS_GetMacFileType(&tmp, &mactype)) { - if (mactype != 'TEXT') { - if (warn) - Param_Warning(77, fname); - return 1; - } - } - } - } - } - - return 0; -} - -static int Param_GetArgument(PARAM_T *param, const char **cparam, int exec) { - int subparse; - short nextOpt; - short nextParam; - short lastOpt; - ArgToken *tok; - - subparse = (exec & PARAMPARSEFLAGS_4) != 0; - nextOpt = !subparse ? ATK_ARG_END : ATK_COMMA; - nextParam = !subparse ? ATK_COMMA : ATK_EQUALS; - lastOpt = !subparse ? ATK_END : ATK_ARG_END; - - tok = Arg_PeekToken(); - OS_ASSERT(1467, tok); - - if ((param->flags & PARAMFLAGS_3) == 0) { - if (tok->val == nextParam || tok->val == ATK_EQUALS) - tok = Arg_UsedToken(); - if (tok->val == nextOpt || tok->val == nextParam || tok->val == lastOpt) { - Param_Error(34); - return 0; - } - if (tok->val != ATK_ARG) { - Param_Error(57, "parameter", Arg_GetTokenName(tok)); - return 0; - } - Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); - Arg_UsedToken(); - *cparam = curparam; - - if (param->flags & PARAMFLAGS_8) { - tok = Arg_PeekToken(); - if (tok->val == ATK_EQUALS) - Arg_UsedToken(); - } - } else if (param->flags & PARAMFLAGS_1) { - *cparam = 0; - if (tok->val == ATK_EQUALS && !subparse) { - if (!(exec & PARAMPARSEFLAGS_40)) { - Param_Error(37); - return 0; - } - Arg_UsedToken(); - } - } else if (param->flags & PARAMFLAGS_2) { - if (tok->val == nextOpt || tok->val == lastOpt) { - *cparam = 0; - } else if (tok->val == nextParam) { - tok = Arg_UsedToken(); - if (tok->val == ATK_ARG) { - Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); - if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { - *cparam = 0; - } else { - Arg_UsedToken(); - *cparam = curparam; - } - } else { - *cparam = 0; - } - } else if (tok->val == ATK_ARG && !tok->text[0]) { - tok = Arg_UsedToken(); - if (tok->val == nextParam) - Arg_UsedToken(); - *cparam = 0; - } else if ((exec & PARAMPARSEFLAGS_4) && tok->val != ATK_EQUALS) { - *cparam = 0; - } else { - if (tok->val == ATK_EQUALS) - tok = Arg_UsedToken(); - if (tok->val == ATK_ARG) { - Arg_GetTokenText(tok, curparam, sizeof(curparam), 1); - if ((param->flags & PARAMFLAGS_12) && Param_IsNonTextFile(curparam, !(exec & PARAMPARSEFLAGS_1))) { - *cparam = 0; - } else { - Arg_UsedToken(); - *cparam = curparam; - } - } else { - *cparam = 0; - } - } - } else { - CLPFatalError("Unknown parameter type"); - } - - if (pTool->TYPE == CWDROPINCOMPILERTYPE && (exec & PARAMPARSEFLAGS_2) && *cparam) { - if (!(exec & PARAMPARSEFLAGS_10)) { - if (subparse) - Arg_AddToToolArgs(&linkargs, ATK_EQUALS, 0); - else - Arg_AddToToolArgs(&linkargs, ATK_COMMA, 0); - } - Param_PushParam(*cparam); - Args_AddToToolArgs(&linkargs); - Param_PopParam(); - } - - return 1; -} - -int Params_Parse(PARAM_T *param, int flags) { - const char *cparam; - flags |= PARAMPARSEFLAGS_10; - - if (param) { - while (param) { - if (flags & PARAMPARSEFLAGS_20) - flags |= PARAMPARSEFLAGS_40; - - if (!Param_GetArgument(param, &cparam, flags)) - return 0; - - if (!(flags & PARAMPARSEFLAGS_1)) { - if (!Param_Parse(param, cparam, flags | (short) ((param->flags & PARAMFLAGS_4) ? PARAMPARSEFLAGS_20 : 0))) - return 0; - } else if (param->flags & PARAMFLAGS_4) { - if (!Param_GetArgument(param, &cparam, flags | PARAMPARSEFLAGS_4)) - return 0; - } - - if (cparam) - flags &= ~PARAMPARSEFLAGS_10; - flags &= ~PARAMPARSEFLAGS_40; - param = param->next; - } - } - - return 1; -} - -void Param_Error(short id, ...) { - va_list va; - va_start(va, id); - Option_ParamError(id, va); - va_end(va); -} - -void Param_Warning(short id, ...) { - va_list va; - va_start(va, id); - Option_ParamWarning(id, va); - va_end(va); -} diff --git a/unsorted/ParserErrors.c b/unsorted/ParserErrors.c deleted file mode 100644 index df5e67e..0000000 --- a/unsorted/ParserErrors.c +++ /dev/null @@ -1,119 +0,0 @@ -#include "parser.h" - -static char errorbuf[1024]; - -void CLPReportError_V(const char *format, va_list ap) { - vsprintf(errorbuf, format, ap); - CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeError, 0); - parseopts.hadErrors = 1; -} - -void CLPReportWarning_V(const char *format, va_list ap) { - vsprintf(errorbuf, format, ap); - CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeWarning, 0); -} - -void CLPReport_V(const char *format, va_list ap) { - vsprintf(errorbuf, format, ap); - CWReportMessage(parseopts.context, NULL, errorbuf, NULL, messagetypeInfo, 0); -} - -void CLPStatus_V(const char *format, va_list ap) { - vsprintf(errorbuf, format, ap); - CWShowStatus(parseopts.context, errorbuf, NULL); -} - -void CLPAlert_V(const char *format, va_list ap) { - vsprintf(errorbuf, format, ap); - CWAlert(parseopts.context, errorbuf, NULL, NULL, NULL); - parseopts.hadErrors = 1; -} - -void CLPOSAlert_V(const char *format, SInt32 err, va_list ap) { - vsprintf(errorbuf, format, ap); - CWAlert(parseopts.context, errorbuf, "Operating system error:", OS_GetErrText(err), NULL); -} - -char *CLPGetErrorString(SInt16 errid, char *buffer) { - getindstring(buffer, 12010, errid); - return buffer; -} - -void CLPReportError(SInt16 errid, ...) { - char format[256]; - va_list va; - - CLPGetErrorString(errid, format); - va_start(va, errid); - CLPReportError_V(format, va); - va_end(va); -} - -void CLPReportWarning(SInt16 errid, ...) { - char format[256]; - va_list va; - - CLPGetErrorString(errid, format); - va_start(va, errid); - CLPReportWarning_V(format, va); - va_end(va); -} - -void CLPReport(SInt16 errid, ...) { - char format[256]; - va_list va; - - CLPGetErrorString(errid, format); - va_start(va, errid); - CLPReport_V(format, va); - va_end(va); -} - -void CLPAlert(SInt16 errid, ...) { - char format[256]; - va_list va; - - CLPGetErrorString(errid, format); - va_start(va, errid); - CLPAlert_V(format, va); - va_end(va); -} - -void CLPOSAlert(SInt16 errid, SInt16 err, ...) { - char format[256]; - va_list va; - - CLPGetErrorString(errid, format); - va_start(va, err); - CLPOSAlert_V(format, err, va); - va_end(va); -} - -void CLPProgress(SInt16 errid, ...) { - char format[256]; - va_list va; - - CLPGetErrorString(errid, format); - va_start(va, errid); - CLPStatus_V(format, va); - va_end(va); -} - -void CLPStatus(SInt16 errid, ...) { - char format[256]; - va_list va; - - CLPGetErrorString(errid, format); - va_start(va, errid); - CLPStatus_V(format, va); - va_end(va); -} - -void CLPFatalError(const char *format, ...) { - va_list va; - - va_start(va, format); - CLPAlert_V(format, va); - va_end(va); - longjmp(exit_plugin, -123); -} diff --git a/unsorted/ParserFace.c b/unsorted/ParserFace.c deleted file mode 100644 index a005ece..0000000 --- a/unsorted/ParserFace.c +++ /dev/null @@ -1,298 +0,0 @@ -#include "parser.h" - -const char *failedCallback; -jmp_buf exit_plugin; -ParseOptsType parseopts; - -static CWResult SetupParamBlock(CWPluginContext context) { - CWResult result; - int x; - Handle h; - PCmdLineEnvir cle; - - memset(&parseopts, 0, sizeof(parseopts)); - parseopts.context = context; - - result = CWSecretGetNamedPreferences(context, "CmdLine Environment", &h); - if (result) - return result; - - cle = **((PCmdLineEnvir **) h); - parseopts.underIDE = cle.underIDE; - parseopts.ioRows = cle.rows; - parseopts.ioCols = cle.cols; - - result = CWParserGetCommandLine(context, &parseopts.args); - if (result) - return result; - - result = CWParserGetToolInfo(context, &parseopts.toolVersion); - if (result) - return result; - - result = CWParserGetTargetInfo(context, &parseopts.cpu, &parseopts.os); - if (result) - return result; - - result = CWParserGetPanels(context, &parseopts.numPanels, &parseopts.panelNames); - if (result) - return result; - - result = CWParserGetPlugins(context, &parseopts.numPlugins, &parseopts.plugins); - if (result) - return result; - - parseopts.passingArgs = 0; - for (x = 0; x < parseopts.numPlugins; x++) { - if (parseopts.plugins[x].storeCommandLine) - parseopts.passingArgs = 1; - } - - return 0; -} - -static CWResult SetupOptions(CWPluginContext context) { - if (!pTool) { - return 2; - } else { - SetupParserToolOptions(); - return 0; - } -} - -static CWResult Parse(CWPluginContext context) { - CWResult result; - - parseopts.success = 1; - parseopts.currentSegment = 1; - parseopts.currentOverlayGroup = 0; - parseopts.currentOverlay = 0; - - Arg_InitToolArgs(&linkargs); - Arg_InitToolArgs(&prelinkargs); - Arg_InitToolArgs(&postlinkargs); - - if (pTool->PreParse) - parseopts.success &= pTool->PreParse(); - - Arg_Init(parseopts.args->argc, parseopts.args->argv); - parseopts.noOptions = Arg_IsEmpty(); - parseopts.success &= Options_Parse(Options_GetOptions(), OFLAGS_1) && !parseopts.hadErrors; - Arg_Reset(); - - result = Parser_StorePanels(context); - if (result) - return result; - - if (pTool->MidParse && parseopts.success) - parseopts.success &= pTool->MidParse(); - - result = Parser_StorePanels(context); - if (result) - return result; - - if (parseopts.showHelp && parseopts.success) - parseopts.success &= Options_DisplayHelp(); - - Arg_Reset(); - if (parseopts.success) - parseopts.success &= Options_Parse(Options_GetOptions(), 0) && !parseopts.hadErrors; - - if (pTool->PostParse && parseopts.success) - parseopts.success &= pTool->PostParse(); - - Arg_Terminate(); - - return (parseopts.success && !parseopts.hadErrors) ? cwNoErr : cwErrRequestFailed; -} - -Handle Parser_FindPrefPanel(const char *name) { - int idx; - Handle h; - - for (idx = 0; idx < pTool->numPrefDataPanels; idx++) { - if (!ustrcmp(name, pTool->prefDataPanels[idx].name)) { - h = NewHandle(pTool->prefDataPanels[idx].size); - if (!h) - return NULL; - - HLock(h); - memcpy(*h, pTool->prefDataPanels[idx].ptr, pTool->prefDataPanels[idx].size); - HUnlock(h); - return h; - } - } - - return NULL; -} - -CWResult Parser_StorePanels(CWPluginContext context) { - int idx; - CWResult result; - const char *name; - Handle h; - - for (idx = 0; idx < parseopts.numPanels; idx++) { - name = parseopts.panelNames[idx]; - h = Parser_FindPrefPanel(name); - if (h) { - result = CWParserSetNamedPreferences(parseopts.context, name, h); - if (result) { - CLPReportError(CLPStr68, name); - return result; - } - } - } - - return cwNoErr; -} - -static CWResult StoreResults(CWPluginContext context) { - int idx; // r25 - CWResult result; - CWCommandLineArgs args; - UInt32 id; // r8 - UInt32 lg; // r10 - - result = Parser_StorePanels(context); - if (result) - return result; - - for (idx = 0; idx < parseopts.numPlugins; idx++) { - if (parseopts.plugins[idx].plugintype == CWDROPINLINKERTYPE && parseopts.plugins[idx].storeCommandLine) { - if (parseopts.plugins[idx].dropinflags & isPreLinker) { - Arg_ToolArgsForPlugin(&prelinkargs, &args); - } else if (parseopts.plugins[idx].dropinflags & isPostLinker) { - Arg_ToolArgsForPlugin(&postlinkargs, &args); - } else { - Arg_ToolArgsForPlugin(&linkargs, &args); - } - result = CWParserStoreCommandLineForPlugin(parseopts.context, idx, &args); - if (result) - return result; - } else if (parseopts.plugins[idx].storeCommandLine) { - id = parseopts.plugins[idx].plugintype; - lg = parseopts.plugins[idx].language; - fprintf(stderr, - "*** No support for %c%c%c%c/%c%c%c%c tool\n", - (id & 0xFF000000) >> 24, - (id & 0x00FF0000) >> 16, - (id & 0x0000FF00) >> 8, - (id & 0x000000FF), - (lg & 0xFF000000) >> 24, - (lg & 0x00FF0000) >> 16, - (lg & 0x0000FF00) >> 8, - (lg & 0x000000FF) - ); - } - } - - return cwNoErr; -} - -CWPLUGIN_ENTRY (CWParser_GetDropInFlags)(const DropInFlags **flags, SInt32 *flagsSize) { - static const DropInFlags sFlags = { - kCurrentDropInFlagsVersion, - CWDROPINPARSERTYPE, - 7, - 0, - 'Seep', - 12 - }; - *flags = &sFlags; - *flagsSize = sizeof(sFlags); - return 0; -} - -CWPLUGIN_ENTRY (CWParser_GetDropInName)(const char **dropinName) { - static const char *sDropInName = "Command-Line Parser"; - *dropinName = sDropInName; - return 0; -} - -CWPLUGIN_ENTRY (CWParser_GetDisplayName)(const char **displayName) { - static const char *sDisplayName = "Command-Line Parser"; - *displayName = sDisplayName; - return 0; -} - -CWPLUGIN_ENTRY (CWParser_GetPanelList)(const CWPanelList **panelList) { - static CWPanelList sPanelList = { - kCurrentCWFamilyListVersion, - 0, - 0 - }; - *panelList = &sPanelList; - return 0; -} - -CWPLUGIN_ENTRY (CWParser_GetTargetList)(const CWTargetList **targetList) { - static CWDataType sCPU = '****'; - static CWDataType sOS = '****'; - static CWTargetList sTargetList = { - kCurrentCWTargetListVersion, - 1, - &sCPU, - 1, - &sOS - }; - *targetList = &sTargetList; - return 0; -} - -CWPLUGIN_ENTRY (CWParser_GetVersionInfo)(const VersionInfo **versioninfo) { - static const VersionInfo vi = { - 1, 1, 0, 0 - }; - *versioninfo = &vi; - return 0; -} - -CWPLUGIN_ENTRY (Parser_SupportsPlugin)(const struct CLPluginInfo *pluginfo, CWDataType cpu, CWDataType os, Boolean *isSupported) { - *isSupported = ParserToolMatchesPlugin(pluginfo->plugintype, pluginfo->language, cpu, os); - return 0; -} - -CWPLUGIN_ENTRY (Parser_SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported) { - *isSupported = ParserToolHandlesPanels(numPanels, panelNames); - return 0; -} - -CWPLUGIN_ENTRY (parser_main)(CWPluginContext context) { - CWResult result; - SInt32 request; - - CWGetPluginRequest(context, &request); - result = setjmp(exit_plugin); - if (result == 0) { - switch (request) { - case reqInitialize: - result = 0; - break; - case 0: - break; - case 1: - result = SetupParamBlock(context); - if (!result) - result = Parser_StorePanels(context); - break; - case 2: - result = SetupParamBlock(context); - if (!result) { - result = SetupOptions(context); - if (!result) { - result = Parse(context); - if (!result) - result = StoreResults(context); - } - } - break; - } - } else { - if (failedCallback && result != 1) - fprintf(stderr, "Unexpected error in %s [%d]\n", failedCallback, result); - } - CWDonePluginRequest(context, result); - - return result; -} diff --git a/unsorted/ParserHelpers-cc.c b/unsorted/ParserHelpers-cc.c deleted file mode 100644 index 07315b3..0000000 --- a/unsorted/ParserHelpers-cc.c +++ /dev/null @@ -1,156 +0,0 @@ -#include "parser.h" - -Handle definesHandle; - -int Opt_AddStringToDefines(const char *opt, void *str, const char *param, int flags) { - AddStringToHandle(&definesHandle, (const char *) str); - if (param) - AddStringToHandle(&definesHandle, param); - return 1; -} - -int Opt_DefineSymbol(const char *var, const char *value) { - char tmp[1024]; - - if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ') || pTool->LANG == Lang_Rez) { - sprintf(tmp, "#define %s %s\n", var, value ? value : "1"); - } else if (pTool->LANG == Lang_Pascal) { - sprintf(tmp, "{$definec %s %s}\n", var, value ? value : "1"); - } else { - sprintf(tmp, "Option '-D|d' is not supported with this plugin"); - CLPReportError(CLPStr28_WarningText, tmp); - return 0; - } - - AddStringToHandle(&definesHandle, tmp); - return 1; -} - -int Opt_UndefineSymbol(const char *opt, void *, const char *arg, int flags) { - char tmp[300]; - - if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) { - sprintf(tmp, "#undef %s\n", arg); - } else if (pTool->LANG == Lang_Pascal) { - sprintf(tmp, "{$undefc %s}\n", arg); - } else { - sprintf(tmp, "Option -%s is not supported with this plugin", opt); - CLPReportError(CLPStr28_WarningText, tmp); - return 0; - } - - AddStringToHandle(&definesHandle, tmp); - return 1; -} - -int Opt_AddPrefixFile(const char *opt, void *handle, const char *filename, int flags) { - char tmp[300]; - - handle = !handle ? &definesHandle : handle; - if (!filename[0]) - return 1; - - if (pTool->LANG == Lang_C_CPP || pTool->LANG == CWFOURCHAR('A','s','m',' ')) { - if (filename[0] == '<' && filename[strlen(filename) - 1] == '>') { - snprintf(tmp, sizeof(tmp), "#include %s\n", filename); - } else { - snprintf(tmp, sizeof(tmp), "#include \"%s\"\n", filename); - } - } else if (pTool->LANG == Lang_Pascal) { - snprintf(tmp, sizeof(tmp), "{$I+}\n{$I %s}\n{$I-}\n", filename); - } else { - sprintf(tmp, "Option -%s is not supported with this plugin", opt); - CLPReportError(CLPStr28_WarningText, tmp); - return 0; - } - - AddStringToHandle((Handle *) handle, tmp); - return 1; -} - -int Opt_PragmaTrueFalse(const char *, void *flag, const char *, int flags) { - if (flags & PARAMPARSEFLAGS_8) - *((unsigned char *) flag) = PR_OFF; - else - *((unsigned char *) flag) = PR_ON; - return 1; -} - -int Opt_PragmaFalseTrue(const char *, void *flag, const char *, int flags) { - if (flags & PARAMPARSEFLAGS_8) - *((unsigned char *) flag) = PR_ON; - else - *((unsigned char *) flag) = PR_OFF; - return 1; -} - -int Opt_PragmaOnOff(const char *, void *flag, const char *arg) { - if (!arg) { - CLPReportError(CLPStr34_ArgumentsExpected); - return 0; - } - - if (!ustrcmp(arg, "on")) { - *((unsigned char *) flag) = PR_ON; - } else if (!ustrcmp(arg, "off")) { - *((unsigned char *) flag) = PR_OFF; - } else { - CLPReportError(CLPStr12, arg); - return 0; - } - - return 1; -} - -int Opt_PragmaOffOn(const char *, void *flag, const char *arg) { - if (!arg) { - CLPReportError(CLPStr34_ArgumentsExpected); - return 0; - } - - if (!ustrcmp(arg, "on")) { - *((unsigned char *) flag) = PR_OFF; - } else if (!ustrcmp(arg, "off")) { - *((unsigned char *) flag) = PR_ON; - } else { - CLPReportError(CLPStr12, arg); - return 0; - } - - return 1; -} - -int SetupPragmas(const Pragma *pragmas) { - const char *set; - char on; - char off; - char tmp[300]; - - while (pragmas->pragma) { - if (pragmas->flags == PRAGMA_FLAGS_0 || pragmas->flags == PRAGMA_FLAGS_1) { - set = 0; - on = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_ON : PR_OFF; - off = !(pragmas->flags == PRAGMA_FLAGS_1) ? PR_OFF : PR_ON; - if (*((char *)pragmas->value) == on) - set = "on"; - else if (*((char *)pragmas->value) == off) - set = "off"; - else if (*((char *)pragmas->value) == PR_AUTO) - set = "auto"; - else if (*((char *)pragmas->value) == PR_RESET) - set = "reset"; - else - OS_ASSERT(186, *((char *)pragmas->value) == PR_UNSET); - - if (set) { - snprintf(tmp, sizeof(tmp), "#pragma %s %s\n", pragmas->pragma, set); - AddStringToHandle(&definesHandle, tmp); - } - } else { - OS_ASSERT(195, !"Can't handle pragma"); - } - pragmas++; - } - - return 1; -} diff --git a/unsorted/ParserHelpers.c b/unsorted/ParserHelpers.c deleted file mode 100644 index 4cb793e..0000000 --- a/unsorted/ParserHelpers.c +++ /dev/null @@ -1,535 +0,0 @@ -#include "parser.h" -#include "cmdline.h" -#include - -SInt16 lastStage; -Boolean dashIMinusMovesPaths; -Boolean usedDashIMinus; -Boolean namingSysPaths; -static char STSbuf[256]; - -int FindFileInPath(const char *filename, OSSpec *fss) { - CWFileInfo fi; - CWResult result; - - fi.fullsearch = 1; - fi.dependencyType = 0; - fi.suppressload = 1; - fi.isdependentoffile = kCurrentCompiledFile; - - result = CWFindAndLoadFile(parseopts.context, filename, &fi); - if (!result) { - OS_FSSpec_To_OSSpec(&fi.filespec, fss); - return 1; - } else { - return 0; - } -} - -char *GetEnvVar(const char *name, Boolean warn, const char **match) { - const char *nptr; - const char *last; - char *ret; - - nptr = name; - last = name; - while (*nptr) { - ret = getenv(nptr); - if (ret) { - if (match) - *match = nptr; - return ret; - } - last = nptr; - nptr = &nptr[1 + strlen(nptr)]; - } - - if (warn) - CLPReportWarning(CLPStr52, last); - *match = 0; - return 0; -} - -static Boolean MatchesExtension(const char *list, const char *filename) { - char *fn; - const char *eptr; - const char *ptr; - - fn = OS_GetFileNamePtr((char *) filename); - eptr = strrchr(fn, '.'); - if (!eptr) - return 0; - if (!list) - return 1; - - ptr = eptr; - while (*list) { - if (*list == '|' && !*ptr) - return 1; - - if (my_tolower(*list) == my_tolower(*ptr)) { - list++; - ptr++; - continue; - } - - while (*list && *list != '|') - list++; - if (*list) - list++; - ptr = eptr; - } - - return !*list && !*ptr; -} - -int Opt_AddAccessPath(const char *opt, void *var, const char *arg, int flags) { - OSPathSpec spec; - int err; - - arg = arg ? arg : opt; - if (!arg) - return 0; - if (!arg[0]) - return 1; - - if (strlen(arg) >= 256) { - CLPReportError(CLPStr13, arg + strlen(arg) - 32, 256); - return 0; - } - - err = OS_MakePathSpec(0, arg, &spec); - if (err == ENOENT || err == ENOENT) { - CLPReportWarning(CLPStr45, arg); - return 1; - } else if (err != 0) { - CLPOSAlert(CLPStr45, err, arg); - return 1; - } - - // this 'if' gets optimised unnecessarily - if (!AddAccessPath(&spec, namingSysPaths, 0, var != NULL)) - return 0; - else - return 1; -} - -int Opt_AddFrameworkPath(const char *opt, void *var, const char *arg, int flags) { - OSPathSpec spec; - int err; - - arg = arg ? arg : opt; - if (!arg) - return 0; - if (!arg[0]) - return 1; - - if (strlen(arg) >= 256) { - CLPReportError(CLPStr13, arg + strlen(arg) - 32, 256); - return 0; - } - - err = OS_MakePathSpec(0, arg, &spec); - if (err == ENOENT || err == ENOENT) { - CLPReportWarning(CLPStr45, arg); - return 1; - } else if (err != 0) { - CLPOSAlert(CLPStr45, err, arg); - return 1; - } else { - Frameworks_AddPath(&spec); - return 1; - } -} - -int Opt_AddFramework(const char *opt, void *var, const char *arg, int flags) { - if (!Frameworks_AddFramework(arg ? arg : opt, 0, 0)) - return 0; - else - return 1; -} - -void ListParseMessage(void (*errprint)(const char *, va_list), const char *envvar, SInt16 id, ...) { - char buf[1024]; - va_list ap; - - if (envvar && envvar[0]) - sprintf(buf, "In environment variable '%s':\n", envvar); - else - buf[0] = 0; - - CLPGetErrorString(id, buf + strlen(buf)); - va_start(ap, id); - errprint(buf, ap); - va_end(ap); -} - -int AddAccessPathList(const char *list, char sep1, char sep2, int source, char *text, Boolean system, SInt32 position, Boolean recursive) { - char tmp[256]; - Boolean recurse; - OSPathSpec spec; - int err; - short type; - char *ptr; - - type = (Boolean) ((system == 1) ? 1 : 0) | (!source ? 0 : 2); - recurse = (list[0] == '+'); - if (recurse) - ++list; - - if (!strchr(list, sep1)) - sep1 = sep2; - - while (*list) { - ptr = tmp; - while (*list && *list != sep1 && (ptr + 1) < &tmp[256]) { - *(ptr++) = *(list++); - } - *ptr = 0; - - if ((ptr + 1) >= &tmp[256]) { - ListParseMessage( - CLPReportError_V, - (source == 1) ? text : NULL, - CLPStr9, - tmp, - tmp + strlen(tmp) - 16, - 256); - return 0; - } - - err = OS_MakePathSpec(0, tmp, &spec); - if (err) { - ListParseMessage( - CLPReportWarning_V, - (source == 1) ? text : NULL, - CLPStr45, - tmp); - } else { - AddAccessPath(&spec, type, position, recurse ^ recursive); - } - - if (*list) - ++list; - recurse = *list == '+'; - if (recurse) - ++list; - } - - return 1; -} - -int Opt_FindAndAddFile(const char *opt, void *var, const char *arg, int flags) { - OSSpec spec; - int err; - Boolean isfile; - - arg = arg ? arg : opt; - if (!arg) - return 0; - if (!*arg) - return 1; - - parseopts.userSpecifiedFiles++; - err = OS_MakeSpec(arg, &spec, &isfile); - if (!err) - err = OS_Status(&spec); - - if (!err && !isfile) { - CLPReportError(CLPStr47, arg); - parseopts.unusedFiles++; - return 0; - } else if (err && err != ENOENT) { - CLPOSAlert(CLPStr44, err, arg); - parseopts.unusedFiles++; - return 0; - } else if (err && parseopts.alwaysUsePaths) { - err = FindFileInPath(arg, &spec) ? 0 : ENOENT; - } - - if (err) { - CLPReportError(CLPStr44, arg); - parseopts.unusedFiles++; - return 0; - } - - if (var && !MatchesExtension((const char *) var, arg)) - CLPReportWarning(CLPStr76, arg, var); - - if (!AddFileToProject(&spec, lastStage, parseopts.lastoutputname, 1, -1)) { - parseopts.unusedFiles++; - return 0; - } else { - parseopts.lastoutputname[0] = 0; - return 1; - } -} - -int Opt_FindAndAddFileRef(const char *opt, void *var, const char *arg) { - OSSpec spec; - int err; - Boolean isfile; - - arg = arg ? arg : opt; - if (!arg) - return 0; - if (!*arg) - return 1; - - parseopts.userSpecifiedFiles++; - if (var && !MatchesExtension((const char *) var, arg)) - CLPReportWarning(CLPStr76, arg, var); - - err = OS_MakeSpec(arg, &spec, &isfile); - if (!err) - err = OS_Status(&spec); - - if (!err && !isfile) { - CLPReportError(CLPStr47, arg); - parseopts.unusedFiles++; - return 0; - } else if (err && parseopts.alwaysUsePaths) { - err = FindFileInPath(arg, &spec) ? 0 : ENOENT; - } - - if (!AddFileToProject(&spec, 0, 0, err == 0, -1)) { - parseopts.unusedFiles++; - return 0; - } else { - return AddAccessPath(&spec.path, 1, -1, 0) != 0; - } -} - -int Opt_AddUnixLibraryFile(const char *opt, void *var, const char *name) { - OSSpec spec; - Boolean failed; - const char *eptr; - const char *eend; - char tmpname[64]; - - if (strlen(name) >= 56) { - CLPReportError(CLPStr13, name + strlen(name) - 32, 64); - return 0; - } - - failed = 1; - if (!var) - var = ".lib|.a"; - - eptr = (const char *) var; - while (eptr && *eptr) { - eend = eptr; - while (*eend && *eend != '|') - ++eend; - - sprintf(tmpname, "lib%s%*.*s", name, eend - eptr, eend - eptr, eptr); - if (FindFileInPath(tmpname, &spec)) { - failed = 0; - break; - } - - if (*eend) - eptr = eend + 1; - else - eptr = eend; - } - - if (failed) { - failed = !FindFileInPath(name, &spec); - if (failed) - CLPReportError(CLPStr49, name, var, name); - } - - if (!failed) { - if (!AddFileToProject(&spec, 0, 0, 1, -1)) { - parseopts.unusedFiles++; - failed = 1; - } - } - - return !failed; -} - -int AddFileList(const char *list, char sep1, char sep2, int source, char *text, SInt32 position) { - char tmp[256]; - OSSpec spec; - char *ptr; - - if (!strchr(list, sep1)) - sep1 = sep2; - - while (*list) { - ptr = tmp; - while (*list && *list != sep1 && (ptr + 1) < &tmp[256]) { - *(ptr++) = *(list++); - } - *ptr = 0; - - if ((ptr + 1) >= &tmp[256]) { - ListParseMessage( - CLPReportError_V, - (source == 1) ? text : 0, - CLPStr9, - tmp, - tmp + strlen(tmp) - 16, - 256 - ); - return 0; - } - - if (!FindFileInPath(tmp, &spec)) { - if (OS_IsDir(&spec)) { - ListParseMessage( - CLPReportError_V, - (source == 1) ? text : 0, - CLPStr16, - tmp - ); - } else { - ListParseMessage( - CLPReportWarning_V, - (source == 1) ? text : 0, - CLPStr44, - tmp - ); - } - } else { - AddFileToProject(&spec, 0, 0, 1, position); - } - - if (*list) - ++list; - } - - return 1; -} - -int IsFileInOutputDirectory(const OSSpec *file) { - OSPathSpec outdir; - GetOutputFileDirectory(&outdir); - return OS_EqualPathSpec(&outdir, &file->path); -} - -void GetCFileNameInOutputDirectory(const char *input, char *name, int maxlen) { - char filename[64]; - OSSpec spec; - int err; - - err = OS_MakeFileSpec(input, &spec); - if (err) { - CLPOSAlert(CLPStr64, err, input); - name[0] = 0; - return; - } - - if (!IsFileInOutputDirectory(&spec)) { - CLPReportWarning(CLPStr61, OS_SpecToStringRelative(&spec, 0, STSbuf, sizeof(STSbuf))); - } - - OS_NameSpecToString(&spec.name, filename, 256); - if (strlen(filename) >= maxlen) { - CLPReportWarning(CLPStr65, filename, maxlen - 1); - filename[maxlen - 1] = 0; - } - - strcpy(name, filename); -} - -void GetPFileNameInOutputDirectory(const char *input, unsigned char *name, int len) { - GetCFileNameInOutputDirectory(input, (char *) name, len); - c2pstr((char *) name); -} - -void AddStringLenToHandle(Handle *h, const char *str, int len) { - SInt32 old; - - if (!*h) { - if ((*h = NewHandle(len + 1))) { - HLock(*h); - memcpy(**h, str, len); - (**h)[len] = 0; - HUnlock(*h); - } else { - exit(-23); - } - } else { - old = GetHandleSize(*h) - 1; - SetHandleSize(*h, old + len + 1); - if (MemError() == noErr) { - HLock(*h); - memcpy(**h + old, str, len); - (**h)[old + len] = 0; - HUnlock(*h); - } else { - exit(-23); - } - } -} - -void AddStringToHandle(Handle *h, const char *str) { - AddStringLenToHandle(h, str, strlen(str)); -} - -int Opt_PrintVersion(const char *opt, void *var, const char *arg, int flags) { - ShowVersion(0); - return 1; -} - -void GetFirstSourceFilenameBase(char *buffer, char *defaul) { - int cnt; - OSSpec spec; - char compiler[32]; - int x; - char *ext; - - cnt = GetFileCount(); - for (x = 0; x < cnt; x++) { - if (GetFileInfo(x, &spec, compiler)) { - if (compiler[0]) { - if (!strstr(compiler, "Lib")) { - OS_NameSpecToString(&spec.name, buffer, 256); - ext = strrchr(buffer, '.'); - if (ext) - *ext = 0; - memmove(buffer, buffer, strlen(buffer) + 1); - return; - } - } - } - } - - strcpy(buffer, defaul); -} - -int Opt_SavePrefs(const char *opt, void *var, const char *arg, int flags) { - Parser_StorePanels(parseopts.context); - return 1; -} - -int ParseNumber(const char *arg, Boolean emit_error, SInt32 *ret, const char **endptr) { - char *end; - - if (arg[0] == '0' && (arg[1] == 'x' || arg[1] == 'X')) { - *ret = strtol(arg + 2, &end, 16); - } else if (arg[0] == '0') { - *ret = strtol(arg + 1, &end, 8); - } else { - *ret = strtol(arg, &end, 10); - } - - if (endptr) - *endptr = end; - - if (*end && emit_error) { - CLPReportError(CLPStr5, "", arg); - return 0; - } - - return 1; -} - -int Opt_MaybeMoveAccessPaths(const char *opt, void *var, const char *arg, int flags) { - if (dashIMinusMovesPaths && !usedDashIMinus) - MoveSystemPathsIntoUserList(); - return 1; -} diff --git a/unsorted/Projects.c b/unsorted/Projects.c deleted file mode 100644 index dca9df2..0000000 --- a/unsorted/Projects.c +++ /dev/null @@ -1,241 +0,0 @@ -#include "parser.h" - -extern char STSbuf[256]; - -int GetFileCount(void) { - SInt32 num; - CWGetProjectFileCount(parseopts.context, &num); - return num; -} - -void SetFileOutputName(SInt32 position, SInt16 which, char *outfilename) { - CWResult result; - if (outfilename && outfilename[0]) { - result = CWParserSetFileOutputName(parseopts.context, position, which ? which : 1, outfilename); - if (result) { - failedCallback = "CWParserSetFileOutputName"; - longjmp(exit_plugin, result); - } - } -} - -int AddFileToProject(OSSpec *oss, SInt16 which, char *outfilename, Boolean exists, SInt32 position) { - CWFileSpec cws; - CWNewProjectEntryInfo pei; - CWResult result; - int err; - - err = OS_OSSpec_To_FSSpec(oss, &cws); - if (err) { - CLPOSAlert(44, err, OS_SpecToStringRelative(oss, 0, STSbuf, sizeof(STSbuf))); - return 0; - } - - if (position == -2) { - pei.position = 0; - } else if (position == -1) { - CWGetProjectFileCount(parseopts.context, &pei.position); - } else if (position == 0) { - pei.position = -1; - } else { - pei.position = position; - } - - pei.segment = parseopts.currentSegment; - pei.overlayGroup = parseopts.currentOverlayGroup; - pei.overlay = parseopts.currentOverlay; - pei.groupPath = NULL; - pei.mergeintooutput = parseopts.mergeIntoOutput; - pei.weakimport = parseopts.weakImport; - pei.initbefore = parseopts.initBefore; - result = CWAddProjectEntry(parseopts.context, &cws, exists == 0, &pei, &position); - if (result) { - failedCallback = "CWAddProjectEntry"; - longjmp(exit_plugin, result); - } - parseopts.initBefore = 0; - parseopts.weakImport = 0; - parseopts.mergeIntoOutput = 0; - SetFileOutputName(position, which, outfilename); - return 1; -} - -Boolean GetFileInfo(SInt32 position, OSSpec *spec, char *plugin) { - CWProjectFileInfo pfi; - if (CWGetFileInfo(parseopts.context, position, 1, &pfi)) - return 0; - - OS_FSSpec_To_OSSpec(&pfi.filespec, spec); - strncpy(plugin, pfi.dropinname, 32); - plugin[31] = 0; - return 1; -} - -int AddAccessPath(OSPathSpec *oss, SInt16 type, SInt32 position, Boolean recursive) { - CWNewAccessPathInfo api; - CWResult result; - OSSpec spec; - int err; - CWAccessPathListInfo apli; - - if ((err = OS_MakeSpecWithPath(oss, NULL, 0, &spec)) || (err = OS_OSSpec_To_FSSpec(&spec, &api.pathSpec))) { - CLPOSAlert(45, err, OS_PathSpecToString(&spec.path, STSbuf, sizeof(STSbuf))); - return 0; - } - - if (position == -2) { - api.position = 0; - } else if (position == -1 || position == 0) { - api.position = -1; - } else if (position == -1) { - result = CWGetAccessPathListInfo(parseopts.context, &apli); - if (result) { - failedCallback = "CWGetAccessPathListInfo"; - longjmp(exit_plugin, result); - } - if ((type & 1) == 1) { - api.position = apli.systemPathCount; - } else { - api.position = apli.userPathCount; - } - } else { - api.position = position; - } - - api.type = (type & 1) ? cwSystemPath : cwUserPath; - api.type = api.type | (CWAccessPathType) ((type & 2) ? cwAccessPathTypeFlag2 : 0); - api.recursive = recursive; - - result = CWParserAddAccessPath(parseopts.context, &api); - if (result) { - failedCallback = "CWParserAddAccessPath"; - longjmp(exit_plugin, result); - } - - return 1; -} - -int MoveSystemPathsIntoUserList(void) { - CWResult result = CWParserSwapAccessPaths(parseopts.context); - return result == cwNoErr; -} - -void AddVirtualFile(const char *filename, Handle *text) { - CWResult result; - CWMemHandle mh; - - if (*text) { - CWSecretAttachHandle(parseopts.context, *text, &mh); - result = CWParserCreateVirtualFile(parseopts.context, filename, mh); - if (result) { - failedCallback = "CWParserCreateVirtualFile"; - longjmp(exit_plugin, result); - } - DisposeHandle(*text); - *text = NULL; - } -} - -void GetOutputFileDirectory(OSPathSpec *dir) { - CWResult result; - CWFileSpec idefss; - OSSpec spec; - - result = CWGetOutputFileDirectory(parseopts.context, &idefss); - if (result) { - failedCallback = "CWGetOutputFileDirectory"; - longjmp(exit_plugin, result); - } - - OS_FSSpec_To_OSSpec(&idefss, &spec); - *dir = spec.path; -} - -void SetOutputFileDirectory(OSPathSpec *dir) { - CWResult result; - CWFileSpec idefss; - OSSpec spec; - - OS_MakeSpecWithPath(dir, NULL, 0, &spec); - OS_OSSpec_To_FSSpec(&spec, &idefss); - - result = CWParserSetOutputFileDirectory(parseopts.context, &idefss); - if (result) { - failedCallback = "CWParserSetOutputFileDirectory"; - longjmp(exit_plugin, result); - } -} - -void AddOverlayGroup(const char *name, CWAddr64 *addr, SInt32 *groupnum, SInt32 *overlaynum) { - CWResult result; - - *overlaynum = -1; - result = CWParserAddOverlay1Group(parseopts.context, name, addr, groupnum); - if (result) { - if (result == cwErrInvalidCallback) { - CLPReportError(72); - } else { - failedCallback = "CWParserAddOverlay1Group"; - longjmp(exit_plugin, result); - } - } -} - -void AddOverlay(SInt32 groupnum, const char *name, SInt32 *overlaynum) { - CWResult result; - - result = CWParserAddOverlay1(parseopts.context, name, groupnum, overlaynum); - if (result) { - if (result == cwErrInvalidCallback) { - CLPReportError(72); - } else { - failedCallback = "CWParserAddOverlay1"; - longjmp(exit_plugin, result); - } - } -} - -void AddSegment(const char *name, SInt16 attrs, SInt32 *segmentnum) { - CWResult result; - - result = CWParserAddSegment(parseopts.context, name, attrs, segmentnum); - if (result) { - if (result == cwErrInvalidCallback) { - CLPReportError(73); - } else { - failedCallback = "CWParserAddSegment"; - longjmp(exit_plugin, result); - } - } -} - -void ChangeSegment(SInt32 segmentnum, const char *name, SInt16 attrs) { - CWResult result; - - result = CWParserSetSegment(parseopts.context, segmentnum, name, attrs); - if (result) { - if (result == cwErrInvalidCallback) { - CLPReportError(73); - } else { - failedCallback = "CWParserSetSegment"; - longjmp(exit_plugin, result); - } - } -} - -int GetSegment(SInt32 segmentnum, char *name, SInt16 *attrs) { - CWResult result; - CWProjectSegmentInfo psi; - - result = CWGetSegmentInfo(parseopts.context, segmentnum, &psi); - if (result) { - if (result == cwErrInvalidCallback) { - CLPReportError(73); - } - return 0; - } - - strcpy(name, psi.name); - *attrs = psi.attributes; - return 1; -} diff --git a/unsorted/StaticParserGlue.c b/unsorted/StaticParserGlue.c deleted file mode 100644 index 7a44487..0000000 --- a/unsorted/StaticParserGlue.c +++ /dev/null @@ -1,29 +0,0 @@ -#include "parser.h" -#include "cmdline.h" - -static BasePluginCallbacks cb = { - parser_main, - CWParser_GetDropInFlags, - CWParser_GetDisplayName, - CWParser_GetDropInName, - CWParser_GetPanelList, - NULL, - NULL, - CWParser_GetVersionInfo, - NULL -}; - -static ParserPluginCallbacks pr_cb = { - Parser_SupportsPlugin, - Parser_SupportsPanels -}; - -int RegisterStaticParserPlugins(void) { - return RegisterStaticParserPlugin(&cb, &pr_cb); -} - -#include "ParserErrors.r" - -int RegisterStaticParserResources(void) { - return RegisterResource("Parser Strings", 12010, STR12010); -} diff --git a/unsorted/TargetOptimizer-ppc-mach.c b/unsorted/TargetOptimizer-ppc-mach.c deleted file mode 100644 index 6c86356..0000000 --- a/unsorted/TargetOptimizer-ppc-mach.c +++ /dev/null @@ -1,71 +0,0 @@ -#include "parser.h" - -char schedule_ppc_default; - -int TargetSetOptFlags(short val, Boolean set) { - switch (val) { - case 'Pe': - pBackEnd.peephole = set; - break; - case 'Sn': - pBackEnd.schedule = 0; - break; - case 'Sh': - pBackEnd.schedule = set; - break; - case 'S?': - pBackEnd.processor = schedule_ppc_default; - break; - case 'SG': - pBackEnd.processor = schedule_ppc_default = PrefCPU_Generic; - break; - case 'S1': - pBackEnd.processor = schedule_ppc_default = PrefCPU_601; - break; - case 'S3': - pBackEnd.processor = schedule_ppc_default = PrefCPU_603; - break; - case 'S#': - pBackEnd.processor = schedule_ppc_default = PrefCPU_603e; - break; - case 'S4': - pBackEnd.processor = schedule_ppc_default = PrefCPU_604; - break; - case 'S%': - pBackEnd.processor = schedule_ppc_default = PrefCPU_604e; - break; - case 'S7': - pBackEnd.processor = schedule_ppc_default = PrefCPU_750; - break; - case 'SA': - pBackEnd.processor = schedule_ppc_default = PrefCPU_Altivec; - break; - default: - return 0; - } - - return 1; -} - -void TargetDisplayOptimizationOptions(Handle txt) { - PrefCPU p; - - if (!pBackEnd.schedule) { - HPrintF(txt, "\t- no instruction scheduling\n"); - } else { - HPrintF(txt, "\t- schedule for %s\n", - !(p = (PrefCPU) pBackEnd.processor) ? "generic PPC" : - (p == PrefCPU_601) ? "601" : - (p == PrefCPU_603) ? "603" : - (p == PrefCPU_603e) ? "603e" : - (p == PrefCPU_604) ? "604" : - (p == PrefCPU_604e) ? "604e" : - (p == PrefCPU_750) ? "750" : - (p == PrefCPU_Altivec) ? "Altivec" : - "???" - ); - } -} - -void TargetSetPragmaOptimizationsToUnspecified(void) { -} diff --git a/unsorted/Targets.c b/unsorted/Targets.c deleted file mode 100644 index 378b9d7..0000000 --- a/unsorted/Targets.c +++ /dev/null @@ -1,65 +0,0 @@ -#include "parser.h" - -ParserTool *pTool; - -int SetParserToolInfo(ParserTool *tool) { - pTool = tool; - - OS_ASSERT(16, pTool->toolInfo && (parseopts.toolVersion || pTool->copyright)); - - return 1; -} - -Boolean ParserToolMatchesPlugin(OSType type, OSType lang, OSType cpu, OSType os) { - if (!pTool) { - CLPFatalError("No options loaded for command line\n"); - return 0; - } - - if ( - (type == CWDROPINANYTYPE || pTool->TYPE == CWDROPINANYTYPE || pTool->TYPE == type) && - (lang == Lang_Any || pTool->LANG == Lang_Any || pTool->LANG == lang) && - (cpu == targetCPUAny || pTool->CPU == targetCPUAny || pTool->CPU == cpu) && - (os == targetOSAny || pTool->OS == targetOSAny || pTool->OS == os) - ) - { - return 1; - } else { - return 0; - } -} - -Boolean ParserToolHandlesPanels(int numPanels, const char **panelNames) { - int idx; - int scan; - - if (!pTool) - CLPFatalError("No options loaded for command line\n"); - - for (idx = 0; idx < numPanels; idx++) { - for (scan = 0; scan < pTool->numPrefPanels; scan++) { - if (!ustrcmp(pTool->prefPanels[scan], panelNames[idx])) - break; - } - - if (scan >= pTool->numPrefPanels) - break; - } - - if (idx >= numPanels) - return 1; - else - return 0; -} - -Boolean SetupParserToolOptions(void) { - int idx; - - Options_Init(); - for (idx = 0; idx < pTool->numOptionLists; idx++) { - Options_AddList(pTool->optionLists[idx]); - } - Options_SortOptions(); - - return 1; -} diff --git a/unsorted/ToolHelpers-cc.c b/unsorted/ToolHelpers-cc.c deleted file mode 100644 index b58f188..0000000 --- a/unsorted/ToolHelpers-cc.c +++ /dev/null @@ -1,36 +0,0 @@ -#include "parser.h" -#include "cmdline.h" - -int Opt_DummyLinkerRoutine(const char *opt, void *, const char *, int) { - CLPFatalError("Calling linker option '%s'\n", opt); - return 0; -} - -int Opt_DummyLinkerSettingRoutine(const char *var, const char *val) { - CLPFatalError("Calling linker settings option '%s'='%s'\n", var, val ? val : ""); - return 0; -} - -void FinishCompilerTool(void) { - SInt32 numfiles; - - if (parseopts.lastoutputname[0]) { - numfiles = GetFileCount(); - - if (pCmdLine.stages == CmdLineStageMask_Dp) { - strcpy(pCmdLineCompiler.outMakefile, parseopts.lastoutputname); - } else if (outputOrdering == OutputOrdering2) { - if (parseopts.possibleFiles > 0 || parseopts.userSpecifiedFiles > 0) - CLPReportError(41, parseopts.lastoutputname); - else - CLPReportError(42, parseopts.lastoutputname); - } else { - SetFileOutputName(numfiles - 1, lastStage, parseopts.lastoutputname); - } - - parseopts.lastoutputname[0] = 0; - } - - if (setOutputDirectory) - pCmdLineCompiler.relPathInOutputDir = 0; -} diff --git a/unsorted/ToolHelpers.c b/unsorted/ToolHelpers.c deleted file mode 100644 index e872546..0000000 --- a/unsorted/ToolHelpers.c +++ /dev/null @@ -1,289 +0,0 @@ -#include "parser.h" -#include "cmdline.h" -#include - -extern char STSbuf[256]; - -static Boolean setStage; -char linkerOutputFilename[256]; -Boolean setLinkerOutputFilename; -Boolean setOutputDirectory; -SInt16 outputOrdering; - -int Opt_HandleOutputName(const char *opt, void *, const char *filename, int flags) { - OSSpec spec; - int err; - SInt32 result; - Boolean isfile; - - if (!filename) - filename = opt; - - if ((pCmdLine.state == OptsCmdLineState_3 || (pCmdLine.state == OptsCmdLineState_0 && pTool->TYPE == CWDROPINLINKERTYPE)) && pCmdLine.toDisk != 4) { - if (setLinkerOutputFilename) { - CLPReportError(CLPStr41, filename); - return 0; - } - setLinkerOutputFilename = 1; - if (pTool->TYPE == CWDROPINCOMPILERTYPE) { - strncpy(linkerOutputFilename, filename, 256); - } else { - OSSpec spec; - int err; - Boolean isfile; - err = OS_MakeSpec(filename, &spec, &isfile); - if (err) { - CLPOSAlert(CLPStr64, err, filename); - return 0; - } - if (isfile) - OS_NameSpecToString(&spec.name, linkerOutputFilename, 256); - SetOutputFileDirectory(&spec.path); - } - return 1; - } else { - err = OS_MakeSpec(filename, &spec, &isfile); - if (err) { - CLPOSAlert(CLPStr64, err, filename); - return 0; - } - - if (!err && !isfile) { - FSSpec ofd; - if (setOutputDirectory) { - CLPReportError(CLPStr59, filename); - return 0; - } - setOutputDirectory = 1; - - OS_OSSpec_To_FSSpec(&spec, &ofd); - result = CWParserSetOutputFileDirectory(parseopts.context, &ofd); - if (result) { - failedCallback = "CWParserSetOutputFileDirectory"; - longjmp(exit_plugin, result); - } - return 1; - } else { - SInt32 index; - CWProjectFileInfo pfi; - if (parseopts.lastoutputname[0]) { - CLPReportError(CLPStr41, filename); - return 0; - } - strncpy(parseopts.lastoutputname, filename, 256); - if (pCmdLine.stages == CmdLineStageMask_Dp) - return 1; - - if (outputOrdering == OutputOrdering0 || outputOrdering == OutputOrdering1) { - CWGetProjectFileCount(parseopts.context, &index); - while (index-- > 0) { - if (!CWGetFileInfo(parseopts.context, index, 0, &pfi) && pfi.filetype == CWFOURCHAR('T','E','X','T')) { - outputOrdering = OutputOrdering1; - break; - } - } - - if (index <= 0) { - CWGetProjectFileCount(parseopts.context, &index); - if (index > 0) - outputOrdering = OutputOrdering1; - --index; - } - - if (outputOrdering == OutputOrdering0) { - outputOrdering = OutputOrdering2; - return 1; - } - - SetFileOutputName(index, lastStage, parseopts.lastoutputname); - parseopts.lastoutputname[0] = 0; - } - - return 1; - } - } -} - -int ValidateToolState(Boolean mustHaveFiles) { - if (parseopts.noOptions) { - pCmdLine.state = OptsCmdLineState_1; - ShowVersion(1); - return 1; - } - - if (parseopts.success) { - if (!parseopts.userSpecifiedFiles) { - if (!parseopts.hadAnyOutput) { - if (mustHaveFiles) { - CLPReportError(CLPStr70); - return 0; - } - } else { - if (mustHaveFiles) - pCmdLine.state = OptsCmdLineState_1; - return 1; - } - } else if (parseopts.unusedFiles > 0) { - CLPReportError(CLPStr69); - return 0; - } - } - - if (pCmdLine.state == OptsCmdLineState_0 || (parseopts.userSpecifiedFiles > 0 && pCmdLine.state == OptsCmdLineState_1)) - pCmdLine.state = OptsCmdLineState_3; - - if (!setStage) { - pCmdLine.stages = CmdLineStageMask_Cg; - if (pCmdLine.state == OptsCmdLineState_2) - pCmdLine.toDisk |= 2; - } - - if (pCmdLine.state == OptsCmdLineState_3 && !(pCmdLine.stages & CmdLineStageMask_Cg)) - pCmdLine.state = OptsCmdLineState_2; - - return 1; -} - -void ToolReportMessage(SInt16 errid, SInt16 type, va_list va) { - char str[256]; - char buf[1024]; - - GetIndString((StringPtr) str, 13000, errid); - p2cstr((StringPtr) str); - vsprintf(buf, str, va); - CWReportMessage(parseopts.context, 0, buf, 0, type, 0); -} - -void ToolReportWarning(SInt16 id, ...) { - va_list va; - va_start(va, id); - ToolReportMessage(id, messagetypeWarning, va); - va_end(va); -} - -void ToolReportError(SInt16 id, ...) { - va_list va; - va_start(va, id); - ToolReportMessage(id, messagetypeError, va); - va_end(va); - parseopts.hadErrors = 1; -} - -void ToolReportOSError(SInt16 id, int err, ...) { - char str[256]; - char buf[1024]; - va_list va; - - GetIndString((StringPtr) str, 13000, id); - p2cstr((StringPtr) str); - va_start(va, err); - vsprintf(buf, str, va); - va_end(va); - CWAlert(parseopts.context, buf, OS_GetErrText(err), 0, 0); -} - -void ToolReportInfo(SInt16 id, ...) { - va_list va; - va_start(va, id); - ToolReportMessage(id, messagetypeInfo, va); - va_end(va); -} - -int Opt_DoNotLink(const char *opt, void *var, const char *arg) { - if (pCmdLine.state == OptsCmdLineState_3 || pCmdLine.state == OptsCmdLineState_0 || pCmdLine.state == OptsCmdLineState_1) - pCmdLine.state = OptsCmdLineState_2; - return 1; -} - -int Opt_IncreaseVerbosity(const char *opt, void *var, const char *arg, int flags) { - if (pCmdLine.verbose) - pCmdLine.verbose++; - else - pCmdLine.verbose = 2; - - Parser_StorePanels(parseopts.context); - return 1; -} - -int Opt_SetStage(const char *opt, void *str, const char *arg, int flags) { - unsigned char *ptr; - Boolean set; - Boolean no; - UInt16 flag; - - ptr = (unsigned char *) str; - // doesn't match - type issue with 'no' - no = (Boolean) ((flags & PARAMPARSEFLAGS_8) >> 3); - set = (Boolean) (no ^ 1); - - while (*ptr) { - if (*ptr == '+') { - set = !no; - } else if (*ptr == '-') { - set = no; - } else if (*ptr == '|') { - set = (Boolean) (no ^ 1); - } else { - flag = (ptr[0] << 8) | ptr[1]; - setStage = 1; - - switch (flag) { - case 'Cg': - if (set) - pCmdLine.stages |= CmdLineStageMask_Cg; - else - pCmdLine.stages &= ~CmdLineStageMask_Cg; - lastStage = CmdLineStage_Cg; - break; - case 'Ds': - if (set) - pCmdLine.stages |= CmdLineStageMask_Ds; - else - pCmdLine.stages &= ~CmdLineStageMask_Ds; - lastStage = CmdLineStage_Ds; - break; - case 'Pp': - if (set) - pCmdLine.stages |= CmdLineStageMask_Pp; - else - pCmdLine.stages &= ~CmdLineStageMask_Pp; - lastStage = CmdLineStage_Pp; - break; - case 'Dp': - if (set) - pCmdLine.stages |= CmdLineStageMask_Dp; - else - pCmdLine.stages &= ~CmdLineStageMask_Dp; - break; - default: - CLPFatalError("Bad stage settings in %s (%c%c)\n", str, ptr[0], ptr[1]); - } - - ++ptr; - } - - ++ptr; - } - - return 1; -} - -int Opt_RedirectStream(const char *opt, void *file, const char *filename) { - OSSpec spec; - int err; - FILE *nw; - - err = OS_MakeFileSpec(filename, &spec); - if (err) { - CLPReportError(CLPStr78, filename, OS_GetErrText(err)); - return 0; - } - - nw = freopen(OS_SpecToString(&spec, STSbuf, 256), "wt", (FILE *) file); - if (!nw) { - CLPReportError(CLPStr78, filename, strerror(errno)); - return 0; - } - - return 1; -} diff --git a/unsorted/Utils.c b/unsorted/Utils.c deleted file mode 100644 index b627c4d..0000000 --- a/unsorted/Utils.c +++ /dev/null @@ -1,174 +0,0 @@ -#include "parser.h" - -int my_tolower(char c) { - if (c >= 'A' && c <= 'Z') - return c | 0x20; - else - return c; -} - -int my_isdigit(char c) { - return (c >= '0' && c <= '9'); -} - -int my_isalpha(char c) { - return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); -} - -int my_isalnum(char c) { - return my_isdigit(c) || my_isalpha(c); -} - -int my_isxdigit(char c) { - return my_isdigit(c) || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F'); -} - -char *Utils_SpellList(char *list, char *buffer, char opts) { - char *sptr; - char *eptr; - char *nptr; - char *bptr; - int pflen; - int npflen; - int undo; - char *neptr; - int cnt; - - undo = 0; - bptr = buffer; - sptr = list; - pflen = 0; - while (sptr) { - if ((opts & 1) && !pflen) - *(bptr++) = *MAINOPTCHAR; - - eptr = strchr(sptr, '|'); - if (!eptr) { - eptr = sptr + strlen(sptr); - nptr = 0; - } else if (eptr[1] == '|') { - nptr = 0; - } else { - nptr = eptr + 1; - } - - if (undo == 0 && !pflen) { - if (opts & 8) { - *(bptr++) = '['; - *(bptr++) = 'n'; - *(bptr++) = 'o'; - *(bptr++) = ']'; - } - if (opts & 0x20) { - *(bptr++) = '['; - *(bptr++) = 'n'; - *(bptr++) = 'o'; - *(bptr++) = '-'; - *(bptr++) = ']'; - } - } - - npflen = 0; - if (nptr) { - while (sptr < nptr && *nptr && *nptr != '|' && sptr[npflen] == nptr[npflen]) - npflen++; - - if (npflen) { - neptr = strchr(nptr, '|'); - if (!neptr) - neptr = nptr + strlen(nptr); - if ((neptr - nptr) < (eptr - sptr) || ((sptr[1] && sptr[1] != '|') ? (sptr[1] != nptr[1]) : 0)) - npflen = 0; - if (opts & 0x40) - npflen = 0; - } - } - - if (pflen) { - sptr += pflen; - while (sptr < eptr) { - *(bptr++) = *(sptr++); - } - if (npflen > pflen) { - *(bptr++) = '['; - undo++; - } - if (npflen < pflen) { - *(bptr++) = ']'; - undo--; - } - } else if (npflen) { - for (cnt = npflen; cnt > 0; cnt--) { - *(bptr++) = *(sptr++); - } - *(bptr++) = '['; - undo++; - } - - while (sptr < eptr) { - *(bptr++) = *(sptr++); - } - - if (opts & 0x10) { - *(bptr++) = '['; - *(bptr++) = '-'; - *(bptr++) = ']'; - } - if (opts & 0x40) { - *(bptr++) = '+'; - } - - sptr = nptr; - if (nptr && bptr[-1] != '[') { - if ((opts & 1) || (bptr[-1] == ']') || ((opts & 8) && !undo)) { - *(bptr++) = ' '; - *(bptr++) = '|'; - *(bptr++) = ' '; - } else { - *(bptr++) = '|'; - } - } - - opts &= ~0x40; - pflen = npflen; - } - - for (cnt = undo; cnt; cnt--) { - *(bptr++) = ']'; - } - - if (opts & 4) - bptr += sprintf(bptr, "=..."); - - *bptr = 0; - return bptr; -} - -int Utils_CompareOptionString(const char *a, const char *b, int cased, int sticky) { - const char *ae; - const char *be; - - for (ae = a; *ae && *ae != '|'; ae++) {} - for (be = b; *be && *be != '|'; be++) {} - - if (sticky && (be - b) < (ae - a)) - return 0; - - if (cased) { - while (a < ae && b < be) { - if (*a != *b) - break; - a++; - b++; - } - } else { - while (a < ae && b < be) { - if (my_tolower(*a) != my_tolower(*b)) - break; - a++; - b++; - } - } - - return (a == ae) && (sticky || b == be); -} diff --git a/unsorted/uCOS.c b/unsorted/uCOS.c deleted file mode 100644 index 11f1668..0000000 --- a/unsorted/uCOS.c +++ /dev/null @@ -1,292 +0,0 @@ -#include "cw_common.h" -#include "cos.h" - -extern Boolean systemHandles; - -static StringPtr COS_pstrcpy(StringPtr dst, ConstStringPtr src) { - short cnt; - for (cnt = src[0]; cnt >= 0; cnt--) { - *(dst++) = *(src++); - } - return dst; -} - -static StringPtr COS_pstrcat(StringPtr dst, ConstStringPtr src) { - // not matching - short as; - short bs; - - bs = *(src++); - as = dst[0]; - if ((bs + as) > 255) - bs = 255 - as; - - dst[0] += bs; - dst = &dst[as]; - dst++; - - while (bs-- > 0) { - *(dst++) = *(src++); - } - return dst; -} - -static void COS_pstrcharcat(StringPtr to, char ch) { - if (to[0] < 255) { - to[0]++; - to[to[0]] = ch; - } -} - -static short COS_pstrcmp(ConstStringPtr a, ConstStringPtr b) { - short as, bs; - if ((bs = *(b++)) != (as = *(a++))) - return 1; - while (as-- > 0) { - if (*(a++) != *(b++)) - return 1; - } - return 0; -} - -Handle COS_NewHandle(SInt32 byteCount) { - return NewHandle(byteCount); -} - -Handle COS_NewOSHandle(SInt32 logicalSize) { - OSErr err; - Handle h; - - if (systemHandles) { - h = TempNewHandle(logicalSize, &err); - if (!err) - return h; - } - - return NULL; -} - -void COS_FreeHandle(Handle handle) { - DisposeHandle(handle); -} - -Boolean COS_ResizeHandle(Handle handle, SInt32 newSize) { - SetHandleSize(handle, newSize); - return LMGetMemErr() == noErr; -} - -SInt32 COS_GetHandleSize(Handle handle) { - return GetHandleSize(handle); -} - -void COS_LockHandle(Handle handle) { - HLock(handle); -} - -void COS_LockHandleHi(Handle handle) { - HLockHi(handle); -} - -void COS_UnlockHandle(Handle handle) { - HUnlock(handle); -} - -int COS_GetHandleState(Handle handle) { - return HGetState(handle); -} - -void COS_SetHandleState(Handle handle, int state) { - HSetState(handle, state); -} - -Boolean COS_IsLockedState(int state) { - return (state & 0x80) >> 7; -} - -char *COS_NewPtr(SInt32 byteCount) { - return NewPtr(byteCount); -} - -char *COS_NewPtrClear(SInt32 byteCount) { - return NewPtrClear(byteCount); -} - -void COS_FreePtr(char *ptr) { - DisposePtr(ptr); -} - -void COS_AppendPtrToHandle(char *ptr1, Handle hand2, SInt32 size) { - PtrAndHand(ptr1, hand2, size); -} - -OSErr COS_GetMemErr(void) { - return LMGetMemErr(); -} - -SInt32 COS_GetTicks(void) { - return LMGetTicks(); -} - -SInt32 COS_GetTime(void) { - return LMGetTime(); -} - -void COS_GetString(char *buffer, SInt16 strListID, SInt16 index) { - GetIndString((StringPtr) buffer, strListID, index); - p2cstr((StringPtr) buffer); -} - -void COS_GetPString(StringPtr buffer, SInt16 strListID, SInt16 index) { - GetIndString((StringPtr) buffer, strListID, index); -} - -Boolean COS_IsMultiByte(const void *str1, const void *str2) { - return OS_IsMultiByte(str1, str2); -} - -OSErr COS_FileNew(const FSSpec *spec, SInt16 *refNum, OSType creator, OSType fileType) { - OSErr err; - - HDelete(spec->vRefNum, spec->parID, spec->name); - err = HCreate(spec->vRefNum, spec->parID, spec->name, creator, fileType); - if (!err) - err = HOpenDF(spec->vRefNum, spec->parID, spec->name, fsRdWrPerm, refNum); - return err; -} - -OSErr COS_FileOpen(const FSSpec *spec, SInt16 *refNum) { - return HOpenDF(spec->vRefNum, spec->parID, spec->name, fsRdPerm, refNum); -} - -OSErr COS_FileGetType(const FSSpec *spec, OSType *fileType) { - OSErr err; - FInfo fi; - - err = HGetFInfo(spec->vRefNum, spec->parID, spec->name, &fi); - *fileType = fi.fdType; - return err; -} - -OSErr COS_FileGetSize(SInt16 refNum, SInt32 *logEOF) { - return GetEOF(refNum, logEOF); -} - -OSErr COS_FileRead(SInt16 refNum, void *buffPtr, SInt32 count) { - return FSRead(refNum, &count, buffPtr); -} - -OSErr COS_FileWrite(SInt16 refNum, const void *buffPtr, SInt32 count) { - return FSWrite(refNum, &count, buffPtr); -} - -OSErr COS_FileGetPos(SInt16 refNum, SInt32 *filePos) { - return GetFPos(refNum, filePos); -} - -OSErr COS_FileSetPos(SInt16 refNum, SInt32 filePos) { - return SetFPos(refNum, fsFromStart, filePos); -} - -OSErr COS_FileClose(SInt16 refNum) { - return FSClose(refNum); -} - -void COS_FileSetFSSpec(FSSpec *spec, ConstStringPtr path) { - char buf[256]; - OSSpec ospec; - - memcpy(buf, path + 1, path[0]); - buf[path[0]] = 0; - - if (OS_MakeSpec(buf, &ospec, NULL) || OS_OSSpec_To_FSSpec(&ospec, spec)) { - spec->vRefNum = 0; - spec->parID = 0; - c2pstrcpy(spec->name, buf); - } -} - -OSErr COS_FileMakeFSSpec(SInt16 vRefNum, SInt32 dirID, ConstStringPtr fileName, FSSpec *spec) { - int oerr; - OSPathSpec opspec; - char buf[256]; - OSSpec ospec; - - oerr = OS_VolDir_To_OSPathSpec(vRefNum, dirID, &opspec); - if (oerr) - return OS_MacError(oerr); - - p2cstrcpy(buf, fileName); - oerr = OS_MakeSpecWithPath(&opspec, buf, 0, &ospec); - if (oerr) { - pstrncpy(spec->name, fileName, 256); - return OS_MacError(oerr); - } else { - return OS_MacError(OS_OSSpec_To_FSSpec(&ospec, spec)); - } -} - -OSErr COS_FileMakeFSSpecWithPath(const FSSpec *inputSpec, ConstStringPtr fileName, FSSpec *spec) { - spec->vRefNum = inputSpec->vRefNum; - spec->parID = inputSpec->parID; - COS_pstrcpy(spec->name, fileName); - return noErr; -} - -OSErr COS_FileGetFileInfo(const FSSpec *spec, OSType *creator, OSType *fileType) { - OSErr err; - FInfo fi; - err = HGetFInfo(spec->vRefNum, spec->parID, spec->name, &fi); - if (fileType) - *fileType = fi.fdType; - if (creator) - *creator = fi.fdCreator; - return err; -} - -void COS_FileGetFSSpecInfo(const FSSpec *spec, SInt16 *vRefNum, SInt32 *dirID, StringPtr fileName) { - if (vRefNum) - *vRefNum = spec->vRefNum; - if (dirID) - *dirID = spec->parID; - if (fileName) - COS_pstrcpy(fileName, spec->name); -} - -static void COS_MakePath(SInt16 vRefNum, SInt32 dirID, StringPtr path) { - FSSpec fss; - OSSpec oss; - fss.vRefNum = vRefNum; - fss.parID = dirID; - COS_pstrcpy(fss.name, path); - if (!OS_FSSpec_To_OSSpec(&fss, &oss)) { - OS_SpecToString(&oss, (char *) path, 256); - c2pstr((char *) path); - } -} - -void COS_FileGetPathName(char *buffer, const FSSpec *spec, SInt32 *mdDat) { - HParamBlockRec rec; - - if (mdDat) { - rec.fileParam.ioNamePtr = (StringPtr) spec->name; - rec.fileParam.ioVRefNum = spec->vRefNum; - rec.fileParam.ioDirID = spec->parID; - rec.fileParam.ioFDirIndex = 0; - if (!PBHGetFInfoSync(&rec)) - *mdDat = rec.fileParam.ioFlMdDat; - else - *mdDat = 0; - } - - COS_pstrcpy((StringPtr) buffer, spec->name); - COS_MakePath(spec->vRefNum, spec->parID, (StringPtr) buffer); - p2cstr((StringPtr) buffer); -} - -int COS_EqualFileSpec(const FSSpec *a, const FSSpec *b) { - if (a->vRefNum != b->vRefNum) - return 0; - if (a->parID != b->parID) - return 0; - return COS_pstrcmp(a->name, b->name) == 0; -} diff --git a/unsorted/uContext1.cpp b/unsorted/uContext1.cpp deleted file mode 100644 index 7ac712d..0000000 --- a/unsorted/uContext1.cpp +++ /dev/null @@ -1,513 +0,0 @@ -#include "plugin_internal.h" - -// Forward declarations -CWResult OSErrtoCWResult(OSErr err); - -static Boolean ValidateContext(CWPluginContext context) { - return context - && (context->shellSignature == CWFOURCHAR('C','W','I','E')) - && (context->request != reqInitialize) - && (context->request != reqTerminate) - && (context->request != reqIdle); -} - -static Boolean ValidateInitTermContext(CWPluginContext context) { - return context - && (context->shellSignature == CWFOURCHAR('C','W','I','E')) - && ((context->request == reqInitialize) - || (context->request == reqTerminate) - || (context->request == reqIdle)); -} - -static Boolean IsVCSContext(CWPluginContext context) { - return context && (context->pluginType == CWDROPINVCSTYPE); -} - -CW_CALLBACK CWGetPluginRequest(CWPluginContext context, SInt32 *request) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (request == NULL) - return cwErrInvalidParameter; - - *request = context->request; - return cwNoErr; -} - -CW_CALLBACK CWGetAPIVersion(CWPluginContext context, SInt32 *version) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (version == NULL) - return cwErrInvalidParameter; - - *version = context->apiVersion; - return cwNoErr; -} - -CW_CALLBACK CWGetIDEInfo(CWPluginContext context, CWIDEInfo *info) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (info == NULL) - return cwErrInvalidParameter; - - *info = *context->shellInfo; - return cwNoErr; -} - -CW_CALLBACK CWGetCallbackOSError(CWPluginContext context, CWOSResult *error) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (error == NULL) - return cwErrInvalidParameter; - - *error = context->callbackOSError; - return cwNoErr; -} - -CW_CALLBACK CWSetPluginOSError(CWPluginContext context, CWOSResult error) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - - context->pluginOSError = error; - return cwNoErr; -} - -CW_CALLBACK CWGetProjectFile(CWPluginContext context, CWFileSpec *projectSpec) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (projectSpec == NULL) - return cwErrInvalidParameter; - - *projectSpec = context->projectFile; - return cwNoErr; -} - -CW_CALLBACK CWGetTargetDataDirectory(CWPluginContext context, CWFileSpec *targetDataDirectorySpec) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (targetDataDirectorySpec == NULL) - return cwErrInvalidParameter; - if (context->targetDataDirectorySpec == NULL) - return cwErrInvalidCallback; - - *targetDataDirectorySpec = *context->targetDataDirectorySpec; - return cwNoErr; -} - -CW_CALLBACK CWGetTargetName(CWPluginContext context, char *name, short maxLength) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - - if (context->apiVersion >= 8) - return context->callbacks->cbGetTargetName(context, name, maxLength); - else - return cwErrRequestFailed; -} - -CW_CALLBACK CWGetProjectFileCount(CWPluginContext context, SInt32 *count) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (count == NULL) - return cwErrInvalidParameter; - - *count = context->numFiles; - return cwNoErr; -} - -CW_CALLBACK CWGetOutputFileDirectory(CWPluginContext context, CWFileSpec *outputFileDirectory) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (outputFileDirectory == NULL) - return cwErrInvalidParameter; - - *outputFileDirectory = context->outputFileDirectory; - return cwNoErr; -} - -CW_CALLBACK CWGetOverlay1GroupsCount(CWPluginContext context, SInt32 *count) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (count == NULL) - return cwErrInvalidParameter; - - *count = context->numOverlayGroups; - return cwNoErr; -} - -CW_CALLBACK CWGetFileInfo(CWPluginContext context, SInt32 whichfile, Boolean checkFileLocation, CWProjectFileInfo *fileinfo) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (fileinfo == NULL) - return cwErrInvalidParameter; - - return context->callbacks->cbGetFileInfo(context, whichfile, checkFileLocation, fileinfo); -} - -CW_CALLBACK CWFindAndLoadFile(CWPluginContext context, const char *filename, CWFileInfo *fileinfo) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (filename == NULL) - return cwErrInvalidParameter; - if (fileinfo == NULL) - return cwErrInvalidParameter; - - return context->callbacks->cbFindAndLoadFile(context, filename, fileinfo); -} - -static CWResult EnsureCachedAccessPaths(CWPluginContext context) { - if (!context->accessPathList) { - CWResult res = context->callbacks->cbCacheAccessPathList(context); - if (res) - return res; - if (!context->accessPathList) - return cwErrRequestFailed; - } - return cwNoErr; -} - -CW_CALLBACK CWGetAccessPathListInfo(CWPluginContext context, CWAccessPathListInfo *pathListInfo) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - if (pathListInfo == NULL) - return cwErrInvalidParameter; - if (context->apiVersion < 10) - return cwErrInvalidCallback; - CWResult res = EnsureCachedAccessPaths(context); - if (res) - return res; - pathListInfo->systemPathCount = context->accessPathList->systemPathCount; - pathListInfo->userPathCount = context->accessPathList->userPathCount; - pathListInfo->alwaysSearchUserPaths = context->accessPathList->alwaysSearchUserPaths; - pathListInfo->convertPaths = context->accessPathList->convertPaths; - return cwNoErr; -} - -CW_CALLBACK CWGetAccessPathInfo(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, CWAccessPathInfo *pathInfo) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - if (pathInfo == NULL) - return cwErrInvalidParameter; - if (context->apiVersion < 10) - return cwErrInvalidCallback; - CWResult res = EnsureCachedAccessPaths(context); - if (res) - return res; - - IDEAccessPath *paths; - SInt32 count; - switch (pathType) { - case cwSystemPath: - paths = context->accessPathList->systemPaths; - count = context->accessPathList->systemPathCount; - break; - case cwUserPath: - paths = context->accessPathList->userPaths; - count = context->accessPathList->userPathCount; - break; - default: - return cwErrInvalidParameter; - } - - if (whichPath < 0 || whichPath >= count) - return cwErrInvalidParameter; - - IDEAccessPath *path = &paths[whichPath]; - pathInfo->pathSpec = path->pathSpec; - pathInfo->recursive = path->recursive; - pathInfo->subdirectoryCount = path->subdirectoryCount; - return cwNoErr; -} - -CW_CALLBACK CWGetAccessPathSubdirectory(CWPluginContext context, CWAccessPathType pathType, SInt32 whichPath, - SInt32 whichSubdirectory, CWFileSpec *subdirectory) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - if (subdirectory == NULL) - return cwErrInvalidParameter; - if (context->apiVersion < 10) - return cwErrInvalidCallback; - CWResult res = EnsureCachedAccessPaths(context); - if (res) - return res; - - IDEAccessPath *paths; - SInt32 count; - switch (pathType) { - case cwSystemPath: - paths = context->accessPathList->systemPaths; - count = context->accessPathList->systemPathCount; - break; - case cwUserPath: - paths = context->accessPathList->userPaths; - count = context->accessPathList->userPathCount; - break; - default: - return cwErrInvalidParameter; - } - - if (whichPath < 0 || whichPath >= count) - return cwErrInvalidParameter; - - IDEAccessPath *path = &paths[whichPath]; - if (whichSubdirectory < 0 || whichSubdirectory >= path->subdirectoryCount) - return cwErrInvalidParameter; - - *subdirectory = path->subdirectories[whichSubdirectory]; - return cwNoErr; -} - -CW_CALLBACK CWGetFileText(CWPluginContext context, const CWFileSpec *filespec, const char **text, SInt32 *textLength, - short *filedatatype) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - if (!filespec) - return cwErrInvalidParameter; - if (!text) - return cwErrInvalidParameter; - if (!textLength) - return cwErrInvalidParameter; - if (!filedatatype) - return cwErrInvalidParameter; - return context->callbacks->cbGetFileText(context, filespec, text, textLength, filedatatype); -} - -CW_CALLBACK CWReleaseFileText(CWPluginContext context, const char *text) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - - if (text) - return context->callbacks->cbReleaseFileText(context, text); - else - return cwNoErr; -} - -CW_CALLBACK CWGetSegmentInfo(CWPluginContext context, SInt32 whichsegment, CWProjectSegmentInfo *segmentinfo) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (!segmentinfo) - return cwErrInvalidParameter; - return context->callbacks->cbGetSegmentInfo(context, whichsegment, segmentinfo); -} - -CW_CALLBACK CWGetOverlay1GroupInfo(CWPluginContext context, SInt32 whichgroup, CWOverlay1GroupInfo *groupinfo) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (!groupinfo) - return cwErrInvalidParameter; - return context->callbacks->cbGetOverlay1GroupInfo(context, whichgroup, groupinfo); -} - -CW_CALLBACK -CWGetOverlay1Info(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, CWOverlay1Info *overlayinfo) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (!overlayinfo) - return cwErrInvalidParameter; - return context->callbacks->cbGetOverlay1Info(context, whichgroup, whichoverlay, overlayinfo); -} - -CW_CALLBACK CWGetOverlay1FileInfo(CWPluginContext context, SInt32 whichgroup, SInt32 whichoverlay, SInt32 whichoverlayfile, - CWOverlay1FileInfo *fileinfo) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (!fileinfo) - return cwErrInvalidParameter; - return context->callbacks->cbGetOverlay1FileInfo(context, whichgroup, whichoverlay, whichoverlayfile, fileinfo); -} - -CW_CALLBACK CWReportMessage(CWPluginContext context, const CWMessageRef *msgRef, const char *line1, const char *line2, - short errorlevel, SInt32 errorNumber) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbReportMessage(context, msgRef, line1, line2, errorlevel, errorNumber); -} - -CW_CALLBACK CWAlert(CWPluginContext context, const char *msg1, const char *msg2, const char *msg3, const char *msg4) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbAlert(context, msg1, msg2, msg3, msg4); -} - -CW_CALLBACK CWShowStatus(CWPluginContext context, const char *line1, const char *line2) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbShowStatus(context, line1, line2); -} - -CW_CALLBACK CWUserBreak(CWPluginContext context) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbUserBreak(context); -} - -CW_CALLBACK CWGetNamedPreferences(CWPluginContext context, const char *prefsname, CWMemHandle *prefsdata) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - if (!prefsname) - return cwErrInvalidParameter; - if (!prefsdata) - return cwErrInvalidParameter; - return context->callbacks->cbGetNamedPreferences(context, prefsname, prefsdata); -} - -CW_CALLBACK CWStorePluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle prefsdata) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbStorePluginData(context, whichfile, type, prefsdata); -} - -CW_CALLBACK CWGetPluginData(CWPluginContext context, SInt32 whichfile, CWDataType type, CWMemHandle *prefsdata) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbGetPluginData(context, whichfile, type, prefsdata); -} - -CW_CALLBACK CWSetModDate(CWPluginContext context, const CWFileSpec *filespec, CWFileTime *moddate, Boolean isGenerated) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (!filespec) - return cwErrInvalidParameter; - return context->callbacks->cbSetModDate(context, filespec, moddate, isGenerated); -} - -CW_CALLBACK CWAddProjectEntry(CWPluginContext context, const CWFileSpec *fileSpec, Boolean isGenerated, - const CWNewProjectEntryInfo *projectEntryInfo, SInt32 *whichfile) { - if (IsVCSContext(context) || !ValidateContext(context)) - return cwErrInvalidParameter; - if (!fileSpec) - return cwErrInvalidParameter; - if (context->apiVersion < 8) - return cwErrRequestFailed; - return context->callbacks->cbAddProjectEntry(context, fileSpec, isGenerated, projectEntryInfo, whichfile); -} - -CW_CALLBACK CWCreateNewTextDocument(CWPluginContext context, const CWNewTextDocumentInfo *docinfo) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - if (!docinfo) - return cwErrInvalidParameter; - return context->callbacks->cbCreateNewTextDocument(context, docinfo); -} - -CW_CALLBACK CWAllocateMemory(CWPluginContext context, SInt32 size, Boolean isPermanent, void **ptr) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (!ptr) - return cwErrInvalidParameter; - return context->callbacks->cbAllocateMemory(context, size, isPermanent, ptr); -} - -CW_CALLBACK CWFreeMemory(CWPluginContext context, void *ptr, Boolean isPermanent) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (!ptr) - return cwNoErr; - return context->callbacks->cbFreeMemory(context, ptr, isPermanent); -} - -CW_CALLBACK CWAllocMemHandle(CWPluginContext context, SInt32 size, Boolean useTempMemory, CWMemHandle *handle) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (!handle) - return cwErrInvalidParameter; - return context->callbacks->cbAllocMemHandle(context, size, useTempMemory, handle); -} - -CW_CALLBACK CWFreeMemHandle(CWPluginContext context, CWMemHandle handle) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbFreeMemHandle(context, handle); -} - -CW_CALLBACK CWGetMemHandleSize(CWPluginContext context, CWMemHandle handle, SInt32 *size) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (!size) - return cwErrInvalidParameter; - return context->callbacks->cbGetMemHandleSize(context, handle, size); -} - -CW_CALLBACK CWResizeMemHandle(CWPluginContext context, CWMemHandle handle, SInt32 newSize) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbResizeMemHandle(context, handle, newSize); -} - -CW_CALLBACK CWLockMemHandle(CWPluginContext context, CWMemHandle handle, Boolean moveHi, void **ptr) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - if (!ptr) - return cwErrInvalidParameter; - return context->callbacks->cbLockMemHandle(context, handle, moveHi, ptr); -} - -CW_CALLBACK CWUnlockMemHandle(CWPluginContext context, CWMemHandle handle) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbUnlockMemHandle(context, handle); -} - -CW_CALLBACK CWDonePluginRequest(CWPluginContext, CWResult resultCode) { - return resultCode; -} - -CW_CALLBACK CWPreDialog(CWPluginContext context) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbPreDialog(context); -} - -CW_CALLBACK CWPostDialog(CWPluginContext context) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbPostDialog(context); -} - -CW_CALLBACK CWPreFileAction(CWPluginContext context, const CWFileSpec *theFile) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbPreFileAction(context, theFile); -} - -CW_CALLBACK CWPostFileAction(CWPluginContext context, const CWFileSpec *theFile) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbPostFileAction(context, theFile); -} - -CW_CALLBACK CWCheckoutLicense(CWPluginContext context, const char *a, const char *b, SInt32 c, void *d, SInt32 *cookiePtr) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbCheckoutLicense(context, a, b, c, d, cookiePtr); -} - -CW_CALLBACK CWCheckinLicense(CWPluginContext context, SInt32 cookie) { - if (!ValidateContext(context) && !ValidateInitTermContext(context)) - return cwErrInvalidParameter; - return context->callbacks->cbCheckinLicense(context, cookie); -} - -CW_CALLBACK CWResolveRelativePath(CWPluginContext context, const CWRelativePath *relativePath, CWFileSpec *fileSpec, Boolean create) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - if (relativePath == NULL) - return cwErrInvalidParameter; - if (fileSpec == NULL) - return cwErrInvalidParameter; - return context->callbacks->cbResolveRelativePath(context, relativePath, fileSpec, create); -} - -CW_CALLBACK CWMacOSErrToCWResult(CWPluginContext context, OSErr err) { - return OSErrtoCWResult(err); -} - -CWResult OSErrtoCWResult(OSErr err) { - switch (err) { - case noErr: return cwNoErr; - case userCanceledErr: return cwErrUserCanceled; - case paramErr: return cwErrInvalidParameter; - case memFullErr: return cwErrOutOfMemory; - case fnfErr: return cwErrFileNotFound; - default: return cwErrRequestFailed; - } -} - diff --git a/unsorted/uContextCL.cpp b/unsorted/uContextCL.cpp deleted file mode 100644 index 2c0a0c7..0000000 --- a/unsorted/uContextCL.cpp +++ /dev/null @@ -1,501 +0,0 @@ -#include "plugin_internal.h" - -static CWCompilerLinkerContext *GetContext(CWPluginContext context) { - if (context && (context->pluginType == CWDROPINCOMPILERTYPE || context->pluginType == CWDROPINLINKERTYPE)) - return static_cast(context); - else - return 0; -} - -CW_CALLBACK CWIsPrecompiling(CWPluginContext context, Boolean* isPrecompiling) { - CWCompilerLinkerContext *cl; - if (!isPrecompiling) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *isPrecompiling = cl->precompile; - return cwNoErr; -} - -CW_CALLBACK CWIsAutoPrecompiling(CWPluginContext context, Boolean* isAutoPrecompiling) { - CWCompilerLinkerContext *cl; - if (!isAutoPrecompiling) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *isAutoPrecompiling = cl->autoprecompile; - return cwNoErr; -} - -CW_CALLBACK CWIsPreprocessing(CWPluginContext context, Boolean* isPreprocessing) { - CWCompilerLinkerContext *cl; - if (!isPreprocessing) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *isPreprocessing = cl->preprocess; - return cwNoErr; -} - -CW_CALLBACK CWIsGeneratingDebugInfo(CWPluginContext context, Boolean* isGenerating) { - CWCompilerLinkerContext *cl; - if (!isGenerating) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *isGenerating = cl->debuginfo; - return cwNoErr; -} - -CW_CALLBACK CWIsCachingPrecompiledHeaders(CWPluginContext context, Boolean* isCaching) { - CWCompilerLinkerContext *cl; - if (!isCaching) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *isCaching = cl->cachingPCH; - return cwNoErr; -} - -CW_CALLBACK CWGetBrowseOptions(CWPluginContext context, CWBrowseOptions* browseOptions) { - CWCompilerLinkerContext *cl; - if (!browseOptions) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *browseOptions = cl->browseoptions; - return cwNoErr; -} - -CW_CALLBACK CWGetBuildSequenceNumber(CWPluginContext context, SInt32* sequenceNumber) { - CWCompilerLinkerContext *cl; - if (!sequenceNumber) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *sequenceNumber = cl->sequenceID; - return cwNoErr; -} - -CW_CALLBACK CWGetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) { - CWCompilerLinkerContext *cl; - if (!targetInfo) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion >= 10) { - *targetInfo = *cl->targetinfo; - } else if (cl->apiVersion >= 8) { - CWTargetInfo *ti = cl->targetinfo; - targetInfo->outputType = ti->outputType; - targetInfo->outfile = ti->outfile; - targetInfo->symfile = ti->symfile; - targetInfo->runfile = ti->runfile; - targetInfo->linkType = ti->linkType; - targetInfo->canRun = ti->canRun; - targetInfo->canDebug = ti->canDebug; - targetInfo->targetCPU = ti->targetCPU; - targetInfo->targetOS = ti->targetOS; -#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS - targetInfo->outfileCreator = ti->outfileCreator; - targetInfo->outfileType = ti->outfileType; - targetInfo->debuggerCreator = ti->debuggerCreator; - targetInfo->runHelperCreator = ti->runHelperCreator; -#endif - } else { - memset(targetInfo, 0, sizeof(CWTargetInfo)); - if (CWFileSpecNotEmpty(&cl->targetinfo_V7.outfile)) - targetInfo->outputType = linkOutputFile; - else - targetInfo->outputType = linkOutputNone; - targetInfo->outfile = cl->targetinfo_V7.outfile; - targetInfo->symfile = cl->targetinfo_V7.symfile; - targetInfo->runfile = cl->targetinfo_V7.outfile; - targetInfo->linkType = cl->targetinfo_V7.linkType; - targetInfo->canRun = cl->targetinfo_V7.canRun; - targetInfo->canDebug = cl->targetinfo_V7.canDebug; -#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS - targetInfo->debuggerCreator = cl->targetinfo_V7.debuggerCreator; - targetInfo->runHelperCreator = cl->targetinfo_V7.runHelperCreator; -#endif - } - return cwNoErr; -} - -CW_CALLBACK CWSetTargetInfo(CWPluginContext context, CWTargetInfo* targetInfo) { - CWCompilerLinkerContext *cl; - if (!targetInfo) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion >= 10) { - *cl->targetinfo = *targetInfo; - } else if (cl->apiVersion >= 8) { - CWTargetInfo *ti = cl->targetinfo; - ti->outputType = targetInfo->outputType; - ti->outfile = targetInfo->outfile; - ti->symfile = targetInfo->symfile; - ti->runfile = targetInfo->runfile; - ti->linkType = targetInfo->linkType; - ti->canRun = targetInfo->canRun; - ti->canDebug = targetInfo->canDebug; - ti->targetCPU = targetInfo->targetCPU; - ti->targetOS = targetInfo->targetOS; -#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS - ti->outfileCreator = targetInfo->outfileCreator; - ti->outfileType = targetInfo->outfileType; - ti->debuggerCreator = targetInfo->debuggerCreator; - ti->runHelperCreator = targetInfo->runHelperCreator; -#endif - } else { - cl->targetinfo_V7.outfile = targetInfo->outfile; - cl->targetinfo_V7.symfile = targetInfo->symfile; - cl->targetinfo_V7.linkType = targetInfo->linkType; - cl->targetinfo_V7.canRun = targetInfo->canRun; - cl->targetinfo_V7.canDebug = targetInfo->canDebug; -#if CWPLUGIN_HOST == CWPLUGIN_HOST_MACOS - cl->targetinfo_V7.useRunHelperApp = targetInfo->runHelperCreator != 0; - cl->targetinfo_V7.debuggerCreator = targetInfo->debuggerCreator; - cl->targetinfo_V7.runHelperCreator = targetInfo->runHelperCreator; -#endif - } - return cwNoErr; -} - -CW_CALLBACK CWGetMainFileNumber(CWPluginContext context, SInt32* fileNumber) { - CWCompilerLinkerContext *cl; - if (!fileNumber) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *fileNumber = cl->whichfile; - return cwNoErr; -} - -CW_CALLBACK CWGetMainFileID(CWPluginContext context, short* fileID) { - CWCompilerLinkerContext *cl; - if (!fileID) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *fileID = cl->fileID; - return cwNoErr; -} - -CW_CALLBACK CWGetMainFileSpec(CWPluginContext context, CWFileSpec* fileSpec) { - CWCompilerLinkerContext *cl; - if (!fileSpec) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *fileSpec = cl->sourcefile; - return cwNoErr; -} - -CW_CALLBACK CWGetMainFileText(CWPluginContext context, const char** text, SInt32* textLength) { - CWCompilerLinkerContext *cl; - if (!text) - return cwErrInvalidParameter; - if (!textLength) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - *text = cl->sourcetext; - *textLength = cl->sourcetextsize; - return cwNoErr; -} - -CW_CALLBACK CWLoadObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle* objectdata) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbLoadObjectData(cl, whichfile, objectdata); -} - -CW_CALLBACK CWStoreObjectData(CWPluginContext context, SInt32 whichfile, CWObjectData* object) { - CWCompilerLinkerContext *cl; - if (!object) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbStoreObjectData(cl, whichfile, object); -} - -CW_CALLBACK CWFreeObjectData(CWPluginContext context, SInt32 whichfile, CWMemHandle objectdata) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbFreeObjectData(cl, whichfile, objectdata); -} - -CW_CALLBACK CWGetSuggestedObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) { - CWCompilerLinkerContext *cl; - if (!fileSpec) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (context->apiVersion < 10) - return cwErrInvalidCallback; - return cl->callbacks->cbGetSuggestedObjectFileSpec(cl, whichfile, fileSpec); -} - -CW_CALLBACK CWGetStoredObjectFileSpec(CWPluginContext context, SInt32 whichfile, CWFileSpec* fileSpec) { - CWCompilerLinkerContext *cl; - if (!fileSpec) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (context->apiVersion < 10) - return cwErrInvalidCallback; - return cl->callbacks->cbGetStoredObjectFileSpec(cl, whichfile, fileSpec); -} - -CW_CALLBACK CWDisplayLines(CWPluginContext context, SInt32 nlines) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbDisplayLines(cl, nlines); -} - -CW_CALLBACK CWGetResourceFile(CWPluginContext context, CWFileSpec* filespec) { - CWCompilerLinkerContext *cl; - if (!filespec) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbGetResourceFile(cl, filespec); -} - -CW_CALLBACK CWPutResourceFile(CWPluginContext context, const char* prompt, const char* name, CWFileSpec* filespec) { - CWCompilerLinkerContext *cl; - if (!prompt) - return cwErrInvalidParameter; - if (!name) - return cwErrInvalidParameter; - if (!filespec) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbPutResourceFile(cl, prompt, name, filespec); -} - -CW_CALLBACK CWCachePrecompiledHeader(CWPluginContext context, const CWFileSpec* filespec, CWMemHandle pchhandle) { - CWCompilerLinkerContext *cl; - if (!filespec) - return cwErrInvalidParameter; - if (!pchhandle) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbCachePrecompiledHeader(cl, filespec, pchhandle); -} - -CW_CALLBACK CWGetPrecompiledHeaderSpec(CWPluginContext context, CWFileSpec *pchspec, const char *target) { - CWCompilerLinkerContext *cl; - if (!pchspec) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbGetPrecompiledHeaderSpec(cl, pchspec, target); -} - -CW_CALLBACK CWBeginSubCompile(CWPluginContext context, SInt32 whichfile, CWPluginContext* subContext) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbBeginSubCompile(cl, whichfile, subContext); -} - -CW_CALLBACK CWEndSubCompile(CWPluginContext subContext) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(subContext))) - return cwErrInvalidCallback; - return cl->callbacks->cbEndSubCompile(subContext); -} - -CW_CALLBACK CWLookUpUnit(CWPluginContext context, const char* name, Boolean isdependency, const void** unitdata, SInt32* unitdatalength) { - CWCompilerLinkerContext *cl; - if (!name) - return cwErrInvalidParameter; - if (!unitdata) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbLookUpUnit(cl, name, isdependency, unitdata, unitdatalength); -} - -CW_CALLBACK CWSBMfiles(CWPluginContext context, short libref) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbSBMfiles(cl, libref); -} - -CW_CALLBACK CWStoreUnit(CWPluginContext context, const char* unitname, CWMemHandle unitdata, CWDependencyTag dependencytag) { - CWCompilerLinkerContext *cl; - if (!unitname) - return cwErrInvalidParameter; - if (!unitdata) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbStoreUnit(cl, unitname, unitdata, dependencytag); -} - -CW_CALLBACK CWReleaseUnit(CWPluginContext context, void* unitdata) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbReleaseUnit(cl, unitdata); -} - -CW_CALLBACK CWUnitNameToFileName(CWPluginContext context, const char* unitname, char* filename) { - CWCompilerLinkerContext *cl; - if (!unitname) - return cwErrInvalidParameter; - if (!filename) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbUnitNameToFileName(cl, unitname, filename); -} - -CW_CALLBACK CWGetTargetStorage(CWPluginContext context, void** storage) { - CWCompilerLinkerContext *cl; - if (!storage) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion >= 8) { - *storage = cl->targetStorage; - return cwNoErr; - } else { - return cwErrRequestFailed; - } -} - -CW_CALLBACK CWSetTargetStorage(CWPluginContext context, void* storage) { - CWCompilerLinkerContext *cl; - if (!storage) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion >= 8) { - cl->targetStorage = storage; - return cwNoErr; - } else { - return cwErrRequestFailed; - } -} - -CW_CALLBACK CWOSErrorMessage(CWPluginContext context, const char *msg, OSErr errorcode) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbOSErrorMessage(cl, msg, errorcode); -} - -CW_CALLBACK CWOSAlert(CWPluginContext context, const char* message, OSErr errorcode) { - CWCompilerLinkerContext *cl; - if (!message) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - return cl->callbacks->cbOSAlert(cl, message, errorcode); -} - -CW_CALLBACK CWGetModifiedFiles(CWPluginContext context, SInt32* modifiedFileCount, const SInt32** modifiedFiles) { - CWCompilerLinkerContext *cl; - if (!modifiedFileCount) - return cwErrInvalidParameter; - if (!modifiedFiles) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (context->apiVersion < 9) - return cwErrInvalidCallback; - return cl->callbacks->cbGetModifiedFiles(cl, modifiedFileCount, modifiedFiles); -} - -CW_CALLBACK CWGetCommandLineArgs(CWPluginContext context, const char** commandLineArgs) { - CWCompilerLinkerContext *cl; - if (!commandLineArgs) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion < 11) - return cwErrInvalidCallback; - if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) - return cwErrRequestFailed; - *commandLineArgs = cl->commandLineArgs; - return cwNoErr; -} - -CW_CALLBACK CWGetWorkingDirectory(CWPluginContext context, CWFileSpec* workingDirectorySpec) { - CWCompilerLinkerContext *cl; - if (!workingDirectorySpec) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion < 11) - return cwErrInvalidCallback; - if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) - return cwErrRequestFailed; - *workingDirectorySpec = *cl->workingDirectorySpec; - return cwNoErr; -} - -CW_CALLBACK CWGetEnvironmentVariableCount(CWPluginContext context, SInt32* count) { - CWCompilerLinkerContext *cl; - if (!count) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion < 11) - return cwErrInvalidCallback; - if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) - return cwErrRequestFailed; - *count = cl->numEnvironmentVariables; - return cwNoErr; -} - -CW_CALLBACK CWGetEnvironmentVariable(CWPluginContext context, SInt32 index, const char** name, const char** value) { - CWCompilerLinkerContext *cl; - if (!name) - return cwErrInvalidParameter; - if (!value) - return cwErrInvalidParameter; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion < 11) - return cwErrInvalidCallback; - if (!cl->commandLineArgs && cl->callbacks->cbGetRuntimeSettings(cl)) - return cwErrRequestFailed; - if (index < 0 || index >= cl->numEnvironmentVariables) - return cwErrInvalidParameter; - *name = cl->environmentVariables[index].name; - *value = cl->environmentVariables[index].value; - return cwNoErr; -} - -CW_CALLBACK CWGetFrameworkCount(CWPluginContext context, SInt32* frameworkCount) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion < 11) - return cwErrInvalidCallback; - if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkCount(cl, frameworkCount)) - return cwErrRequestFailed; - return cwNoErr; -} - -CW_CALLBACK CWGetFrameworkInfo(CWPluginContext context, SInt32 whichFramework, CWFrameworkInfo* frameworkInfo) { - CWCompilerLinkerContext *cl; - if (!(cl = GetContext(context))) - return cwErrInvalidCallback; - if (cl->apiVersion < 11) - return cwErrInvalidCallback; - if (!cl->commandLineArgs && cl->callbacks->cbGetFrameworkInfo(cl, whichFramework, frameworkInfo)) - return cwErrRequestFailed; - return cwNoErr; -} diff --git a/unsorted/uContextParser.cpp b/unsorted/uContextParser.cpp deleted file mode 100644 index 35d6dfa..0000000 --- a/unsorted/uContextParser.cpp +++ /dev/null @@ -1,207 +0,0 @@ -#include "plugin_internal.h" - -static CWParserContext *GetContext(CWPluginContext context) { - if (context && (context->pluginType == CWDROPINPARSERTYPE)) - return static_cast(context); - else - return 0; -} - -CW_CALLBACK CWParserGetBuildDate(CWPluginContext context, const char **buildDate, const char **buildTime) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!buildDate) - return cwErrInvalidParameter; - if (!buildTime) - return cwErrInvalidParameter; - *buildDate = pc->build_date; - *buildTime = pc->build_time; - return cwNoErr; -} - -CW_CALLBACK CWParserGetCommandLine(CWPluginContext context, CWCommandLineArgs **args) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!args) - return cwErrInvalidParameter; - *args = pc->args; - return cwNoErr; -} - -CW_CALLBACK CWParserGetTargetInfo(CWPluginContext context, CWDataType *cpu, CWDataType *os) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!cpu) - return cwErrInvalidParameter; - if (!os) - return cwErrInvalidParameter; - *cpu = pc->cpu; - *os = pc->os; - return cwNoErr; -} - -CW_CALLBACK CWParserGetToolInfo(CWPluginContext context, const ToolVersionInfo **toolVersionInfo) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!toolVersionInfo) - return cwErrInvalidParameter; - *toolVersionInfo = pc->build_tool; - return cwNoErr; -} - -CW_CALLBACK CWParserGetPlugins(CWPluginContext context, int *numPlugins, const CLPluginInfo **pluginInfo) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!numPlugins) - return cwErrInvalidParameter; - if (!pluginInfo) - return cwErrInvalidParameter; - *numPlugins = pc->numPlugins; - *pluginInfo = pc->plugins; - return cwNoErr; -} - -CW_CALLBACK CWParserGetPanels(CWPluginContext context, int *numPanels, const char ***panelNames) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!numPanels) - return cwErrInvalidParameter; - if (!panelNames) - return cwErrInvalidParameter; - *numPanels = pc->numPanels; - *panelNames = pc->panelNames; - return cwNoErr; -} - -CW_CALLBACK CWParserStoreCommandLineForPanel(CWPluginContext context, int index, const CWCommandLineArgs *args) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (index < 0 || index >= pc->numPanels) - return cwErrInvalidParameter; - if (!args) - return cwErrInvalidParameter; - pc->panel_args[index] = *args; - return cwNoErr; -} - -CW_CALLBACK CWParserStoreCommandLineForPlugin(CWPluginContext context, int index, const CWCommandLineArgs *args) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (index < 0 || index >= pc->numPlugins) - return cwErrInvalidParameter; - if (!args) - return cwErrInvalidParameter; - pc->plugin_args[index] = *args; - return cwNoErr; -} - -CW_CALLBACK CWParserSetNamedPreferences(CWPluginContext context, const char *panelName, Handle paneldata) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!panelName) - return cwErrInvalidParameter; - return pc->callbacks->cbParserSetNamedPreferences(pc, panelName, paneldata); -} - -CW_CALLBACK CWParserAddAccessPath(CWPluginContext context, const CWNewAccessPathInfo *api) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!api) - return cwErrInvalidParameter; - return pc->callbacks->cbParserAddAccessPath(pc, api); -} - -CW_CALLBACK CWParserSwapAccessPaths(CWPluginContext context) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - return pc->callbacks->cbParserSwapAccessPaths(pc); -} - -CW_CALLBACK CWParserSetOutputFileDirectory(CWPluginContext context, const CWFileSpec *idefss) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!idefss) - return cwErrInvalidParameter; - return pc->callbacks->cbParserSetOutputFileDirectory(pc, idefss); -} - -CW_CALLBACK CWParserSetFileOutputName(CWPluginContext context, SInt32 position, short which, const char *outfilename) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!outfilename) - return cwErrInvalidParameter; - return pc->callbacks->cbParserSetFileOutputName(pc, position, which, outfilename); -} - -CW_CALLBACK CWParserAddOverlay1Group(CWPluginContext context, const char *name, const CWAddr64 *addr, SInt32 *newGroupNumber) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!name) - return cwErrInvalidParameter; - if (!addr) - return cwErrInvalidParameter; - if (!newGroupNumber) - return cwErrInvalidParameter; - return pc->callbacks->cbParserAddOverlay1Group(pc, name, addr, newGroupNumber); -} - -CW_CALLBACK CWParserAddOverlay1(CWPluginContext context, const char *name, SInt32 groupNumber, SInt32 *newOverlayNumber) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!name) - return cwErrInvalidParameter; - if (!newOverlayNumber) - return cwErrInvalidParameter; - return pc->callbacks->cbParserAddOverlay1(pc, name, groupNumber, newOverlayNumber); -} - -CW_CALLBACK CWParserAddSegment(CWPluginContext context, const char *name, short attrs, SInt32 *newSegmentNumber) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!name) - return cwErrInvalidParameter; - if (!newSegmentNumber) - return cwErrInvalidParameter; - return pc->callbacks->cbParserAddSegment(pc, name, attrs, newSegmentNumber); -} - -CW_CALLBACK CWParserSetSegment(CWPluginContext context, SInt32 segmentNumber, const char *name, short attrs) { - CWParserContext *pc; - if (!(pc = GetContext(context))) - return cwErrInvalidCallback; - if (!name) - return cwErrInvalidParameter; - return pc->callbacks->cbParserSetSegment(pc, segmentNumber, name, attrs); -} - -CW_CALLBACK CWParserCreateVirtualFile(CWPluginContext context, const char *name, CWMemHandle text) { - CWNewTextDocumentInfo info; - info.documentname = name; - info.text = text; - info.markDirty = 1; - return CWCreateNewTextDocument(context, &info); -} - -CW_CALLBACK CWParserDisplayTextHandle(CWPluginContext context, const char *name, CWMemHandle text) { - CWNewTextDocumentInfo info; - info.documentname = name; - info.text = text; - info.markDirty = 0; - return CWCreateNewTextDocument(context, &info); -} diff --git a/unsorted/uContextSecret.cpp b/unsorted/uContextSecret.cpp deleted file mode 100644 index b33ca81..0000000 --- a/unsorted/uContextSecret.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "plugin_internal.h" - -static Boolean ValidateContext(CWPluginContext context) { - return context && (context->shellSignature == CWFOURCHAR('C','W','I','E')); -} - -typedef CWResult (*cbSecretAttachHandleType)(CWPluginContext, Handle, CWMemHandle *); -typedef CWResult (*cbSecretDetachHandleType)(CWPluginContext, CWMemHandle, Handle *); -typedef CWResult (*cbSecretPeekHandleType)(CWPluginContext, CWMemHandle, Handle *); -typedef CWResult (*cbSecretGetNamedPreferencesType)(CWPluginContext, const char *, Handle *); - -CW_CALLBACK CWSecretAttachHandle(CWPluginContext context, Handle handle, CWMemHandle *memHandle) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return ((cbSecretAttachHandleType) context->callbacks->cbInternal[0])(context, handle, memHandle); -} - -CW_CALLBACK CWSecretDetachHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return ((cbSecretDetachHandleType) context->callbacks->cbInternal[1])(context, memHandle, handle); -} - -CW_CALLBACK CWSecretPeekHandle(CWPluginContext context, CWMemHandle memHandle, Handle *handle) { - if (!ValidateContext(context)) - return cwErrInvalidParameter; - return ((cbSecretPeekHandleType) context->callbacks->cbInternal[2])(context, memHandle, handle); -} - -CW_CALLBACK CWSecretGetNamedPreferences(CWPluginContext context, const char *prefsname, Handle *prefsdata) { - if (!prefsdata) - return cwErrInvalidParameter; - - CWMemHandle memHandle; - CWResult res = CWGetNamedPreferences(context, prefsname, &memHandle); - if (!res) - res = CWSecretDetachHandle(context, memHandle, prefsdata); - return res; -} -- cgit v1.2.3