#include "mmodel.h"
#include "print.h"
#include "segnames.h"
+#include "strbuf.h"
#include "target.h"
#include "tgttrans.h"
#include "version.h"
#include "macrotab.h"
#include "output.h"
#include "scanner.h"
-#include "standard.h"
#include "segments.h"
+#include "standard.h"
+#include "svnversion.h"
" --help\t\tHelp (this text)\n"
" --include-dir dir\tSet an include directory search path\n"
" --list-opt-steps\tList all optimizer steps and exit\n"
- " --memory-model model\tSet the memory model\n"
+ " --local-strings\tEmit string literals immediately\n"
+ " --memory-model model\tSet the memory model\n"
" --register-space b\tSet space available for register variables\n"
" --register-vars\tEnable register variables\n"
" --rodata-name seg\tSet the name of the RODATA segment\n"
cbmsys ("__C128__");
break;
- case TGT_ACE:
- cbmsys ("__ACE__");
- break;
-
case TGT_PLUS4:
cbmsys ("__PLUS4__");
break;
+static void OptLocalStrings (const char* Opt attribute ((unused)),
+ const char* Arg attribute ((unused)))
+/* Emit string literals immediately */
+{
+ IS_Set (&LocalStrings, 1);
+}
+
+
+
static void OptMemoryModel (const char* Opt, const char* Arg)
/* Set the memory model */
{
static void OptVersion (const char* Opt attribute ((unused)),
- const char* Arg attribute ((unused)))
-/* Print the assembler version */
+ const char* Arg attribute ((unused)))
+/* Print the compiler version */
{
fprintf (stderr,
- "cc65 V%u.%u.%u\n",
- VER_MAJOR, VER_MINOR, VER_PATCH);
+ "cc65 V%s\nSVN version: %s\n",
+ GetVersionAsString (), SVNVersion);
+ exit (EXIT_SUCCESS);
+}
+
+
+
+static void OptWarning (const char* Opt attribute ((unused)), const char* Arg)
+/* Handle the -W option */
+{
+ StrBuf W = AUTO_STRBUF_INITIALIZER;
+
+ /* Arg is a list of suboptions, separated by commas */
+ while (Arg) {
+
+ const char* Pos;
+ int Enabled = 1;
+ IntStack* S;
+
+ /* The suboption may be prefixed with '-' or '+' */
+ if (*Arg == '-') {
+ Enabled = 0;
+ ++Arg;
+ } else if (*Arg == '+') {
+ /* This is the default */
+ ++Arg;
+ }
+
+ /* Get the next suboption */
+ Pos = strchr (Arg, ',');
+ if (Pos) {
+ SB_CopyBuf (&W, Arg, Pos - Arg);
+ Arg = Pos + 1;
+ } else {
+ SB_CopyStr (&W, Arg);
+ Arg = 0;
+ }
+ SB_Terminate (&W);
+
+ /* Search for the warning */
+ S = FindWarning (SB_GetConstBuf (&W));
+ if (S == 0) {
+ InvArg (Opt, SB_GetConstBuf (&W));
+ }
+ IS_Set (S, Enabled);
+ }
+
+ /* Free allocated memory */
+ SB_Done (&W);
}
{ "--help", 0, OptHelp },
{ "--include-dir", 1, OptIncludeDir },
{ "--list-opt-steps", 0, OptListOptSteps },
+ { "--local-strings", 0, OptLocalStrings },
{ "--memory-model", 1, OptMemoryModel },
{ "--register-space", 1, OptRegisterSpace },
{ "--register-vars", 0, OptRegisterVars },
const char* Arg = ArgVec[I];
/* Check for an option */
- if (Arg [0] == '-') {
+ if (Arg[0] == '-') {
- switch (Arg [1]) {
+ switch (Arg[1]) {
case '-':
LongOption (&I, OptTab, sizeof(OptTab)/sizeof(OptTab[0]));
default:
UnknownOption (Arg);
break;
- }
+ }
}
break;
break;
case 'W':
- IS_Set (&WarnDisable, 1);
+ OptWarning (Arg, GetArg (&I, 2));
break;
default:
/* Create the output file if we didn't had any errors */
if (PreprocessOnly == 0 && (ErrorCount == 0 || Debug)) {
- /* Open the file */
+ /* Emit literals, externals, do cleanup and optimizations */
+ FinishCompile ();
+
+ /* Open the file */
OpenOutputFile ();
- /* Write the output to the file */
+ /* Write the output to the file */
WriteAsmOutput ();
Print (stdout, 1, "Wrote output to `%s'\n", OutputFilename);