More .size/.sizeof support

git-svn-id: svn://svn.cc65.org/cc65/trunk@2699 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-11-30 18:41:32 +00:00
parent 7825f7d4a4
commit cf7b4e227a
9 changed files with 198 additions and 38 deletions

View File

@@ -42,6 +42,7 @@
#include "expr.h"
#include "nexttok.h"
#include "scanner.h"
#include "sizeof.h"
#include "symbol.h"
#include "symtab.h"
#include "struct.h"
@@ -173,7 +174,12 @@ static long DoStructInternal (long Offs, unsigned Type)
} else if (GetSymTabType (Struct) != ST_STRUCT) {
Error ("Not a struct/union");
} else {
MemberSize = Member (GetStructSize (Struct));
SymEntry* SizeSym = GetSizeOfScope (Struct);
if (!SymIsDef (SizeSym)) {
Error ("Size of struct/union is unknown");
} else {
MemberSize = GetSymVal (SizeSym);
}
}
break;
@@ -218,7 +224,7 @@ static long DoStructInternal (long Offs, unsigned Type)
*/
if (!Anon) {
/* Add a symbol */
SymEntry* SizeSym = SymFind (CurrentScope, ".size", SYM_ALLOC_NEW);
SymEntry* SizeSym = GetSizeOfScope (CurrentScope);
SymDef (SizeSym, GenLiteralExpr (Size), ADDR_SIZE_DEFAULT, SF_NONE);
/* Close the struct scope */