static void inherit_f2(struct f2 *inheritor_f2, struct f2 *from_f2) { #define inherit(memb) if((!(inheritor_f2->memb) || !(*inheritor_f2->memb))&&from_f2->memb)inheritor_f2->memb=from_f2->memb if (BIT_ISSET(inheritor_f2->flags, F2_FLAGS_FROM_CACHE)) { *inheritor_f2 = *from_f2; return; } #if 0 if (!strcmp((const char *)inheritor_f2->form, "*")) inherit(cf); #endif inherit(base); inherit(cont); inherit(norm); /* Fix the CF and GW fields: in L2 we can't make any kind of a match without these either matching CF/NORM or GW/SENSE, so this coercion is safe */ if (!inheritor_f2->cf || (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS) && strcmp((char*)inheritor_f2->cf,(char*)from_f2->cf))) { inheritor_f2->cf = from_f2->cf; BIT_CLEAR(inheritor_f2->flags, F2_FLAGS_NORM_IS_CF); } if (!inheritor_f2->gw || (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS) && strcmp((char*)inheritor_f2->gw,(char*)from_f2->gw))) inheritor_f2->gw = from_f2->gw; if (!inheritor_f2->sense || (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS) && strcmp((char*)inheritor_f2->sense,(char*)from_f2->sense))) inheritor_f2->sense = from_f2->sense; if (!inheritor_f2->pos) inheritor_f2->pos = from_f2->pos; else { if (!BIT_ISSET(inheritor_f2->flags, F2_FLAGS_NOT_IN_SIGS)) { if (strcmp((char*)inheritor_f2->pos,(char*)from_f2->pos)) { /* silently correct x[y]N where it is really x[y]'N */ inheritor_f2->epos = inheritor_f2->pos; inheritor_f2->pos = from_f2->pos; } } } inherit(epos); inherit(stem); inherit(morph); inherit(morph2); #undef inherit }
void mtsm::flush(FILE *fp, statem *s, string tag_list) { if (is_html && s) { inherit(s, 1); driver->flush(fp, s); // Set rj, ce, ti to unknown if they were known and // we have seen an eol or br. This ensures that these values // are emitted during the next glyph (as they step from n..0 // at each newline). if ((driver->bool_values[MTSM_EOL].is_known && driver->bool_values[MTSM_EOL].value) || (driver->bool_values[MTSM_BR].is_known && driver->bool_values[MTSM_BR].value)) { if (driver->units_values[MTSM_TI].is_known) driver->units_values[MTSM_TI].is_known = 0; if (driver->int_values[MTSM_RJ].is_known && driver->int_values[MTSM_RJ].value > 0) driver->int_values[MTSM_RJ].is_known = 0; if (driver->int_values[MTSM_CE].is_known && driver->int_values[MTSM_CE].value > 0) driver->int_values[MTSM_CE].is_known = 0; } // reset the boolean values driver->bool_values[MTSM_BR].set(0); driver->bool_values[MTSM_EOL].set(0); // reset space value driver->int_values[MTSM_SP].set(0); // lastly write out any direct tag entries if (tag_list != string("")) { string t = tag_list + '\0'; fputs(t.contents(), fp); } } }
int MIMESubMap::inherit(const MIMESubMap *pParent, int existedOnly) { iterator iter; for (iter = pParent->begin(); iter != pParent->end(); iter = pParent->next(iter)) inherit(iter, existedOnly); return 0; }
MaDir::MaDir(MaDir *dp, MaAuth *auth) { indexName = mprStrdup(dp->indexName); if (auth) { inherit(auth); } path = 0; setPath(dp->path); }
void partition (inspector_t* insp) { // aliases insp_strategy strategy = insp->strategy; map_list* meshMaps = insp->meshMaps; map_list* partitionings = insp->partitionings; int tileSize = insp->avgTileSize; int prefetchHalo = insp->prefetchHalo; loop_list* loops = insp->loops; int nLoops = loops->size(); int seed = insp->seed; loop_t* seedLoop = insp->loops->at(seed); set_t* seedLoopSet = seedLoop->set; int setSize = seedLoopSet->size; int nThreads = insp->nThreads; // partition the seed loop iteration space int* indMap = NULL; int nCore, nExec, nNonExec; if (partitionings) { indMap = inherit (seedLoop, tileSize, partitionings, &nCore, &nExec, &nNonExec, nThreads); insp->partitioningMode = "inherited"; } #ifdef SLOPE_METIS if (! indMap && meshMaps) { indMap = metis (seedLoop, tileSize, meshMaps, &nCore, &nExec, &nNonExec, nThreads); insp->partitioningMode = "metis"; } #endif if (! indMap) { indMap = chunk (seedLoop, tileSize, &nCore, &nExec, &nNonExec, nThreads); insp->partitioningMode = "chunk"; } // initialize tiles: // ... start with creating as many empty tiles as needed ... int t; tile_list* tiles = new tile_list (nCore + nExec + nNonExec); for (t = 0; t < nCore; t++) { tiles->at(t) = tile_init (nLoops, LOCAL, prefetchHalo); } for (; t < nCore + nExec; t++) { tiles->at(t) = tile_init (nLoops, EXEC_HALO, prefetchHalo); } for (; t < nCore + nExec + nNonExec; t++) { tiles->at(t) = tile_init (nLoops, NON_EXEC_HALO, prefetchHalo); } // ... explicitly track the tile region (core, exec_halo, and non_exec_halo) ... set_t* tileRegions = set("tiles", nCore, nExec, nNonExec); // ... and, finally, map the partitioned seed loop to tiles assign_loop (seedLoop, loops, tiles, indMap, SEED); insp->tileRegions = tileRegions; insp->iter2tile = map ("i2t", set_cpy(seedLoopSet), set_cpy(tileRegions), indMap, setSize); insp->tiles = tiles; }
int MIMEMap::inherit( const MIMEMap * pParent, int existedOnly, char * pFilter ) { iterator iter; if (( pFilter == NULL )||( *pFilter == '*' )) { for( iter = pParent->begin(); iter != pParent->end(); iter = pParent->next( iter ) ) { inherit( iter, existedOnly ); } } else { char * p; iter = pParent->findSubMap( pFilter, p ); if ( iter != pParent->end() ) { MIMESubMap *pMap; iterator iter2; iter2 = find( iter.first() ); if ( iter2 == end() ) { if ( !existedOnly ) { pMap = addSubMap( pFilter, p - pFilter ); } else return 0; } else pMap = iter2.second(); ++p; if ( *p == '*' ) { pMap->inherit( iter.second(), existedOnly ); } else { MIMESubMap::iterator iterSub= iter.second()->find( p ); if ( iterSub == iter.second()->end() ) return 0; else { pMap->inherit( iterSub, existedOnly ); } } } } return 0; }
int mtsm::changed(statem *s) { if (s == 0 || !is_html) return 0; s = new statem(s); inherit(s, 0); int result = has_changed(MTSM_EOL, s) || has_changed(MTSM_BR, s) || has_changed(MTSM_FI, s) || has_changed(MTSM_IN, s) || has_changed(MTSM_LL, s) || has_changed(MTSM_PO, s) || has_changed(MTSM_RJ, s) || has_changed(MTSM_SP, s) || has_changed(MTSM_TA, s) || has_changed(MTSM_CE, s); delete s; return result; }
/* Copy constructor; does not copy kd-Trees or texture */ Mesh::Mesh(const Mesh &mesh) { m_nVertices = mesh.m_nVertices; m_nNormals = mesh.m_nNormals; m_nUVs = mesh.m_nUVs; m_nTriangles = mesh.m_nTriangles; m_vertices = new Vertex[m_nVertices]; m_normals = new Normal[m_nNormals]; m_uvs = new UV[m_nUVs]; m_triangles = new MeshTriangle[m_nTriangles]; /* Copy data over from other mesh */ memcpy(m_vertices, mesh.m_vertices, sizeof(Vertex) * m_nVertices); memcpy(m_normals, mesh.m_normals, sizeof(Normal) * m_nNormals); memcpy(m_uvs, mesh.m_uvs, sizeof(UV) * m_nUVs); memcpy(m_triangles, mesh.m_triangles, sizeof(MeshTriangle) * m_nTriangles); for(unsigned i = m_nTriangles; i--;) { m_triangles[i].mesh = this; ASSERT(m_triangles[i].A < m_nVertices); ASSERT(m_triangles[i].B < m_nVertices); ASSERT(m_triangles[i].C < m_nVertices); if (m_nNormals > 0) { ASSERT(m_triangles[i].nA < m_nNormals); ASSERT(m_triangles[i].nB < m_nNormals); ASSERT(m_triangles[i].nC < m_nNormals); } if (m_nUVs > 0) { ASSERT(m_triangles[i].tA < m_nUVs); ASSERT(m_triangles[i].tB < m_nUVs); ASSERT(m_triangles[i].tC < m_nUVs); } } m_batch = 0; m_spatialAccel = NULL; inherit(mesh); }
// ---------------------------------------------------------------------------- // TextLanguage::readLanguageDefinition // // Reads in a text definition of a language. See slade.pk3 for // formatting examples // ---------------------------------------------------------------------------- bool TextLanguage::readLanguageDefinition(MemChunk& mc, string source) { Tokenizer tz; // Open the given text data if (!tz.openMem(mc, source)) { Log::warning(1, S_FMT("Warning: Unable to open %s", source)); return false; } // Parse the definition text ParseTreeNode root; if (!root.parse(tz)) return false; // Get parsed data for (unsigned a = 0; a < root.nChildren(); a++) { auto node = root.getChildPTN(a); // Create language TextLanguage* lang = new TextLanguage(node->getName()); // Check for inheritance if (!node->inherit().IsEmpty()) { TextLanguage* inherit = fromId(node->inherit()); if (inherit) inherit->copyTo(lang); else Log::warning( 1, S_FMT("Warning: Language %s inherits from undefined language %s", node->getName(), node->inherit()) ); } // Parse language info for (unsigned c = 0; c < node->nChildren(); c++) { auto child = node->getChildPTN(c); // Language name if (S_CMPNOCASE(child->getName(), "name")) lang->setName(child->stringValue()); // Comment begin else if (S_CMPNOCASE(child->getName(), "comment_begin")) { lang->setCommentBeginList(child->stringValues()); } // Comment end else if (S_CMPNOCASE(child->getName(), "comment_end")) { lang->setCommentEndList(child->stringValues()); } // Line comment else if (S_CMPNOCASE(child->getName(), "comment_line")) { lang->setLineCommentList(child->stringValues()); } // Preprocessor else if (S_CMPNOCASE(child->getName(), "preprocessor")) lang->setPreprocessor(child->stringValue()); // Case sensitive else if (S_CMPNOCASE(child->getName(), "case_sensitive")) lang->setCaseSensitive(child->boolValue()); // Doc comment else if (S_CMPNOCASE(child->getName(), "comment_doc")) lang->setDocComment(child->stringValue()); // Keyword lookup link else if (S_CMPNOCASE(child->getName(), "keyword_link")) lang->word_lists_[WordType::Keyword].lookup_url = child->stringValue(); // Constant lookup link else if (S_CMPNOCASE(child->getName(), "constant_link")) lang->word_lists_[WordType::Constant].lookup_url = child->stringValue(); // Function lookup link else if (S_CMPNOCASE(child->getName(), "function_link")) lang->f_lookup_url_ = child->stringValue(); // Jump blocks else if (S_CMPNOCASE(child->getName(), "blocks")) { for (unsigned v = 0; v < child->nValues(); v++) lang->jump_blocks_.push_back(child->stringValue(v)); } else if (S_CMPNOCASE(child->getName(), "blocks_ignore")) { for (unsigned v = 0; v < child->nValues(); v++) lang->jb_ignore_.push_back(child->stringValue(v)); } // Block begin else if (S_CMPNOCASE(child->getName(), "block_begin")) lang->block_begin_ = child->stringValue(); // Block end else if (S_CMPNOCASE(child->getName(), "block_end")) lang->block_end_ = child->stringValue(); // Preprocessor block begin else if (S_CMPNOCASE(child->getName(), "pp_block_begin")) { for (unsigned v = 0; v < child->nValues(); v++) lang->pp_block_begin_.push_back(child->stringValue(v)); } // Preprocessor block end else if (S_CMPNOCASE(child->getName(), "pp_block_end")) { for (unsigned v = 0; v < child->nValues(); v++) lang->pp_block_end_.push_back(child->stringValue(v)); } // Word block begin else if (S_CMPNOCASE(child->getName(), "word_block_begin")) { for (unsigned v = 0; v < child->nValues(); v++) lang->word_block_begin_.push_back(child->stringValue(v)); } // Word block end else if (S_CMPNOCASE(child->getName(), "word_block_end")) { for (unsigned v = 0; v < child->nValues(); v++) lang->word_block_end_.push_back(child->stringValue(v)); } // Keywords else if (S_CMPNOCASE(child->getName(), "keywords")) { // Go through values for (unsigned v = 0; v < child->nValues(); v++) { string val = child->stringValue(v); // Check for '$override' if (S_CMPNOCASE(val, "$override")) { // Clear any inherited keywords lang->clearWordList(WordType::Keyword); } // Not a special symbol, add as keyword else lang->addWord(WordType::Keyword, val); } } // Constants else if (S_CMPNOCASE(child->getName(), "constants")) { // Go through values for (unsigned v = 0; v < child->nValues(); v++) { string val = child->stringValue(v); // Check for '$override' if (S_CMPNOCASE(val, "$override")) { // Clear any inherited constants lang->clearWordList(WordType::Constant); } // Not a special symbol, add as constant else lang->addWord(WordType::Constant, val); } } // Types else if (S_CMPNOCASE(child->getName(), "types")) { // Go through values for (unsigned v = 0; v < child->nValues(); v++) { string val = child->stringValue(v); // Check for '$override' if (S_CMPNOCASE(val, "$override")) { // Clear any inherited constants lang->clearWordList(WordType::Type); } // Not a special symbol, add as constant else lang->addWord(WordType::Type, val); } } // Properties else if (S_CMPNOCASE(child->getName(), "properties")) { // Go through values for (unsigned v = 0; v < child->nValues(); v++) { string val = child->stringValue(v); // Check for '$override' if (S_CMPNOCASE(val, "$override")) { // Clear any inherited constants lang->clearWordList(WordType::Property); } // Not a special symbol, add as constant else lang->addWord(WordType::Property, val); } } // Functions else if (S_CMPNOCASE(child->getName(), "functions")) { bool lang_has_void = lang->isWord(Keyword, "void") || lang->isWord(Type, "void"); if (lang->id_ != "zscript") { // Go through children (functions) for (unsigned f = 0; f < child->nChildren(); f++) { auto child_func = child->getChildPTN(f); string params; // Simple definition if (child_func->nChildren() == 0) { if (child_func->stringValue(0).empty()) { if (lang_has_void) params = "void"; else params = ""; } else { params = child_func->stringValue(0); } // Add function lang->addFunction( child_func->getName(), params, "", "", !child_func->getName().Contains("."), child_func->type()); // Add args for (unsigned v = 1; v < child_func->nValues(); v++) lang->addFunction(child_func->getName(), child_func->stringValue(v)); } // Full definition else { string name = child_func->getName(); vector<string> args; string desc = ""; string deprecated = ""; for (unsigned p = 0; p < child_func->nChildren(); p++) { auto child_prop = child_func->getChildPTN(p); if (child_prop->getName() == "args") { for (unsigned v = 0; v < child_prop->nValues(); v++) args.push_back(child_prop->stringValue(v)); } else if (child_prop->getName() == "description") desc = child_prop->stringValue(); else if (child_prop->getName() == "deprecated") deprecated = child_prop->stringValue(); } if (args.empty() && lang_has_void) args.push_back("void"); for (unsigned as = 0; as < args.size(); as++) lang->addFunction(name, args[as], desc, deprecated, as == 0, child_func->type()); } } } // ZScript function info which cannot be parsed from (g)zdoom.pk3 else { zfunc_ex_prop ex_prop; for (unsigned f = 0; f < child->nChildren(); f++) { auto child_func = child->getChildPTN(f); for (unsigned p = 0; p < child_func->nChildren(); ++p) { auto child_prop = child_func->getChildPTN(p); if (child_prop->getName() == "description") ex_prop.description = child_prop->stringValue(); else if (child_prop->getName() == "deprecated_f") ex_prop.deprecated_f = child_prop->stringValue(); } lang->zfuncs_ex_props_.emplace(child_func->getName(), ex_prop); } } } } } return true; }