コード例 #1
0
void MultiWayGroup::generate_code(StatementList *x,
				  IInteger bound_below,
                                  IInteger bound_above) {
    Expression *low_check = NULL;
    Expression *high_check = NULL;
    DataType *bool_type = get_type_builder(_env)->get_boolean_type();

    // if there are no more than two entries, build if statements

    int lab_count = get_label_count();
    if (lab_count <= 2) {
	for (int i=0;i < lab_count; i ++) {
	    MultiWayBranchStatement::case_pair pair = _statement->get_case(i);

	    low_check = create_binary_expression(_env,
                                                 bool_type,
                                                 k_is_equal_to,
                                                 create_var_use(_decision),
                                                 ie(pair.first));
            x->append_statement(create_branch_statement(_env,low_check,pair.second));
	    }
	x->append_statement(create_jump_statement(_env,_default_lab));
	delete _statement;
	_statement = 0;
	return;
	}
  	
    if (bound_below.is_undetermined() || (_low_bound > bound_below + 1)) {
	low_check = create_binary_expression(_env,
						 bool_type,
						 k_is_less_than,
						 create_var_use(_decision),
						 ie(_low_bound));
	x->append_statement(create_branch_statement(_env,low_check,_default_lab));
	}
    if (bound_above.is_undetermined() || (_high_bound < bound_above)) {
        high_check = create_binary_expression(_env,
                                                 bool_type,
                                                 k_is_greater_than,
                                                 create_var_use(_decision),
                                                 ie(_high_bound));
	x->append_statement(create_branch_statement(_env,high_check,_default_lab));
        }

    // in fill the statement so that missing entries are added so as to 
    // complete the table

    IInteger next_value = _low_bound;
    while (next_value < _high_bound) {
	if (!_statement->lookup_case(next_value)) {
	    _statement->insert_case(next_value,_default_lab);
	    }	
	next_value ++;
	}
    
    x->append_statement(_statement);
    }
コード例 #2
0
ConstantLattice::ConstantLattice(IInteger value) :
  _key(B_CONST),
  _value(value)
{
  assert(!value.is_undetermined());
  assert(!value.is_signless_infinity());
}
コード例 #3
0
void MarkGuardedFors::
do_procedure_definition(ProcedureDefinition *pd) 
{
  for (Iter<ForStatement> iter = object_iterator<ForStatement>(pd);
       iter.is_valid(); iter.next()) {
    ForStatement *the_for = &iter.current();
    if (is_for_statement_guarded(the_for)) continue;

    IInteger ii = 
      evaluate_for_statement_entry_test(the_for);
    if (ii.is_undetermined()) return;
    if (ii == 0)  return;
    if (ii == 1) {
      set_for_statement_guarded(the_for);
    }
  }
}