/** * @brief Feed the content of doc texts maps from a file. * * This mecchanism allows to load different files for translation. * * "mathdoctexts" files must have been formatted as follows : * - a line beginning by ':' immediately declares a keyword, * - a line beginning by '"' contains text until the last '"', * - text can directly follow a keyword, if separated by one or * many separator characters (space or tab). * - a direct line break between two double quoted strings * will insert a '\n' line break in the resulting notice string. */ static void importDocStrings(const string& filename) { string s; string key, text; istream* file = openArchFile(filename); while ( getline(*file, s) ) { size_t pt1; // Text pointer. /* The first character determines whether will follow a key or a text. */ switch (s[0]) { case ':': text = ""; getKey(s, key, pt1); if (pt1==string::npos) continue; break; case '\"': pt1 = 0; break; default: continue; } getText(s, pt1, text); storePair(key, text); } printStringMapContent(gGlobal->gDocNoticeStringMap, "gGlobal->gDocNoticeStringMap"); printStringMapContent(gGlobal->gDocAutodocStringMap, "gGlobal->gDocAutodocStringMap"); printStringMapContent(gGlobal->gDocMathStringMap, "gGlobal->gDocMathStringMap"); printStringMapContent(gGlobal->gDocMetadatasStringMap, "gGlobal->gDocMetadatasStringMap"); delete(file); }
/** * returns number of extra arguments consumed */ unsigned parseGNU(Options& opts, unsigned argc, const char* argv[]) { /* gnu style long options can take the forms: * --option=arg * --option arg */ string arg(argv[0]); size_t arg_opt_start = arg.find_first_not_of('-'); size_t arg_opt_sep = arg.find_first_of('='); string option = arg.substr(arg_opt_start, arg_opt_sep - arg_opt_start); unsigned extra_argc_consumed = 0; if (arg_opt_sep == string::npos) { /* no argument found => argument in argv[1] (maybe) */ /* xxx, need to handle case where option isn't required */ #if 0 /* commented out, to return to true GNU style processing * where longopts have to include an =, otherwise they are * booleans */ if (argc == 1) return 0; /* run out of argv for argument */ extra_argc_consumed = 1; #endif if(!storePair(opts, true, false, option, "1")) { return 0; } } else { /* argument occurs after option_sep */ string val = arg.substr(arg_opt_sep + 1); storePair(opts, true, false, option, val); } return extra_argc_consumed; }
unsigned parseSHORT(Options& opts, unsigned argc, const char* argv[]) { /* short options can take the forms: * --option arg * -option arg */ string arg(argv[0]); size_t arg_opt_start = arg.find_first_not_of('-'); string option = arg.substr(arg_opt_start); /* lookup option */ /* argument in argv[1] */ /* xxx, need to handle case where option isn't required */ if (argc == 1) { cerr << "Not processing option without argument `" << option << "'" << endl; return 0; /* run out of argv for argument */ } storePair(opts, false, true, option, string(argv[1])); return 1; }
void scanLine(Options& opts, string& line) { /* strip any leading whitespace */ size_t start = line.find_first_not_of(" \t\n\r"); if (start == string::npos) { /* blank line */ return; } if (line[start] == '#') { /* comment line */ return; } /* look for first whitespace or ':' after the option end */ size_t option_end = line.find_first_of(": \t\n\r",start); string option = line.substr(start, option_end - start); /* look for ':', eat up any whitespace first */ start = line.find_first_not_of(" \t\n\r", option_end); if (start == string::npos) { /* error: badly formatted line */ return; } if (line[start] != ':') { /* error: badly formatted line */ return; } /* look for start of value string -- eat up any leading whitespace */ start = line.find_first_not_of(" \t\n\r", ++start); if (start == string::npos) { /* error: badly formatted line */ return; } /* extract the value part, which may contain embedded spaces * by searching for a word at a time, until we hit a comment or end of line */ size_t value_end = start; do { if (line[value_end] == '#') { /* rest of line is a comment */ value_end--; break; } value_end = line.find_first_of(" \t\n\r", value_end); /* consume any white space, incase there is another word. * any trailing whitespace will be removed shortly */ value_end = line.find_first_not_of(" \t\n\r", value_end); } while (value_end != string::npos); /* strip any trailing space from value*/ value_end = line.find_last_not_of(" \t\n\r", value_end); string value; if (value_end >= start) { value = line.substr(start, value_end +1 - start); } else { /* error: no value */ return; } /* store the value in option */ storePair(opts, true, false, option, value); }
bool storePair(Options& opts, const string& name, const string& value) { return storePair(opts, true, true, name, value); }
/* * Generate array store * */ static void genArrayPut(CompilationUnit *cUnit, MIR *mir, OpSize size, RegLocation rlArray, RegLocation rlIndex, RegLocation rlSrc, int scale) { RegisterClass regClass = dvmCompilerRegClassBySize(size); int lenOffset = OFFSETOF_MEMBER(ArrayObject, length); int dataOffset = OFFSETOF_MEMBER(ArrayObject, contents); int regPtr; rlArray = loadValue(cUnit, rlArray, kCoreReg); rlIndex = loadValue(cUnit, rlIndex, kCoreReg); if (dvmCompilerIsTemp(cUnit, rlArray.lowReg)) { dvmCompilerClobber(cUnit, rlArray.lowReg); regPtr = rlArray.lowReg; } else { regPtr = dvmCompilerAllocTemp(cUnit); genRegCopy(cUnit, regPtr, rlArray.lowReg); } /* null object? */ ArmLIR * pcrLabel = NULL; if (!(mir->OptimizationFlags & MIR_IGNORE_NULL_CHECK)) { pcrLabel = genNullCheck(cUnit, rlArray.sRegLow, rlArray.lowReg, mir->offset, NULL); } if (!(mir->OptimizationFlags & MIR_IGNORE_RANGE_CHECK)) { int regLen = dvmCompilerAllocTemp(cUnit); //NOTE: max live temps(4) here. /* Get len */ loadWordDisp(cUnit, rlArray.lowReg, lenOffset, regLen); /* regPtr -> array data */ opRegImm(cUnit, kOpAdd, regPtr, dataOffset); genBoundsCheck(cUnit, rlIndex.lowReg, regLen, mir->offset, pcrLabel); dvmCompilerFreeTemp(cUnit, regLen); } else { /* regPtr -> array data */ opRegImm(cUnit, kOpAdd, regPtr, dataOffset); } /* at this point, regPtr points to array, 2 live temps */ if ((size == kLong) || (size == kDouble)) { //TODO: need specific wide routine that can handle fp regs if (scale) { int rNewIndex = dvmCompilerAllocTemp(cUnit); opRegRegImm(cUnit, kOpLsl, rNewIndex, rlIndex.lowReg, scale); opRegReg(cUnit, kOpAdd, regPtr, rNewIndex); } else { opRegReg(cUnit, kOpAdd, regPtr, rlIndex.lowReg); } rlSrc = loadValueWide(cUnit, rlSrc, regClass); HEAP_ACCESS_SHADOW(true); storePair(cUnit, regPtr, rlSrc.lowReg, rlSrc.highReg); HEAP_ACCESS_SHADOW(false); dvmCompilerFreeTemp(cUnit, regPtr); } else { rlSrc = loadValue(cUnit, rlSrc, regClass); HEAP_ACCESS_SHADOW(true); storeBaseIndexed(cUnit, regPtr, rlIndex.lowReg, rlSrc.lowReg, scale, size); HEAP_ACCESS_SHADOW(false); } }