TOK_ABSOLUTE = TOK_FIRST_KEYWORD, /* ABSOLUTE keyword */
TOK_ADDRSIZE, /* ADDRSIZE keyword */
TOK_COUNT, /* COUNT keyword */
+ TOK_DEF, /* DEF keyword */
TOK_ENUM, /* ENUM keyword */
TOK_EQUATE, /* EQUATE keyword */
TOK_EXPORT, /* EXPORT keyword */
TOK_OUTPUTNAME, /* OUTPUTNAME keyword */
TOK_OUTPUTOFFS, /* OUTPUTOFFS keyword */
TOK_PARENT, /* PARENT keyword */
+ TOK_REF, /* REF keyword */
TOK_RO, /* RO keyword */
TOK_RW, /* RW keyword */
TOK_SCOPE, /* SCOPE keyword */
} Parent;
Collection* ImportList; /* List of imports if this is an export */
Collection* CheapLocals; /* List of cheap local symbols */
+ Collection DefLineInfoList;/* Line info of symbol definition */
+ Collection RefLineInfoList;/* Line info of symbol references */
char Name[1]; /* Name of symbol */
};
D->library_id = M->Lib.Info->Id;
} else {
D->library_id = CC65_INV_ID;
- }
+ }
if (M->MainScope) {
D->scope_id = M->MainScope->Id;
} else {
/* Initialize it as necessary */
S->ImportList = 0;
S->CheapLocals = 0;
+ CollInit (&S->DefLineInfoList);
+ CollInit (&S->RefLineInfoList);
memcpy (S->Name, SB_GetConstBuf (Name), SB_GetLen (Name) + 1);
/* Return it */
{
CollFree (S->ImportList);
CollFree (S->CheapLocals);
+ CollDone (&S->DefLineInfoList);
+ CollDone (&S->RefLineInfoList);
xfree (S);
}
{ "abs", TOK_ABSOLUTE },
{ "addrsize", TOK_ADDRSIZE },
{ "count", TOK_COUNT },
+ { "def", TOK_DEF },
{ "enum", TOK_ENUM },
{ "equ", TOK_EQUATE },
{ "exp", TOK_EXPORT },
{ "oname", TOK_OUTPUTNAME },
{ "ooffs", TOK_OUTPUTOFFS },
{ "parent", TOK_PARENT },
+ { "ref", TOK_REF },
{ "ro", TOK_RO },
{ "rw", TOK_RW },
{ "scope", TOK_SCOPE },
/* Most of the following variables are initialized with a value that is
* overwritten later. This is just to avoid compiler warnings.
*/
+ Collection DefLineIds = COLLECTION_INITIALIZER;
unsigned ExportId = CC65_INV_ID;
unsigned FileId = CC65_INV_ID;
unsigned Id = CC65_INV_ID;
StrBuf Name = STRBUF_INITIALIZER;
unsigned ParentId = CC65_INV_ID;
+ Collection RefLineIds = COLLECTION_INITIALIZER;
unsigned ScopeId = CC65_INV_ID;
unsigned SegId = CC65_INV_ID;
cc65_size Size = 0;
SymInfo* S;
enum {
- ibNone = 0x000,
-
- ibAddrSize = 0x001,
- ibExportId = 0x002,
- ibFileId = 0x004,
- ibId = 0x008,
- ibParentId = 0x010,
- ibScopeId = 0x020,
- ibSegId = 0x040,
- ibSize = 0x080,
- ibName = 0x100,
- ibType = 0x200,
- ibValue = 0x400,
+ ibNone = 0x0000,
+
+ ibAddrSize = 0x0001,
+ ibDefLineId = 0x0002,
+ ibExportId = 0x0004,
+ ibFileId = 0x0008,
+ ibId = 0x0010,
+ ibParentId = 0x0020,
+ ibRefLineId = 0x0040,
+ ibScopeId = 0x0080,
+ ibSegId = 0x0100,
+ ibSize = 0x0200,
+ ibName = 0x0400,
+ ibType = 0x0800,
+ ibValue = 0x1000,
ibRequired = ibAddrSize | ibId | ibName,
} InfoBits = ibNone;
Token Tok;
/* Something we know? */
- if (D->Tok != TOK_ADDRSIZE && D->Tok != TOK_EXPORT &&
- D->Tok != TOK_FILE && D->Tok != TOK_ID &&
- D->Tok != TOK_NAME && D->Tok != TOK_PARENT &&
+ if (D->Tok != TOK_ADDRSIZE && D->Tok != TOK_DEF &&
+ D->Tok != TOK_EXPORT && D->Tok != TOK_FILE &&
+ D->Tok != TOK_ID && D->Tok != TOK_NAME &&
+ D->Tok != TOK_PARENT && D->Tok != TOK_REF &&
D->Tok != TOK_SCOPE && D->Tok != TOK_SEGMENT &&
D->Tok != TOK_SIZE && D->Tok != TOK_TYPE &&
D->Tok != TOK_VALUE) {
InfoBits |= ibAddrSize;
break;
+ case TOK_DEF:
+ while (1) {
+ if (!IntConstFollows (D)) {
+ goto ErrorExit;
+ }
+ CollAppendId (&DefLineIds, (unsigned) D->IVal);
+ NextToken (D);
+ if (D->Tok != TOK_PLUS) {
+ break;
+ }
+ NextToken (D);
+ }
+ InfoBits |= ibDefLineId;
+ break;
+
case TOK_EXPORT:
if (!IntConstFollows (D)) {
goto ErrorExit;
InfoBits |= ibParentId;
break;
+ case TOK_REF:
+ while (1) {
+ if (!IntConstFollows (D)) {
+ goto ErrorExit;
+ }
+ CollAppendId (&RefLineIds, (unsigned) D->IVal);
+ NextToken (D);
+ if (D->Tok != TOK_PLUS) {
+ break;
+ }
+ NextToken (D);
+ }
+ InfoBits |= ibRefLineId;
+ break;
+
case TOK_SCOPE:
if (!IntConstFollows (D)) {
goto ErrorExit;
S->Seg.Id = SegId;
S->Scope.Id = ScopeId;
S->Parent.Id = ParentId;
+ CollMove (&DefLineIds, &S->DefLineInfoList);
+ CollMove (&RefLineIds, &S->RefLineInfoList);
/* Remember it */
CollReplaceExpand (&D->Info->SymInfoById, S, Id);
ErrorExit:
/* Entry point in case of errors */
+ CollDone (&DefLineIds);
+ CollDone (&RefLineIds);
SB_Done (&Name);
return;
}
}
}
- /* Walk over all modules. If a module doesn't have scopes, it wasn't
+ /* Walk over all modules. If a module doesn't have scopes, it wasn't
* compiled with debug info which is ok. If it has debug info, it must
* also have a main scope. If there are scopes, sort them by name.
*/