/* */
/* */
/* */
-/* (C) 2002-2009, Ullrich von Bassewitz */
+/* (C) 2002-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/*****************************************************************************/
-/* Code */
+/* Code */
/*****************************************************************************/
Expr->Name = 0;
Expr->IVal = 0;
Expr->FVal = FP_D_Make (0.0);
+ Expr->LVal = 0;
Expr->BitOffs = 0;
Expr->BitWidth = 0;
return Expr;
+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
case E_LOC_ABS:
/* Absolute: numeric address or const */
- SB_Printf (&Buf, "$%04X", (int)(Offs & 0xFFFF));
+ SB_Printf (&Buf, "$%04X", (int)(Offs & 0xFFFF));
break;
case E_LOC_GLOBAL:
case E_LOC_STATIC:
/* Global or static variable */
- if (Offs) {
- SB_Printf (&Buf, "%s%+ld", SymGetAsmName (Expr->Sym), Offs);
- } else {
- SB_Printf (&Buf, "%s", SymGetAsmName (Expr->Sym));
- }
+ if (Offs) {
+ SB_Printf (&Buf, "%s%+ld", SymGetAsmName (Expr->Sym), Offs);
+ } else {
+ SB_Printf (&Buf, "%s", SymGetAsmName (Expr->Sym));
+ }
break;
case E_LOC_REGISTER:
/* Register variable */
- SB_Printf (&Buf, "regbank+%u", (unsigned)((Offs + Expr->Name) & 0xFFFFU));
+ SB_Printf (&Buf, "regbank+%u", (unsigned)((Offs + Expr->Name) & 0xFFFFU));
break;
case E_LOC_LITERAL:
/* Literal in the literal pool */
- if (Offs) {
- SB_Printf (&Buf, "%s%+ld", LocalLabelName (Expr->Name), Offs);
- } else {
- SB_Printf (&Buf, "%s", LocalLabelName (Expr->Name));
- }
+ if (Offs) {
+ SB_Printf (&Buf, "%s%+ld", LocalLabelName (Expr->Name), Offs);
+ } else {
+ SB_Printf (&Buf, "%s", LocalLabelName (Expr->Name));
+ }
break;
default:
{
Expr->Sym = 0;
Expr->Type = Type;
- Expr->Flags = E_LOC_ABS | E_RTYPE_RVAL;
+ Expr->Flags = E_LOC_ABS | E_RTYPE_RVAL | (Expr->Flags & E_HAVE_MARKS);
Expr->Name = 0;
Expr->IVal = Value;
Expr->FVal = FP_D_Make (0.0);
{
Expr->Sym = 0;
Expr->Type = type_int;
- Expr->Flags = E_LOC_ABS | E_RTYPE_RVAL;
+ Expr->Flags = E_LOC_ABS | E_RTYPE_RVAL | (Expr->Flags & E_HAVE_MARKS);
Expr->Name = 0;
Expr->IVal = Value;
Expr->FVal = FP_D_Make (0.0);
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);
Expr->Type = TypeDup (NewType);
return OldType;
}
-
-
-