mirror of
https://github.com/cc65/cc65.git
synced 2024-09-29 17:56:21 +00:00
Parse additional def and ref keywords for symbols.
git-svn-id: svn://svn.cc65.org/cc65/trunk@5217 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
2a038ffef9
commit
69ebab6064
@ -127,6 +127,7 @@ typedef enum {
|
|||||||
TOK_ABSOLUTE = TOK_FIRST_KEYWORD, /* ABSOLUTE keyword */
|
TOK_ABSOLUTE = TOK_FIRST_KEYWORD, /* ABSOLUTE keyword */
|
||||||
TOK_ADDRSIZE, /* ADDRSIZE keyword */
|
TOK_ADDRSIZE, /* ADDRSIZE keyword */
|
||||||
TOK_COUNT, /* COUNT keyword */
|
TOK_COUNT, /* COUNT keyword */
|
||||||
|
TOK_DEF, /* DEF keyword */
|
||||||
TOK_ENUM, /* ENUM keyword */
|
TOK_ENUM, /* ENUM keyword */
|
||||||
TOK_EQUATE, /* EQUATE keyword */
|
TOK_EQUATE, /* EQUATE keyword */
|
||||||
TOK_EXPORT, /* EXPORT keyword */
|
TOK_EXPORT, /* EXPORT keyword */
|
||||||
@ -147,6 +148,7 @@ typedef enum {
|
|||||||
TOK_OUTPUTNAME, /* OUTPUTNAME keyword */
|
TOK_OUTPUTNAME, /* OUTPUTNAME keyword */
|
||||||
TOK_OUTPUTOFFS, /* OUTPUTOFFS keyword */
|
TOK_OUTPUTOFFS, /* OUTPUTOFFS keyword */
|
||||||
TOK_PARENT, /* PARENT keyword */
|
TOK_PARENT, /* PARENT keyword */
|
||||||
|
TOK_REF, /* REF keyword */
|
||||||
TOK_RO, /* RO keyword */
|
TOK_RO, /* RO keyword */
|
||||||
TOK_RW, /* RW keyword */
|
TOK_RW, /* RW keyword */
|
||||||
TOK_SCOPE, /* SCOPE keyword */
|
TOK_SCOPE, /* SCOPE keyword */
|
||||||
@ -349,6 +351,8 @@ struct SymInfo {
|
|||||||
} Parent;
|
} Parent;
|
||||||
Collection* ImportList; /* List of imports if this is an export */
|
Collection* ImportList; /* List of imports if this is an export */
|
||||||
Collection* CheapLocals; /* List of cheap local symbols */
|
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 */
|
char Name[1]; /* Name of symbol */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1533,6 +1537,8 @@ static SymInfo* NewSymInfo (const StrBuf* Name)
|
|||||||
/* Initialize it as necessary */
|
/* Initialize it as necessary */
|
||||||
S->ImportList = 0;
|
S->ImportList = 0;
|
||||||
S->CheapLocals = 0;
|
S->CheapLocals = 0;
|
||||||
|
CollInit (&S->DefLineInfoList);
|
||||||
|
CollInit (&S->RefLineInfoList);
|
||||||
memcpy (S->Name, SB_GetConstBuf (Name), SB_GetLen (Name) + 1);
|
memcpy (S->Name, SB_GetConstBuf (Name), SB_GetLen (Name) + 1);
|
||||||
|
|
||||||
/* Return it */
|
/* Return it */
|
||||||
@ -1546,6 +1552,8 @@ static void FreeSymInfo (SymInfo* S)
|
|||||||
{
|
{
|
||||||
CollFree (S->ImportList);
|
CollFree (S->ImportList);
|
||||||
CollFree (S->CheapLocals);
|
CollFree (S->CheapLocals);
|
||||||
|
CollDone (&S->DefLineInfoList);
|
||||||
|
CollDone (&S->RefLineInfoList);
|
||||||
xfree (S);
|
xfree (S);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2061,6 +2069,7 @@ static void NextToken (InputData* D)
|
|||||||
{ "abs", TOK_ABSOLUTE },
|
{ "abs", TOK_ABSOLUTE },
|
||||||
{ "addrsize", TOK_ADDRSIZE },
|
{ "addrsize", TOK_ADDRSIZE },
|
||||||
{ "count", TOK_COUNT },
|
{ "count", TOK_COUNT },
|
||||||
|
{ "def", TOK_DEF },
|
||||||
{ "enum", TOK_ENUM },
|
{ "enum", TOK_ENUM },
|
||||||
{ "equ", TOK_EQUATE },
|
{ "equ", TOK_EQUATE },
|
||||||
{ "exp", TOK_EXPORT },
|
{ "exp", TOK_EXPORT },
|
||||||
@ -2081,6 +2090,7 @@ static void NextToken (InputData* D)
|
|||||||
{ "oname", TOK_OUTPUTNAME },
|
{ "oname", TOK_OUTPUTNAME },
|
||||||
{ "ooffs", TOK_OUTPUTOFFS },
|
{ "ooffs", TOK_OUTPUTOFFS },
|
||||||
{ "parent", TOK_PARENT },
|
{ "parent", TOK_PARENT },
|
||||||
|
{ "ref", TOK_REF },
|
||||||
{ "ro", TOK_RO },
|
{ "ro", TOK_RO },
|
||||||
{ "rw", TOK_RW },
|
{ "rw", TOK_RW },
|
||||||
{ "scope", TOK_SCOPE },
|
{ "scope", TOK_SCOPE },
|
||||||
@ -3462,11 +3472,13 @@ static void ParseSym (InputData* D)
|
|||||||
/* Most of the following variables are initialized with a value that is
|
/* Most of the following variables are initialized with a value that is
|
||||||
* overwritten later. This is just to avoid compiler warnings.
|
* overwritten later. This is just to avoid compiler warnings.
|
||||||
*/
|
*/
|
||||||
|
Collection DefLineIds = COLLECTION_INITIALIZER;
|
||||||
unsigned ExportId = CC65_INV_ID;
|
unsigned ExportId = CC65_INV_ID;
|
||||||
unsigned FileId = CC65_INV_ID;
|
unsigned FileId = CC65_INV_ID;
|
||||||
unsigned Id = CC65_INV_ID;
|
unsigned Id = CC65_INV_ID;
|
||||||
StrBuf Name = STRBUF_INITIALIZER;
|
StrBuf Name = STRBUF_INITIALIZER;
|
||||||
unsigned ParentId = CC65_INV_ID;
|
unsigned ParentId = CC65_INV_ID;
|
||||||
|
Collection RefLineIds = COLLECTION_INITIALIZER;
|
||||||
unsigned ScopeId = CC65_INV_ID;
|
unsigned ScopeId = CC65_INV_ID;
|
||||||
unsigned SegId = CC65_INV_ID;
|
unsigned SegId = CC65_INV_ID;
|
||||||
cc65_size Size = 0;
|
cc65_size Size = 0;
|
||||||
@ -3475,19 +3487,21 @@ static void ParseSym (InputData* D)
|
|||||||
|
|
||||||
SymInfo* S;
|
SymInfo* S;
|
||||||
enum {
|
enum {
|
||||||
ibNone = 0x000,
|
ibNone = 0x0000,
|
||||||
|
|
||||||
ibAddrSize = 0x001,
|
ibAddrSize = 0x0001,
|
||||||
ibExportId = 0x002,
|
ibDefLineId = 0x0002,
|
||||||
ibFileId = 0x004,
|
ibExportId = 0x0004,
|
||||||
ibId = 0x008,
|
ibFileId = 0x0008,
|
||||||
ibParentId = 0x010,
|
ibId = 0x0010,
|
||||||
ibScopeId = 0x020,
|
ibParentId = 0x0020,
|
||||||
ibSegId = 0x040,
|
ibRefLineId = 0x0040,
|
||||||
ibSize = 0x080,
|
ibScopeId = 0x0080,
|
||||||
ibName = 0x100,
|
ibSegId = 0x0100,
|
||||||
ibType = 0x200,
|
ibSize = 0x0200,
|
||||||
ibValue = 0x400,
|
ibName = 0x0400,
|
||||||
|
ibType = 0x0800,
|
||||||
|
ibValue = 0x1000,
|
||||||
|
|
||||||
ibRequired = ibAddrSize | ibId | ibName,
|
ibRequired = ibAddrSize | ibId | ibName,
|
||||||
} InfoBits = ibNone;
|
} InfoBits = ibNone;
|
||||||
@ -3501,9 +3515,10 @@ static void ParseSym (InputData* D)
|
|||||||
Token Tok;
|
Token Tok;
|
||||||
|
|
||||||
/* Something we know? */
|
/* Something we know? */
|
||||||
if (D->Tok != TOK_ADDRSIZE && D->Tok != TOK_EXPORT &&
|
if (D->Tok != TOK_ADDRSIZE && D->Tok != TOK_DEF &&
|
||||||
D->Tok != TOK_FILE && D->Tok != TOK_ID &&
|
D->Tok != TOK_EXPORT && D->Tok != TOK_FILE &&
|
||||||
D->Tok != TOK_NAME && D->Tok != TOK_PARENT &&
|
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_SCOPE && D->Tok != TOK_SEGMENT &&
|
||||||
D->Tok != TOK_SIZE && D->Tok != TOK_TYPE &&
|
D->Tok != TOK_SIZE && D->Tok != TOK_TYPE &&
|
||||||
D->Tok != TOK_VALUE) {
|
D->Tok != TOK_VALUE) {
|
||||||
@ -3533,6 +3548,21 @@ static void ParseSym (InputData* D)
|
|||||||
InfoBits |= ibAddrSize;
|
InfoBits |= ibAddrSize;
|
||||||
break;
|
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:
|
case TOK_EXPORT:
|
||||||
if (!IntConstFollows (D)) {
|
if (!IntConstFollows (D)) {
|
||||||
goto ErrorExit;
|
goto ErrorExit;
|
||||||
@ -3579,6 +3609,21 @@ static void ParseSym (InputData* D)
|
|||||||
InfoBits |= ibParentId;
|
InfoBits |= ibParentId;
|
||||||
break;
|
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:
|
case TOK_SCOPE:
|
||||||
if (!IntConstFollows (D)) {
|
if (!IntConstFollows (D)) {
|
||||||
goto ErrorExit;
|
goto ErrorExit;
|
||||||
@ -3672,6 +3717,8 @@ static void ParseSym (InputData* D)
|
|||||||
S->Seg.Id = SegId;
|
S->Seg.Id = SegId;
|
||||||
S->Scope.Id = ScopeId;
|
S->Scope.Id = ScopeId;
|
||||||
S->Parent.Id = ParentId;
|
S->Parent.Id = ParentId;
|
||||||
|
CollMove (&DefLineIds, &S->DefLineInfoList);
|
||||||
|
CollMove (&RefLineIds, &S->RefLineInfoList);
|
||||||
|
|
||||||
/* Remember it */
|
/* Remember it */
|
||||||
CollReplaceExpand (&D->Info->SymInfoById, S, Id);
|
CollReplaceExpand (&D->Info->SymInfoById, S, Id);
|
||||||
@ -3680,6 +3727,8 @@ static void ParseSym (InputData* D)
|
|||||||
|
|
||||||
ErrorExit:
|
ErrorExit:
|
||||||
/* Entry point in case of errors */
|
/* Entry point in case of errors */
|
||||||
|
CollDone (&DefLineIds);
|
||||||
|
CollDone (&RefLineIds);
|
||||||
SB_Done (&Name);
|
SB_Done (&Name);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user