For segment based symbols, add information about the segment to the debug info.

git-svn-id: svn://svn.cc65.org/cc65/trunk@5062 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-06-14 19:25:50 +00:00
parent 82bab7fb89
commit c768fc7373
3 changed files with 148 additions and 18 deletions

View File

@@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1998-2010, Ullrich von Bassewitz */
/* (C) 1998-2011, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@@ -398,6 +398,100 @@ long GetExprVal (ExprNode* Expr)
static void GetSegExprValInternal (ExprNode* Expr, SegExprDesc* D, int Sign)
/* Check if the given expression consists of a segment reference and only
* constant values, additions and subtractions. If anything else is found,
* set D->TooComplex to true.
* Internal, recursive routine.
*/
{
Export* E;
switch (Expr->Op) {
case EXPR_LITERAL:
D->Val += (Sign * Expr->V.IVal);
break;
case EXPR_SYMBOL:
/* Get the referenced export */
E = GetExprExport (Expr);
/* If this export has a mark set, we've already encountered it.
* This means that the export is used to define it's own value,
* which in turn means, that we have a circular reference.
*/
if (ExportHasMark (E)) {
CircularRefError (E);
} else {
MarkExport (E);
GetSegExprValInternal (E->Expr, D, Sign);
UnmarkExport (E);
}
break;
case EXPR_SECTION:
if (D->Seg) {
/* We cannot handle more than one segment reference in o65 */
D->TooComplex = 1;
} else {
/* Get the section from the expression */
Section* S = GetExprSection (Expr);
/* Remember the segment reference */
D->Seg = S->Seg;
/* Add the offset of the section to the constant value */
D->Val += Sign * (S->Offs + D->Seg->PC);
}
break;
case EXPR_SEGMENT:
if (D->Seg) {
/* We cannot handle more than one segment reference in o65 */
D->TooComplex = 1;
} else {
/* Remember the segment reference */
D->Seg = Expr->V.Seg;
/* Add the offset of the segment to the constant value */
D->Val += (Sign * D->Seg->PC);
}
break;
case EXPR_PLUS:
GetSegExprValInternal (Expr->Left, D, Sign);
GetSegExprValInternal (Expr->Right, D, Sign);
break;
case EXPR_MINUS:
GetSegExprValInternal (Expr->Left, D, Sign);
GetSegExprValInternal (Expr->Right, D, -Sign);
break;
default:
/* Expression contains illegal operators */
D->TooComplex = 1;
break;
}
}
void GetSegExprVal (ExprNode* Expr, SegExprDesc* D)
/* Check if the given expression consists of a segment reference and only
* constant values, additions and subtractions. If anything else is found,
* set D->TooComplex to true. The function will initialize D.
*/
{
/* Initialize the given structure */
D->Val = 0;
D->TooComplex = 0;
D->Seg = 0;
/* Call our recursive calculation routine */
GetSegExprValInternal (Expr, D, 1);
}
ExprNode* LiteralExpr (long Val, ObjData* O)
/* Return an expression tree that encodes the given literal value */
{