Example #1
0
simplerule::simplerule(ste * enclosures,
                       expr * condition,
                       ste * locals, stmt * body,
                       int priority)
    :rule(), name(name), enclosures(enclosures), condition(condition),
     locals(locals), body(body), condname(NULL), rulename(NULL),
     priority(priority)
{
    if (condition != NULL && body != NULL) {
        Error.CondError(condition->has_side_effects(),
                        "Rule Condition must not have side effects.");
        if (args->pmurphik) {
            Error.CondError(!type_equal(condition->gettype(), realtype),
                            "Condition for probabilistic rule must be a real expression.");
            if (condition->hasvalue()
                    && ((condition->getrvalue() < 0)
                        || (condition->getrvalue() > 1)))
                Error.Error("Real condition for rule must be >=0 and <=1.");
        } else
            Error.CondError(!type_equal(condition->gettype(), booltype),
                            "Condition for rule must be a boolean expression.");
    }
    NextSimpleRule = SimpleRuleList;
    SimpleRuleList = this;

    size = CountSize(enclosures);

    // Rearrange enclosures so that the ones that are NOT
    // mentioned in the condition go first
    rearrange_enclosures();
}
Example #2
0
File: rule.C Project: Jashinta/570
simplerule::simplerule(ste *enclosures,
		       expr *condition,
		       ste *locals,
		       stmt *body,
		       bool unfair,
                       int priority)
:rule(), name( name ), enclosures(enclosures),  condition(condition),
 locals(locals), body(body), condname(NULL), rulename(NULL), unfair(unfair),
 priority(priority)
{
  if ( condition != NULL && body != NULL )
    {
      Error.CondError(condition->has_side_effects(),
		      "Rule Condition must not have side effects.");
      Error.CondError(!type_equal(condition->gettype(), booltype),
		      "Condition for rule must be a boolean expression.");
    }
  NextSimpleRule = SimpleRuleList;
  SimpleRuleList = this;

  size = CountSize(enclosures);

  // Rearrange enclosures so that the ones that are NOT
  // mentioned in the condition go first
  rearrange_enclosures();
  
}