return out;
}
+
+ public static ReachState addUpArity( ReachState rs,
+ ReachTuple rt ) {
+ assert rs != null;
+ assert rt != null;
+
+ CanonicalOp op =
+ new CanonicalOp( CanonicalOp.REACHSTATE_ADDUPARITY_REACHTUPLE,
+ rs,
+ rt );
+
+ Canonical result = op2result.get( op );
+ if( result != null ) {
+ return (ReachState) result;
+ }
+
+ // otherwise, no cached result...
+ ReachState out;
+
+ // the reason for this add is that we are aware a tuple
+ // with the same hrnID might already be in the state, so
+ // if it is we should combine properly
+ ReachState rtOnly = ReachState.factory( rt );
+ out = Canonical.unionUpArity( rs, rtOnly );
+
+ op2result.put( op, out );
+ return out;
+ }
+
public static ReachState remove( ReachState rs, ReachTuple rt ) {
assert rs != null;
if( age == AllocSite.AGE_notInThisSite ) {
// things not from the site just go back in
- baseState = Canonical.add( baseState, rt );
+ baseState = Canonical.addUpArity( baseState, rt );
} else if( age == AllocSite.AGE_summary ) {
// arity, if ARITY-ONE we'll branch the base state after the loop
if( rt.getArity() == ReachTuple.ARITY_ZEROORMORE ) {
// add two overly conservative symbols to reach state (PUNTING)
- baseState = Canonical.add( baseState,
- ReachTuple.factory( as.getSummary(),
- true, // multi
- ReachTuple.ARITY_ZEROORMORE,
- false // out-of-context
- )
- );
- baseState = Canonical.add( baseState,
- ReachTuple.factory( as.getSummary(),
- true, // multi
- ReachTuple.ARITY_ZEROORMORE,
- true // out-of-context
- )
- );
+
+ baseState = Canonical.addUpArity( baseState,
+ ReachTuple.factory( as.getSummary(),
+ true, // multi
+ ReachTuple.ARITY_ZEROORMORE,
+ false // out-of-context
+ )
+ );
+
+ baseState = Canonical.addUpArity( baseState,
+ ReachTuple.factory( as.getSummary(),
+ true, // multi
+ ReachTuple.ARITY_ZEROORMORE,
+ true // out-of-context
+ )
+ );
} else {
assert rt.getArity() == ReachTuple.ARITY_ONE;
found2Sooc = true;
} else {
// the in-context just becomes shadow
- baseState = Canonical.add( baseState,
- ReachTuple.factory( as.getSummaryShadow(),
- true, // multi
- rt.getArity(),
- false // out-of-context
- )
- );
+ baseState = Canonical.addUpArity( baseState,
+ ReachTuple.factory( as.getSummaryShadow(),
+ true, // multi
+ rt.getArity(),
+ false // out-of-context
+ )
+ );
}
if( rt.isOutOfContext() ) {
// becomes the in-context version
- baseState = Canonical.add( baseState,
- ReachTuple.factory( rt.getHrnID(),
- false, // multi
- ReachTuple.ARITY_ONE,
- false // out-of-context
- )
- );
+ baseState = Canonical.addUpArity( baseState,
+ ReachTuple.factory( rt.getHrnID(),
+ false, // multi
+ ReachTuple.ARITY_ONE,
+ false // out-of-context
+ )
+ );
} else {
// otherwise the ith symbol becomes shadowed
- baseState = Canonical.add( baseState,
- ReachTuple.factory( -rt.getHrnID(),
- false, // multi
- ReachTuple.ARITY_ONE,
- false // out-of-context
- )
- );
+ baseState = Canonical.addUpArity( baseState,
+ ReachTuple.factory( -rt.getHrnID(),
+ false, // multi
+ ReachTuple.ARITY_ONE,
+ false // out-of-context
+ )
+ );
}
}
}
// make a branch with every possibility of the one-to-many
// mapping for 2S? appended to the baseState
out = Canonical.add( out,
- Canonical.add( baseState,
- ReachTuple.factory( as.getSummary(),
- true, // multi
- ReachTuple.ARITY_ONE,
- false // out-of-context
- )
- )
+ Canonical.addUpArity( baseState,
+ ReachTuple.factory( as.getSummary(),
+ true, // multi
+ ReachTuple.ARITY_ONE,
+ false // out-of-context
+ )
+ )
);
out = Canonical.add( out,
- Canonical.add( baseState,
- ReachTuple.factory( as.getSummary(),
- true, // multi
- ReachTuple.ARITY_ONE,
- true // out-of-context
- )
- )
+ Canonical.addUpArity( baseState,
+ ReachTuple.factory( as.getSummary(),
+ true, // multi
+ ReachTuple.ARITY_ONE,
+ true // out-of-context
+ )
+ )
);
for( int i = 0; i < as.getAllocationDepth(); ++i ) {
out = Canonical.add( out,
- Canonical.add( baseState,
- ReachTuple.factory( as.getIthOldest( i ),
- false, // multi
- ReachTuple.ARITY_ONE,
- true // out-of-context
- )
- )
+ Canonical.addUpArity( baseState,
+ ReachTuple.factory( as.getIthOldest( i ),
+ false, // multi
+ ReachTuple.ARITY_ONE,
+ true // out-of-context
+ )
+ )
);
}
if( age == AllocSite.SHADOWAGE_notInThisSite ) {
// things not from the site just go back in
- out = Canonical.add( out, rt );
+ out = Canonical.addUpArity( out, rt );
} else {
assert !rt.isOutOfContext();
// otherwise unshadow it
- out = Canonical.add( out,
- ReachTuple.factory( -rt.getHrnID(),
- rt.isMultiObject(),
- rt.getArity(),
- false
- )
- );
+ out = Canonical.addUpArity( out,
+ ReachTuple.factory( -rt.getHrnID(),
+ rt.isMultiObject(),
+ rt.getArity(),
+ false
+ )
+ );
}
}
// possible changes, so keep a running union with the edge's
// partially updated new beta set
e.setBetaNew( Canonical.unionORpreds( e.getBetaNew(),
- localDelta
- )
+ localDelta
+ )
);
edgesWithNewBeta.add( e );
rt.isOutOfContext()
);
if( !oocHrnIdOoc2callee.contains( hio ) ) {
- stateNew = Canonical.add( stateNew, rt );
+ stateNew = Canonical.addUpArity( stateNew, rt );
continue;
}
if( age == AllocSite.AGE_notInThisSite ) {
// things not from the site just go back in
- stateNew = Canonical.add( stateNew, rt );
+ stateNew = Canonical.addUpArity( stateNew, rt );
} else if( age == AllocSite.AGE_summary ||
rt.isOutOfContext()
) {
- // the in-context summary and all existing out-of-context
- // stuff all become
- stateNew = Canonical.add( stateNew,
- ReachTuple.factory( as.getSummary(),
- true, // multi
- rt.getArity(),
- true // out-of-context
- )
- );
+
+ stateNew = Canonical.addUpArity( stateNew,
+ ReachTuple.factory( as.getSummary(),
+ true, // multi
+ rt.getArity(),
+ true // out-of-context
+ )
+ );
+
} else {
// otherwise everything else just goes to an out-of-context
// version, everything else the same
assert !rt.isMultiObject();
- stateNew = Canonical.add( stateNew,
- ReachTuple.factory( rt.getHrnID(),
- rt.isMultiObject(),
- rt.getArity(),
- true // out-of-context
- )
- );
+ stateNew = Canonical.addUpArity( stateNew,
+ ReachTuple.factory( rt.getHrnID(),
+ rt.isMultiObject(), // multi
+ rt.getArity(),
+ true // out-of-context
+ )
+ );
}
}
}
if( !foundState ) {
- markedHrnIDs = Canonical.add( markedHrnIDs, rtOld );
+ markedHrnIDs = Canonical.addUpArity( markedHrnIDs, rtOld );
}
}
ReachTuple rtOld = rtItr.next();
if( !markedHrnIDs.containsTuple( rtOld ) ) {
- statePruned = Canonical.add( statePruned, rtOld );
+ statePruned = Canonical.addUpArity( statePruned, rtOld );
}
}
assert !stateOld.equals( statePruned );