Commit 7c3e386a authored by Botond Baranyi's avatar Botond Baranyi
Browse files

Implemented object-oriented features - stage 4 - reference refactoring (bug 552011)



Change-Id: I71a30baa221cafdbf138e17ab3920e10e62cbfdf
Signed-off-by: Botond Baranyi's avatarBotond Baranyi <botond.baranyi@ericsson.com>
parent e7dbef22
......@@ -705,6 +705,7 @@ public:
/** Returns whether the reference can be represented by an in-line C++
* expression. */
virtual bool has_single_expr() = 0;
virtual bool has_parameters() const { return false; }
/** Sets the code section of embedded values (parameters, array indices). */
virtual void set_code_section(
GovernedSimple::code_section_t p_code_section);
......
......@@ -76,7 +76,6 @@ namespace Ttcn {
class Reference;
class PortTypeBody;
class Def_Type;
class Ref_pard;
class ClassTypeBody;
/** Stores the modifier of an attribute */
......@@ -1014,7 +1013,7 @@ namespace Common {
* and in parametrised templates. Returns true if the reference in assignment \a lhs
* is found.
* Recursive: calls itself incase of multiple embedded functions / parametrised templates.*/
bool chk_this_template_ref_pard(Ttcn::Ref_pard* ref_pard, Common::Assignment* lhs);
bool chk_this_template_ref_pard(Ttcn::Reference* ref_pard, Common::Assignment* lhs);
bool chk_this_template_generic(Template *t, namedbool incomplete_allowed,
namedbool allow_omit, namedbool allow_any_or_omit, namedbool sub_chk,
namedbool implicit_omit, Common::Assignment *lhs);
......
......@@ -6245,7 +6245,7 @@ void Type::chk_this_template_ref(Template *t)
}
}
bool Type::chk_this_template_ref_pard(Ttcn::Ref_pard* ref_pard, Common::Assignment* lhs)
bool Type::chk_this_template_ref_pard(Ttcn::Reference* ref_pard, Common::Assignment* lhs)
{
// Check if the reference on the left hand side of the assignment can be found
// among the parameters
......@@ -6254,7 +6254,7 @@ bool Type::chk_this_template_ref_pard(Ttcn::Ref_pard* ref_pard, Common::Assignme
size_t nof_pars = par_list->get_nof_pars();
for (size_t i = 0; i < nof_pars; ++i) {
Ttcn::ActualPar* par = par_list->get_par(i);
Ttcn::Ref_base* par_ref = 0;
Ttcn::Reference* par_ref = 0;
switch(par->get_selection()) {
case Ttcn::ActualPar::AP_TEMPLATE: {
Ttcn::TemplateInstance* temp_ins = par->get_TemplateInstance();
......@@ -6282,8 +6282,7 @@ bool Type::chk_this_template_ref_pard(Ttcn::Ref_pard* ref_pard, Common::Assignme
if (ass->get_asstype() == Assignment::A_FUNCTION_RTEMP ||
ass->get_asstype() == Assignment::A_EXT_FUNCTION_RTEMP ||
ass->get_asstype() == Assignment::A_TEMPLATE) {
ref_pard = dynamic_cast<Ttcn::Ref_pard*>(par_ref);
if (ref_pard && chk_this_template_ref_pard(ref_pard, lhs))
if (par_ref->has_parameters() && chk_this_template_ref_pard(par_ref, lhs))
return true;
}
}
......@@ -6401,9 +6400,10 @@ bool Type::chk_this_template_generic(Template *t, namedbool incomplete_allowed,
case Assignment::A_FUNCTION_RTEMP:
case Assignment::A_EXT_FUNCTION_RTEMP:
case Assignment::A_TEMPLATE: {
Ttcn::Ref_pard* ref_pard = dynamic_cast<Ttcn::Ref_pard*>(ref);
if (ref_pard)
if (ref->has_parameters()) {
Ttcn::Reference* ref_pard = dynamic_cast<Ttcn::Reference*>(ref);
self_ref |= chk_this_template_ref_pard(ref_pard, lhs);
}
break; // acceptable
}
default:
......
......@@ -430,7 +430,7 @@ namespace Common {
void Value::chk_expr_immutability() {
switch (valuetype) {
case V_REFD: {/**< referenced */
Ttcn::Ref_base* ttcn_ref = dynamic_cast<Ttcn::Ref_base*>(u.ref.ref);
Ttcn::Reference* ttcn_ref = dynamic_cast<Ttcn::Reference*>(u.ref.ref);
if (ttcn_ref != NULL) {
ttcn_ref->chk_immutability();
}
......@@ -1267,7 +1267,7 @@ namespace Common {
}
// v1 [r2] b4
Value::Value(operationtype_t p_optype, Value* p_v1, Ttcn::Ref_base *p_r2,
Value::Value(operationtype_t p_optype, Value* p_v1, Ttcn::Reference *p_r2,
bool p_b4)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
......@@ -1339,7 +1339,7 @@ namespace Common {
}
 
// r1
Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1)
Value::Value(operationtype_t p_optype, Ttcn::Reference *p_r1)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
u.expr.v_optype = p_optype;
......@@ -1356,7 +1356,7 @@ namespace Common {
}
// r1 [r2] b4
Value::Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
Value::Value(operationtype_t p_optype, Ttcn::Reference* p_r1, Ttcn::Reference* p_r2,
bool p_b4)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
......@@ -1414,7 +1414,7 @@ namespace Common {
}
 
// r1 [v2] or [r1] v2
Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Value *p_v2)
Value::Value(operationtype_t p_optype, Ttcn::Reference *p_r1, Value *p_v2)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
u.expr.v_optype = p_optype;
......@@ -1437,7 +1437,7 @@ namespace Common {
}
 
// r1 t_list2 b4
Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1,
Value::Value(operationtype_t p_optype, Ttcn::Reference *p_r1,
Ttcn::ParsedActualParameters* p_t_list2, bool p_b4)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
......@@ -1768,7 +1768,7 @@ namespace Common {
u.verdict = p_verdict;
}
 
Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Ttcn::Ref_base *p_r2)
Value::Value(operationtype_t p_optype, Ttcn::Reference *p_r1, Ttcn::Reference *p_r2)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
u.expr.v_optype = p_optype;
......@@ -1790,7 +1790,7 @@ namespace Common {
}
// r1 r2 [v3]
Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Ttcn::Ref_base *p_r2,
Value::Value(operationtype_t p_optype, Ttcn::Reference *p_r1, Ttcn::Reference *p_r2,
Value *p_v3)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
......@@ -1813,7 +1813,7 @@ namespace Common {
}
// r1 r2 [v3] [v4]
Value::Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
Value::Value(operationtype_t p_optype, Ttcn::Reference* p_r1, Ttcn::Reference* p_r2,
Value* p_v3, Value* p_v4)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
......@@ -1838,7 +1838,7 @@ namespace Common {
}
// r1 r2 [v3] [v4] [v5]
Value::Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
Value::Value(operationtype_t p_optype, Ttcn::Reference* p_r1, Ttcn::Reference* p_r2,
Value* p_v3, Value* p_v4, Value* p_v5)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0), in_brackets(false)
{
......@@ -4409,7 +4409,7 @@ namespace Common {
void Value::chk_expr_ref_ischosen()
{
Error_Context cntxt(this, "In the operand of operation `%s'", get_opname());
Ttcn::Ref_base *tmpref=u.expr.r1;
Ttcn::Reference *tmpref=u.expr.r1;
Assignment *ass=tmpref->get_refd_assignment();
if (!ass) {
set_valuetype(V_ERROR);
......@@ -4899,7 +4899,7 @@ namespace Common {
}
 
void Value::chk_expr_operand_undef_running(Type::expected_value_t exp_val,
Ttcn::Ref_base *ref, bool any_from, Ttcn::Ref_base* index_ref,
Ttcn::Reference *ref, bool any_from, Ttcn::Reference* index_ref,
const char *opnum, const char *opname)
{
if(valuetype==V_ERROR) return;
......@@ -5198,7 +5198,7 @@ namespace Common {
return NULL;
}
 
void Value::chk_expr_operand_tmrref(Ttcn::Ref_base *ref,
void Value::chk_expr_operand_tmrref(Ttcn::Reference *ref,
const char *opnum,
const char *opname,
bool any_from)
......@@ -5250,16 +5250,14 @@ namespace Common {
set_valuetype(V_ERROR);
}
 
void Value::chk_expr_operand_activate(Ttcn::Ref_base *ref,
void Value::chk_expr_operand_activate(Ttcn::Reference *ref,
const char *,
const char *opname)
{
if(valuetype==V_ERROR) return;
// if(u.expr.state==EXPR_CHECKING_ERR) return;
Ttcn::Ref_pard *t_ref_pard = dynamic_cast<Ttcn::Ref_pard*>(ref);
if (!t_ref_pard) FATAL_ERROR("Value::chk_expr_operand_activate()");
Error_Context cntxt(this, "In `%s' operation", opname);
if (!t_ref_pard->chk_activate_argument()) set_valuetype(V_ERROR);
if (!ref->chk_activate_argument()) set_valuetype(V_ERROR);
}
 
void Value::chk_expr_operand_activate_refd(Value *val,
......@@ -5299,7 +5297,7 @@ namespace Common {
} else set_valuetype(V_ERROR);
}
 
void Value::chk_expr_operand_execute(Ttcn::Ref_base *ref, Value *val,
void Value::chk_expr_operand_execute(Ttcn::Reference *ref, Value *val,
const char *,
const char *opname)
{
......@@ -6485,7 +6483,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
Type* t_type = 0;
{
Error_Context cntxt(this, "In the parameters of %s()", opname);
Ttcn::Ref_base* ref = u.expr.r1;
Ttcn::Reference* ref = u.expr.r1;
Ttcn::FieldOrArrayRefs* t_subrefs = ref->get_subrefs();
Type* t_type_last = 0;
Assignment* t_ass = ref->get_refd_assignment();
......@@ -10799,18 +10797,10 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
 
Ttcn::Reference* Value::steal_ttcn_ref()
{
Ttcn::Reference *ret_val =
dynamic_cast<Ttcn::Reference*>(steal_ttcn_ref_base());
if(!ret_val) FATAL_ERROR("Value::steal_ttcn_ref()");
return ret_val;
}
Ttcn::Ref_base* Value::steal_ttcn_ref_base()
{
Ttcn::Ref_base *t_ref;
Ttcn::Reference *t_ref;
if(valuetype==V_REFD) {
t_ref=dynamic_cast<Ttcn::Ref_base*>(u.ref.ref);
if(!t_ref) FATAL_ERROR("Value::steal_ttcn_ref_base()");
t_ref=dynamic_cast<Ttcn::Reference*>(u.ref.ref);
if(!t_ref) FATAL_ERROR("Value::steal_ttcn_ref()");
u.ref.ref=0;
}
else if(valuetype==V_UNDEF_LOWERID) {
......@@ -10821,7 +10811,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
u.val_id=0;
}
else {
FATAL_ERROR("Value::steal_ttcn_ref_base()");
FATAL_ERROR("Value::steal_ttcn_ref()");
t_ref = 0;
}
set_valuetype(V_ERROR);
......@@ -11208,7 +11198,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
} // switch
}
 
void Value::chk_recursions_expr_decode(Ttcn::Ref_base* ref,
void Value::chk_recursions_expr_decode(Ttcn::Reference* ref,
ReferenceChain& refch) {
Error_Context cntxt(this, "In the operand of operation `%s'", get_opname());
Assignment *ass = ref->get_refd_assignment();
......@@ -11266,7 +11256,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
INCOMPLETE_NOT_ALLOWED, OMIT_ALLOWED, NO_SUB_CHK, NOT_IMPLICIT_OMIT, NOT_STR_ELEM);
break; }
case Ttcn::Template::TEMPLATE_REFD: {
Ttcn::Ref_base *refb = t->get_reference();
Ttcn::Reference *refb = t->get_reference();
Common::Assignment *ass = refb->get_refd_assignment();
self_ref |= (ass == lhs);
break; }
......@@ -11573,7 +11563,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
break;
 
case Ttcn::LogArgument::L_REF: {
Ttcn::Ref_base *ref = la->get_ref();
Ttcn::Reference *ref = la->get_ref();
Common::Assignment *ass = ref->get_refd_assignment();
self_ref |= (ass == lhs);
break; }
......@@ -13657,7 +13647,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
if (specific_value->get_valuetype() == Value::V_REFD) {
Ttcn::Reference* reference =
dynamic_cast<Ttcn::Reference*>(specific_value->get_reference());
if (reference) {
if (reference != NULL && !reference->has_parameters()) {
reference->generate_code_ispresentboundchosen(expr, false,
u.expr.v_optype, NULL);
break;
......@@ -13667,7 +13657,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
Ttcn::Reference* reference =
dynamic_cast<Ttcn::Reference*>(u.expr.ti1->get_Template()
->get_reference());
if (reference) {
if (reference != NULL && !reference->has_parameters()) {
reference->generate_code_ispresentboundchosen(expr, true,
u.expr.v_optype, NULL);
break;
......@@ -13704,7 +13694,8 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
expr->expr=mputstr(expr->expr, ".is_bound()");
break;
case OPTYPE_ISPRESENT:
expr->expr=mputprintf(expr->expr, ".is_present()");
expr->expr=mputprintf(expr->expr, ".is_present(%s)",
!u.expr.ti1->is_only_specific_value() && omit_in_value_list ? "TRUE" : "");
break;
case OPTYPE_SIZEOF:
expr->expr=mputstr(expr->expr, ".size_of()");
......@@ -14170,7 +14161,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
}
void Value::generate_code_expr_class_create(expression_struct* expr,
Ttcn::Ref_base* type, Ttcn::ActualParList* ap_list)
Ttcn::Reference* type, Ttcn::ActualParList* ap_list)
{
expr->expr = mputstr(expr->expr, "new ");
type->generate_code(expr);
......@@ -14184,7 +14175,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
}
 
void Value::generate_code_expr_comp_create(expression_struct *expr,
Ttcn::Ref_base *type, Value *name, Value *location, bool alive)
Ttcn::Reference *type, Value *name, Value *location, bool alive)
{
expr->expr = mputstr(expr->expr, "TTCN_Runtime::create_component(");
// first two arguments: component type
......@@ -16356,7 +16347,7 @@ void Value::chk_expr_operand_execute_refd(Value *v1,
expr->expr = mputprintf(expr->expr, "%s", param_id.c_str());
}
 
void LazyFuzzyParamData::generate_code_ap_default_ref(expression_struct *expr, Ttcn::Ref_base* ref, Scope* scope, boolean lazy) {
void LazyFuzzyParamData::generate_code_ap_default_ref(expression_struct *expr, Ttcn::Reference* ref, Scope* scope, boolean lazy) {
expression_struct ref_expr;
Code::init_expr(&ref_expr);
ref->generate_code(&ref_expr);
......
......@@ -42,7 +42,6 @@ namespace Asn {
namespace Ttcn {
class Reference;
class Ref_base;
class TemplateInstance;
class TemplateInstances;
class ActualParList;
......@@ -346,7 +345,7 @@ namespace Common {
Value *v1;
Template *t1;
TemplateInstance *ti1;
Ttcn::Ref_base *r1; /**< timer, component or class */
Ttcn::Reference *r1; /**< timer, component or class */
LogArguments *logargs; /**< arguments of log2str() */
Type* type;
};
......@@ -356,7 +355,7 @@ namespace Common {
Identifier *i2;
Ttcn::ParsedActualParameters *t_list2;
Ttcn::ActualParList *ap_list2;
Ttcn::Ref_base *r2;
Ttcn::Reference *r2;
Ttcn::FieldOrArrayRefs* subrefs2;
};
Value *v3;
......@@ -424,16 +423,16 @@ namespace Common {
/** Constructor used by V_EXPR "v1" or [v1] */
Value(operationtype_t p_optype, Value *p_v1);
/** Constructor used bt V_EXPR "v1 [r2] b4": COMP_RUNNING, COMP_ALIVE */
Value(operationtype_t p_optype, Value* p_v1, Ttcn::Ref_base* p_r2, bool p_b4);
Value(operationtype_t p_optype, Value* p_v1, Ttcn::Reference* p_r2, bool p_b4);
/** Constructor used by V_EXPR "ti1": LENGTHOF, SIZEOF, VALUEOF, TTCN2STRING */
Value(operationtype_t p_optype, TemplateInstance *p_ti1);
/** Constructor used by V_EXPR "ti1 subrefs2": VALUEOF */
Value(operationtype_t p_optype, TemplateInstance *p_ti1,
Ttcn::FieldOrArrayRefs* p_subrefs2);
/** Constructor used by V_EXPR "r1": TMR_READ, ACTIVATE */
Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1);
Value(operationtype_t p_optype, Ttcn::Reference *p_r1);
/** Constructor used by V_EXPR "r1 [r2] b4": UNDEF_RUNNING */
Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
Value(operationtype_t p_optype, Ttcn::Reference* p_r1, Ttcn::Reference* p_r2,
bool p_b4);
/** ACTIVATE_REFD, OPTYPE_INVOKE, OPTYPE_COMP_ALIVE_REFD */
Value(operationtype_t p_optype, Value *p_v1,
......@@ -442,9 +441,9 @@ namespace Common {
Value(operationtype_t p_optype, Value *p_v1,
Ttcn::ParsedActualParameters *p_t_list2, Value *p_v3);
/** Constructor used by V_EXPR "r1 [v2]": EXECUTE or [r1] v2 */
Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Value *v2);
Value(operationtype_t p_optype, Ttcn::Reference *p_r1, Value *v2);
/** Constructor used by V_EXPR "r1 t_list2 b4": UNDEF_CREATE */
Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1,
Value(operationtype_t p_optype, Ttcn::Reference *p_r1,
Ttcn::ParsedActualParameters* p_t_list2, bool p_b4);
/** Constructor used by V_EXPR "v1 v2" */
Value(operationtype_t p_optype, Value *p_v1, Value *p_v2);
......@@ -476,14 +475,14 @@ namespace Common {
Value(valuetype_t p_vt, Block *p_block);
Value(valuetype_t p_vt, verdict_t p_verdict);
/** Constructor used by decode */
Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Ttcn::Ref_base *p_r2);
Value(operationtype_t p_optype, Ttcn::Reference *p_r1, Ttcn::Reference *p_r2);
/** Constructor used by decvalue_unichar*/
Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Ttcn::Ref_base *p_r2, Value *p_v3);
Value(operationtype_t p_optype, Ttcn::Reference *p_r1, Ttcn::Reference *p_r2, Value *p_v3);
/** Constructor used by V_EXPR "r1 r2 v3 v4" */
Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Ttcn::Ref_base *p_r2,
Value(operationtype_t p_optype, Ttcn::Reference *p_r1, Ttcn::Reference *p_r2,
Value *p_v3, Value* p_v4);
/** Constructor used by V_EXPR "r1 r2 v3 v4 v5" */
Value(operationtype_t p_optype, Ttcn::Ref_base* p_r1, Ttcn::Ref_base* p_r2,
Value(operationtype_t p_optype, Ttcn::Reference* p_r1, Ttcn::Reference* p_r2,
Value* p_v3, Value* p_v4, Value* p_v5);
/** Constructor used by V_ANY_VALUE and V_ANY_OR_OMIT */
Value(valuetype_t p_vt, Ttcn::LengthRestriction* p_len_res);
......@@ -614,8 +613,8 @@ namespace Common {
const char *opnum1 = "left",
const char *opnum2 = "right");
void chk_expr_operand_undef_running(Type::expected_value_t exp_val,
Ttcn::Ref_base *ref, bool any_from,
Ttcn::Ref_base* index_ref,
Ttcn::Reference *ref, bool any_from,
Ttcn::Reference* index_ref,
const char *opnum, const char *opname);
/** Returns the referred component or class type if it is correct. */
Type *chk_expr_operand_undef_create();
......@@ -624,16 +623,16 @@ namespace Common {
void chk_expr_comptype_compat();
Type* chk_expr_operand_compref(Value *val, const char *opnum,
const char *opname, bool any_from = false);
void chk_expr_operand_tmrref(Ttcn::Ref_base *ref,
void chk_expr_operand_tmrref(Ttcn::Reference *ref,
const char *opnum, const char *opname,
bool any_from = false);
void chk_expr_operand_activate(Ttcn::Ref_base *ref,
void chk_expr_operand_activate(Ttcn::Reference *ref,
const char *opnum, const char *opname);
void chk_expr_operand_activate_refd(Value *val,
Ttcn::TemplateInstances* t_list2,
Ttcn::ActualParList *&parlist,
const char *opnum, const char *opname);
void chk_expr_operand_execute(Ttcn::Ref_base *ref, Value *val,
void chk_expr_operand_execute(Ttcn::Reference *ref, Value *val,
const char *opnum, const char *opname);
void chk_expr_operand_execute_refd(Value *v1,
Ttcn::TemplateInstances* t_list2,
......@@ -812,7 +811,6 @@ namespace Common {
/** Usable during AST building. If VariableRef is needed, then use
* the return value of this function, then delete this. */
Ttcn::Reference* steal_ttcn_ref();
Ttcn::Ref_base* steal_ttcn_ref_base();
void steal_invoke_data(Value*& p_v, Ttcn::ParsedActualParameters*& p_ti,
Ttcn::ActualParList*& p_ap);
Common::Assignment* get_refd_assignment();
......@@ -824,7 +822,7 @@ namespace Common {
void chk_recursions(ReferenceChain& refch);
/** Checks for circular references within embedded expressions */
void chk_recursions_expr(ReferenceChain& refch);
void chk_recursions_expr_decode(Ttcn::Ref_base* ref, ReferenceChain& refch);
void chk_recursions_expr_decode(Ttcn::Reference* ref, ReferenceChain& refch);
/** Check that the value (a V_EXPR) - being used as the RHS - refers to
* the LHS of the assignment.
* @return true if self-assignment*/
......@@ -957,11 +955,11 @@ namespace Common {
/** Helper function for \a generate_code_expr_expr(). It handles
* create() for classes. */
static void generate_code_expr_class_create(expression_struct* expr,
Ttcn::Ref_base* type, Ttcn::ActualParList* ap_list);
Ttcn::Reference* type, Ttcn::ActualParList* ap_list);
/** Helper function for \a generate_code_expr_expr(). It handles
* create() for components. */
static void generate_code_expr_comp_create(expression_struct *expr,
Ttcn::Ref_base *type, Value *name, Value *location, bool alive);
Ttcn::Reference *type, Value *name, Value *location, bool alive);
/** Helper function for \a generate_code_expr_expr(). It handles
* activate(). */
void generate_code_expr_activate(expression_struct *expr);
......@@ -1097,7 +1095,7 @@ namespace Common {
static void generate_code(expression_struct *expr, Value* value, Scope* scope, boolean lazy);
static void generate_code(expression_struct *expr, TemplateInstance* temp, template_restriction_t gen_restriction_check, Scope* scope, boolean lazy);
static void generate_code_param_class(expression_struct *expr, expression_struct& param_expr, const string& param_id, const string& type_name, boolean lazy);
static void generate_code_ap_default_ref(expression_struct *expr, Ttcn::Ref_base* ref, Scope* scope, boolean lazy);
static void generate_code_ap_default_ref(expression_struct *expr, Ttcn::Reference* ref, Scope* scope, boolean lazy);
static void generate_code_ap_default_value(expression_struct *expr, Value* value, Scope* scope, boolean lazy);
static void generate_code_ap_default_ti(expression_struct *expr, TemplateInstance* ti, Scope* scope, boolean lazy);
};
......
This diff is collapsed.
......@@ -79,7 +79,7 @@ namespace Ttcn {
union {
Value *val; ///< Value for AP_VALUE. Owned by ActualPar
TemplateInstance *temp; ///< %Template for AP_TEMPLATE. Owned by ActualPar
Ref_base *ref; ///< %Reference for AP_REF. Owned by ActualPar
Reference *ref; ///< %Reference for AP_REF. Owned by ActualPar
ActualPar *act; ///< For AP_DEFAULT. \b Not owned by ActualPar
};
Scope *my_scope; ///< %Scope. Not owned
......@@ -105,7 +105,7 @@ namespace Ttcn {
/// Actual par for an in template parameter
ActualPar(TemplateInstance *t);
/// Actual par for an {out or inout} {value or template} parameter
ActualPar(Ref_base *r);
ActualPar(Reference *r);
/// Created from the default value of a formal par, at the call site,
///
ActualPar(ActualPar *a);
......@@ -117,7 +117,7 @@ namespace Ttcn {
ap_selection_t get_selection() const { return selection; }
Value *get_Value() const;
TemplateInstance *get_TemplateInstance() const;
Ref_base *get_Ref() const;
Reference *get_Ref() const;
ActualPar *get_ActualPar() const;
/** Checks the embedded recursions within the value or template instance. */
void chk_recursions(ReferenceChain& refch);
......@@ -339,19 +339,33 @@ namespace Ttcn {
* module name or not.
*/
class Reference : public Ref_base {
ActualParList *parlist;
/** "Processed" parameter list, after the semantic check. */
ActualParList* parlist;
/** "Raw" parameter list, before the semantic check. */
Ttcn::ParsedActualParameters* params;
bool gen_const_prefix;
/** Used by generate_code_cached(). Stores the generated expression string,
* so it doesn't get regenerated every time. */
char* expr_cache;
/** Copy constructor. Private, used by Reference::clone() only */
Reference(const Reference& p);
public:
Reference(Identifier *p_id);
Reference(Identifier *p_modid, Identifier *p_id)
: Ref_base(p_modid, p_id), parlist(0), gen_const_prefix(false) { }
: Ref_base(p_modid, p_id), parlist(NULL), params(NULL), gen_const_prefix(false), expr_cache(NULL) { }
Reference(Identifier *p_modid, Identifier *p_id,
ParsedActualParameters *p_params);
~Reference();
virtual bool has_parameters() const;
virtual Reference *clone() const;
virtual void set_fullname(const string& p_fullname);
virtual void set_my_scope(Scope* p_scope);
virtual string get_dispname();
virtual Common::Assignment *get_refd_assignment(bool check_parlist = true);
virtual const Identifier* get_modid();
virtual const Identifier* get_id();
virtual ActualParList *get_parlist();
void set_gen_const_prefix() { gen_const_prefix = true; }
/** Checks whether \a this points to a variable or value parameter.
* Returns the type of the respective variable or variable field or NULL
......@@ -360,7 +374,9 @@ namespace Ttcn {
/** Checks if \a this points to a component.
* Returns the type of the component if so or NULL in case of error. */
Type *chk_comptype_ref();
bool chk_activate_argument();
virtual bool has_single_expr();
virtual void set_code_section(GovernedSimple::code_section_t p_code_section);
virtual void generate_code(expression_struct_t *expr);
/** Generates the C++ equivalent of port references within
* connect/disconnect/map/unmap statements into \a expr.
......@@ -372,70 +388,6 @@ namespace Ttcn {
* and the referred objects are bound or not.*/
void generate_code_ispresentboundchosen(expression_struct_t *expr,
bool is_template, const Value::operationtype_t optype, const char* field);
/** Lets the referenced assignment object know, that the reference is used
* at least once (only relevant for formal parameters and external constants). */
void ref_usage_found();
private:
/** Detects whether the first identifier in subrefs is a module id */
void detect_modid();
};
/**
* Parameterized TTCN-3 reference
*/
class Ref_pard : public Ref_base {
/** "Processed" parameter list, after the semantic check. */
ActualParList parlist;
/** "Raw" parameter list, before the semantic check. */
Ttcn::ParsedActualParameters *params;
/** Used by generate_code_cached(). Stores the generated expression string,
* so it doesn't get regenerated every time. */
char* expr_cache;
/** Set if the module identifier also had an object identifier.
* (This ensures that the module identifier refers to a module, and not a
* possible local class object variable.) */
bool has_objid;
/** Set if this object was incorrectly created as a parameterized reference
* by the parser, and is actually a non-parameterized reference with a
* method call as its first subref (only if OOP features are enabled) */
bool truncated;
/** Points to the truncated reference, if the 'truncated' flag is set.
* Otherwise null. */
Ttcn::Reference* truncated_ref;
/** Copy constructor. Private, used by Ref_pard::clone() only */
Ref_pard(const Ref_pard& p);
/// %Assignment disabled
Ref_pard& operator=(const Ref_pard& p);
public:
/** Constructor
* \param p_modid the module in which it resides
* \param p_id the identifier
* \param p_params parameters. For a function, this is the list constructed
* for the actual parameters.
* */
Ref_pard(Identifier *p_modid, Identifier *p_id,
ParsedActualParameters *p_params, bool p_has_objid = true);
~Ref_pard();
virtual Ref_pard *clone() const;
virtual void set_fullname(const string& p_fullname);
virtual void set_my_scope(Scope *p_scope);
string get_dispname();
virtual Common::Assignment *get_refd_assignment(bool check_parlist = true);
virtual const Identifier *get_modid();
virtual const Identifier *get_id();
virtual ActualParList *get_parlist();
/** Checks whether \a this is a correct argument of an activate operation
* or statement. The reference shall point to an altstep with proper
* `runs on' clause and the actual parameters that are passed by reference
* shall not point to local definitions. The function returns true if the
* altstep reference is correct and false in case of any error. */
bool chk_activate_argument();
virtual bool has_single_expr();
virtual void set_code_section(
GovernedSimple::code_section_t p_code_section);
virtual void generate_code (expression_struct_t *expr);
virtual void generate_code_const_ref(expression_struct_t *expr);
/** Used when an 'all from' is called on a function or parametrised template,
* generate_code would generate new temporaries for the function's parameters
* each call. This method makes sure the same temporaries are used every time
......@@ -444,6 +396,12 @@ namespace Ttcn {
* is cached, since the preamble is only needed after the first call).
* On further runs the cached expression is returned.*/
virtual void generate_code_cached (expression_struct_t *expr);
/** Lets the referenced assignment object know, that the reference is used
* at least once (only relevant for formal parameters and external constants). */
void ref_usage_found();
private:
/** Detects whether the first identifier in subrefs is a module id */
void detect_modid();
};
/**
......@@ -1776,7 +1734,7 @@ namespace Ttcn {
* the constructor has no parameters. */
FormalParList* fp_list;
Ref_pard* base_call;
Reference* base_call;
StatementBlock* block;
......@@ -1787,14 +1745,14 @@ namespace Ttcn {