MCPcopy Create free account
hub / github.com/csmith-project/csmith / visit_facts

Method visit_facts

src/FunctionInvocation.cpp:505–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

503}
504
505bool
506FunctionInvocation::visit_facts(vector<const Fact*>& inputs, CGContext& cg_context) const
507{
508 bool unordered = false; //has_uncertain_call();
509 bool ok = false;
510 bool is_func_call = (invoke_type == eFuncCall);
511 static int g = 0;
512 Effect running_eff_context(cg_context.get_effect_context());
513 if (!unordered) {
514 // unsigned int flags = ptr_cmp ? (cg_context.flags | NO_DANGLING_PTR) : cg_context.flags;
515 for (size_t i=0; i<param_value.size(); i++) {
516 Effect param_eff_accum;
517 int h = g++;
518 CGContext param_cg_context(cg_context, running_eff_context, &param_eff_accum);
519 // the parameters might be function calls
520 const Expression* value = param_value[i];
521 if (h == 236)
522 BREAK_NOP; // for debugging
523 if (!value->visit_facts(inputs, param_cg_context)) {
524 return false;
525 }
526 // Update the "running effect context": the context that we must use
527 // when we generate subsequent parameters within this invocation.
528 running_eff_context.add_effect(param_eff_accum);
529 // Update the total effect of this invocation, too.
530 cg_context.merge_param_context(param_cg_context, !is_func_call);
531 }
532 ok = true;
533 }
534 else {
535 ok = visit_unordered_params(inputs, cg_context);
536 }
537 if (ok && is_func_call) {
538 // make a copy of env
539 vector<const Fact*> inputs_copy = inputs;
540 const FunctionInvocationUser* func_call = dynamic_cast<const FunctionInvocationUser*>(this);
541 Effect effect_accum;
542 //CGContext new_context(func_call->func, cg_context.get_effect_context(), &effect_accum);
543 CGContext new_context(cg_context, func_call->func, cg_context.get_effect_context(), &effect_accum);
544 ok = func_call->revisit(inputs, new_context);
545 if (ok) {
546 assert(cg_context.curr_blk);
547 //cg_context.add_external_effect(*new_context.get_effect_accum());
548 cg_context.add_visible_effect(*new_context.get_effect_accum(), cg_context.curr_blk);
549 Effect& func_effect = func_call->func->feffect;
550 func_effect.add_external_effect(*new_context.get_effect_accum(), cg_context.call_chain);
551 }
552 }
553 return ok;
554}
555
556/*
557 * Build an "invocation" of a binary operation.

Callers 1

Calls 7

sizeMethod · 0.80
merge_param_contextMethod · 0.80
revisitMethod · 0.80
add_visible_effectMethod · 0.80
get_effect_accumMethod · 0.80
add_effectMethod · 0.45
add_external_effectMethod · 0.45

Tested by

no test coverage detected