]> git.sur5r.net Git - cc65/blobdiff - src/ca65/condasm.c
New module strstack
[cc65] / src / ca65 / condasm.c
index 0aef3b364ed11e89fe27f94cfa97a49f42c0a657..b092b79720fdfbb604aa648fb361bfc42cfdd4b9 100644 (file)
@@ -122,7 +122,7 @@ static IfDesc* GetCurrentIf (void)
 static void FreeIf (void)
 /* Free all .IF descriptors until we reach one with the NeedTerm bit set */
 {
-    int Done = 0;
+    int Done;
     do {
                IfDesc* D = GetCurrentIf();
                if (D == 0) {
@@ -295,7 +295,7 @@ void DoConditionals (void)
                NextTok ();
                if (IfCond) {
                    ExprNode* Expr = Expression();
-                   SetIfCond (D, IsConstExpr (Expr));
+                   SetIfCond (D, IsConstExpr (Expr, 0));
                    FreeExpr (Expr);
                }
                IfCond = GetCurrentIfCond ();
@@ -321,7 +321,7 @@ void DoConditionals (void)
                        SetIfCond (D, 1);
                         SkipUntilSep ();
                     }
-               }
+               }
                IfCond = GetCurrentIfCond ();
                break;
 
@@ -330,7 +330,7 @@ void DoConditionals (void)
                NextTok ();
                if (IfCond) {
                    ExprNode* Expr = Expression();
-                   SetIfCond (D, !IsConstExpr (Expr));
+                   SetIfCond (D, !IsConstExpr (Expr, 0));
                    FreeExpr (Expr);
                }
                IfCond = GetCurrentIfCond ();
@@ -367,7 +367,7 @@ void DoConditionals (void)
 
            case TOK_IFP816:
                D = AllocIf (".IFP816", 1);
-               NextTok ();
+               NextTok ();
                if (IfCond) {
                            SetIfCond (D, GetCPU() == CPU_65816);
                }
@@ -413,6 +413,39 @@ void DoConditionals (void)
 
 
 
+int CheckConditionals (void)
+/* Check if the current token is one that starts a conditional directive, and
+ * call DoConditionals if so. Return true if a conditional directive was found,
+ * return false otherwise.
+ */
+{
+    switch (Tok) {
+        case TOK_ELSE:
+        case TOK_ELSEIF:
+        case TOK_ENDIF:
+        case TOK_IF:
+        case TOK_IFBLANK:
+        case TOK_IFCONST:
+        case TOK_IFDEF:
+        case TOK_IFNBLANK:
+        case TOK_IFNCONST:
+        case TOK_IFNDEF:
+        case TOK_IFNREF:
+        case TOK_IFP02:
+        case TOK_IFP816:
+        case TOK_IFPC02:
+        case TOK_IFPSC02:
+        case TOK_IFREF:
+            DoConditionals ();
+            return 1;
+
+        default:
+            return 0;
+    }
+}
+
+
+
 void CheckOpenIfs (void)
 /* Called from the scanner before closing an input file. Will check for any
  * open .ifs in this file.