/*****************************************************************************/
-/*                            Helper functions                              */
+/*                            Helper functions                              */
 /*****************************************************************************/
 
 
 
 
 
-void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc *Expr)
+void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr)
 /* Call an expression function with checks. */
 {
     /* Remember the stack pointer */
 
 
 
+void MarkedExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr)
+/* Call an expression function with checks and record start and end of the
+ * generated code.
+ */
+{
+    CodeMark Start, End;
+    GetCodePos (&Start);
+    ExprWithCheck (Func, Expr);
+    GetCodePos (&End);
+    ED_SetCodeRange (Expr, &Start, &End);
+}
+
+
+
 static Type* promoteint (Type* lhst, Type* rhst)
 /* In an expression with two ints, return the type of the result */
 {
 
 
 
 
-void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc *Expr);
+void ExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr);
 /* Call an expression function with checks. */
 
+void MarkedExprWithCheck (void (*Func) (ExprDesc*), ExprDesc* Expr);
+/* Call an expression function with checks and record start and end of the
+ * generated code.
+ */
+
 void PushAddr (const ExprDesc* Expr);
 /* If the expression contains an address that was somehow evaluated,
  * push this address on the stack. This is a helper function for all
 
 int evalexpr (unsigned flags, void (*Func) (ExprDesc*), ExprDesc* Expr);
 /* Will evaluate an expression via the given function. If the result is a
- * constant, 0 is returned and the value is put in the lval struct. If the
+ * constant, 0 is returned and the value is put in the Expr struct. If the
  * result is not constant, LoadExpr is called to bring the value into the
  * primary register and 1 is returned.
  */
 
 
 
 
+void ED_SetCodeRange (ExprDesc* Expr, const CodeMark* Start, const CodeMark* End)
+/* Set the code range for this expression */
+{
+    Expr->Flags |= E_HAVE_MARKS;
+    Expr->Start = *Start;
+    Expr->End   = *End;
+}
+
+
+
+int ED_CodeRangeIsEmpty (const ExprDesc* Expr)
+/* Return true if no code was output for this expression */
+{
+    /* We must have code marks */
+    PRECONDITION (Expr->Flags & E_HAVE_MARKS);
+
+    return CodeRangeIsEmpty (&Expr->Start, &Expr->End);
+}
+
+
+
 const char* ED_GetLabelName (const ExprDesc* Expr, long Offs)
 /* Return the assembler label name of the given expression. Beware: This
  * function may use a static buffer, so the name may get "lost" on the second
 int ED_IsNullPtr (const ExprDesc* Expr)
 /* Return true if the given expression is a NULL pointer constant */
 {
-    return (Expr->Flags & (E_MASK_LOC|E_MASK_RTYPE|E_BITFIELD)) == 
+    return (Expr->Flags & (E_MASK_LOC|E_MASK_RTYPE|E_BITFIELD)) ==
                                 (E_LOC_ABS|E_RTYPE_RVAL) &&
            Expr->IVal == 0                               &&
            IsClassInt (Expr->Type);
 
 #include "inline.h"
 
 /* cc65 */
+#include "asmcode.h"
 #include "datatype.h"
 
 
 
     /* Test */
     E_NEED_TEST         = 0x0400,       /* Expression needs a test to set cc */
-    E_CC_SET            = 0x0800        /* Condition codes are set */
+    E_CC_SET            = 0x0800,       /* Condition codes are set */
+
+    E_HAVE_MARKS        = 0x1000,       /* Code marks are valid */
+
 };
 
 /* Describe the result of an expression */
     struct SymEntry*   Sym;            /* Symbol table entry if known */
     Type*              Type;           /* Type array of expression */
     unsigned            Flags;
-    unsigned long      Name;           /* Name or label number */
+    unsigned long      Name;           /* Name or label number */
     long                       IVal;           /* Integer value if expression constant */
     Double              FVal;           /* Floating point value */
 
+    /* Bit field stuff */
     unsigned            BitOffs;        /* Bit offset for bit fields */
     unsigned            BitWidth;       /* Bit width for bit fields */
+
+    /* Start and end of generated code */
+    CodeMark            Start;
+    CodeMark            End;
 };
 
 
 #  define ED_MarkAsUntested(Expr)   do { (Expr)->Flags &= ~E_CC_SET; } while (0)
 #endif
 
+void ED_SetCodeRange (ExprDesc* Expr, const CodeMark* Start, const CodeMark* End);
+/* Set the code range for this expression */
+
+int ED_CodeRangeIsEmpty (const ExprDesc* Expr);
+/* Return true if no code was output for this expression */
+
 const char* ED_GetLabelName (const ExprDesc* Expr, long Offs);
 /* Return the assembler label name of the given expression. Beware: This
  * function may use a static buffer, so the name may get "lost" on the second