1
0
mirror of https://github.com/cc65/cc65.git synced 2024-07-05 21:29:03 +00:00

Better handling of imports in the ExprNode structure.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4841 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2010-11-09 20:34:08 +00:00
parent da792b3fd0
commit c9b9069208
2 changed files with 19 additions and 12 deletions

View File

@ -109,11 +109,12 @@ struct ExprNode {
union { union {
long IVal; /* If this is a int value */ long IVal; /* If this is a int value */
struct SymEntry* Sym; /* If this is a symbol */ struct SymEntry* Sym; /* If this is a symbol */
unsigned SegNum; /* If this is a segment */ unsigned SecNum; /* If this is a section and Obj != 0 */
struct Import* Imp; /* If this is an import */ unsigned ImpNum; /* If this is an import and Obj != 0 */
struct Import* Imp; /* If this is an import and Obj == 0 */
struct MemoryArea* Mem; /* If this is a memory area */ struct MemoryArea* Mem; /* If this is a memory area */
struct Segment* Seg; /* If this is a segment */ struct Segment* Seg; /* If this is a segment */
struct Section* Sec; /* If section and Obj is NULL */ struct Section* Sec; /* If this is a section and Obj == 0 */
} V; } V;
}; };

View File

@ -136,7 +136,7 @@ int IsConstExpr (ExprNode* Root)
case EXPR_MEMAREA: case EXPR_MEMAREA:
/* A memory area is const if it is not relocatable and placed */ /* A memory area is const if it is not relocatable and placed */
return !Root->V.Mem->Relocatable && return !Root->V.Mem->Relocatable &&
(Root->V.Mem->Flags & MF_PLACED); (Root->V.Mem->Flags & MF_PLACED);
default: default:
@ -196,8 +196,16 @@ Import* GetExprImport (ExprNode* Expr)
/* Check that this is really a symbol */ /* Check that this is really a symbol */
PRECONDITION (Expr->Op == EXPR_SYMBOL); PRECONDITION (Expr->Op == EXPR_SYMBOL);
/* Return the import */ /* If we have an object file, get the import from it, otherwise
return Expr->V.Imp; * (internally generated expressions), get the import from the
* import pointer.
*/
if (Expr->Obj) {
/* Return the export */
return CollAt (&Expr->Obj->Imports, Expr->V.ImpNum);
} else {
return Expr->V.Imp;
}
} }
@ -226,7 +234,7 @@ Section* GetExprSection (ExprNode* Expr)
*/ */
if (Expr->Obj) { if (Expr->Obj) {
/* Return the export */ /* Return the export */
return CollAt (&Expr->Obj->Sections, Expr->V.SegNum); return CollAt (&Expr->Obj->Sections, Expr->V.SecNum);
} else { } else {
return Expr->V.Sec; return Expr->V.Sec;
} }
@ -467,7 +475,6 @@ ExprNode* ReadExpr (FILE* F, ObjData* O)
/* Read an expression from the given file */ /* Read an expression from the given file */
{ {
ExprNode* Expr; ExprNode* Expr;
unsigned ImpNum;
/* Read the node tag and handle NULL nodes */ /* Read the node tag and handle NULL nodes */
unsigned char Op = Read8 (F); unsigned char Op = Read8 (F);
@ -488,13 +495,12 @@ ExprNode* ReadExpr (FILE* F, ObjData* O)
case EXPR_SYMBOL: case EXPR_SYMBOL:
/* Read the import number */ /* Read the import number */
ImpNum = ReadVar (F); Expr->V.ImpNum = ReadVar (F);
Expr->V.Imp = CollAt (&O->Imports, ImpNum);
break; break;
case EXPR_SECTION: case EXPR_SECTION:
/* Read the segment number */ /* Read the segment number */
Expr->V.SegNum = Read8 (F); Expr->V.SecNum = Read8 (F);
break; break;
default: default:
@ -541,7 +547,7 @@ int EqualExpr (ExprNode* E1, ExprNode* E2)
case EXPR_SYMBOL: case EXPR_SYMBOL:
/* Import must be identical */ /* Import must be identical */
return (E1->V.Imp == E2->V.Imp); return (GetExprImport (E1) == GetExprImport (E2));
case EXPR_SECTION: case EXPR_SECTION:
/* Section must be identical */ /* Section must be identical */