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

OOP: fixed usage of 'this' as actual parameter in a function call (Bug 563718)


Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
Change-Id: Iabbfe5461545d9e02418d140b0374d927abb0e79
parent adbfed7f
......@@ -1039,6 +1039,9 @@ namespace Ttcn {
if (!Ref_base::has_single_expr()) {
return false;
}
if (reftype == REF_THIS && id == NULL) {
return false;
}
if (parlist != NULL) {
Common::Assignment* ass = get_refd_assignment();
const FormalParList* fplist = (ass != NULL) ? ass->get_FormalParList() : NULL;
......@@ -1124,8 +1127,10 @@ namespace Ttcn {
expr->expr = mputstr(expr->expr, "this->");
}
else { // no 'id' means it's just a 'this' reference
expr->expr = mputprintf(expr->expr, "%s(this)",
ass->get_Type()->get_genname_value(my_scope).c_str());
string tmp_id = my_scope->get_scope_mod_gen()->get_temporary_id();
expr->preamble = mputprintf(expr->preamble, "%s %s(this);\n",
ass->get_Type()->get_genname_value(my_scope).c_str(), tmp_id.c_str());
expr->expr = mputprintf(expr->expr, "%s", tmp_id.c_str());
return;
}
}
......
......@@ -33,6 +33,10 @@ type union Uni {
charstring cs
}
function f_this_as_param(object p) {
log(p);
}
type class BaseClass runs on CT mtc CT system CT {
public const integer m_const := 1;
private const IntList m_const2 := { 1, 2, 3 };
......@@ -96,6 +100,7 @@ type class BaseClass runs on CT mtc CT system CT {
if (this != v_ref2) {
setverdict(fail, "inequality failed");
}
f_this_as_param(this);
}
}
finally {
......
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