int InitializeArray(TYP *tp) { int nbytes; char *p; nbytes = 0; if( lastst == begin) { NextToken(); /* skip past the brace */ while(lastst != end) { nbytes += InitializeType(tp->btp); if( lastst == comma) NextToken(); else if( lastst != end) error(ERR_PUNCT); } NextToken(); /* skip closing brace */ } else if( lastst == sconst && tp->btp->type == bt_char) { nbytes = strlen(laststr) * 1 + 1; p = laststr; while( *p ) GenerateChar(*p++); GenerateChar(0); NextToken(); } else if( lastst != semicolon) error(ERR_ILLINIT); if( nbytes < tp->size) { genstorage( tp->size - nbytes); nbytes = tp->size; } else if( tp->size != 0 && nbytes > tp->size) error(ERR_INITSIZE); /* too many initializers */ return nbytes; }
void CItemSpawn::OnTick(bool fExec) { ADDTOCALLSTACK("CitemSpawn:OnTick"); INT64 iMinutes; if ( m_itSpawnChar.m_TimeHiMin <= 0 ) iMinutes = Calc_GetRandLLVal(30) + 1; else iMinutes = minimum(m_itSpawnChar.m_TimeHiMin, m_itSpawnChar.m_TimeLoMin) + Calc_GetRandLLVal(abs(m_itSpawnChar.m_TimeHiMin - m_itSpawnChar.m_TimeLoMin)); if ( iMinutes <= 0 ) iMinutes = 1; if ( !fExec || IsTimerExpired() ) SetTimeout(iMinutes * 60 * TICK_PER_SEC); // set time to check again. if ( !fExec || m_currentSpawned >= GetAmount() ) return; CResourceDef *pDef = FixDef(); if ( !pDef ) { RESOURCE_ID_BASE rid = IsType(IT_SPAWN_ITEM) ? m_itSpawnItem.m_ItemID : m_itSpawnChar.m_CharID; DEBUG_ERR(("Bad Spawn point uid=0%lx, id=%s\n", (DWORD)GetUID(), g_Cfg.ResourceGetName(rid))); return; } if ( IsType(IT_SPAWN_ITEM) ) GenerateItem(pDef); else GenerateChar(pDef); }
int InitializeArray(TYP *tp) { int nbytes; char *p; nbytes = 0; if( lastst == begin) { NextToken(); /* skip past the brace */ while(lastst != end) { // Allow char array initialization like { "something", "somethingelse" } if (lastst == sconst && (tp->GetBtp()->type==bt_char || tp->GetBtp()->type==bt_uchar)) { nbytes = strlen(laststr) * 2 + 2; p = laststr; while( *p ) GenerateChar(*p++); GenerateChar(0); NextToken(); } else nbytes += InitializeType(tp->GetBtp()); if( lastst == comma) NextToken(); else if( lastst != end) error(ERR_PUNCT); } NextToken(); /* skip closing brace */ } else if( lastst == sconst && (tp->GetBtp()->type == bt_char || tp->GetBtp()->type==bt_uchar)) { nbytes = strlen(laststr) * 2 + 2; p = laststr; while( *p ) GenerateChar(*p++); GenerateChar(0); NextToken(); } else if( lastst != semicolon) error(ERR_ILLINIT); if( nbytes < tp->size) { genstorage( tp->size - nbytes); nbytes = tp->size; } else if( tp->size != 0 && nbytes > tp->size) error(ERR_INITSIZE); /* too many initializers */ return nbytes; }
/* * dump the string literal pool. */ void dumplits() { char *cp; cseg(); nl(); align(8); nl(); while( strtab != NULL) { nl(); put_label(strtab->label,strtab->str); cp = strtab->str; while(*cp) GenerateChar(*cp++); GenerateChar(0); strtab = strtab->next; } nl(); }
void dumplits() { char *cp; int64_t nn; slit *lit; dfs.printf("<Dumplits>\n"); roseg(); if (casetab) { nl(); align(8); nl(); } while (casetab != nullptr) { nl(); if (casetab->pass == 2) put_label(casetab->label, "", casetab->nmspace, 'D'); for (nn = 0; nn < casetab->num; nn++) { if (casetab->cases[nn].pass==2) GenerateLabelReference(casetab->cases[nn].label, 0); } casetab = casetab->next; } if (quadtab) { nl(); align(8); nl(); } // Dumping to ro segment - no need for GC skip /* nn = GetQuadtabLen(); if (nn) { sprintf_s(buf, sizeof(buf), "\tdw\t$%I64X ; GC_skip\n", nn | 0xFFF0200000000000LL); ofs.printf("%s", buf); } */ while(quadtab != nullptr) { nl(); if (DataLabels[quadtab->label]) { put_label(quadtab->label, "", quadtab->nmspace, 'D'); ofs.printf("\tdh\t"); quadtab->Pack(64); ofs.printf("%s", quadtab->ToString(64)); outcol += 35; } quadtab = quadtab->next; } if (strtab) { nl(); align(8); nl(); } //nn = GetStrtabLen(); //if (nn) { // sprintf_s(buf, sizeof(buf), "\tdw\t$%I64X ; GC_skip\n", nn | 0xFFF0200000000000LL); // ofs.printf("%s", buf); //} for (lit = strtab; lit; lit = lit->next) { ENODE *ep; agr = ep = (ENODE *)lit->str; dfs.printf("."); nl(); if (!lit->isString) { if (DataLabels[lit->label]) put_label(lit->label, strip_crlf(&lit->str[1]), lit->nmspace, 'D'); } else put_label(lit->label,strip_crlf(&lit->str[1]),lit->nmspace,'D'); if (lit->isString) { cp = lit->str; switch (*cp) { case 'B': cp++; while (*cp) GenerateByte(*cp++); GenerateByte(0); break; case 'C': cp++; while (*cp) GenerateChar(*cp++); GenerateChar(0); break; case 'H': cp++; while (*cp) GenerateHalf(*cp++); GenerateHalf(0); break; case 'W': cp++; while (*cp) GenerateWord(*cp++); GenerateWord(0); break; } } else { if (DataLabels[lit->label]) { ep->PutStructConst(ofs); } } } strtab = nullptr; nl(); dfs.printf("</Dumplits>\n"); }
int initchar() { GenerateChar(GetIntegerExpression((ENODE **)NULL)); return 1; }
int initchar() { GenerateChar(GetIntegerExpression()); return 1; }