Commit 2cadead1 authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Fixed new default parameter code generation in encvalue arguments



Change-Id: I1957a0ee1e572d5b9194e77190f1195cb2adce25
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent a6e39624
......@@ -13917,10 +13917,14 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
expr->expr = mputprintf(expr->expr, "oct2bit(%s)", tmp_id.c_str());
if (expr2.postamble)
expr->postamble = mputstr(expr->postamble, expr2.postamble);
} else
} else {
if (expr2.preamble != NULL) {
expr->preamble = mputstr(expr->preamble, expr2.preamble);
}
expr->expr = mputprintf(expr->expr, "%s(%s%s)",
gov_last->get_legacy_coding_function(true)->get_genname_from_scope(scope).c_str(),
expr2.expr, is_templ ? ".valueof()" : "");
}
}
else { // new codec handling
Type* gov = templ->get_my_governor();
......@@ -14168,6 +14172,9 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
if (expr2.postamble)
expr->postamble = mputstr(expr->postamble, expr2.postamble);
} else {
if (expr2.preamble != NULL) {
expr->preamble = mputstr(expr->preamble, expr2.preamble);
}
expr->expr = mputprintf(expr->expr, "oct2unichar(bit2oct(%s(%s%s)), %s)",
gov_last->get_legacy_coding_function(true)->get_genname_from_scope(scope).c_str(),
expr2.expr, is_templ ? ".valueof()" : "", v2_code);
......
......@@ -26,4 +26,8 @@ void ef__reset()
current_number = 0;
}
BITSTRING ef__enc__uni(const Uni& x) {
return int2bit(x.i(), 8);
}
}
......@@ -38,6 +38,18 @@ type set Set {
record of integer roi
}
type union Uni {
integer i
}
with {
encode "custom"
}
// Custom encoding function for type Uni (equivalent to an 'int2bit' on the integer field)
external function ef_enc_uni(in Uni x) return bitstring
with { extension "prototype(convert) encode(custom)" }
type component CT {}
/******************** Templates *********************/
......@@ -86,4 +98,6 @@ template Set t_set_template_lists(
template Set.roi p3 := { [0] := 0, [ef_next_number()] := 3 })
:= { soi1 := p1, soi2 := p2, roi := p3 };
template Uni t_uni(template integer p := ef_next_number()) := { i := p };
}
......@@ -172,6 +172,34 @@ testcase tc_pard_def_template_lists() runs on CT
}
}
testcase tc_pard_def_encvalue_w_custom_encoding() runs on CT
{
ef_reset();
var bitstring results[4] := { encvalue(t_uni), encvalue(t_uni()), encvalue(t_uni(-)), encvalue(t_uni(p := -)) };
var bitstring exp_results[4] := { '00010110'B, '00010110'B, '00010110'B, '00010110'B };
if (results == exp_results) {
setverdict(pass);
}
else {
setverdict(fail, "Got: ", results, ", expected: ", exp_results);
}
}
testcase tc_pard_def_encvalue_unichar_w_custom_encoding() runs on CT
{
ef_reset();
var universal charstring results[4] := { encvalue_unichar(t_uni), encvalue_unichar(t_uni()),
encvalue_unichar(t_uni(-)), encvalue_unichar(t_uni(p := -)) };
var universal charstring exp_results[4] := { char(0, 0, 0, 22), char(0, 0, 0, 22),
char(0, 0, 0, 22), char(0, 0, 0, 22) };
if (results == exp_results) {
setverdict(pass);
}
else {
setverdict(fail, "Got: ", results, ", expected: ", exp_results);
}
}
control {
execute(tc_pard_def_int());
execute(tc_pard_def_int_expr());
......@@ -183,6 +211,8 @@ control {
execute(tc_pard_def_set());
execute(tc_pard_def_rec_named_template_list());
execute(tc_pard_def_template_lists());
execute(tc_pard_def_encvalue_w_custom_encoding());
execute(tc_pard_def_encvalue_unichar_w_custom_encoding());
}
}
......@@ -170,6 +170,34 @@ testcase tc_pard_def_template_lists() runs on CT
}
}
testcase tc_pard_def_encvalue_w_custom_encoding() runs on CT
{
ef_reset();
var bitstring results[4] := { encvalue(t_uni), encvalue(t_uni()), encvalue(t_uni(-)), encvalue(t_uni(p := -)) };
var bitstring exp_results[4] := { '00000001'B, '00000010'B, '00000011'B, '00000100'B };
if (results == exp_results) {
setverdict(pass);
}
else {
setverdict(fail, "Got: ", results, ", expected: ", exp_results);
}
}
testcase tc_pard_def_encvalue_unichar_w_custom_encoding() runs on CT
{
ef_reset();
var universal charstring results[4] := { encvalue_unichar(t_uni), encvalue_unichar(t_uni()),
encvalue_unichar(t_uni(-)), encvalue_unichar(t_uni(p := -)) };
var universal charstring exp_results[4] := { char(0, 0, 0, 1), char(0, 0, 0, 2),
char(0, 0, 0, 3), char(0, 0, 0, 4) };
if (results == exp_results) {
setverdict(pass);
}
else {
setverdict(fail, "Got: ", results, ", expected: ", exp_results);
}
}
control {
execute(tc_pard_def_int());
execute(tc_pard_def_int_expr());
......@@ -181,6 +209,8 @@ control {
execute(tc_pard_def_set());
execute(tc_pard_def_rec_named_template_list());
execute(tc_pard_def_template_lists());
execute(tc_pard_def_encvalue_w_custom_encoding());
execute(tc_pard_def_encvalue_unichar_w_custom_encoding());
}
}
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