]> git.sur5r.net Git - cc65/blobdiff - src/cc65/pragma.c
remove TABs
[cc65] / src / cc65 / pragma.c
index 27015285e79d2a33bc979280ce2728fe94959f45..b05ef6122bb4fce4efc24bd4f649999e395f16cc 100644 (file)
@@ -51,7 +51,7 @@
 #include "scanstrbuf.h"
 #include "symtab.h"
 #include "pragma.h"
-#include "trampoline.h"
+#include "wrappedcall.h"
 
 
 
@@ -78,9 +78,10 @@ typedef enum {
     PRAGMA_DATASEG,                                     /* obsolete */
     PRAGMA_INLINE_STDFUNCS,
     PRAGMA_LOCAL_STRINGS,
+    PRAGMA_MESSAGE,
     PRAGMA_OPTIMIZE,
-    PRAGMA_REGVARADDR,
     PRAGMA_REGISTER_VARS,
+    PRAGMA_REGVARADDR,
     PRAGMA_REGVARS,                                     /* obsolete */
     PRAGMA_RODATA_NAME,
     PRAGMA_RODATASEG,                                   /* obsolete */
@@ -114,6 +115,7 @@ static const struct Pragma {
     { "dataseg",                PRAGMA_DATASEG            },      /* obsolete */
     { "inline-stdfuncs",        PRAGMA_INLINE_STDFUNCS    },
     { "local-strings",          PRAGMA_LOCAL_STRINGS      },
+    { "message",                PRAGMA_MESSAGE            },
     { "optimize",               PRAGMA_OPTIMIZE           },
     { "register-vars",          PRAGMA_REGISTER_VARS      },
     { "regvaraddr",             PRAGMA_REGVARADDR         },
@@ -125,7 +127,7 @@ static const struct Pragma {
     { "static-locals",          PRAGMA_STATIC_LOCALS      },
     { "staticlocals",           PRAGMA_STATICLOCALS       },      /* obsolete */
     { "warn",                   PRAGMA_WARN               },
-    { "wrapped-call",           PRAGMA_WRAPPED_CALL      },
+    { "wrapped-call",           PRAGMA_WRAPPED_CALL       },
     { "writable-strings",       PRAGMA_WRITABLE_STRINGS   },
     { "zpsym",                  PRAGMA_ZPSYM              },
 };
@@ -354,7 +356,7 @@ static int BoolKeyword (StrBuf* Ident)
     }
 
     /* Error */
-    Error ("Pragma argument must be one of `on', `off', `true' or `false'");
+    Error ("Pragma argument must be one of 'on', 'off', 'true' or 'false'");
     return 0;
 }
 
@@ -386,11 +388,11 @@ static void StringPragma (StrBuf* B, void (*Func) (const char*))
 static void SegNamePragma (StrBuf* B, segment_t Seg)
 /* Handle a pragma that expects a segment name parameter */
 {
-    StrBuf      S = AUTO_STRBUF_INITIALIZER;
     const char* Name;
+    StrBuf S = AUTO_STRBUF_INITIALIZER;
+    int Push = 0;
 
     /* Check for the "push" or "pop" keywords */
-    int Push = 0;
     switch (ParsePushPop (B)) {
 
         case PP_NONE:
@@ -403,7 +405,13 @@ static void SegNamePragma (StrBuf* B, segment_t Seg)
         case PP_POP:
             /* Pop the old value and output it */
             PopSegName (Seg);
-            g_segname (Seg);
+
+            /* BSS variables are output at the end of the compilation.  Don't
+            ** bother to change their segment, now.
+            */
+            if (Seg != SEG_BSS) {
+                g_segname (Seg);
+            }
 
             /* Done */
             goto ExitPoint;
@@ -434,12 +442,18 @@ static void SegNamePragma (StrBuf* B, segment_t Seg)
         } else {
             SetSegName (Seg, Name);
         }
-        g_segname (Seg);
+
+        /* BSS variables are output at the end of the compilation.  Don't
+        ** bother to change their segment, now.
+        */
+        if (Seg != SEG_BSS) {
+            g_segname (Seg);
+        }
 
     } else {
 
         /* Segment name is invalid */
-        Error ("Illegal segment name: `%s'", Name);
+        Error ("Illegal segment name: '%s'", Name);
 
     }
 
@@ -468,7 +482,7 @@ static void WrappedCallPragma (StrBuf* B)
             break;
 
         case PP_POP:
-            PopTrampoline();
+            PopWrappedCall();
 
             /* Done */
             goto ExitPoint;
@@ -509,15 +523,16 @@ static void WrappedCallPragma (StrBuf* B)
     Entry = FindSym(Name);
 
     /* Check if the name is valid */
-    if (Entry && Entry->Flags & (SC_FUNC | SC_STORAGE)) {
+    if (Entry && Entry->Flags & SC_FUNC) {
 
-        PushTrampoline(Entry, Val);
+        PushWrappedCall(Entry, (unsigned char) Val);
         Entry->Flags |= SC_REF;
+        Entry->V.F.Func->Flags |= FD_CALL_WRAPPER;
 
     } else {
 
         /* Segment name is invalid */
-        Error ("Wrapped-call target does not exist or is not a function or array");
+        Error ("Wrapped-call target does not exist or is not a function");
 
     }
 
@@ -737,6 +752,13 @@ static void IntPragma (StrBuf* B, IntStack* Stack, long Low, long High)
 
 
 
+static void MakeMessage (const char* Message)
+{
+    fprintf (stderr, "%s(%u): Note: %s\n", GetInputName (CurTok.LI), GetInputLine (CurTok.LI), Message);
+}
+
+
+
 static void ParsePragma (void)
 /* Parse the contents of the _Pragma statement */
 {
@@ -766,7 +788,7 @@ static void ParsePragma (void)
         ** for unknown pragmas, but warn about them if enabled (the default).
         */
         if (IS_Get (&WarnUnknownPragma)) {
-            Warning ("Unknown pragma `%s'", SB_GetConstBuf (&Ident));
+            Warning ("Unknown pragma '%s'", SB_GetConstBuf (&Ident));
         }
         goto ExitPoint;
     }
@@ -836,6 +858,10 @@ static void ParsePragma (void)
             FlagPragma (&B, &LocalStrings);
             break;
 
+        case PRAGMA_MESSAGE:
+            StringPragma (&B, MakeMessage);
+            break;
+
         case PRAGMA_OPTIMIZE:
             FlagPragma (&B, &Optimize);
             break;
@@ -872,9 +898,9 @@ static void ParsePragma (void)
             FlagPragma (&B, &StaticLocals);
             break;
 
-       case PRAGMA_WRAPPED_CALL:
-           WrappedCallPragma(&B);
-           break;
+        case PRAGMA_WRAPPED_CALL:
+            WrappedCallPragma(&B);
+            break;
 
         case PRAGMA_WARN:
             WarnPragma (&B);