DataFrame filter_grouped_single_env( const GroupedDataFrame& gdf, const List& args, const Environment& env){ const DataFrame& data = gdf.data() ; CharacterVector names = data.names() ; SymbolSet set ; for( int i=0; i<names.size(); i++){ set.insert( Rf_install( names[i] ) ) ; } // a, b, c -> a & b & c Call call( and_calls( args, set ) ) ; int nrows = data.nrows() ; LogicalVector test = no_init(nrows); LogicalVector g_test ; GroupedCallProxy call_proxy( call, gdf, env ) ; int ngroups = gdf.ngroups() ; GroupedDataFrame::group_iterator git = gdf.group_begin() ; for( int i=0; i<ngroups; i++, ++git){ SlicingIndex indices = *git ; int chunk_size = indices.size() ; g_test = call_proxy.get( indices ); check_filter_result(g_test, chunk_size ) ; for( int j=0; j<chunk_size; j++){ test[ indices[j] ] = g_test[j] ; } } DataFrame res = subset( data, test, names, classes_grouped() ) ; res.attr( "vars") = data.attr("vars") ; return res ; }
/// Remove the Value requiring a release from the tracked set for /// Instance and return the resultant state. ProgramStateRef ObjCDeallocChecker::removeValueRequiringRelease( ProgramStateRef State, SymbolRef Instance, SymbolRef Value) const { assert(Instance); assert(Value); const ObjCIvarRegion *RemovedRegion = getIvarRegionForIvarSymbol(Value); if (!RemovedRegion) return State; const SymbolSet *Unreleased = State->get<UnreleasedIvarMap>(Instance); if (!Unreleased) return State; // Mark the value as no longer requiring a release. SymbolSet::Factory &F = State->getStateManager().get_context<SymbolSet>(); SymbolSet NewUnreleased = *Unreleased; for (auto &Sym : *Unreleased) { const ObjCIvarRegion *UnreleasedRegion = getIvarRegionForIvarSymbol(Sym); assert(UnreleasedRegion); if (RemovedRegion->getDecl() == UnreleasedRegion->getDecl()) { NewUnreleased = F.remove(NewUnreleased, Sym); } } if (NewUnreleased.isEmpty()) { return State->remove<UnreleasedIvarMap>(Instance); } return State->set<UnreleasedIvarMap>(Instance, NewUnreleased); }
// version of grouped filter when contributions to ... come from several environment DataFrame filter_grouped_multiple_env( const GroupedDataFrame& gdf, const List& args, const DataDots& dots){ const DataFrame& data = gdf.data() ; CharacterVector names = data.names() ; SymbolSet set ; for( int i=0; i<names.size(); i++){ set.insert( Rf_install( names[i] ) ) ; } int nrows = data.nrows() ; LogicalVector test(nrows, TRUE); LogicalVector g_test ; for( int k=0; k<args.size(); k++){ Call call( (SEXP)args[k] ) ; GroupedCallProxy call_proxy( call, gdf, dots.envir(k) ) ; int ngroups = gdf.ngroups() ; GroupedDataFrame::group_iterator git = gdf.group_begin() ; for( int i=0; i<ngroups; i++, ++git){ SlicingIndex indices = *git ; int chunk_size = indices.size() ; g_test = call_proxy.get( indices ); check_filter_result(g_test, chunk_size ) ; for( int j=0; j<chunk_size; j++){ test[ indices[j] ] = test[ indices[j] ] & g_test[j] ; } } } DataFrame res = subset( data, test, names, classes_grouped() ) ; res.attr( "vars") = data.attr("vars") ; return res ; }
SEXP filter_not_grouped( DataFrame df, List args, const DataDots& dots){ CharacterVector names = df.names() ; SymbolSet set ; for( int i=0; i<names.size(); i++){ set.insert( Rf_install( names[i] ) ) ; } if( dots.single_env() ){ Environment env = dots.envir(0) ; // a, b, c -> a & b & c Shield<SEXP> call( and_calls( args, set ) ) ; // replace the symbols that are in the data frame by vectors from the data frame // and evaluate the expression CallProxy proxy( (SEXP)call, df, env ) ; LogicalVector test = proxy.eval() ; check_filter_result(test, df.nrows()); DataFrame res = subset( df, test, df.names(), classes_not_grouped() ) ; return res ; } else { int nargs = args.size() ; CallProxy first_proxy(args[0], df, dots.envir(0) ) ; LogicalVector test = first_proxy.eval() ; check_filter_result(test, df.nrows()); for( int i=1; i<nargs; i++){ LogicalVector test2 = CallProxy(args[i], df, dots.envir(i) ).eval() ; combine_and(test, test2) ; } DataFrame res = subset( df, test, df.names(), classes_not_grouped() ) ; return res ; } }
bool Object_DisplayMode::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; symbols.insert(Gura_UserSymbol(format)); symbols.insert(Gura_UserSymbol(w)); symbols.insert(Gura_UserSymbol(h)); symbols.insert(Gura_UserSymbol(refresh_rate)); return true; }
SymbolSet CTNode::childSymbols (void) const { SymbolSet symbols; for (CTChilds::const_iterator chIt = childs_.begin(); chIt != childs_.end(); ++ chIt) { symbols.insert ((*chIt)->symbol()); } return symbols; }
bool Object_BBox::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; symbols.insert(Gura_UserSymbol(xMin)); symbols.insert(Gura_UserSymbol(yMin)); symbols.insert(Gura_UserSymbol(xMax)); symbols.insert(Gura_UserSymbol(yMax)); return true; }
DataFrame filter_not_grouped( DataFrame df, const LazyDots& dots){ CharacterVector names = df.names() ; SymbolSet set ; for( int i=0; i<names.size(); i++){ set.insert( Rf_installChar( names[i] ) ) ; } if( dots.single_env() ){ Environment env = dots[0].env() ; // a, b, c -> a & b & c Shield<SEXP> call( and_calls( dots, set, env ) ) ; // replace the symbols that are in the data frame by vectors from the data frame // and evaluate the expression CallProxy proxy( (SEXP)call, df, env ) ; LogicalVector test = check_filter_logical_result(proxy.eval()) ; if( test.size() == 1){ if( test[0] == TRUE ){ return df ; } else { return empty_subset(df, df.names(), classes_not_grouped()) ; } } else { check_filter_result(test, df.nrows()); return subset(df, test, classes_not_grouped() ) ; } } else { int nargs = dots.size() ; Call call(dots[0].expr()); CallProxy first_proxy(call, df, dots[0].env() ) ; LogicalVector test = check_filter_logical_result(first_proxy.eval()) ; if( test.size() == 1 ) { if( !test[0] ){ return empty_subset(df, df.names(), classes_not_grouped() ) ; } } else { check_filter_result(test, df.nrows()); } for( int i=1; i<nargs; i++){ Rcpp::checkUserInterrupt() ; Call call( dots[i].expr() ) ; CallProxy proxy(call, df, dots[i].env() ) ; LogicalVector test2 = check_filter_logical_result(proxy.eval()) ; if( combine_and(test, test2) ){ return empty_subset(df, df.names(), classes_not_grouped() ) ; } } DataFrame res = subset( df, test, classes_not_grouped() ) ; return res ; } }
// **************************************************************************** // Method: ConfiguratingSet::GetShiftSymbols // // Purpose: // Get the set of symbols which can be shifted in this set. // // Programmer: Jeremy Meredith // Creation: April 5, 2002 // // **************************************************************************** SymbolSet ConfiguratingSet::GetShiftSymbols() { SymbolSet shiftsymbols; for (size_t i=0; i<items.size(); i++) { if (! items[i].CanReduce()) shiftsymbols.insert(items[i].GetNextSymbol()); } return shiftsymbols; }
bool Object_GlyphSlot::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; symbols.insert(Gura_UserSymbol(advance)); symbols.insert(Gura_UserSymbol(format)); symbols.insert(Gura_UserSymbol(bitmap)); symbols.insert(Gura_UserSymbol(bitmap_left)); symbols.insert(Gura_UserSymbol(bitmap_top)); symbols.insert(Gura_UserSymbol(outline)); return true; }
/// If this is the beginning of -dealloc, mark the values initially stored in /// instance variables that must be released by the end of -dealloc /// as unreleased in the state. void ObjCDeallocChecker::checkBeginFunction( CheckerContext &C) const { initIdentifierInfoAndSelectors(C.getASTContext()); // Only do this if the current method is -dealloc. SVal SelfVal; if (!isInInstanceDealloc(C, SelfVal)) return; SymbolRef SelfSymbol = SelfVal.getAsSymbol(); const LocationContext *LCtx = C.getLocationContext(); ProgramStateRef InitialState = C.getState(); ProgramStateRef State = InitialState; SymbolSet::Factory &F = State->getStateManager().get_context<SymbolSet>(); // Symbols that must be released by the end of the -dealloc; SymbolSet RequiredReleases = F.getEmptySet(); // If we're an inlined -dealloc, we should add our symbols to the existing // set from our subclass. if (const SymbolSet *CurrSet = State->get<UnreleasedIvarMap>(SelfSymbol)) RequiredReleases = *CurrSet; for (auto *PropImpl : getContainingObjCImpl(LCtx)->property_impls()) { ReleaseRequirement Requirement = getDeallocReleaseRequirement(PropImpl); if (Requirement != ReleaseRequirement::MustRelease) continue; SVal LVal = State->getLValue(PropImpl->getPropertyIvarDecl(), SelfVal); Optional<Loc> LValLoc = LVal.getAs<Loc>(); if (!LValLoc) continue; SVal InitialVal = State->getSVal(LValLoc.getValue()); SymbolRef Symbol = InitialVal.getAsSymbol(); if (!Symbol || !isa<SymbolRegionValue>(Symbol)) continue; // Mark the value as requiring a release. RequiredReleases = F.add(RequiredReleases, Symbol); } if (!RequiredReleases.isEmpty()) { State = State->set<UnreleasedIvarMap>(SelfSymbol, RequiredReleases); } if (State != InitialState) { C.addTransition(State); } }
// **************************************************************************** // Method: ConfiguratingSet::GetReduceSymbols // // Purpose: // Get the set of symbols which will cause a reduction. // // Programmer: Jeremy Meredith // Creation: April 5, 2002 // // **************************************************************************** SymbolSet ConfiguratingSet::GetReduceSymbols() { SymbolSet reducesymbols; for (size_t i=0; i<items.size(); i++) { if (items[i].CanReduce()) { reducesymbols.merge(items[i].GetFollow()); } } return reducesymbols; }
SymbolSet allLookaheadsOf(const Item & item, const Grammar & grammar) { SymbolList followingSymbols = item.rule.remainingSymbolsAfter(item.dottedSymbol); followingSymbols.push_back({ Symbol::Type::TERMINAL, "" }); SymbolSet allLookaheads; for(auto & lookahead : item.lookaheads) { followingSymbols.back() = lookahead; auto first = grammar.first(followingSymbols); allLookaheads.insert(first.begin(), first.end()); } return allLookaheads; }
void TypeCycleChecker::PartialOrder(SymbolSet& types) { // // assert that the "index" of all types that should be checked is initially // set to OMEGA // for (TypeSymbol* type = (TypeSymbol*) types.FirstElement(); type; type = (TypeSymbol*) types.NextElement()) { if (type -> index == OMEGA) ProcessSubtypes(type); } ReverseTypeList(); }
SEXP assert_correct_filter_subcall(SEXP x, const SymbolSet& set, const Environment& env){ switch(TYPEOF(x)){ case LANGSXP: return x ; case SYMSXP: { if( set.count(x) ) return x ; // look in the environment SEXP res = Rf_findVar( x, env ) ; if( res == R_UnboundValue ){ if( x == Rf_install("T") ){ return Rf_ScalarLogical(TRUE) ; } else if( x == Rf_install("F") ){ return Rf_ScalarLogical(FALSE) ; } std::stringstream s ; s << "unknown column : " << CHAR(PRINTNAME(x)) ; stop(s.str()); } return res ; } default: break ; } stop("incompatible expression in filter") ; return x ; // never happens }
bool Object_content::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; symbols.insert(Gura_UserSymbol(images)); return true; }
SEXP assert_correct_filter_subcall(SEXP x, const SymbolSet& set, const Environment& env){ switch(TYPEOF(x)){ case LGLSXP: return x; case LANGSXP: return x ; case SYMSXP: { if( set.count(x) ) return x ; // look in the environment SEXP var = PROTECT( Rf_findVar( x, env ) ) ; SEXP res = Rf_duplicate(var) ; UNPROTECT(1) ; if( res == R_UnboundValue ){ if( x == Rf_install("T") ){ return Rf_ScalarLogical(TRUE) ; } else if( x == Rf_install("F") ){ return Rf_ScalarLogical(FALSE) ; } stop( "unknown column : %s", CHAR(PRINTNAME(x)) ); } return res ; } default: break ; } stop("incompatible expression in filter") ; return x ; // never happens }
DataFrame filter_grouped_multiple_env( const Data& gdf, const LazyDots& dots){ const DataFrame& data = gdf.data() ; CharacterVector names = data.names() ; SymbolSet set ; for( int i=0; i<names.size(); i++){ set.insert( Rf_installChar( names[i] ) ) ; } int nrows = data.nrows() ; LogicalVector test(nrows, TRUE); LogicalVector g_test ; for( int k=0; k<dots.size(); k++){ Rcpp::checkUserInterrupt() ; const Lazy& lazy = dots[k] ; Call call( lazy.expr() ) ; GroupedCallProxy<Data, Subsets> call_proxy( call, gdf, lazy.env() ) ; int ngroups = gdf.ngroups() ; typename Data::group_iterator git = gdf.group_begin() ; for( int i=0; i<ngroups; i++, ++git){ SlicingIndex indices = *git ; int chunk_size = indices.size() ; g_test = check_filter_logical_result(call_proxy.get( indices )); if( g_test.size() == 1 ){ if( g_test[0] != TRUE ){ for( int j=0; j<chunk_size; j++){ test[indices[j]] = FALSE ; } } } else { check_filter_result(g_test, chunk_size ) ; for( int j=0; j<chunk_size; j++){ if( g_test[j] != TRUE ){ test[ indices[j] ] = FALSE ; } } } } } DataFrame res = subset( data, test, names, classes_grouped<Data>() ) ; res.attr( "vars") = data.attr("vars") ; return res ; }
bool Object_Vector::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; symbols.insert(Gura_Symbol(x)); symbols.insert(Gura_Symbol(y)); return true; }
// **************************************************************************** // Method: Sequence::GetFirstSet // // Purpose: // Get the first set of this sequence. // // Programmer: Jeremy Meredith // Creation: April 5, 2002 // // **************************************************************************** SymbolSet Sequence::GetFirstSet(const vector<const Rule*> &rules) const { SymbolSet first; for (size_t i=0; i<symbols.size(); i++) { if (symbols[i]->IsTerminal()) { first.insert(symbols[i]); break; } first.merge( symbols[i]->GetFirstSet(rules) ); if (! symbols[i]->IsNullable(rules)) break; } return first; }
bool Object_mpq::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; symbols.insert(Gura_Symbol(numer)); symbols.insert(Gura_Symbol(denom)); return true; }
DataFrame filter_grouped_single_env( const Data& gdf, const LazyDots& dots){ typedef GroupedCallProxy<Data, Subsets> Proxy ; Environment env = dots[0].env() ; const DataFrame& data = gdf.data() ; CharacterVector names = data.names() ; SymbolSet set ; for( int i=0; i<names.size(); i++){ set.insert( Rf_installChar( names[i] ) ) ; } // a, b, c -> a & b & c Call call( and_calls( dots, set, env ) ) ; int nrows = data.nrows() ; LogicalVector test(nrows, TRUE); LogicalVector g_test ; Proxy call_proxy( call, gdf, env ) ; int ngroups = gdf.ngroups() ; typename Data::group_iterator git = gdf.group_begin() ; for( int i=0; i<ngroups; i++, ++git){ SlicingIndex indices = *git ; int chunk_size = indices.size() ; g_test = check_filter_logical_result( call_proxy.get( indices ) ) ; if( g_test.size() == 1 ){ int val = g_test[0] == TRUE ; for( int j=0; j<chunk_size; j++){ test[ indices[j] ] = val ; } } else { check_filter_result(g_test, chunk_size ) ; for( int j=0; j<chunk_size; j++){ if( g_test[j] != TRUE ) test[ indices[j] ] = FALSE ; } } } DataFrame res = subset( data, test, names, classes_grouped<Data>() ) ; res.attr( "vars") = data.attr("vars") ; return res ; }
bool Object_FTC_Manager::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; #if 0 symbols.insert(Gura_Symbol(x)); symbols.insert(Gura_Symbol(y)); #endif return true; }
QString ZBarReaderTest::decode(const QImage &image) { Image zbarImg(image.width(), image.height(), "Y800", image.bits(), image.bytesPerLine() * image.height()); QString line; ImageScanner scanner; scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1); scanner.scan(zbarImg); SymbolSet s = scanner.get_results(); int resSize = s.get_size(); if (resSize > 0) { mTotalRead++; for (SymbolIterator symbol = scanner.get_results().symbol_begin(); symbol != scanner.get_results().symbol_end(); ++symbol) { if (QString::compare("QR-Code ", QString(symbol->get_type_name().data()).trimmed())) line += " | " + QString(symbol->get_data().data()).replace("\n", "<br>"); } } return line; }
QString ZBarReaderTest::decodeIterative(const QImage &image) { Image zbarImg(image.width(), image.height(), "Y800", image.bits(), image.bytesPerLine() * image.height()); QString line; ImageScanner scanner; scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1); scanner.scan(zbarImg); SymbolSet s = scanner.get_results(); int resSize = s.get_size(); if (resSize == 0) { int fib1 = 1, fib2 = 1; int fib; for (fib = fib1 + fib2; fib < 11; fib = fib1 + fib2) { int roiWidth = (1. / fib) * image.width(), roiHeight = (1. / fib) * image.height(); for (int x = 0; x < image.width(); x += 50) { for (int y = 0; y < image.height(); y += 50) { // qDebug () << "roiWidth" << roiWidth << "roiHeight" << roiHeight; QImage img = image.copy(x, y, roiWidth, roiHeight); Image i(img.width(), img.height(), "Y800", img.bits(), img.bytesPerLine() * img.height()); scanner.scan(i); } } int temp = fib1; fib1 = fib; fib2 = temp; } } SymbolSet s2 = scanner.get_results(); resSize = s2.get_size(); if (resSize > 0) { mTotalRead++; for (SymbolIterator symbol = scanner.get_results().symbol_begin(); symbol != scanner.get_results().symbol_end(); ++symbol) { if (QString::compare("QR-Code ", QString(symbol->get_type_name().data()).trimmed())) line += " | " + QString(symbol->get_data().data()).replace("\n", "<br>"); } } return line; }
// **************************************************************************** // Method: Symbol::GetFirstSet // // Purpose: // Gets the first set for any production of this symbol. // For terminals, the first set is the identity operation. // // Programmer: Jeremy Meredith // Creation: April 5, 2002 // // **************************************************************************** SymbolSet Symbol::GetFirstSet(const vector<const Rule*> &rules) const { SymbolSet first; if (type == Terminal) { first.insert(this); } else { for (size_t i=0; i<rules.size(); i++) { if (rules[i]->GetLHS() == this && // Try to avoid infinite recursion -- this should be improved! (rules[i]->GetRHS().Empty() || rules[i]->GetRHS()[0] != this)) { first.merge( rules[i]->GetRHS().GetFirstSet(rules) ); } } } return first; }
// **************************************************************************** // Method: ConfiguratingItem::CreateClosure // // Purpose: // Get the list of configurating items in the closure of the current item. // // Programmer: Jeremy Meredith // Creation: April 5, 2002 // // **************************************************************************** ConfiguratingSet ConfiguratingItem::CreateClosure(const vector<const Rule*> &rules) { ConfiguratingSet closure; Sequence s = rule->GetRHS().GetSubsequence(pos); if (!s.Empty() && s[0]->IsNonTerminal()) { Sequence remaining = s.GetSubsequence(1); SymbolSet closurefollow = remaining.GetFirstSet(rules); if (remaining.IsNullable(rules)) { closurefollow.merge(follow); } for (size_t i=0; i<rules.size(); i++) { if (s[0] == rules[i]->GetLHS()) { closure.AddItem(ConfiguratingItem(rules[i], closurefollow)); } } } return closure; }
// // For each file whose associated source (".java") has changed, add it to the // list to be recompiled... // void Control::FindMoreRecentInputFiles(SymbolSet& file_candidates) { FileSymbol* file_symbol; for (file_symbol = (FileSymbol*) file_candidates.FirstElement(); file_symbol; file_symbol = (FileSymbol*) file_candidates.NextElement()) { // // If the type is not zipped and it is not already contained in the // recompilation set, then check it... // if ((! file_symbol -> IsZip()) && (! recompilation_file_set.IsElement(file_symbol)) && (! expired_file_set.IsElement(file_symbol))) { // // If there is no java source file or its time stamp is not newer // than file_symbol then reset file_symbol to NULL. Otherwise, // reset file symbol to the newer file. // DirectoryEntry* java_entry = FindInputFile(file_symbol); if (! java_entry) { // A source file that was compiled in the previous pass no // longer exists. if (file_symbol -> IsJava()) expired_file_set.AddElement(file_symbol); } else if (java_entry -> Mtime() > file_symbol -> mtime) { // A newer file was found. file_symbol -> mtime = java_entry -> Mtime(); recompilation_file_set.AddElement(file_symbol); } } } }
SEXP assert_correct_filter_subcall(SEXP x, const SymbolSet& set){ switch(TYPEOF(x)){ case LANGSXP: return x ; case SYMSXP: { if( set.count(x) ) return x ; std::stringstream s ; s << "unknown column : " << CHAR(PRINTNAME(x)) ; stop(s.str()); } default: break ; } stop("incompatible expression in filter") ; return x ; // never happens }
bool Object_AudioCVT::DoDirProp(Environment &env, SymbolSet &symbols) { Signal &sig = GetSignal(); if (!Object::DoDirProp(env, symbols)) return false; symbols.insert(Gura_UserSymbol(needed)); symbols.insert(Gura_UserSymbol(src_format)); symbols.insert(Gura_UserSymbol(dst_format)); symbols.insert(Gura_UserSymbol(rate_incr)); symbols.insert(Gura_UserSymbol(buf)); symbols.insert(Gura_UserSymbol(len)); symbols.insert(Gura_UserSymbol(len_cvt)); symbols.insert(Gura_UserSymbol(len_mult)); symbols.insert(Gura_UserSymbol(len_ratio)); return true; }