本文整理汇总了C++中SymbolSet类的典型用法代码示例。如果您正苦于以下问题:C++ SymbolSet类的具体用法?C++ SymbolSet怎么用?C++ SymbolSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SymbolSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: filter_grouped_single_env
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 ;
}
示例2: assert
/// 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);
}
示例3: filter_grouped_multiple_env
// 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 ;
}
示例4: filter_not_grouped
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 ;
}
}
示例5:
SymbolSet
CTNode::childSymbols (void) const
{
SymbolSet symbols;
for (CTChilds::const_iterator chIt = childs_.begin();
chIt != childs_.end(); ++ chIt) {
symbols.insert ((*chIt)->symbol());
}
return symbols;
}
示例6: filter_not_grouped
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 ;
}
}
示例7:
// ****************************************************************************
// 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;
}
示例8: initIdentifierInfoAndSelectors
/// 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);
}
}
示例9: allLookaheadsOf
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;
}
示例10: PartialOrder
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();
}
示例11: assert_correct_filter_subcall
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
}
示例12: assert_correct_filter_subcall
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
}
示例13: filter_grouped_multiple_env
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 ;
}
示例14:
// ****************************************************************************
// 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;
}
示例15: filter_grouped_single_env
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 ;
}