+ /* if extern then add it into the extern list */
+ if (IS_EXTERN (sym->etype))
+ {
+ addSetHead (&externs, sym);
+ continue;
+ }
+
+ /* if allocation required check is needed
+ then check if the symbol really requires
+ allocation only for local variables */
+
+ if (arFlag && !IS_AGGREGATE (sym->type) &&
+ !(sym->_isparm && !IS_REGPARM (sym->etype)) &&
+ !sym->allocreq && sym->level)
+ continue;
+
+ /* for bitvar locals and parameters */
+ if (!arFlag && !sym->allocreq && sym->level
+ && !SPEC_ABSA (sym->etype)) {
+ continue;
+ }
+
+ /* if global variable & not static or extern
+ and addPublics allowed then add it to the public set */
+ if ((sym->level == 0 ||
+ (sym->_isparm && !IS_REGPARM (sym->etype))) &&
+ addPublics &&
+ !IS_STATIC (sym->etype) &&
+ (IS_FUNC(sym->type) ? (sym->used || IFFUNC_HASBODY(sym->type)) : 1))
+ {
+ addSetHead (&publics, sym);
+ }
+
+ /* if extern then do nothing or is a function
+ then do nothing */
+ if (IS_FUNC (sym->type))
+ continue;
+
+ /* print extra debug info if required */
+ if (options.debug) {
+ cdbSymbol (sym, cdbFile, FALSE, FALSE);
+ if (!sym->level) /* global */
+ if (IS_STATIC (sym->etype))
+ fprintf (map->oFile, "F%s$", moduleName); /* scope is file */
+ else
+ fprintf (map->oFile, "G$"); /* scope is global */
+ else
+ /* symbol is local */
+ fprintf (map->oFile, "L%s$", (sym->localof ? sym->localof->name : "-null-"));
+ fprintf (map->oFile, "%s$%d$%d", sym->name, sym->level, sym->block);
+ }
+
+ /* if it has an initial value then do it only if
+ it is a global variable */
+ if (sym->ival && sym->level == 0) {
+ if (SPEC_OCLS(sym->etype)==xidata) {
+ // create a new "XINIT (CODE)" symbol, that will be emitted later
+ newSym=copySymbol (sym);
+ SPEC_OCLS(newSym->etype)=xinit;
+ sprintf (newSym->name, "_xinit_%s", sym->name);
+ sprintf (newSym->rname,"_xinit_%s", sym->rname);
+ SPEC_CONST(newSym->etype)=1;
+ //SPEC_STAT(newSym->etype)=1;
+ addSym (SymbolTab, newSym, newSym->name, 0, 0, 1);
+
+ // add it to the "XINIT (CODE)" segment
+ addSet(&xinit->syms, newSym);
+
+ //fprintf (stderr, "moved %s from xdata to xidata\n", sym->rname);
+
+ } else {
+ if (IS_AGGREGATE (sym->type)) {
+ ival = initAggregates (sym, sym->ival, NULL);
+ } else {
+ if (getNelements(sym->type, sym->ival)>1) {
+ werror (W_EXCESS_INITIALIZERS, "scalar",
+ sym->name, sym->lineDef);
+ }
+ ival = newNode ('=', newAst_VALUE (symbolVal (sym)),
+ decorateType (resolveSymbols (list2expr (sym->ival))));
+ }
+ codeOutFile = statsg->oFile;
+
+#if 1
+ if (ival) {
+ // set ival's lineno to where the symbol was defined
+ lineno=ival->lineno=sym->lineDef;
+ allocInfo = 0;
+ eBBlockFromiCode (iCodeFromAst (ival));
+ allocInfo = 1;
+ }