- else {
- /* allocate space */
- if ((options.debug || sym->level == 0) && !options.nodebug)
- fprintf(map->oFile,"==.\n");
- if (IS_STATIC(sym->etype))
- tfprintf(map->oFile, "!slabeldef\n", sym->rname);
- else
- tfprintf(map->oFile, "!labeldef\n", sym->rname);
- tfprintf(map->oFile, "\t!ds\n", (unsigned int)getSize (sym->type) & 0xffff);
- }
-
- /* if it has a initial value then do it only if
- it is a global variable */
- if (sym->ival && sym->level == 0) {
- ast *ival = NULL;
-
- if (IS_AGGREGATE (sym->type))
- ival = initAggregates (sym, sym->ival, NULL);
- else
- ival = newNode ('=', newAst (EX_VALUE, symbolVal (sym)),
- decorateType (resolveSymbols (list2expr (sym->ival))));
- codeOutFile = statsg->oFile;
+
+ /* 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);
+ if (!IS_AGGREGATE(sym->type)) {
+ resolveIvalSym(newSym->ival);
+ }
+ // add it to the "XINIT (CODE)" segment
+ addSet(&xinit->syms, newSym);
+ sym->ival=NULL;
+ } 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 0
+ if (ival) {
+ // set ival's lineno to where the symbol was defined
+ lineno=ival->lineno=sym->lineDef;
+ allocInfo = 0;
+ eBBlockFromiCode (iCodeFromAst (ival));
+ allocInfo = 1;
+ }
+#else
+ if (ival) {
+ // set ival's lineno to where the symbol was defined
+ setAstLineno (ival, lineno=sym->lineDef);
+ // check if this is not a constant expression
+ if (!constExprTree(ival)) {
+ werror (E_CONST_EXPECTED, "found expression");
+ // but try to do it anyway
+ }