Commit a685eb2e authored by Botond Baranyi's avatar Botond Baranyi
Browse files

When checking whether a reference can be generated as a single expression, the...


When checking whether a reference can be generated as a single expression, the subreferences are taken into account, too (bug 563718)
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: I383875aa8802d050a9cd4bd3cd75a88e7c2342a4
parent b1b6c914
......@@ -1817,7 +1817,7 @@ namespace Common {
}
ap_list->set_fullname(parsed_pars->get_fullname());
ap_list->set_my_scope(parsed_pars->get_my_scope());
ref->set_actual_par_list(ap_list);
ref->set_parameter_list(ap_list, NULL);
}
t = get_pooltype(T_USTR);
// todo: set *last_method
......@@ -1876,7 +1876,7 @@ namespace Common {
}
ap_list->set_fullname(parsed_pars->get_fullname());
ap_list->set_my_scope(parsed_pars->get_my_scope());
ref->set_actual_par_list(ap_list);
ref->set_parameter_list(ap_list, fp_list);
}
if (last_method != NULL) {
*last_method = ass;
......
......@@ -236,14 +236,23 @@ namespace Ttcn {
return u.ff.ap_list;
}
void FieldOrArrayRef::set_actual_par_list(ActualParList* p_ap_list)
FormalParList* FieldOrArrayRef::get_formal_par_list() const
{
if (ref_type != FUNCTION_REF || !u.ff.checked) {
FATAL_ERROR("FieldOrArrayRef::get_formal_par_list()");
}
return u.ff.fp_list;
}
void FieldOrArrayRef::set_parameter_list(ActualParList* p_ap_list, FormalParList* p_fp_list)
{
if (ref_type != FUNCTION_REF || u.ff.checked) {
FATAL_ERROR("FieldOrArrayRef::set_actual_par_list()");
FATAL_ERROR("FieldOrArrayRef::set_parameter_list()");
}
u.ff.checked = true;
delete u.ff.parsed_pars;
u.ff.ap_list = p_ap_list;
u.ff.fp_list = p_fp_list;
}
void FieldOrArrayRef::append_stringRepr(string& str) const
......@@ -1080,6 +1089,19 @@ namespace Ttcn {
}
}
}
for (size_t i = 0; i < subrefs.get_nof_refs(); ++i) {
FieldOrArrayRef* subref = subrefs.get_ref(i);
if (subref->get_type() == FieldOrArrayRef::FUNCTION_REF) {
ActualParList* ap_list = subref->get_actual_par_list();
FormalParList* fp_list = subref->get_formal_par_list();
for (size_t j = 0; j < ap_list->get_nof_pars(); ++j) {
if (!ap_list->get_par(j)->has_single_expr(
fp_list != NULL ? fp_list->get_fp_byIndex(i) : NULL)) {
return false;
}
}
}
}
return true;
}
......
......@@ -205,7 +205,10 @@ namespace Ttcn {
bool checked;
union {
ParsedActualParameters* parsed_pars; ///< parsed function parameters, used by FUNCTION_REF
ActualParList* ap_list; ///< actual parameter list (after semantic analysis), used by FUNCTION_REF
struct {
ActualParList* ap_list; ///< actual parameter list (after semantic analysis), used by FUNCTION_REF
FormalParList* fp_list; ///< formal parameter list (after semantic analysis, not owned), used by FUNCTION_REF
};
};
} ff; ///< field or function
Value *arp; ///< value of the index, used by ARRAY_REF
......@@ -230,8 +233,9 @@ namespace Ttcn {
Value* get_val() const;
ParsedActualParameters* get_parsed_pars() const;
ActualParList* get_actual_par_list() const;
FormalParList* get_formal_par_list() const;
bool parameters_checked() const;
void set_actual_par_list(ActualParList* p_ap_list);
void set_parameter_list(ActualParList* p_ap_list, FormalParList* p_fp_list);
/** Appends the string representation of the sub-reference to \a str. */
void append_stringRepr(string& str) const;
/** Sets the first letter in the name of the field to lowercase if it's an
......
......@@ -470,6 +470,12 @@ function f_test_in(Node p1, Node2 p2) {
p2.f(p1.get_next());
}
type class InParTester {
public function test(object x) return boolean {
return x of Node;
}
}
testcase tc_function_pars_in() runs on CT {
var Node n1 := Node.create(1, Node.create(2, null));
var Node2 n2 := Node2.create(null, null);
......@@ -477,9 +483,11 @@ testcase tc_function_pars_in() runs on CT {
if (log2str(n2.get_data()) != log2str(n1.get_next())) {
setverdict(fail, "Expected: ", n1.get_next(), ", got: ", n2.get_data());
}
else {
setverdict(pass);
var InParTester t := InParTester.create;
if (not t.test(n1.get_next())) {
setverdict(fail, "InParTester failed");
}
setverdict(pass);
}
type class Something {
......
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