/* begin the translation process */ int asm_writeObjectFile(t_translation_infos *infos, char *output_file) { FILE *fp; int errorcode; if (output_file == NULL) { /* set "output.o" as output file name */ output_file = "output.o"; } #ifndef NDEBUG fprintf(stdout, "\n\n*******************************************\n"); fprintf(stdout, "INITIALIZE OUTPUT FILE: %s. \n", output_file); fprintf(stdout, "CODE SEGMENT has a size of %d instructions \n", infos->codesize); fprintf(stdout, "DATA SEGMENT has a size of %d elements \n" , (getLength(infos->code) - infos->codesize) ); fprintf(stdout, "NUMBER OF LABELS : %d. \n", getLength(infos->labels)); fprintf(stdout, "*******************************************\n\n"); #endif /* open a new file */ fp = fopen(output_file, "w"); if (fp == NULL) return ASM_FOPEN_ERROR; /* print the header of the object file */ errorcode = print_header_infos(fp); if (errorcode != ASM_OK) { if (fclose(fp) == EOF) return ASM_FCLOSE_ERROR; return errorcode; } /* print the code and data segment */ errorcode = translateCode(infos, fp); if (errorcode != ASM_OK) { if (fclose(fp) == EOF) return ASM_FCLOSE_ERROR; return errorcode; } /* print the trailer informations */ //DOES NOTHING /* close the file and return */ errorcode = fclose(fp); if (errorcode == EOF) return ASM_FCLOSE_ERROR; return ASM_OK; }
int main() { int i = 0; std::string sourceStr("12259"); std::map<int, char> dictionary; for(i = 1; i <= 26; ++i) { dictionary[i] = char('a' + i - 1); } translateCode(dictionary, sourceStr); return 0; }
XalanOutputTranscoder* XalanTranscodingServices::makeNewTranscoder( const XalanDOMString& theEncodingName, eCode& theResult, size_type theBlockSize) { XALAN_USING_XERCES(XMLPlatformUtils) assert(XMLPlatformUtils::fgTransService != 0); XalanOutputTranscoder* theTranscoder = 0; XMLTransService::Codes theCode = XMLTransService::Ok; if (encodingIsUTF16(theEncodingName) == true) { theResult = OK; theTranscoder = new XalanUTF16Transcoder; } else { XALAN_USING_XERCES(XMLTranscoder) XMLTranscoder* theXercesTranscoder = XMLPlatformUtils::fgTransService->makeNewTranscoderFor( c_wstr(theEncodingName), theCode, // A glitch in Xerces 2.3 omits the default parameter, so // we have to provide one. #if XERCES_VERSION_MAJOR == 2 && XERCES_VERSION_MINOR == 3 theBlockSize, XMLPlatformUtils::fgMemoryManager); #else theBlockSize); #endif theResult = translateCode(theCode); assert(theResult == XalanTranscodingServices::OK || theXercesTranscoder == 0); if (theResult == XalanTranscodingServices::OK) { theTranscoder = new XalanToXercesTranscoderWrapper(*theXercesTranscoder); } } return theTranscoder; }
StringBuffer &errorMessage(StringBuffer &out) const { return translateCode(out).append("\n").append(errMsg.str()); }
char executeClick(int px, int py) { if(py >= DEFAULT_TOP) { if(py <= DEFAULT_BOTTOM) { if(px >= INS_LEFT && px <= INS_RIGHT) { toggleIns(); } if(px >= CTRL_LEFT && px <= CTRL_RIGHT) { toggleControl(); } if(px >= SELECT_LEFT && px <= SELECT_RIGHT) { toggleSelect(); } if(px >= CLEAR_LEFT && px <= CLEAR_RIGHT) { return CLEAR_KEY; } } return 0; } if(activeKeyboard() == KB_MESSAGEASE) { downX = px; downY = py; upX = px; upY = py; px -= 32; py -= 37; if(px >= 1 && py >= 1 && px <= 31 && py <= 31) // caps { toggleCaps(); downX = 0; downY = 0; } if(px >= 1 && py >= 33 && px <= 31 && py <= 62) // shift { toggleShift(); downX = 0; downY = 0; } if(px >= 1 && py >= 64 && px <= 31 && py <= 94) // special { toggleSpecial(); downX = 0; downY = 0; } if(px >= 160 && py >= 1 && px <= 190 && py <= 31) // backspace { return translateCode(K_B, SYMBOLS); } if(px >= 160 && py >= 33 && px <= 190 && py <= 62) // return { return translateCode(K_R, SYMBOLS); } if(px >= 129 && py >= 1 && px <= 158 && py <= 31) // delete { return translateCode(K_D, SYMBOLS); } if(px >= 129 && py >= 33 && px <= 158 && py <= 62) // space { shift = 0; return translateCode(K_W, SYMBOLS); } if(px >= 129 && py >= 64 && px <= 158 && py <= 94) // number toggle { isNumbers = 1 - isNumbers; downX = 0; downY = 0; } curChar = 0; return 0; } py -= 37; if(py < 0) return 0; int tilex = 0; int tiley = py / 19; if(tiley < 0 || tiley > 4) return 0; switch(tiley) { case 0: // first row if(px < 13) return 0; px -= 13; tilex = px / 19; break; case 1: // second row if(px < 23) return 0; if(px >= 213 && px <= 242) // backspace return translateCode(K_B, SYMBOLS); px -= 23; tilex = px / 19; break; case 2: // third row if(px < 13) return 0; if(px >= 203 && px <= 242) // return return translateCode(K_R, SYMBOLS); px -= 13; tilex = px / 19; break; case 3: // fourth row if(px < 13) return 0; if(px < 42) // shift { toggleShift(); curChar = 0; return 0; } px -= 42; tilex = px / 19; break; case 4: // fifth row if(px < 13) return 0; if(px >= 89 && px < 184) // space return translateCode(K_W, SYMBOLS); px -= 13; tilex = px / 19; break; } if(tilex < 0 || tilex > 11) return 0; char c = 0; // capture character. if(tiley == 0) // this is the numbers { if(shift == 1) c = translateCode(keyboard_Hit[tilex], SYMBOLS); else c = translateCode(keyboard_Hit[tilex], NUMBERS); } else // this is letters { if((caps == 0 && shift == 0) || (caps == 1 && shift == 1)) { if(special == 0) c = translateCode(keyboard_Hit[tilex+(tiley*12)],LOWERCASE); else c = translateCode(keyboard_Hit[tilex+(tiley*12)],SPECIAL0); } else { if(special == 0) c = translateCode(keyboard_Hit[tilex+(tiley*12)],UPPERCASE); else c = translateCode(keyboard_Hit[tilex+(tiley*12)],SPECIAL1); } } if(c==DEL) // Return { // to ensure we dont lowercase on a delete } else if(c == CAP) { toggleCaps(); curChar = 0; c = 0; } else if(c == SPL) { toggleSpecial(); curChar = 0; c = 0; } else { shift = 0; } return c; }