Commit 014b3866 authored by BenceJanosSzabo's avatar BenceJanosSzabo
Browse files

OER regression test fixes



Change-Id: I2db45aece5f22f9e853acc588c164582c61b1163
Signed-off-by: default avatarBenceJanosSzabo <bence.janos.szabo@ericsson.com>
parent ee77c173
...@@ -3004,45 +3004,50 @@ void Type::chk_oer() { ...@@ -3004,45 +3004,50 @@ void Type::chk_oer() {
break; break;
case T_INT_A: { case T_INT_A: {
if (is_constrained()) { if (is_constrained()) {
Location loc; if (get_sub_type()->is_integer_subtype_notempty()) {
int_limit_t upper = get_sub_type()->get_root()->get_int_limit(true, &loc); Location loc;
int_limit_t lower = get_sub_type()->get_root()->get_int_limit(false, &loc); int_limit_t upper = get_sub_type()->get_int_limit(true, &loc);
bool lower_inf = lower.get_type() != int_limit_t::NUMBER; int_limit_t lower = get_sub_type()->get_int_limit(false, &loc);
bool upper_inf = upper.get_type() != int_limit_t::NUMBER; bool lower_inf = lower.get_type() != int_limit_t::NUMBER;
if (lower_inf || upper_inf) { bool upper_inf = upper.get_type() != int_limit_t::NUMBER;
oerattrib->signed_ = lower_inf; if (lower_inf || upper_inf) {
oerattrib->bytes = -1; oerattrib->signed_ = lower_inf;
} else { oerattrib->bytes = -1;
int_val_t low = lower.get_value();
int_val_t up = upper.get_value();
if (low < 0) {
oerattrib->signed_ = true;
if (low >= -128 && up <= 127) {
oerattrib->bytes = 1;
} else if (low >= -32768 && up <= 32767) {
oerattrib->bytes = 2;
} else if (low >= -2147483648 && up <= 2147483647) {
oerattrib->bytes = 4;
} else if ((low+1) >= -9223372036854775807LL && up <= 9223372036854775807LL) {
oerattrib->bytes = 8;
} else {
oerattrib->bytes = -1;
}
} else { } else {
static int_val_t uns_8_byte("18446744073709551615", NULL); int_val_t low = lower.get_value();
oerattrib->signed_ = false; int_val_t up = upper.get_value();
if (up <= 255) { if (low < 0) {
oerattrib->bytes = 1; oerattrib->signed_ = true;
} else if (up <= 65535) { if (low >= -128 && up <= 127) {
oerattrib->bytes = 2; oerattrib->bytes = 1;
} else if (up <= 4294967295) { } else if (low >= -32768 && up <= 32767) {
oerattrib->bytes = 4; oerattrib->bytes = 2;
} else if (up <= uns_8_byte) { } else if (low >= -2147483648LL && up <= 2147483647) {
oerattrib->bytes = 8; oerattrib->bytes = 4;
} else if ((low+1) >= -9223372036854775807LL && up <= 9223372036854775807LL) {
oerattrib->bytes = 8;
} else {
oerattrib->bytes = -1;
}
} else { } else {
oerattrib->bytes = -1; static int_val_t uns_8_byte("18446744073709551615", NULL);
oerattrib->signed_ = false;
if (up <= 255) {
oerattrib->bytes = 1;
} else if (up <= 65535) {
oerattrib->bytes = 2;
} else if (up <= 4294967295LL) {
oerattrib->bytes = 4;
} else if (up <= uns_8_byte) {
oerattrib->bytes = 8;
} else {
oerattrib->bytes = -1;
}
} }
} }
} else {
oerattrib->signed_ = true;
oerattrib->bytes = -1;
} }
} else { } else {
oerattrib->signed_ = true; oerattrib->signed_ = true;
......
...@@ -218,6 +218,8 @@ public: ...@@ -218,6 +218,8 @@ public:
bool is_length_compatible(const SubtypeConstraint *p_st) const; bool is_length_compatible(const SubtypeConstraint *p_st) const;
bool is_upper_limit_infinity() const; bool is_upper_limit_infinity() const;
bool is_lower_limit_infinity() const; bool is_lower_limit_infinity() const;
bool is_integer_subtype_notempty() const
{ return subtype==ST_INTEGER && integer_st && !integer_st->is_empty(); }
}; };
/** /**
......
...@@ -666,8 +666,8 @@ namespace Ttcn { ...@@ -666,8 +666,8 @@ namespace Ttcn {
(type->has_encoding(Type::CT_RAW)&&ti_type->has_encoding(Type::CT_RAW)) || (type->has_encoding(Type::CT_RAW)&&ti_type->has_encoding(Type::CT_RAW)) ||
(type->has_encoding(Type::CT_TEXT)&&ti_type->has_encoding(Type::CT_TEXT)) || (type->has_encoding(Type::CT_TEXT)&&ti_type->has_encoding(Type::CT_TEXT)) ||
(type->has_encoding(Type::CT_XER)&&ti_type->has_encoding(Type::CT_XER)) || (type->has_encoding(Type::CT_XER)&&ti_type->has_encoding(Type::CT_XER)) ||
(type->has_encoding(Type::CT_JSON)&&ti_type->has_encoding(Type::CT_JSON))) || (type->has_encoding(Type::CT_JSON)&&ti_type->has_encoding(Type::CT_JSON)) ||
(type->has_encoding(Type::CT_OER)&&ti_type->has_encoding(Type::CT_OER))) { (type->has_encoding(Type::CT_OER)&&ti_type->has_encoding(Type::CT_OER)))) {
act_attr->error("Type `%s' and type `%s' have no common encoding", act_attr->error("Type `%s' and type `%s' have no common encoding",
ti_type->get_typename().c_str(), type->get_typename().c_str()); ti_type->get_typename().c_str(), type->get_typename().c_str());
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment