#include "pseudo.h"
#include "repeat.h"
#include "segment.h"
+#include "sizeof.h"
#include "spool.h"
#include "struct.h"
#include "symbol.h"
static void DoEndProc (void)
/* Leave a lexical level */
{
- if (CurrentScope == RootScope || GetCurrentSymTabType () != ST_PROC) {
+ if (GetCurrentSymTabType () != ST_PROC) {
/* No local scope */
ErrorSkip ("No open .PROC");
} else {
static void DoEndScope (void)
/* Leave a lexical level */
{
- if (CurrentScope == RootScope || GetCurrentSymTabType () != ST_SCOPE) {
+ if ( GetCurrentSymTabType () != ST_SCOPE) {
/* No local scope */
ErrorSkip ("No open .SCOPE");
} else {
if (Tok == TOK_IDENT) {
+ SymEntry* Sym;
+
/* The new scope has a name. Remember it. */
strcpy (Name, SVal);
/* Search for the symbol, generate a new one if needed */
- SymEntry* Sym = SymFind (CurrentScope, Name, SYM_ALLOC_NEW);
+ Sym = SymFind (CurrentScope, Name, SYM_ALLOC_NEW);
/* Skip the scope name */
NextTok ();
static void DoTag (void)
/* Allocate space for a struct */
{
+ SymEntry* SizeSym;
long Size;
/* Read the struct name */
- SymTable* Struct = ParseScopedSymTable (SYM_FIND_EXISTING);
+ SymTable* Struct = ParseScopedSymTable ();
/* Check the supposed struct */
if (Struct == 0) {
return;
}
- /* Get the size of the struct */
- Size = GetSymVal (SymFind (Struct, ".size", SYM_FIND_EXISTING));
+ /* Get the symbol that defines the size of the struct */
+ SizeSym = GetSizeOfScope (Struct);
+
+ /* Check if it does exist and if its value is known */
+ if (SizeSym == 0 || !SymIsConst (SizeSym, &Size)) {
+ ErrorSkip ("Size of struct/union is unknown");
+ return;
+ }
/* Optional multiplicator may follow */
if (Tok == TOK_COMMA) {
{ ccNone, DoASCIIZ },
{ ccNone, DoAssert },
{ ccNone, DoAutoImport },
+ { ccNone, DoUnexpected }, /* .BANKBYTE */
{ ccNone, DoUnexpected }, /* .BLANK */
{ ccNone, DoBss },
{ ccNone, DoByte },
{ ccNone, DoUnexpected }, /* .FORCEWORD */
{ ccNone, DoGlobal },
{ ccNone, DoGlobalZP },
+ { ccNone, DoUnexpected }, /* .HIBYTE */
+ { ccNone, DoUnexpected }, /* .HIWORD */
{ ccNone, DoI16 },
{ ccNone, DoI8 },
{ ccKeepToken, DoConditionals }, /* .IF */
{ ccNone, DoLineCont },
{ ccNone, DoList },
{ ccNone, DoListBytes },
+ { ccNone, DoUnexpected }, /* .LOBYTE */
{ ccNone, DoUnexpected }, /* .LOCAL */
{ ccNone, DoLocalChar },
+ { ccNone, DoUnexpected }, /* .LOWORD */
{ ccNone, DoMacPack },
{ ccNone, DoMacro },
{ ccNone, DoUnexpected }, /* .MATCH */
{ ccNone, DoScope },
{ ccNone, DoSegment },
{ ccNone, DoSetCPU },
+ { ccNone, DoUnexpected }, /* .SIZEOF */
{ ccNone, DoSmart },
{ ccNone, DoUnexpected }, /* .STRAT */
{ ccNone, DoUnexpected }, /* .STRING */
-int TokIsPseudo (unsigned Tok)
-/* Return true if the given token is a pseudo instruction token */
-{
- return (Tok >= TOK_FIRSTPSEUDO && Tok <= TOK_LASTPSEUDO);
-}
-
-
-
void HandlePseudo (void)
/* Handle a pseudo instruction */
{