1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-26 17:36:57 +00:00

Added .SCOPE/.ENDSCOPE

git-svn-id: svn://svn.cc65.org/cc65/trunk@2624 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2003-11-08 23:27:30 +00:00
parent 587b807921
commit 88e702db0f
4 changed files with 67 additions and 18 deletions

View File

@ -7,7 +7,7 @@
/* */
/* */
/* (C) 2000-2003 Ullrich von Bassewitz */
/* Römerstrasse 52 */
/* Römerstraße 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
@ -216,7 +216,7 @@ unsigned GetFileIndex (const char* Name)
/* If we don't have this index, print a diagnostic and use the main file */
if (F == 0) {
Error ("File name `%s' not found in file table", Name);
return 0;
return 0;
} else {
return F->Index;
}
@ -265,3 +265,4 @@ void WriteFiles (void)

View File

@ -148,7 +148,7 @@ static void SetBoolOption (unsigned char* Flag)
/* Map the keyword to a number */
switch (GetSubKey (Keys, sizeof (Keys) / sizeof (Keys [0]))) {
case 0: *Flag = 0; NextTok (); break;
case 1: *Flag = 1; NextTok (); break;
case 1: *Flag = 1; NextTok (); break;
default: ErrorSkip ("`on' or `off' expected"); break;
}
} else if (TokIsSep (Tok)) {
@ -256,7 +256,7 @@ static void ConDes (const char* Name, unsigned Type)
static void DoA16 (void)
/* Switch the accu to 16 bit mode (assembler only) */
{
{
if (GetCPU() != CPU_65816) {
Error ("Command is only valid in 65816 mode");
} else {
@ -410,7 +410,7 @@ static void DoAssert (void)
/* Read the message */
if (Tok != TOK_STRCON) {
ErrorSkip ("String constant expected");
ErrorSkip ("String constant expected");
} else {
AddAssertion (Expr, Action, GetStringId (SVal));
NextTok ();
@ -710,6 +710,19 @@ static void DoEndProc (void)
static void DoEndScope (void)
/* Leave a lexical level */
{
if (CurrentScope != RootScope) {
SymLeaveLevel ();
} else {
/* No local scope */
ErrorSkip ("No open lexical level");
}
}
static void DoError (void)
/* User error */
{
@ -792,7 +805,7 @@ static void DoFeature (void)
NextTok ();
}
/* Allow more than one keyword */
/* Allow more than one keyword */
if (Tok == TOK_COMMA) {
NextTok ();
} else {
@ -1041,7 +1054,7 @@ static void DoIncBin (void)
size_t BytesRead = fread (Buf, 1, BytesToRead, F);
if (BytesToRead != BytesRead) {
/* Some sort of error */
ErrorSkip ("Cannot read from include file `%s': %s",
ErrorSkip ("Cannot read from include file `%s': %s",
Name, strerror (errno));
break;
}
@ -1396,6 +1409,35 @@ static void DoROData (void)
static void DoScope (void)
/* Start a local scope */
{
char Name[sizeof (SVal)];
if (Tok == TOK_IDENT) {
unsigned AddrSize;
/* The new scope has a name. Remember and skip it. */
strcpy (Name, SVal);
NextTok ();
/* Read an optional address size specifier */
AddrSize = OptionalAddrSize ();
/* Enter a new scope with the given name */
SymEnterLevel (Name, AddrSize);
} else {
/* An unnamed scope */
SymEnterLevel (AnonName (Name, sizeof (Name), "Scope"), ADDR_SIZE_DEFAULT);
}
}
static void DoSegment (void)
/* Switch to another segment */
{
@ -1570,6 +1612,7 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccNone, DoUnexpected }, /* .ENDMACRO */
{ ccNone, DoEndProc },
{ ccNone, DoUnexpected }, /* .ENDREPEAT */
{ ccNone, DoEndScope },
{ ccNone, DoUnexpected }, /* .ENDSTRUCT */
{ ccNone, DoError },
{ ccNone, DoExitMacro },
@ -1617,41 +1660,42 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccNone, DoP02 },
{ ccNone, DoP816 },
{ ccNone, DoPageLength },
{ ccNone, DoUnexpected }, /* .PARAMCOUNT */
{ ccNone, DoUnexpected }, /* .PARAMCOUNT */
{ ccNone, DoPC02 },
{ ccNone, DoPopSeg },
{ ccNone, DoProc },
{ ccNone, DoPSC02 },
{ ccNone, DoPushSeg },
{ ccNone, DoUnexpected }, /* .REFERENCED */
{ ccNone, DoUnexpected }, /* .REFERENCED */
{ ccNone, DoReloc },
{ ccNone, DoRepeat },
{ ccNone, DoRes },
{ ccNone, DoInvalid }, /* .RIGHT */
{ ccNone, DoROData },
{ ccNone, DoROData },
{ ccNone, DoScope },
{ ccNone, DoSegment },
{ ccNone, DoSetCPU },
{ ccNone, DoSmart },
{ ccNone, DoUnexpected }, /* .STRAT */
{ ccNone, DoUnexpected }, /* .STRING */
{ ccNone, DoUnexpected }, /* .STRLEN */
{ ccNone, DoUnexpected }, /* .STRAT */
{ ccNone, DoUnexpected }, /* .STRING */
{ ccNone, DoUnexpected }, /* .STRLEN */
{ ccNone, DoStruct },
{ ccNone, DoSunPlus },
{ ccNone, DoUnexpected }, /* .TAG */
{ ccNone, DoUnexpected }, /* .TCOUNT */
{ ccNone, DoUnexpected }, /* .TIME */
{ ccNone, DoUnexpected }, /* .TCOUNT */
{ ccNone, DoUnexpected }, /* .TIME */
{ ccNone, DoUnion },
{ ccNone, DoUnexpected }, /* .VERSION */
{ ccNone, DoWarning },
{ ccNone, DoWord },
{ ccNone, DoUnexpected }, /* .XMATCH */
{ ccNone, DoUnexpected }, /* .XMATCH */
{ ccNone, DoZeropage },
};
/*****************************************************************************/
/* Code */
/* Code */
/*****************************************************************************/

View File

@ -160,6 +160,7 @@ struct DotKeyword {
{ ".ENDPROC", TOK_ENDPROC },
{ ".ENDREP", TOK_ENDREP },
{ ".ENDREPEAT", TOK_ENDREP },
{ ".ENDSCOPE", TOK_ENDSCOPE },
{ ".ENDSTRUCT", TOK_ENDSTRUCT },
{ ".ERROR", TOK_ERROR },
{ ".EXITMAC", TOK_EXITMACRO },
@ -227,6 +228,7 @@ struct DotKeyword {
{ ".RES", TOK_RES },
{ ".RIGHT", TOK_RIGHT },
{ ".RODATA", TOK_RODATA },
{ ".SCOPE", TOK_SCOPE },
{ ".SEGMENT", TOK_SEGMENT },
{ ".SETCPU", TOK_SETCPU },
{ ".SHL", TOK_SHL },

View File

@ -148,6 +148,7 @@ enum Token {
TOK_ENDMACRO,
TOK_ENDPROC,
TOK_ENDREP,
TOK_ENDSCOPE,
TOK_ENDSTRUCT,
TOK_ERROR,
TOK_EXITMACRO,
@ -191,7 +192,7 @@ enum Token {
TOK_MID,
TOK_NULL,
TOK_ORG,
TOK_OUT,
TOK_OUT,
TOK_P02,
TOK_P816,
TOK_PAGELENGTH,
@ -207,6 +208,7 @@ enum Token {
TOK_RES,
TOK_RIGHT,
TOK_RODATA,
TOK_SCOPE,
TOK_SEGMENT,
TOK_SETCPU,
TOK_SMART,