diff --git a/compiler2/Type_chk.cc b/compiler2/Type_chk.cc index 3473861e45b8cde11245abe3ee3fcd8474e3e744..3c957134595eb078ad22b75d97054c433d18932f 100644 --- a/compiler2/Type_chk.cc +++ b/compiler2/Type_chk.cc @@ -3197,7 +3197,7 @@ bool Type::chk_this_value(Value *value, Common::Assignment *lhs, expected_value_ chk(); Value *v_last = value->get_value_refd_last(0, expected_value); if (v_last->get_valuetype() == Value::V_OMIT) { - if (!omit_allowed) { + if (OMIT_NOT_ALLOWED == omit_allowed) { value->error("`omit' value is not allowed in this context"); value->set_valuetype(Value::V_ERROR); } @@ -3353,7 +3353,7 @@ bool Type::chk_this_value(Value *value, Common::Assignment *lhs, expected_value_ } // switch // check value against subtype - if(sub_chk && (sub_type!=NULL)) sub_type->chk_this_value(value); + if(SUB_CHK == sub_chk && (sub_type!=NULL)) sub_type->chk_this_value(value); return self_ref; } @@ -3503,7 +3503,7 @@ bool Type::chk_this_refd_value(Value *value, Common::Assignment *lhs, expected_v } TypeCompatInfo info(value->get_my_scope()->get_scope_mod(), this, governor, true, false); - info.set_str1_elem(str_elem); + info.set_str1_elem(IS_STR_ELEM == str_elem); if (ref->get_subrefs()) info.set_str2_elem(ref->get_subrefs()->refers_to_string_element()); TypeChain l_chain; TypeChain r_chain; @@ -4271,7 +4271,7 @@ bool Type::chk_this_value_Seq_T(Value *value, Common::Assignment *lhs, expected_ CompField *cf = get_comp_byName(value_id); // check the ordering of fields if (in_synch) { - if (incomplete_allowed) { + if (INCOMPLETE_ALLOWED == incomplete_allowed) { bool found = false; for (size_t i = next_index; i < n_type_comps; i++) { CompField *cf2 = get_comp_byIndex(i); @@ -4292,7 +4292,7 @@ bool Type::chk_this_value_Seq_T(Value *value, Common::Assignment *lhs, expected_ // the value must be complete unless implicit omit is set CompField *cf2 = get_comp_byIndex(seq_index); CompField *cf2_orig = cf2; - while (implicit_omit && seq_index < n_type_comps && cf2 != cf && + while (IMPLICIT_OMIT == implicit_omit && seq_index < n_type_comps && cf2 != cf && cf2->get_is_optional()) cf2 = get_comp_byIndex(++seq_index); if (seq_index >= n_type_comps || cf2 != cf) { @@ -4307,7 +4307,7 @@ bool Type::chk_this_value_Seq_T(Value *value, Common::Assignment *lhs, expected_ Value *comp_value = nv->get_value(); comp_value->set_my_governor(type); if (comp_value->get_valuetype() == Value::V_NOTUSED) { - if (implicit_omit) { + if (IMPLICIT_OMIT == implicit_omit) { comp_value->set_valuetype(Value::V_OMIT); } else { continue; @@ -4322,16 +4322,16 @@ bool Type::chk_this_value_Seq_T(Value *value, Common::Assignment *lhs, expected_ is_empty = false; } } - if (incomplete_allowed != INCOMPLETE_ALLOWED || implicit_omit) { + if (INCOMPLETE_ALLOWED != incomplete_allowed || IMPLICIT_OMIT == implicit_omit) { for (size_t i = 0; i < n_type_comps; i++) { const Identifier& id = get_comp_byIndex(i)->get_name(); if (!comp_map.has_key(id.get_name())) { - if (get_comp_byIndex(i)->get_is_optional() && implicit_omit) { + if (get_comp_byIndex(i)->get_is_optional() && IMPLICIT_OMIT == implicit_omit) { value->add_se_comp(new NamedValue(new Identifier(id), new Value(Value::V_OMIT))); is_empty = false; } - else if (!incomplete_allowed) + else if (INCOMPLETE_ALLOWED != incomplete_allowed) value->error("Field `%s' is missing from record value", id.get_dispname().c_str()); else if (incomplete_allowed == WARNING_FOR_INCOMPLETE) { @@ -4378,7 +4378,7 @@ bool Type::chk_this_value_Set_T(Value *value, Common::Assignment *lhs, expected_ Value *comp_value = nv->get_value(); comp_value->set_my_governor(type); if (comp_value->get_valuetype() == Value::V_NOTUSED) { - if (implicit_omit) { + if (IMPLICIT_OMIT == implicit_omit) { comp_value->set_valuetype(Value::V_OMIT); } else { continue; @@ -4393,16 +4393,16 @@ bool Type::chk_this_value_Set_T(Value *value, Common::Assignment *lhs, expected_ is_empty = false; } } - if (incomplete_allowed != INCOMPLETE_ALLOWED || implicit_omit) { + if (INCOMPLETE_ALLOWED != incomplete_allowed || IMPLICIT_OMIT == implicit_omit) { for (size_t i = 0; i < n_type_comps; i++) { const Identifier& id = get_comp_byIndex(i)->get_name(); if(!comp_map.has_key(id.get_name())) { - if (get_comp_byIndex(i)->get_is_optional() && implicit_omit) { + if (get_comp_byIndex(i)->get_is_optional() && IMPLICIT_OMIT == implicit_omit) { value->add_se_comp(new NamedValue(new Identifier(id), new Value(Value::V_OMIT))); is_empty = false; } - else if (!incomplete_allowed) + else if (INCOMPLETE_ALLOWED != incomplete_allowed) value->error("Field `%s' is missing from set value", id.get_dispname().c_str()); else if (incomplete_allowed == WARNING_FOR_INCOMPLETE) { @@ -4475,7 +4475,7 @@ bool Type::chk_this_value_Seq_A(Value *value, Common::Assignment *lhs, expected_ for ( ; t_i < n_type_comps; t_i++) { cf2 = u.secho.ctss->get_comp_byIndex(t_i); if (cf2 == cf || (!cf2->get_is_optional() && !cf2->has_default() && - !implicit_omit)) + IMPLICIT_OMIT != implicit_omit)) break; } if (cf2 != cf) { @@ -4506,7 +4506,7 @@ bool Type::chk_this_value_Seq_A(Value *value, Common::Assignment *lhs, expected_ if (!cf->get_is_optional() && !cf->has_default()) value->error("Mandatory component `%s' is missing from SEQUENCE value", id.get_dispname().c_str()); - else if (cf->get_is_optional() && implicit_omit) + else if (cf->get_is_optional() && IMPLICIT_OMIT == implicit_omit) value->add_se_comp(new NamedValue(new Identifier(id), new Value(Value::V_OMIT))); } @@ -4554,7 +4554,7 @@ bool Type::chk_this_value_Set_A(Value *value, Common::Assignment *lhs, expected_ if (!cf->get_is_optional() && !cf->has_default()) value->error("Mandatory component `%s' is missing from SET value", id.get_dispname().c_str()); - else if (cf->get_is_optional() && implicit_omit) + else if (cf->get_is_optional() && IMPLICIT_OMIT == implicit_omit) value->add_se_comp(new NamedValue(new Identifier(id), new Value(Value::V_OMIT))); } @@ -4591,7 +4591,7 @@ bool Type::chk_this_value_SeOf(Value *value, Common::Assignment *lhs, expected_v (unsigned long)(i + 1)); v_comp->set_my_governor(u.seof.ofType); if (v_comp->get_valuetype() == Value::V_NOTUSED) { - if (!incomplete_allowed) + if (INCOMPLETE_ALLOWED != incomplete_allowed) v_comp->error("Not used symbol `-' is not allowed in this " "context"); else if (incomplete_allowed == WARNING_FOR_INCOMPLETE) { @@ -4732,7 +4732,7 @@ bool Type::chk_this_value_Array(Value *value, Common::Assignment *lhs, expected_ Value *v_comp = value->get_comp_byIndex(i); v_comp->set_my_governor(u.array.element_type); if (v_comp->get_valuetype() == Value::V_NOTUSED) { - if (!incomplete_allowed) + if (INCOMPLETE_ALLOWED != incomplete_allowed) v_comp->error("Not used symbol `-' is not allowed in this " "context"); else if (incomplete_allowed == WARNING_FOR_INCOMPLETE) { @@ -4853,7 +4853,7 @@ bool Type::chk_this_value_Signature(Value *value, Common::Assignment *lhs, CompField *cf = get_comp_byName(value_id); // check the ordering of fields if (in_synch) { - if (incomplete_allowed) { + if (INCOMPLETE_ALLOWED == incomplete_allowed) { bool found = false; for (size_t i = next_index; i < n_type_comps; i++) { CompField *cf2 = get_comp_byIndex(i); @@ -4891,7 +4891,7 @@ bool Type::chk_this_value_Signature(Value *value, Common::Assignment *lhs, INCOMPLETE_NOT_ALLOWED, cf->get_is_optional() ? OMIT_ALLOWED : OMIT_NOT_ALLOWED, SUB_CHK); } - if (!incomplete_allowed) { + if (INCOMPLETE_ALLOWED != incomplete_allowed) { for (size_t i = 0; i < u.signature.parameters->get_nof_in_params(); i++) { const Identifier& id = get_comp_byIndex(i)->get_name(); //u.signature.parameters->get_param_byIndex(n) if (!comp_map.has_key(id.get_name()) && SignatureParam::PARAM_OUT != u.signature.parameters->get_in_param_byIndex(i)->get_direction()) { @@ -5504,11 +5504,11 @@ bool Type::chk_this_template_generic(Template *t, namedbool incomplete_allowed, namedbool implicit_omit, Common::Assignment *lhs) { bool self_ref = false; - if (!allow_omit && t->get_template_refd_last()->get_templatetype() == + if (OMIT_ALLOWED != allow_omit && t->get_template_refd_last()->get_templatetype() == Ttcn::Template::OMIT_VALUE) { t->error("`omit' value is not allowed in this context"); } - if (!allow_any_or_omit && t->get_template_refd_last()->get_templatetype() == + if (ANY_OR_OMIT_ALLOWED != allow_any_or_omit && t->get_template_refd_last()->get_templatetype() == Ttcn::Template::ANY_OR_OMIT) { t->error("Using `*' for mandatory field"); } @@ -5622,9 +5622,9 @@ bool Type::chk_this_template_generic(Template *t, namedbool incomplete_allowed, break; } if (t->get_length_restriction()) chk_this_template_length_restriction(t); - if (!allow_omit && t->get_ifpresent()) + if (OMIT_ALLOWED != allow_omit && t->get_ifpresent()) t->error("`ifpresent' is not allowed here"); - if(sub_chk && temptype != Ttcn::Template::PERMUTATION_MATCH) { + if(SUB_CHK == sub_chk && temptype != Ttcn::Template::PERMUTATION_MATCH) { /* Note: A "permuation" itself has no type - it is just a fragment. */ if(sub_type!=NULL) sub_type->chk_this_template_generic(t); } @@ -6118,7 +6118,7 @@ bool Type::chk_this_template_Seq(Template *t, namedbool incomplete_allowed, CompField *cf = get_comp_byName(temp_id); if (in_synch) { - if (incomplete_allowed) { + if (INCOMPLETE_ALLOWED == incomplete_allowed) { // missing fields are allowed, but take care of ordering bool found = false; for (size_t j = next_index; j < n_type_comps; j++) { @@ -6141,7 +6141,7 @@ bool Type::chk_this_template_Seq(Template *t, namedbool incomplete_allowed, // the template must be complete CompField *cf2 = get_comp_byIndex(i); if (cf2 != cf) { - if (!cf2->get_is_optional() || !implicit_omit) { + if (!cf2->get_is_optional() || IMPLICIT_OMIT != implicit_omit) { namedtemp->error("Unexpected field `%s' in record template, " "expecting `%s'", temp_dispname_str, cf2->get_name().get_dispname().c_str()); @@ -6162,17 +6162,17 @@ bool Type::chk_this_template_Seq(Template *t, namedbool incomplete_allowed, (is_optional ? ANY_OR_OMIT_ALLOWED : ANY_OR_OMIT_NOT_ALLOWED), SUB_CHK, implicit_omit, lhs); } - if (incomplete_allowed != INCOMPLETE_ALLOWED || implicit_omit) { + if (incomplete_allowed != INCOMPLETE_ALLOWED || IMPLICIT_OMIT == implicit_omit) { // check missing fields for (size_t i = 0; i < n_type_comps; i++) { const Identifier& id = get_comp_byIndex(i)->get_name(); if (!comp_map.has_key(id.get_name())) { - if (implicit_omit && get_comp_byIndex(i)->get_is_optional()) { + if (IMPLICIT_OMIT == implicit_omit && get_comp_byIndex(i)->get_is_optional()) { // do not overwrite base fields if (!t->get_base_template()) t->add_named_temp(new Ttcn::NamedTemplate(new Identifier(id), new Template(Template::OMIT_VALUE))); - } else if (!incomplete_allowed) { + } else if (INCOMPLETE_ALLOWED != incomplete_allowed) { t->error("Field `%s' is missing from template for record type `%s'", id.get_dispname().c_str(), get_typename().c_str()); } @@ -6246,17 +6246,17 @@ bool Type::chk_this_template_Set(Template *t, (is_optional ? ANY_OR_OMIT_ALLOWED : ANY_OR_OMIT_NOT_ALLOWED), SUB_CHK, implicit_omit, lhs); } - if (incomplete_allowed != INCOMPLETE_ALLOWED || implicit_omit) { + if (incomplete_allowed != INCOMPLETE_ALLOWED || IMPLICIT_OMIT == implicit_omit) { // check missing fields for (size_t i = 0; i < n_type_comps; i++) { const Identifier& id = get_comp_byIndex(i)->get_name(); if (!comp_map.has_key(id.get_name())) { - if (get_comp_byIndex(i)->get_is_optional() && implicit_omit) { + if (get_comp_byIndex(i)->get_is_optional() && IMPLICIT_OMIT == implicit_omit) { // do not overwrite base fields if (!t->get_base_template()) t->add_named_temp(new Ttcn::NamedTemplate(new Identifier(id), new Template(Template::OMIT_VALUE))); - } else if (!incomplete_allowed) { + } else if (INCOMPLETE_ALLOWED != incomplete_allowed) { t->error("Field `%s' is missing from template for set type `%s'", id.get_dispname().c_str(), get_typename().c_str()); } @@ -6304,7 +6304,7 @@ bool Type::chk_this_template_SeqOf(Template *t, namedbool incomplete_allowed, break; } case Ttcn::Template::TEMPLATE_LIST: { Ttcn::Template::completeness_t c = - t->get_completeness_condition_seof(incomplete_allowed); + t->get_completeness_condition_seof(INCOMPLETE_ALLOWED == incomplete_allowed); Template *t_base; size_t nof_base_comps; if (c == Ttcn::Template::C_PARTIAL) { @@ -6443,7 +6443,7 @@ bool Type::chk_this_template_SetOf(Template *t, namedbool incomplete_allowed, break;} case Ttcn::Template::TEMPLATE_LIST: { Ttcn::Template::completeness_t c = - t->get_completeness_condition_seof(incomplete_allowed); + t->get_completeness_condition_seof(INCOMPLETE_ALLOWED == incomplete_allowed); Template *t_base; size_t nof_base_comps; if (c == Ttcn::Template::C_PARTIAL) { @@ -6607,7 +6607,7 @@ bool Type::chk_this_template_array(Template *t, namedbool incomplete_allowed, implicit_omit, lhs); break; case Ttcn::Template::TEMPLATE_NOTUSED: - if (!incomplete_allowed) + if (INCOMPLETE_ALLOWED != incomplete_allowed) t_comp->error("Not used symbol `-' is not allowed in this " "context"); else if (incomplete_allowed == WARNING_FOR_INCOMPLETE) { @@ -6752,7 +6752,7 @@ void Type::chk_this_template_Signature(Template *t, namedbool incomplete_allowed if(!first_undef_out) first_undef_out = par; break; default: //inout - if (!incomplete_allowed) { + if (INCOMPLETE_ALLOWED != incomplete_allowed) { t->error("Signature template is incomplete, because the inout " "parameter `%s' is missing", id.get_dispname().c_str()); } @@ -6764,7 +6764,7 @@ void Type::chk_this_template_Signature(Template *t, namedbool incomplete_allowed } } if(first_undef_in!=NULL && first_undef_out!=NULL) { - if (!incomplete_allowed) { + if (INCOMPLETE_ALLOWED != incomplete_allowed) { t->error("Signature template is incomplete, because the in parameter " "`%s' and the out parameter `%s' are missing", first_undef_in->get_id().get_dispname().c_str(), diff --git a/compiler2/subtype.cc b/compiler2/subtype.cc index 55a55b1ebe2f1554040385fc6e9c9e2707f12981..1157f826355833b76feccd3fc5c8122647733d4c 100644 --- a/compiler2/subtype.cc +++ b/compiler2/subtype.cc @@ -1926,7 +1926,7 @@ void SubType::chk_this_template(Template *templ) { switch (templ->get_templatetype()) { case Template::TEMPLATE_LIST: - if ( (length_restriction!=NULL) && !length_restriction->is_empty() ) { + if ( (length_restriction!=NULL) && TTRUE != length_restriction->is_empty() ) { size_t nof_comp_woaon = templ->get_nof_comps_not_anyornone(); if (!templ->temps_contains_anyornone_symbol() && nof_comp_woaon < length_restriction->get_minimal().get_size()) { @@ -2083,7 +2083,7 @@ void SubType::chk_this_template_pattern(const char *patt_type, Template *templ) templ->error("Template is incompatible with subtype"); return; } - if ( (length_restriction!=NULL) && !length_restriction->is_empty() ) { + if ( (length_restriction!=NULL) && TTRUE != length_restriction->is_empty() ) { Int patt_min_len = static_cast<Int>(templ->get_min_length_of_pattern()); if (patt_min_len < (Int)(length_restriction->get_minimal().get_size()) && !templ->pattern_contains_anyornone_symbol()) { @@ -3032,7 +3032,7 @@ Int SubType::get_length_restriction() const if (checked!=STC_YES) FATAL_ERROR("SubType::get_length_restriction()"); if (parsed==NULL) return -1; // only own length restriction counts if (length_restriction==NULL) return -1; - if (length_restriction->is_empty()) return -1; + if (TTRUE == length_restriction->is_empty()) return -1; return ( (length_restriction->get_minimal()==length_restriction->get_maximal()) ? (Int)(length_restriction->get_minimal().get_size()) : -1 ); diff --git a/compiler2/ttcn3/AST_ttcn3.cc b/compiler2/ttcn3/AST_ttcn3.cc index 493bc0cdbba9054dfa86d6e8b080b499461a2d14..d46db573fa1c5df67fce48bf5c708fccd692b7d4 100644 --- a/compiler2/ttcn3/AST_ttcn3.cc +++ b/compiler2/ttcn3/AST_ttcn3.cc @@ -3892,7 +3892,7 @@ namespace Ttcn { Code::merge_cdef(target, &cdef); Code::free_cdef(&cdef); - if (has_implicit_omit_attr()) { + if (IMPLICIT_OMIT == has_implicit_omit_attr()) { target->functions.post_init = mputprintf(target->functions.post_init, "modulepar_%s.set_implicit_omit();\n", name); } @@ -4021,7 +4021,7 @@ namespace Ttcn { } break; default: - if (has_implicit_omit_attr()) { + if (IMPLICIT_OMIT == has_implicit_omit_attr()) { error("Implicit omit not supported for template module parameters"); } #if defined(MINGW) @@ -4040,7 +4040,7 @@ namespace Ttcn { type->chk_this_template_ref(def_template); checked = true; type->chk_this_template_generic(def_template, INCOMPLETE_ALLOWED, - OMIT_ALLOWED, ANY_OR_OMIT_ALLOWED, SUB_CHK, has_implicit_omit_attr() ? IMPLICIT_OMIT : NOT_IMPLICIT_OMIT, 0); + OMIT_ALLOWED, ANY_OR_OMIT_ALLOWED, SUB_CHK, IMPLICIT_OMIT == has_implicit_omit_attr() ? IMPLICIT_OMIT : NOT_IMPLICIT_OMIT, 0); if (!semantic_check_only) { def_template->set_genname_prefix("modulepar_"); def_template->set_genname_recursive(get_genname()); @@ -4067,7 +4067,7 @@ namespace Ttcn { Code::merge_cdef(target, &cdef); Code::free_cdef(&cdef); - if (has_implicit_omit_attr()) { + if (IMPLICIT_OMIT == has_implicit_omit_attr()) { FATAL_ERROR("Def_Modulepar_Template::generate_code()"); } @@ -4238,7 +4238,7 @@ namespace Ttcn { type->chk_this_template_generic(body, derived_ref != NULL ? INCOMPLETE_ALLOWED : WARNING_FOR_INCOMPLETE, OMIT_ALLOWED, ANY_OR_OMIT_ALLOWED, SUB_CHK, - has_implicit_omit_attr() ? IMPLICIT_OMIT : NOT_IMPLICIT_OMIT, 0); + IMPLICIT_OMIT == has_implicit_omit_attr() ? IMPLICIT_OMIT : NOT_IMPLICIT_OMIT, 0); erroneous_attrs = chk_erroneous_attr(w_attrib_path, type, get_my_scope(), get_fullname(), false);