本文整理汇总了C++中ProgramState类的典型用法代码示例。如果您正苦于以下问题:C++ ProgramState类的具体用法?C++ ProgramState怎么用?C++ ProgramState使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProgramState类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc,char** argv) {
cout << "Hello Lord Firal" << endl;
int i;
// create program state
ProgramState* state = new ProgramState();
state->setRunning(true);
// read in flags
while((i=getopt(argc,argv,"tu:")) != EOF) {
switch(i) {
case 'u': {
state->setRunning(false);
break;
}
case 'l': {
// load in the parameter
break;
}
default:
break;
}
}
// process flags
// run the program
if(state->getRunning()) {
Lazy* program = new Lazy(state);
program->run();
delete program;
}
return 0;
}
示例2: ProgramStateRelease
/// Decrement the number of times this state is referenced.
void ProgramStateRelease(const ProgramState *state) {
assert(state->refCount > 0);
ProgramState *s = const_cast<ProgramState*>(state);
if (--s->refCount == 0) {
ProgramStateManager &Mgr = s->getStateManager();
Mgr.StateSet.RemoveNode(s);
s->~ProgramState();
Mgr.freeStates.push_back(s);
}
}
示例3: recycleUnusedStates
void ProgramStateManager::recycleUnusedStates() {
for (std::vector<ProgramState*>::iterator i = recentlyAllocatedStates.begin(),
e = recentlyAllocatedStates.end(); i != e; ++i) {
ProgramState *state = *i;
if (state->referencedByExplodedNode())
continue;
StateSet.RemoveNode(state);
freeStates.push_back(state);
state->~ProgramState();
}
recentlyAllocatedStates.clear();
}
示例4: execute
void IfStatement::execute(ProgramState &state) {
bool evalTrue = false;
switch (op) {
case EQ:
evalTrue = state.getValueOf(variableName) == value;
break;
case NEQ:
evalTrue = state.getValueOf(variableName) != value;
break;
case LT:
evalTrue = state.getValueOf(variableName) < value;
break;
case LEQ:
evalTrue = state.getValueOf(variableName) <= value;
break;
case GT:
evalTrue = state.getValueOf(variableName) > value;
break;
case GEQ:
evalTrue = state.getValueOf(variableName) >= value;
break;
}
if(evalTrue) {
state.setPC(lineNumber);
}
else {
state.incrementPC();
}
}
示例5: getPersistentState
ProgramStateRef
ProgramStateManager::removeDeadBindings(ProgramStateRef state,
const StackFrameContext *LCtx,
SymbolReaper& SymReaper) {
// This code essentially performs a "mark-and-sweep" of the VariableBindings.
// The roots are any Block-level exprs and Decls that our liveness algorithm
// tells us are live. We then see what Decls they may reference, and keep
// those around. This code more than likely can be made faster, and the
// frequency of which this method is called should be experimented with
// for optimum performance.
ProgramState NewState = *state;
NewState.Env = EnvMgr.removeDeadBindings(NewState.Env, SymReaper, state);
// Clean up the store.
StoreRef newStore = StoreMgr->removeDeadBindings(NewState.getStore(), LCtx,
SymReaper);
NewState.setStore(newStore);
SymReaper.setReapedStore(newStore);
return getPersistentState(NewState);
}
示例6: new
ProgramStateRef ProgramStateManager::getPersistentState(ProgramState &State) {
llvm::FoldingSetNodeID ID;
State.Profile(ID);
void *InsertPos;
if (ProgramState *I = StateSet.FindNodeOrInsertPos(ID, InsertPos))
return I;
ProgramState *newState = nullptr;
if (!freeStates.empty()) {
newState = freeStates.back();
freeStates.pop_back();
}
else {
newState = (ProgramState*) Alloc.Allocate<ProgramState>();
}
new (newState) ProgramState(State);
StateSet.InsertNode(newState, InsertPos);
return newState;
}
示例7: execute
void ReturnStatement::execute(ProgramState &state) {
state.popPC();
}
示例8: execute
void GotoStatement::execute(ProgramState &state) {
state.setPC(lineNumber);
}
示例9: SetUpOrLoadInitialState
void SetUpOrLoadInitialState(CommandLineOpts &inception_state, SeqListClass &my_keys, TrackProgress &my_progress, ImageSpecClass &my_image_spec, SlicedPrequel& my_prequel_setup)
{
if ( !inception_state.bkg_control.signal_chunks.restart_from.empty() )
{
// restarting from saved computational state
// beadfind, bfmask.bin and beadfind.h5 will be ignored
// note that if we are here we will never load the separator data
inception_state.sys_context.GenerateContext (); // find our directories
inception_state.sys_context.SetUpAnalysisLocation();
LoadBeadFindState(inception_state, my_keys, my_image_spec);
}
else if (inception_state.mod_control.reusePriorBeadfind && inception_state.bkg_control.signal_chunks.restart_from.empty())
{
// starting execution fresh, justBeadFind already run
// get any state from beadFind
LoadBeadFindState(inception_state, my_keys, my_image_spec);
// save current command line options to state file
std::string stateFile = inception_state.sys_context.analysisLocation + "/analysisState.json";
if (rename(stateFile.c_str(),(inception_state.sys_context.analysisLocation+"/analysisState_beadfind.json").c_str()) )
{
fprintf(stdout, "Unable to copy beadfind analysisState.json");
}
SetUpKeys(my_keys, inception_state.key_context, inception_state.flow_context);
ProgramState state ( stateFile );
state.Save ( inception_state,my_keys,my_image_spec );
state.WriteState();
// region layout saved in inception_state.loc_context
// region definitions in background model via my_prequel_setup
my_prequel_setup.SetRegions ( inception_state.loc_context.numRegions,
my_image_spec.rows,my_image_spec.cols,
inception_state.loc_context.regionXSize,
inception_state.loc_context.regionYSize );
my_prequel_setup.FileLocations ( inception_state.sys_context.analysisLocation );
}
else
{
// starting execution fresh, justBeadFind not run
inception_state.SetUpProcessing();
CreateResultsFolder (inception_state.sys_context.GetResultsFolder());
inception_state.sys_context.SetUpAnalysisLocation();
// convert from old key representatino to more useful modern style
SetUpKeys(my_keys, inception_state.key_context, inception_state.flow_context);
//@TODO: side effects here on the entire image class
// after this point, Images will behave differently when read in
SetUpToProcessImages ( my_image_spec, inception_state );
// region layout saved into inception_state.loc_context
SetUpRegionsForAnalysis ( my_image_spec.rows, my_image_spec.cols, inception_state.loc_context );
// region layout shared in background model and beadfind via my_prequel_setup
my_prequel_setup.SetRegions ( inception_state.loc_context.numRegions,
my_image_spec.rows,my_image_spec.cols,
inception_state.loc_context.regionXSize,
inception_state.loc_context.regionYSize );
my_prequel_setup.FileLocations ( inception_state.sys_context.analysisLocation );
}
strncpy(ImageTransformer::PCATest,inception_state.img_control.PCATest,sizeof(ImageTransformer::PCATest)-1);
fprintf(stdout, "Analysis region size is width %d, height %d\n", inception_state.loc_context.regionXSize, inception_state.loc_context.regionYSize);
}
示例10: getStateManager
const ProgramState *ProgramState::makeWithStore(const StoreRef &store) const {
ProgramState NewSt = *this;
NewSt.setStore(store);
return getStateManager().getPersistentState(NewSt);
}
示例11: main
int main(int argc, char* argv[])
{
if (argc == 1) {
// We don't have arguments, we start the graphical interface.
QApplication a(argc, argv);
ComplexNetsGui::MainWindow w;
w.show();
return a.exec();
} else {
// We read the arguments sent at the command line.
ProgramState *state = new ProgramState();
struct gengetopt_args_info *args_info = (struct gengetopt_args_info *) malloc(sizeof(struct gengetopt_args_info));
if (cmdline_parser(argc, argv, args_info) != 0) {
usageErrorMessage("There was an error reading from the command line.");
ERROR_EXIT;
}
if (args_info->input_file_given) {
if (args_info->erdos_given || args_info->barabasi_given || args_info->hot_given || args_info->molloy_given || args_info->hyperbolic_given) {
usageErrorMessage("Cannot load a graph from an input file and generate a model at the same time.");
ERROR_EXIT;
}
if (args_info->weighted_given) {
state->setWeighted(true);
}
if (args_info->digraph_given) {
state->setDigraph(true);
}
string path = args_info->input_file_arg;
try {
state->readGraphFromFile(path.c_str());
cout << "Succesfully read graph from file " + path + "\n";
} catch (const FileNotFoundException& e) {
errorMessage("The specified input was not found in the filesystem.");
ERROR_EXIT;
} catch (const DuplicatedEdgeLoading& ex) {
errorMessage("The specified input file has duplicated edges.");
ERROR_EXIT;
} catch (...) {
errorMessage("There were problems reading the input file.");
ERROR_EXIT;
}
} else if (args_info->erdos_given) {
if (!args_info->n_given) {
usageErrorMessage("Erdos-Renyi graph generation requires a number of nodes.");
ERROR_EXIT;
}
if (!args_info->p_given) {
usageErrorMessage("Erdos-Renyi graph generation requires a probability.");
ERROR_EXIT;
}
int n = args_info->n_arg;
float p = args_info->p_arg;
VALIDATE_POS(n);
VALIDATE_P(p);
state->setErdosRenyiGraph(n, p);
cout << "Succesfully created an Erdos-Renyi graph with " + to_string(n) + " nodes.\n";
} else if (args_info->barabasi_given) {
if (!args_info->m0_given) {
usageErrorMessage("Barabasi-Albert graph generation requires an initial number of nodes.");
ERROR_EXIT;
}
if (!args_info->m_given) {
usageErrorMessage("Barabasi-Albert graph generation requires a number of nodes to attach with new nodes.");
ERROR_EXIT;
}
if (!args_info->n_given) {
usageErrorMessage("Barabasi-Albert graph generation requires a number of nodes.");
ERROR_EXIT;
}
int n = args_info->n_arg;
int m0 = args_info->m0_arg;
int m = args_info->m_arg;
VALIDATE_POS(n);
VALIDATE_POS(m0);
VALIDATE_POS(m);
if (m > m0) {
usageErrorMessage("The number of nodes to attach cannot be greater than the initial number of nodes.");
ERROR_EXIT;
}
state->setBarabasiAlbertGraph(m0, m, n);
cout << "Succesfully created a Barabasi-Albert graph with " + to_string(n) + " nodes.\n";
//.........这里部分代码省略.........