// write_mdl take an array of pointer to images and a palette // and the generates a Moving DeLight file format containing all the // images. Note, only the mode 320x200x256 is sopprted here for saving // images. All images should be sized so they will fit on an mdl screen // but no checking of that is done hhere. void write_mdl(image **images, short total_images, palette *pal,char *fn, short firstpage, short images_per_page) { FILE *fp; char buf[18]; unsigned short xy[2],x; char name[13],page; unsigned char *c; short i; palette *np; clear_errors(); CONDITION(images && pal && fn && total_images>0,"bad parms"); CONDITION(pal->pal_size()==256,"MDL write only support 256 color images"); fp=fopen(fn,"wb"); if (!fp) set_error(imWRITE_ERROR); else { strcpy(buf,"JC20"); // Signature for mdl file buf[4]=255; // 255 is graph driver 320x200x256 buf[5]=0; // graph mode 0 for this graph driver buf[6]=19; // the BIOS mode is 19 fwrite(buf,7,1,fp); np=pal->copy(); // make a copy before we change np->shift(-COLOR_SHIFT); // PC palette don't have 8 bit color regs fwrite(np->addr(),1,768,fp); delete np; // destroy the copy me made memset(buf,0,11); // 11 reserved bytes (0) follow fwrite(buf,11,1,fp); for (i=0;i<total_images;i++) { memset(buf,0,6); // each image has 6 bytes of reserved 0 fwrite(buf,6,1,fp); xy[0]=int_to_intel(i%100+20); xy[1]=int_to_intel(30); // the x and y position on the screen fwrite(xy,4,1,fp); sprintf(name,"JC%-10d",i); // set the name of the image fwrite(name,12,1,fp); page=firstpage+i/images_per_page; fwrite(&page,1,1,fp); // put all of the image on the first page xy[0]=int_to_intel(images[i]->width()*images[i]->height()+4); // calc the size of the image fwrite(xy,2,1,fp); xy[0]=int_to_intel(images[i]->width()); fwrite(xy,2,1,fp); xy[0]=int_to_intel(images[i]->height()); fwrite(xy,2,1,fp); for (x=0;x<(unsigned short)images[i]->height();x++) // write all the scan_lines for the { c=images[i]->scan_line(x); // image fwrite(c,images[i]->width(),1,fp); } } fclose(fp); // close the file and make sure buffers empty } }
long AppWindow :: ProcRecordTell(wMessage m) { switch ((int)m.mp1) { case MiRecord: { RecConditionForm recForm; recForm.FormUp(this); if (recForm.GetResult() == AcFormExit) switch (recForm.GetThread()) { case 0: // Primary thread CONDITION(FAC_ERRDEMO, recForm.GetType()? CtWarning: CtError, recForm.GetConditionCode()) ATLOC (2, 0) << recForm.GetArgument() << Remember; break; } } break; case MiTell: ThisThread->ConditionNotify(CtError | CtWarning); break; } return 0; }
void gui_status_manager::pop() { CONDITION(first,"No status's to pop!"); gui_status_node *p=first; first=first->next; delete p; }
long AppWindow :: ProcError(wMessage m) { switch ((int)m.mp1) { case MiFatal: CONDITION(FAC_ERRDEMO, CtFatal | CtError, UE_CORRUPT) ATLOC (1, 0) << "Data Structures" << Tell; break; case MiError: { ObjectIO iolib; if (!iolib.OpenFile("test.doc")) { CONDITIONAT(FAC_ERRDEMO, CtError,UE_INITIO) << Tell; break; } // ... // ... } break; case MiWarning: CONDITIONAT(FAC_ERRDEMO, CtWarning, UW_GUESSWHAT) << "This app does nothing of significant interest!" << Tell; break; default: break; } return 0; }
void text_status_manager::pop() { CONDITION(first,"No status's to pop!"); if (level==1) dprintf("\n"); level--; text_status_node *p=first; first=first->next; delete p; }
int CacheList::loaded(int id) { CacheItem *me=list+id; CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); if (me->last_access>=0) return 1; else return 0; }
bool MeasureThreadCounter::runnable() { int seconds(m_nSeconds), wait; if(m_bClientAction) { tout << "server wait for some action from any client" << endl; tout << "and count after that "; }else tout << "server count now "; tout << "between " << getTimeString(seconds, &wait) << "for running folder threads." << endl; TERMINALEND; if(m_bClientAction) { LOCK(m_CLIENTACTIONMUTEX); m_bCounting= false; while(!m_bClientActionDone) { CONDITION(m_CLIENTACTIONCOND, m_CLIENTACTIONMUTEX); if(stopping()) { m_bCounting= true; UNLOCK(m_CLIENTACTIONMUTEX); return false; } } beginCount(); AROUSEALL(m_CLIENTACTIONCOND); m_bCounting= true; tout << "wait now for " << getTimeString(seconds, &wait) << endl; if(m_bClientAction) { tout << " activated from " << m_tClient.who << endl; tout << " to inform " << m_tClient.folder << ":" << m_tClient.subroutine << " set with value " << m_tClient.value << endl; } UNLOCK(m_CLIENTACTIONMUTEX); TERMINALEND; }else beginCount(); do{ //cout << "sleep for " << wait << " seconds" << endl; if(SLEEP(wait) != ETIMEDOUT) { outputCounting(m_nSeconds - seconds); return false; } seconds-= wait; if(seconds > 0) { tout << "wait for " << getTimeString(seconds, &wait) << endl; TERMINALEND; } }while(seconds > 0); outputCounting(m_nSeconds); return false; }
void CSharpFlatCodeGen::COND_TRANSLATE() { out << " _widec = " << GET_KEY() << ";\n"; out << " _keys = " << vCS() << "<<1;\n" " _conds = " << CO() << "[" << vCS() << "];\n" // " _keys = " << ARR_OFF( CK(), "(" + vCS() + "<<1)" ) << ";\n" // " _conds = " << ARR_OFF( C(), CO() + "[" + vCS() + "]" ) << ";\n" "\n" " _slen = " << CSP() << "[" << vCS() << "];\n" " if (_slen > 0 && " << CK() << "[_keys] <=" << GET_WIDE_KEY() << " &&\n" " " << GET_WIDE_KEY() << " <= " << CK() << "[_keys+1])\n" " _cond = " << C() << "[_conds+" << GET_WIDE_KEY() << " - " << CK() << "[_keys]];\n" " else\n" " _cond = 0;" "\n"; /* XXX This version of the code doesn't work because Mono is weird. Works * fine in Microsoft's csc, even though the bug report filed claimed it * didn't. " _slen = " << CSP() << "[" << vCS() << "];\n" " _cond = _slen > 0 && " << CK() << "[_keys] <=" << GET_WIDE_KEY() << " &&\n" " " << GET_WIDE_KEY() << " <= " << CK() << "[_keys+1] ?\n" " " << C() << "[_conds+" << GET_WIDE_KEY() << " - " << CK() << "[_keys]] : 0;\n" "\n"; */ out << " switch ( _cond ) {\n"; for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { GenCondSpace *condSpace = csi; out << " case " << condSpace->condSpaceId + 1 << ": {\n"; out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << KEY(condSpace->baseKey) << " + (" << GET_KEY() << " - " << KEY(keyOps->minKey) << "));\n"; for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { out << TABS(2) << "if ( "; CONDITION( out, *csi ); Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); out << " ) _widec += " << condValOffset << ";\n"; } out << " }\n"; out << " break;\n"; } SWITCH_DEFAULT(); out << " }\n"; }
pmenu_item::pmenu_item(char *Name, psub_menu *Sub, pmenu_item *Next, int xpos) { xp=xpos; id=0; hotkey=-1; next=Next; on_off=NULL; CONDITION(Name,"Sub menu cannot have a NULL name"); n=strcpy((char *)jmalloc(strlen(Name)+1,"pmenu_item::name"),Name); sub=Sub; }
void CSharpTabCodeGen::COND_TRANSLATE() { out << " _widec = " << GET_KEY() << ";\n" " _klen = " << CL() << "[" << vCS() << "];\n" " _keys = " << CAST(keysType) << " ("<< CO() << "[" << vCS() << "]*2);\n" " if ( _klen > 0 ) {\n" " " << signedKeysType << " _lower = _keys;\n" " " << signedKeysType << " _mid;\n" " " << signedKeysType << " _upper = " << CAST(signedKeysType) << " (_keys + (_klen<<1) - 2);\n" " while (true) {\n" " if ( _upper < _lower )\n" " break;\n" "\n" " _mid = " << CAST(signedKeysType) << " (_lower + (((_upper-_lower) >> 1) & ~1));\n" " if ( " << GET_WIDE_KEY() << " < " << CK() << "[_mid] )\n" " _upper = " << CAST(signedKeysType) << " (_mid - 2);\n" " else if ( " << GET_WIDE_KEY() << " > " << CK() << "[_mid+1] )\n" " _lower = " << CAST(signedKeysType) << " (_mid + 2);\n" " else {\n" " switch ( " << C() << "[" << CO() << "[" << vCS() << "]" " + ((_mid - _keys)>>1)] ) {\n"; for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { GenCondSpace *condSpace = csi; out << " case " << condSpace->condSpaceId << ": {\n"; out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << KEY(condSpace->baseKey) << " + (" << GET_KEY() << " - " << KEY(keyOps->minKey) << "));\n"; for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { out << TABS(2) << "if ( "; CONDITION( out, *csi ); Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); out << " ) _widec += " << condValOffset << ";\n"; } out << " break;\n" " }\n"; } SWITCH_DEFAULT(); out << " }\n" " break;\n" " }\n" " }\n" " }\n" "\n"; }
void TabCodeGen::COND_TRANSLATE() { out << " _widec = " << GET_KEY() << ";\n" " _klen = " << CL() << "[" << vCS() << "];\n" " _keys = " << ARR_OFF( CK(), "(" + CO() + "[" + vCS() + "]*2)" ) << ";\n" " if ( _klen > 0 ) {\n" " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_lower = _keys;\n" " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_mid;\n" " " << PTR_CONST() << WIDE_ALPH_TYPE() << PTR_CONST_END() << POINTER() << "_upper = _keys + (_klen<<1) - 2;\n" " while (1) {\n" " if ( _upper < _lower )\n" " break;\n" "\n" " _mid = _lower + (((_upper-_lower) >> 1) & ~1);\n" " if ( " << GET_WIDE_KEY() << " < _mid[0] )\n" " _upper = _mid - 2;\n" " else if ( " << GET_WIDE_KEY() << " > _mid[1] )\n" " _lower = _mid + 2;\n" " else {\n" " switch ( " << C() << "[" << CO() << "[" << vCS() << "]" " + ((_mid - _keys)>>1)] ) {\n"; for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { GenCondSpace *condSpace = csi; out << " case " << condSpace->condSpaceId << ": {\n"; out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << KEY(condSpace->baseKey) << " + (" << GET_KEY() << " - " << KEY(keyOps->minKey) << "));\n"; for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { out << TABS(2) << "if ( "; CONDITION( out, *csi ); Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); out << " ) _widec += " << condValOffset << ";\n"; } out << " break;\n" " }\n"; } SWITCH_DEFAULT(); out << " }\n" " break;\n" " }\n" " }\n" " }\n" "\n"; }
void CSharpGotoCodeGen::COND_TRANSLATE( GenStateCond *stateCond, int level ) { GenCondSpace *condSpace = stateCond->condSpace; out << TABS(level) << L"_widec = " << CAST(WIDE_ALPH_TYPE()) << L"(" << KEY(condSpace->baseKey) << L" + (" << GET_KEY() << L" - " << KEY(keyOps->minKey) << L"));\n"; for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { out << TABS(level) << L"if ( "; CONDITION( out, *csi ); Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); out << L" ) _widec += " << condValOffset << L";\n"; } }
Condition* Condition::CreateCondition(int condition_id, int optional){ switch( condition_id ){ CONDITION(Condition_Ranger_Poison, 5, false, &ranger_poison, on_tick, optional); CONDITION(Condition_Ranger_HealTier1, 1, false, &ranger_healtier1, on_tick, optional); CONDITION(Condition_Ranger_HealTier2, 2, false, &ranger_healtier2, on_tick, optional); CONDITION(Condition_Ranger_HealTier3, 3, false, &ranger_healtier3, on_tick, optional); CONDITION(Condition_Ranger_HealTier4, 4, false, &ranger_healtier4, on_tick, optional); CONDITION(Condition_Ranger_CripplingShot, 2, false, &ranger_cripplingshot, on_attack, optional); CONDITION(Condition_Ranger_Preparation, 2, false, &ranger_preparation, on_attack, optional); } log_err("Invalid Condition Id"); return NULL; }
part_frame *CacheList::part(int id) { CacheItem *me = list + id; CONDITION(id<total && id>=0 && me->file_number>=0, "Bad id"); if (me->last_access >= 0) { touch(me); // hold me, feel me, be me! return (part_frame *) me->data; } else { touch(me); locate(me); me->data = (void *) new part_frame(fp); last_offset = fp->tell(); return (part_frame *) me->data; } }
sound_effect *CacheList::sfx(int id) { CacheItem *me = list + id; CONDITION(id<total && id>=0 && me->file_number>=0, "Bad id"); if (me->last_access >= 0) { touch(me); // hold me, feel me, be me! return (sound_effect *) me->data; } else { touch(me); // hold me, feel me, be me! char *fn = crc_manager.get_filename(me->file_number); me->data = (void *) new sound_effect(fn); return (sound_effect *) me->data; } }
foretile *CacheList::foret(int id) { CacheItem *me = list + id; CONDITION(id<total && id>=0 && me->file_number>=0, "Bad id"); if (me->last_access >= 0) { touch(me); return (foretile *) me->data; } else { touch(me); locate(me); me->data = (void *) new foretile(fp); last_offset = fp->tell(); return (foretile *) me->data; } }
char_tint *CacheList::ctint(int id) { CacheItem *me = list + id; CONDITION(id<total && id>=0 && me->file_number>=0, "Bad id" && me->type==SPEC_PALETTE); if (me->last_access >= 0) { touch(me); return (char_tint *) me->data; } else { touch(me); locate(me); me->data = (void *) new char_tint(fp); last_offset = fp->tell(); return (char_tint *) me->data; } }
void MeasureThreadCounter::clientAction(const string& folder, const string& subroutine, const ppi_value& value, const string& from) { LOCK(m_CLIENTACTIONMUTEX); if(!m_bCounting) {// activate only when object do not wait for counting // because by waiting for client action the action will be set // only when MeasureThreadCounter has informed all MeasureThread's to count m_bClientActionDone= true; m_tClient.who= from; m_tClient.folder= folder; m_tClient.subroutine= subroutine; m_tClient.value= value; AROUSE(m_CLIENTACTIONCOND); CONDITION(m_CLIENTACTIONCOND, m_CLIENTACTIONMUTEX); } UNLOCK(m_CLIENTACTIONMUTEX); }
ScreenBranch::ScreenBranch( CString sClassName ) : Screen( sClassName ) { LOG->Trace( "ScreenBranch::ScreenBranch()" ); CStringArray as; split( CHOICES, ",", as, true ); for( unsigned i=0; i<as.size(); i++ ) { CString sChoice = Capitalize( as[i] ); CString sCondition = CONDITION(sChoice); if( Lua::RunExpression(sCondition) ) { m_sChoice = sChoice; HandleScreenMessage( SM_GoToNextScreen ); return; } } RageException::Throw( "On screen '%s' no conditions are true", sClassName.c_str() ); }
void FlatCodeGen::COND_TRANSLATE() { out << " _widec = " << GET_KEY() << ";\n"; out << " _keys = " << ARR_OFF( CK(), "(" + vCS() + "<<1)" ) << ";\n" " _conds = " << ARR_OFF( C(), CO() + "[" + vCS() + "]" ) << ";\n" "\n" " _slen = " << CSP() << "[" << vCS() << "];\n" " _cond = _slen > 0 && _keys[0] <=" << GET_WIDE_KEY() << " &&\n" " " << GET_WIDE_KEY() << " <= _keys[1] ?\n" " _conds[" << GET_WIDE_KEY() << " - _keys[0]] : 0;\n" "\n"; out << " switch ( _cond ) {\n"; for ( CondSpaceList::Iter csi = condSpaceList; csi.lte(); csi++ ) { GenCondSpace *condSpace = csi; out << " case " << condSpace->condSpaceId + 1 << ": {\n"; out << TABS(2) << "_widec = " << CAST(WIDE_ALPH_TYPE()) << "(" << KEY(condSpace->baseKey) << " + (" << GET_KEY() << " - " << KEY(keyOps->minKey) << "));\n"; for ( GenCondSet::Iter csi = condSpace->condSet; csi.lte(); csi++ ) { out << TABS(2) << "if ( "; CONDITION( out, *csi ); Size condValOffset = ((1 << csi.pos()) * keyOps->alphSize()); out << " ) _widec += " << condValOffset << ";\n"; } out << " }\n"; out << " break;\n"; } SWITCH_DEFAULT(); out << " }\n"; }
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) { // Clean up elements stack: // Since we made sure to get the elements in the proper order when // adding we do not need to do so again here. COND_DOC_ERROR(m_elementStack.last()->element != qName.utf8(), QString("Malformed XML: Unexpected closing element found."). arg(m_elementStack.last()->element).utf8()); m_elementStack.removeLast(); // Interface: if (DBUS("interface")) { CONDITION(!m_currentInterface, "end of interface found without start."); m_currentInterface->endBodyLine = lineNumber(); closeScopes(); m_currentInterface = 0; } if (DBUS("method") || DBUS("signal")) { CONDITION(!m_currentMethod, "end of method found without start."); CONDITION(!m_currentInterface, "end of method found outside interface."); m_currentMethod->endBodyLine = lineNumber(); m_currentInterface->addSubEntry(m_currentMethod); m_currentMethod = 0; } if (DBUS("property")) { CONDITION(!m_currentProperty, "end of property found without start."); CONDITION(!m_currentInterface, "end of property found outside interface."); m_currentProperty->endBodyLine = lineNumber(); m_currentInterface->addSubEntry(m_currentProperty); m_currentProperty = 0; } if (DBUS("arg")) { CONDITION(!m_currentMethod, "end of arg found outside method."); m_currentMethod->argList->append(m_currentArgument); m_currentArgument = 0; } if (EXTENSION("namespace")) { Entry * current = m_namespaceStack.last(); CONDITION(!current, "end of namespace without start."); m_namespaceStack.removeLast(); current->endBodyLine = lineNumber(); closeScopes(); } if (EXTENSION("struct")) { StructData * data = m_structStack.last(); CONDITION(!data, "end of struct without start."); data->entry->endBodyLine = lineNumber(); QString current_type; current_type.append(QString("(")); current_type.append(data->type); current_type.append(QString(")")); addNamedType(current_type.utf8()); closeScopes(); m_structStack.removeLast(); } if (EXTENSION("member")) { StructData * data = m_structStack.last(); CONDITION(!data, "end of member outside struct."); data->entry->addSubEntry(m_currentEntry); } if (EXTENSION("enum") || EXTENSION("flagset")) { CONDITION(!m_currentEnum, "end of enum without start."); m_currentEnum->endBodyLine = lineNumber(); closeScopes(); m_currentEnum = 0; } if (EXTENSION("value")) { CONDITION(!m_currentEntry, "end of value without start"); m_currentEntry->endBodyLine = lineNumber(); m_currentEnum->addSubEntry(m_currentEntry); } return true; }
char *_costume_get_string(const pcostumestrx cxstrlist, const pcostumex cxlist, const CHAR *target, const CHAR *format) { char *ret = (char *) malloc (sizeof(char) * 1024); char *ptr = ret, *tmpptr, *tarptr; char tmp; char _temp[20] = {0,}; // find temp u32 inttmp; int count; pcostumex costmp; pcostumestrx cosstrtmp; BOOL not; #define CONDITION(x) ((x) && not) || (!(x) && !not) tarptr = target; _costume_ict = format; zeroset(ret, sizeof(char) * 1024); do { switch(*_costume_ict++) { case '+': // add variable to ret switch(*_costume_ict++) { case _COTM_VARIABLE: for (count = 0; _isalnumub((int)(*_costume_ict)); _costume_ict++, count++) _temp[count] = *_costume_ict; _temp[count] = 0; if (NULL == (costmp = _costume_find_variable(cxlist, _temp))) return -1; // error inttmp = costmp->data; tmpptr = __itoa(inttmp); for (; *tmpptr; tmpptr++) *ptr++ = *tmpptr; break; case _COTM_STRVARIABLE: for (count = 0; _isalnumub((int)(*_costume_ict)); _costume_ict++, count++) _temp[count] = *_costume_ict; _temp[count] = 0; if (NULL == (cosstrtmp = _costume_find_strvariable(cxstrlist, _temp))) return -1; // error tmpptr = cosstrtmp->data; for (; *tmpptr; tmpptr++) *ptr++ = *tmpptr; break; case '*': // *x, *@int, *$str, *!x RE1: switch(*_costume_ict++) { case '!': switch(*_costume_ict++) { case 's': while (CONDITION(_isspace(*tarptr))) *ptr++ = *tarptr++; break; case 'S': while (CONDITION(!_isspace(*tarptr))) *ptr++ = *tarptr++; break; case 'd': while (CONDITION(_isnumeric(*tarptr))) *ptr++ = *tarptr++; break; case 'D': while (CONDITION(!_isnumeric(*tarptr))) *ptr++ = *tarptr++; break; case 'w': while (CONDITION(_isalnumub(*tarptr))) *ptr++ = *tarptr++; break; case 'W': while (CONDITION(!_isalnumub(*tarptr))) *ptr++ = *tarptr++; break; case '\\': switch(*_costume_ict++) { case 'n': while (CONDITION(*tarptr == '\n')) *ptr++ = *tarptr++; break; case 'r': while (CONDITION(*tarptr == '\r')) *ptr++ = *tarptr++; break; case 't': while (CONDITION(*tarptr == '\t')) *ptr++ = *tarptr++; break; case 'f': while (CONDITION(*tarptr == '\f')) *ptr++ = *tarptr++; break; default: while(CONDITION(*tarptr == *(_costume_ict-1))) *ptr++ = *tarptr++; break; } break; } not = TRUE; break; case '\\': switch(*_costume_ict++) { case 'n': if(CONDITION(*tarptr == '\n')) *ptr++ = *tarptr++; break; case 'r': if(CONDITION(*tarptr == '\r')) *ptr++ = *tarptr++; break; case 't': if(CONDITION(*tarptr == '\t')) *ptr++ = *tarptr++; break; case 'f': if(CONDITION(*tarptr == '\f')) *ptr++ = *tarptr++; break; default: if(CONDITION(*tarptr == *(_costume_ict-1))) *ptr++ = *tarptr++; break; } not = TRUE; break; case '^': // not not = FALSE; goto RE1; break; default: if(_isalnumub((int)(*_costume_ict))) { if(CONDITION(*tarptr == *_costume_ict)) *ptr++ = *tarptr++; not = TRUE; } break; } break; } break; case '*': // *x, *@int, *$str, *!x RE2: switch(*_costume_ict++) { case '!': switch(*_costume_ict++) { case 's': while (CONDITION(_isspace(*tarptr))) tarptr++; break; case 'S': while (CONDITION(!_isspace(*tarptr))) tarptr++; break; case 'd': while (CONDITION(_isnumeric(*tarptr))) tarptr++; break; case 'D': while (CONDITION(!_isnumeric(*tarptr))) tarptr++; break; case 'w': while (CONDITION(_isalnumub(*tarptr))) tarptr++; break; case 'W': while (CONDITION(!_isalnumub(*tarptr))) tarptr++; break; case '\\': switch(*_costume_ict++) { case 'n': while (CONDITION(*tarptr == '\n')) tarptr++; break; case 'r': while (CONDITION(*tarptr == '\r')) tarptr++; break; case 't': while (CONDITION(*tarptr == '\t')) tarptr++; break; case 'f': while (CONDITION(*tarptr == '\f')) tarptr++; break; default: while(CONDITION(*tarptr == *(_costume_ict-1))) tarptr++; break; } break; } not = TRUE; break; case '\\': switch(*_costume_ict++) { case 'n': if(CONDITION(*tarptr == '\n')) tarptr++; break; case 'r': if(CONDITION(*tarptr == '\r')) tarptr++; break; case 't': if(CONDITION(*tarptr == '\t')) tarptr++; break; case 'f': if(CONDITION(*tarptr == '\f')) tarptr++; break; default: if(CONDITION(*tarptr == *(_costume_ict-1))) tarptr++; break; } not = TRUE; break; case '^': // not not = FALSE; goto RE2; break; default: if(_isalnumub((int)(*_costume_ict))) { if(CONDITION(*tarptr == *_costume_ict)) *tarptr++; not = TRUE; } break; } break; case '/': // Delimiter break; case '\\': switch(*_costume_ict++) { case 'n': *ptr++ = '\n'; break; case 'r': *ptr++ = '\r'; break; case 't': *ptr++ = '\t'; break; case 'f': *ptr++ = '\f'; break; default: *ptr++ = *(_costume_ict-1); break; } break; default: if (_isalnum((int)(tmp = *(_costume_ict - 1)))) { *ptr++ = tmp; for (; _isalnum((int)*_costume_ict); _costume_ict++) *ptr++ = *_costume_ict; } break; } } while (*_costume_ict && *_costume_ict != ']'); return ret; }
void STATEMENT() { //initialization if(TOKEN == identsym) { //stores the name of the identifier that will be initialized char name[12]; strcpy(name, IDENTIFIER); //if identifier is not a variable, produce error if(getSymbol(IDENTIFIER).kind != 2) { ERROR("Error number 12, assignment to constant or procedure not allowed."); } GETTOKEN(); if(TOKEN != becomessym) { ERROR("Error number 13, assignment operator expected."); } GETTOKEN(); EXPRESSION(); symbol current = getSymbol(name); //STO 0 M printToFile(4,current.level,current.addr); lines++; } //procedure call (not in tiny PL/0) else if(TOKEN == callsym) { GETTOKEN(); if(TOKEN != identsym) { ERROR("Error number 14, call must be followed by an identifier."); } //if the identifier is not a procedure, produce an error if(getSymbol(IDENTIFIER).kind != 3) { ERROR("Error number 15, call of a constant or variable is meaningless."); } GETTOKEN(); } //a group of statements else if(TOKEN == beginsym) { GETTOKEN(); STATEMENT(); while(TOKEN == semicolonsym) { GETTOKEN(); STATEMENT(); } if(TOKEN != endsym) { ERROR("Error number 26, end is expected."); } GETTOKEN(); } else if(TOKEN == ifsym) { GETTOKEN(); CONDITION(); //top of the stack has whether it is true or false if(TOKEN != thensym) { ERROR("Error number 16, then expected."); } //after the condition, count how many instructions are written int currentLines = lines; inConditional++; fpos_t filePos; fgetpos(ifp, &filePos); //loop ensures this is done twice int i; for(i = 0; i < 2; i++) { if(i == 1) { inConditional--; //make branch here (lines contains the line that you jump to if the condition is not met) //printToFile() //JPC 0 M = lines printToFile(8,0,lines); //returns the file to the previous position fsetpos(ifp, &filePos); lines = currentLines; //Lines increment for prinToFile used in for loop //lines++; } lines++; GETTOKEN(); STATEMENT(); } } else if(TOKEN == whilesym) { int jumpBackLine = lines; GETTOKEN(); CONDITION(); //top of the stack has whether it is true or false if(TOKEN != dosym) { ERROR("Error number 18, do expected."); } //after the condition, count how many instructions are written int currentLines = lines; inConditional++; fpos_t filePos; fgetpos(ifp, &filePos); //loop ensures this is done twice int i; for(i = 0; i < 2; i++) { if(i == 1) { inConditional--; //make branch here (lines + 1 contains the line that you jump to if the condition is not met) //printToFile() //JPC 0 M = l printToFile(8,0,lines + 1); //returns the file to the previous position fsetpos(ifp, &filePos); lines = currentLines; //Lines increment for the printToFile used in for loop //lines++; } //the line for the branch is added lines++; GETTOKEN(); STATEMENT(); } //JMP 0 M = jumpBackLines printToFile(7,0,jumpBackLine); lines++; } }
u32 armcpu_exec() { // Usually, fetching and executing are processed parallelly. // So this function stores the cycles of each process to // the variables below, and returns appropriate cycle count. u32 cFetch = 0; u32 cExecute = 0; //this assert is annoying. but sometimes it is handy. //assert(ARMPROC.instruct_adr!=0x00000000); //#ifdef DEVELOPER #if 0 if ((((ARMPROC.instruct_adr & 0x0F000000) == 0x0F000000) && (PROCNUM == 0)) || (((ARMPROC.instruct_adr & 0x0F000000) == 0x00000000) && (PROCNUM == 1))) { switch (ARMPROC.instruct_adr & 0xFFFF) { case 0x00000000: printf("BIOS%c: Reset!!!\n", PROCNUM?'7':'9'); emu_halt(); break; case 0x00000004: printf("BIOS%c: Undefined instruction\n", PROCNUM?'7':'9'); //emu_halt(); break; case 0x00000008: //printf("BIOS%c: SWI\n", PROCNUM?'7':'9'); break; case 0x0000000C: printf("BIOS%c: Prefetch Abort!!!\n", PROCNUM?'7':'9'); //emu_halt(); break; case 0x00000010: //printf("BIOS%c: Data Abort!!!\n", PROCNUM?'7':'9'); //emu_halt(); break; case 0x00000014: printf("BIOS%c: Reserved!!!\n", PROCNUM?'7':'9'); break; case 0x00000018: //printf("BIOS%c: IRQ\n", PROCNUM?'7':'9'); break; case 0x0000001C: printf("BIOS%c: Fast IRQ\n", PROCNUM?'7':'9'); break; } } #endif #if 0 //#ifdef GDB_STUB if (ARMPROC.stalled) { return STALLED_CYCLE_COUNT; } /* check for interrupts */ if (ARMPROC.irq_flag) { armcpu_irqException(&ARMPROC); } cFetch = armcpu_prefetch(&ARMPROC); if (ARMPROC.stalled) { return MMU_fetchExecuteCycles<PROCNUM>(cExecute, cFetch); } #endif //cFetch = armcpu_prefetch(&ARMPROC); //printf("%d: %08X\n",PROCNUM,ARMPROC.instruct_adr); if(ARMPROC.CPSR.bits.T == 0) { const u32 condition = CONDITION(ARMPROC.instruction); if( condition == 0x0E //fast path for unconditional instructions || (TEST_COND(condition, CODE(ARMPROC.instruction), ARMPROC.CPSR)) //handles any condition ) { #ifdef HAVE_LUA CallRegisteredLuaMemHook(ARMPROC.instruct_adr, 4, ARMPROC.instruction, LUAMEMHOOK_EXEC); // should report even if condition=false? #endif if(PROCNUM==0) { #ifdef DEVELOPER DEBUG_statistics.instructionHits[0].arm[INSTRUCTION_INDEX(ARMPROC.instruction)]++; #endif cExecute = arm_instructions_set_0[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruction); } else { #ifdef DEVELOPER DEBUG_statistics.instructionHits[1].arm[INSTRUCTION_INDEX(ARMPROC.instruction)]++; #endif cExecute = arm_instructions_set_1[INSTRUCTION_INDEX(ARMPROC.instruction)](ARMPROC.instruction); } } else cExecute = 1; // If condition=false: 1S cycle #ifdef GDB_STUB if ( ARMPROC.post_ex_fn != NULL) { /* call the external post execute function */ ARMPROC.post_ex_fn(ARMPROC.post_ex_fn_data, ARMPROC.instruct_adr, 0); } ARMPROC.mem_if->prefetch32( ARMPROC.mem_if->data, ARMPROC.next_instruction); #endif cFetch = armcpu_prefetch<PROCNUM>(); return MMU_fetchExecuteCycles<PROCNUM>(cExecute, cFetch); } #ifdef HAVE_LUA CallRegisteredLuaMemHook(ARMPROC.instruct_adr, 2, ARMPROC.instruction, LUAMEMHOOK_EXEC); #endif if(PROCNUM==0) { #ifdef DEVELOPER DEBUG_statistics.instructionHits[0].thumb[ARMPROC.instruction>>6]++; #endif cExecute = thumb_instructions_set_0[ARMPROC.instruction>>6](ARMPROC.instruction); }
void STATEMENT() { //initialization if(TOKEN == identsym) { //stores the name of the identifier that will be initialized char name[12]; strcpy(name, IDENTIFIER); //if identifier is not a variable, produce error if(getSymbol(IDENTIFIER).kind != 2) { ERROR("Error number 12, assignment to constant or procedure not allowed."); } GETTOKEN(); if(TOKEN != becomessym) { ERROR("Error number 13, assignment operator expected."); } GETTOKEN(); EXPRESSION(); symbol current = getSymbol(name); //STO L M printToFile(4,lexiLevel-current.level,current.addr); lines++; } else if(TOKEN == callsym) { GETTOKEN(); if(TOKEN != identsym) { ERROR("Error number 14, call must be followed by an identifier."); } //if the identifier is not a procedure, produce an error if(getSymbol(IDENTIFIER).kind != 3) { ERROR("Error number 15, call of a constant or variable is meaningless."); } symbol current = getSymbol(IDENTIFIER); //CAL L M printToFile(5, lexiLevel-current.level, current.addr); lines++; GETTOKEN(); } //a group of statements else if(TOKEN == beginsym) { GETTOKEN(); STATEMENT(); while(TOKEN == semicolonsym) { GETTOKEN(); STATEMENT(); } if(TOKEN != endsym) { printf("Line: %d %s\n", lines, IDENTIFIER); ERROR("Error number 26, end is expected."); } GETTOKEN(); } else if(TOKEN == ifsym) { GETTOKEN(); CONDITION(); //top of the stack has whether it is true or false if(TOKEN != thensym) { ERROR("Error number 16, then expected."); } //after the condition, count how many instructions are written int currentLines = lines; inConditional++; fpos_t filePos; fgetpos(ifp, &filePos); //loop ensures this is done twice int i; for(i = 0; i < 2; i++) { if(i == 1) { inConditional--; //JPC 0 M = lines printToFile(8,0,lines); //returns the file to the previous position fsetpos(ifp, &filePos); lines = currentLines; } lines++; GETTOKEN(); STATEMENT(); fpos_t filePos2; fgetpos(ifp, &filePos2); if(TOKEN == semicolonsym) { GETTOKEN(); } //we need another line for the jump if(i == 0 && TOKEN == elsesym) { lines++; } else if(TOKEN != elsesym) { TOKEN = semicolonsym; fsetpos(ifp, &filePos2); } } if(TOKEN == elsesym) { //gets the position of the else currentLines = lines; inConditional++; fgetpos(ifp, &filePos); for(i = 0; i < 2; i++) { if(i == 1) { inConditional--; //jmp end of loop printToFile(7,0,lines); //returns the file to the previous position fsetpos(ifp, &filePos); lines = currentLines; } lines++; GETTOKEN(); STATEMENT(); } } } else if(TOKEN == whilesym) { int jumpBackLine = lines; GETTOKEN(); CONDITION(); //top of the stack has whether it is true or false if(TOKEN != dosym) { ERROR("Error number 18, do expected."); } //after the condition, count how many instructions are written int currentLines = lines; inConditional++; fpos_t filePos; fgetpos(ifp, &filePos); //loop ensures this is done twice int i; for(i = 0; i < 2; i++) { if(i == 1) { inConditional--; //make branch here (lines + 1 contains the line that you jump to if the condition is not met) //printToFile() //JPC 0 M = l printToFile(8,0,lines + 1); //returns the file to the previous position fsetpos(ifp, &filePos); lines = currentLines; //Lines increment for the printToFile used in for loop //lines++; } //the line for the branch is added lines++; GETTOKEN(); STATEMENT(); } //JMP 0 M = jumpBackLines printToFile(7,0,jumpBackLine); lines++; } else if(TOKEN == readsym) { GETTOKEN(); if(TOKEN != identsym) { ERROR("Error number 28, identifier expected after read."); } symbol current = getSymbol(IDENTIFIER); if(current.kind != 2) { ERROR("Error number 29, writing to a constant or procedure is not allowed."); } //SIO 0 1 //STO 0 M printToFile(9, 0, 1); printToFile(4,lexiLevel-current.level,current.addr); lines += 2; GETTOKEN(); } else if(TOKEN == writesym) { GETTOKEN(); if(TOKEN != identsym) { ERROR("Error number 30, identifier expected after write."); } symbol current = getSymbol(IDENTIFIER); if(current.kind == 3) { ERROR("Error number 31, cannot write a procedure."); } if(current.kind == 2) { //LOD L M printToFile(3, lexiLevel-current.level, current.addr); } if(current.kind == 1) { //LIT 0 val printToFile(1, 0, current.val); } //SIO 0 0 printToFile(9, 0, 0); lines +=2; GETTOKEN(); } }
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &attributes) { // add to elements stack: m_elementStack.append(new ElementData(qName.utf8())); // First we need a node. if (DBUS("node")) { CONDITION(!m_currentNode.isEmpty(), "Node inside a node."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QCString("Anonymous node found.")); m_currentNode = attributes.value(idx).utf8(); // A node is actually of little interest, so do nothing here. return true; } // Then we need an interface. if (DBUS("interface")) { // We need a nodeName for interfaces: CONDITION(m_currentNode.isEmpty(), "Interface without a node."); CONDITION(m_currentInterface, "Interface within another interface."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Interface without a name found.")); // A interface is roughly equivalent to a class: m_currentInterface = createEntry(); m_currentInterface->section = Entry::CLASS_SEC; m_currentInterface->spec |= Entry::Interface; m_currentInterface->type = "Interface"; m_currentInterface->name = substitute(attributes.value(idx).utf8(), ".", "::"); openScopes(m_currentInterface); return true; } if (DBUS("method") || DBUS("signal")) { // We need a interfaceName for methods and signals: CONDITION(!m_currentInterface, "Method or signal found outside a interface."); CONDITION(m_currentMethod, "Method or signal found inside another method or signal."); CONDITION(m_currentProperty, "Methor or signal found inside a property."); CONDITION(!m_structStack.isEmpty(), "Method or signal found inside a struct."); CONDITION(m_currentEnum, "Methor or signal found inside a enum."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Method or signal without a name found.")); m_currentMethod = createEntry(); m_currentMethod->section = Entry::FUNCTION_SEC; m_currentMethod->name = attributes.value(idx).utf8(); m_currentMethod->mtype = Method; m_currentMethod->type = "void"; if (DBUS("signal")) { m_currentMethod->mtype = Signal; } } if (DBUS("arg")) { // We need a method for arguments: CONDITION(!m_currentMethod, "Argument found outside a method or signal."); CONDITION(m_currentArgument, "Argument found inside another argument."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Argument without a name found.")); COND_DOC_ERROR(!hasType(attributes), QString("Argument without a type found.")); const int direction_idx(indexOf(attributes, "direction")); if ((m_currentMethod->mtype == Signal && direction_idx >= 0 && attributes.value(direction_idx) != "in") || (m_currentMethod->mtype == Method && direction_idx >= 0 && attributes.value(direction_idx) != "in" && attributes.value(direction_idx) != "out")) { m_errorString = "Invalid direction found."; return false; } m_currentArgument = new Argument; m_currentArgument->type = getType(attributes).utf8(); m_currentArgument->name = attributes.value(name_idx).utf8(); if (direction_idx >= 0) { m_currentArgument->attrib = attributes.value(direction_idx).utf8(); } else { if (m_currentMethod->mtype == Signal) { m_currentArgument->attrib = "in"; } else { m_currentArgument->attrib = "out"; } } } if (DBUS("property")) { CONDITION(m_currentMethod, "Property found inside a method or signal."); CONDITION(!m_currentInterface, "Property found outside an interface."); CONDITION(m_currentProperty, "Property found inside another property."); CONDITION(!m_structStack.isEmpty(), "Property found inside a struct."); CONDITION(m_currentEnum, "Property found inside a enum."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous property found.")); COND_DOC_ERROR(!hasType(attributes), QString("Property without a type found.")); const int access_idx(indexOf(attributes, "access")); COND_DOC_ERROR(access_idx < 0, QString("Property without a access attribute found.")); COND_DOC_ERROR(attributes.value(access_idx) != "read" && attributes.value(access_idx) != "write" && attributes.value(access_idx) != "readwrite", QString("Property with invalid access attribute \"%1\" found."). arg(attributes.value(access_idx))); m_currentProperty = createEntry(); m_currentProperty->section = Entry::FUNCTION_SEC; if (attributes.value(access_idx) == "read" || attributes.value(access_idx) == "readwrite") { m_currentProperty->spec |= Entry::Readable; } if (attributes.value(access_idx) == "write" || attributes.value(access_idx) == "readwrite") { m_currentProperty->spec |= Entry::Writable; } m_currentProperty->name = attributes.value(name_idx).utf8(); m_currentProperty->mtype = Property; m_currentProperty->type = getType(attributes).utf8(); } if (EXTENSION("namespace")) { CONDITION(m_currentNode.isEmpty(), "Namespace found outside a node."); CONDITION(m_currentInterface, "Namespace found inside an interface."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Anonymous namespace found.")); m_namespaceStack.append(openNamespace(attributes.value(idx))); openScopes(m_namespaceStack.last()); } if (EXTENSION("struct")) { CONDITION(m_currentMethod, "Struct found inside a method or signal."); CONDITION(m_currentProperty, "Struct found inside a property."); CONDITION(m_currentEnum, "Struct found inside an enum."); const int idx(indexOf(attributes, "name")); COND_DOC_ERROR(idx < 0, QString("Anonymous struct found.")); Entry * current_struct = createEntry(); current_struct->section = Entry::CLASS_SEC; current_struct->spec = Entry::Struct; current_struct->name = attributes.value(idx).utf8(); openScopes(current_struct); current_struct->type = current_struct->name + " struct"; m_structStack.append(new StructData(current_struct)); } if (EXTENSION("member")) { CONDITION(m_structStack.isEmpty(), "Member found outside of struct."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous member found.")); COND_DOC_ERROR(!hasType(attributes), QString("Member without a type found.")); createEntry(); m_currentEntry->section = Entry::VARIABLE_SEC; m_currentEntry->name = attributes.value(name_idx).utf8(); m_currentEntry->type = getType(attributes).utf8(); QString type(getDBusType(m_currentEntry->type)); m_structStack.last()->type.append(type.utf8()); } if (EXTENSION("enum") || EXTENSION("flagset")) { CONDITION(m_currentMethod, "Enum found inside a method or signal."); CONDITION(m_currentProperty, "Enum found inside a property."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous enum found.")); const int type_idx(indexOf(attributes, "type")); QString type = "u"; if (type_idx >= 0) { type = attributes.value(type_idx); } if (type != "y" && type != "q" && type != "u" && type != "t") { DOC_ERROR(QString("Invalid enum type \"%1\" found.").arg(type)); } m_currentEnum = createEntry(); m_currentEnum->section = Entry::ENUM_SEC; m_currentEnum->name = attributes.value(name_idx).utf8(); openScopes(m_currentEnum); m_currentEnum->type = m_currentEntry->name + " enum"; addNamedType(type.utf8()); } if (EXTENSION("value")) { CONDITION(!m_currentEnum, "Value found outside an enum."); const int name_idx(indexOf(attributes, "name")); COND_DOC_ERROR(name_idx < 0, QString("Anonymous value found.")); const int value_idx(indexOf(attributes, "value")); createEntry(); m_currentEntry->section = Entry::VARIABLE_SEC; m_currentEntry->name = attributes.value(name_idx).utf8(); m_currentEntry->type = m_currentEnum->name; // "@"; // enum marker! if (value_idx >= 0) { m_currentEntry->initializer = attributes.value(value_idx).utf8(); } } return true; }
LObject *CacheList::lblock(int id) { CacheItem *me=list+id; CONDITION(id<total && id>=0 && me->file_number>=0,"Bad id"); return (LObject *)me->data; }