case OPTYPE_REMOVE_BOM:
u.expr.v1=p.u.expr.v1->clone();
break;
+ case OPTYPE_HOSTID: // [v1]
+ u.expr.v1=p.u.expr.v1?p.u.expr.v1->clone():0;
+ break;
case OPTYPE_ADD: // v1 v2
case OPTYPE_SUBTRACT:
case OPTYPE_MULTIPLY:
u.expr.r1=p.u.expr.r1->clone();
u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0;
break;
+ case OPTYPE_CHECKSTATE_ANY: // [r1] v2
+ case OPTYPE_CHECKSTATE_ALL:
+ u.expr.r1=p.u.expr.r1?p.u.expr.r1->clone():0;
+ u.expr.v2=p.u.expr.v2->clone();
+ break;
case OPTYPE_COMP_CREATE: // r1 [v2] [v3]
u.expr.r1=p.u.expr.r1->clone();
u.expr.v2=p.u.expr.v2?p.u.expr.v2->clone():0;
u.expr.v3 = p.u.expr.v3 ? p.u.expr.v3->clone() : 0;
break;
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
u.expr.logargs = p.u.expr.logargs->clone();
break;
default:
case OPTYPE_REMOVE_BOM:
case OPTYPE_GET_STRINGENCODING:
case OPTYPE_DECODE_BASE64:
+ case OPTYPE_HOSTID:
delete u.expr.v1;
break;
case OPTYPE_ADD: // v1 v2
delete u.expr.r1;
delete u.expr.v2;
break;
+ case OPTYPE_CHECKSTATE_ANY: // [r1] v2
+ case OPTYPE_CHECKSTATE_ALL:
+ delete u.expr.r1;
+ delete u.expr.v2;
+ break;
case OPTYPE_COMP_CREATE: // r1 [v2] [v3] b4
delete u.expr.r1;
delete u.expr.v2;
delete u.expr.v3;
break;
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
delete u.expr.logargs;
break;
default:
if(!p_v1) FATAL_ERROR("Value::Value()");
u.expr.v1=p_v1;
break;
+ case OPTYPE_HOSTID:
+ u.expr.v1=p_v1;
+ break;
default:
FATAL_ERROR("Value::Value()");
} // switch
case OPTYPE_TTCN2STRING:
if(!p_ti1) FATAL_ERROR("Value::Value()");
u.expr.ti1=p_ti1;
+ // Needed in the case of OPTYPE_ENCVALUE_UNICHAR
+ u.expr.v2=NULL;
break;
default:
FATAL_ERROR("Value::Value()");
}
}
- // r1 [v2]
+ // r1 [v2] or [r1] v2
Value::Value(operationtype_t p_optype, Ttcn::Ref_base *p_r1, Value *p_v2)
: GovernedSimple(S_V), valuetype(V_EXPR), my_governor(0)
{
u.expr.r1=p_r1;
u.expr.v2=p_v2;
break;
+ case OPTYPE_CHECKSTATE_ANY:
+ case OPTYPE_CHECKSTATE_ALL:
+ if(!p_v2) FATAL_ERROR("Value::Value()");
+ u.expr.r1=p_r1; // may be null if any port or all port
+ u.expr.v2=p_v2;
+ break;
default:
FATAL_ERROR("Value::Value()");
} // switch
u.expr.state = EXPR_NOT_CHECKED;
switch(p_optype) {
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
if (!p_logargs) FATAL_ERROR("Value::Value()");
u.expr.logargs = p_logargs;
break;
if(!p_r1 || !p_r2) FATAL_ERROR("Value::Value()");
u.expr.r1=p_r1;
u.expr.r2=p_r2;
+ // Needed in the case of OPTYPE_DECVALUE_UNICHAR
+ u.expr.v3=NULL;
break;
default:
FATAL_ERROR("Value::Value()");
case OPTYPE_DECODE_BASE64:
u.expr.v1->set_fullname(p_fullname+".<operand>");
break;
+ case OPTYPE_HOSTID: // [v1]
+ if(u.expr.v1) u.expr.v1->set_fullname(p_fullname+".<operand>");
+ break;
case OPTYPE_ADD: // v1 v2
case OPTYPE_SUBTRACT:
case OPTYPE_MULTIPLY:
case OPTYPE_LOG2STR:
u.expr.logargs->set_fullname(p_fullname+".<logargs>");
break;
+ case OPTYPE_ANY2UNISTR:
+ u.expr.logargs->set_fullname(p_fullname+".<logarg>");
+ break;
+ case OPTYPE_CHECKSTATE_ANY: // [r1] v2
+ case OPTYPE_CHECKSTATE_ALL:
+ u.expr.v2->set_fullname(p_fullname+".<operand1>");
+ break;
default:
FATAL_ERROR("Value::set_fullname_expr()");
} // switch
case OPTYPE_DECODE_BASE64:
u.expr.v1->set_my_scope(p_scope);
break;
+ case OPTYPE_HOSTID: // [v1]
+ if(u.expr.v1) u.expr.v1->set_my_scope(p_scope);
+ break;
case OPTYPE_ADD: // v1 v2
case OPTYPE_SUBTRACT:
case OPTYPE_MULTIPLY:
u.expr.r1->set_my_scope(p_scope);
if(u.expr.v2) u.expr.v2->set_my_scope(p_scope);
break;
+ case OPTYPE_CHECKSTATE_ANY: // [r1] v2
+ case OPTYPE_CHECKSTATE_ALL:
+ if(u.expr.r1) u.expr.r1->set_my_scope(p_scope);
+ u.expr.v2->set_my_scope(p_scope);
+ break;
case OPTYPE_COMP_CREATE: // r1 [v2] [v3]
u.expr.r1->set_my_scope(p_scope);
if(u.expr.v2) u.expr.v2->set_my_scope(p_scope);
u.expr.v3->set_my_scope(p_scope);
break;
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
u.expr.logargs->set_my_scope(p_scope);
break;
default:
case OPTYPE_REMOVE_BOM:
u.expr.v1->set_code_section(p_code_section);
break;
+ case OPTYPE_HOSTID: // [v1]
+ if(u.expr.v1) u.expr.v1->set_code_section(p_code_section);
+ break;
case OPTYPE_ADD: // v1 v2
case OPTYPE_SUBTRACT:
case OPTYPE_MULTIPLY:
u.expr.r1->set_code_section(p_code_section);
if(u.expr.v2) u.expr.v2->set_code_section(p_code_section);
break;
+ case OPTYPE_CHECKSTATE_ANY: // [r1] v2
+ case OPTYPE_CHECKSTATE_ALL:
+ if(u.expr.r1) u.expr.r1->set_code_section(p_code_section);
+ u.expr.v2->set_code_section(p_code_section);
+ break;
case OPTYPE_COMP_CREATE: // r1 [v2] [v3] b4
u.expr.r1->set_code_section(p_code_section);
if(u.expr.v2) u.expr.v2->set_code_section(p_code_section);
u.expr.v3->set_code_section(p_code_section);
break;
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
u.expr.logargs->set_code_section(p_code_section);
break;
default:
case OPTYPE_ISVALUE:
case OPTYPE_ISBOUND:
case OPTYPE_PROF_RUNNING:
+ case OPTYPE_CHECKSTATE_ANY:
+ case OPTYPE_CHECKSTATE_ALL:
return Type::T_BOOL;
case OPTYPE_GETVERDICT:
return Type::T_VERDICT;
case OPTYPE_TTCN2STRING:
case OPTYPE_GET_STRINGENCODING:
case OPTYPE_ENCODE_BASE64:
+ case OPTYPE_HOSTID:
return Type::T_CSTR;
case OPTYPE_INT2UNICHAR:
case OPTYPE_OCT2UNICHAR:
case OPTYPE_ENCVALUE_UNICHAR:
+ case OPTYPE_ANY2UNISTR:
return Type::T_USTR;
case OPTYPE_INT2BIT:
case OPTYPE_HEX2BIT:
return "getverdict()";
case OPTYPE_TESTCASENAME:
return "testcasename()";
+ case OPTYPE_CHECKSTATE_ANY:
+ if (u.expr.r1) {
+ return "port.checkstate()";
+ } else {
+ return "any port.checkstate()";
+ }
+ case OPTYPE_CHECKSTATE_ALL:
+ if (u.expr.r1) {
+ return "port.checkstate()";
+ } else {
+ return "all port.checkstate()";
+ }
case OPTYPE_UNARYPLUS: // v1
return "unary +";
case OPTYPE_UNARYMINUS:
return "encode_base64()";
case OPTYPE_DECODE_BASE64:
return "decode_base64()";
+ case OPTYPE_HOSTID: // [v1]
+ return "hostid()";
case OPTYPE_ADD: // v1 v2
return "+";
case OPTYPE_SUBTRACT:
return "isbound()";
case OPTYPE_LOG2STR:
return "log2str()";
+ case OPTYPE_ANY2UNISTR:
+ return "any2unistr()";
case OPTYPE_TTCN2STRING:
return "ttcn2string()";
case OPTYPE_PROF_RUNNING:
void Value::chk_expr_operand_encode(ReferenceChain *refch,
Type::expected_value_t exp_val) {
- Error_Context cntxt(this, "In the parameter of encvalue()");
+ Error_Context cntxt(this, "In the parameter of %s",
+ u.expr.v_optype == OPTYPE_ENCVALUE_UNICHAR ? "encvalue_unichar()" : "encvalue()");
Type t_chk(Type::T_ERROR);
Type* t_type;
void Value::chk_expr_operands_decode(operationtype_t p_optype)
{
- Error_Context cntxt(this, "In the parameters of decvalue()"); //todo
+ Error_Context cntxt(this, "In the parameters of %s",
+ p_optype == OPTYPE_DECVALUE_UNICHAR ? "decvalue_unichar()" : "decvalue()");
Ttcn::Ref_base* ref = u.expr.r1;
Ttcn::FieldOrArrayRefs* t_subrefs = ref->get_subrefs();
Type* t_type = 0;
chk_expr_val_ustr_7bitchars(v1, the, opname);
}
break;
+ case OPTYPE_HOSTID:
+ v1=u.expr.v1 ? u.expr.v1 : 0;
+ if (v1)
+ {
+ Error_Context cntxt(this, "In the first operand of operation `%s'", opname);
+ v1->set_lowerid_to_ref();
+ tt1=v1->get_expr_returntype(exp_val);
+ chk_expr_operandtype_cstr(tt1, second, opname, v1);
+ chk_expr_eval_value(v1, t_chk, refch, exp_val);
+ }
+ break;
case OPTYPE_UNICHAR2OCT: // v1 [v2]
v1=u.expr.v1;
{
chk_expr_operand_activate(u.expr.r1, the, opname);
chk_expr_dynamic_part(exp_val, true);
break;
+ case OPTYPE_CHECKSTATE_ANY: // [r1] v2
+ case OPTYPE_CHECKSTATE_ALL:
+ chk_expr_dynamic_part(exp_val, false);
+ v2=u.expr.v2;
+ if(v2) {
+ Error_Context cntxt(this, "In the first operand of operation `%s'", opname);
+ v2->set_lowerid_to_ref();
+ tt2=v2->get_expr_returntype(exp_val);
+ chk_expr_operandtype_cstr(tt2, first, opname, v2);
+ chk_expr_eval_value(v2, t_chk, refch, exp_val);
+ }
+ break;
case OPTYPE_ACTIVATE_REFD:{ //v1 t_list2
Ttcn::ActualParList *parlist = new Ttcn::ActualParList;
chk_expr_operand_activate_refd(u.expr.v1,u.expr.t_list2->get_tis(), parlist, the,
}
chk_expr_operands_replace();
break; }
- case OPTYPE_LOG2STR: {
+ case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR: {
Error_Context cntxt(this, "In the operand of operation `%s'", opname);
u.expr.logargs->chk();
if (!semantic_check_only) u.expr.logargs->join_strings();
case OPTYPE_MATCH: // v1 t2
case OPTYPE_ISCHOSEN_T:
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
case OPTYPE_ENCODE:
case OPTYPE_DECODE:
case OPTYPE_ISBOUND:
case OPTYPE_DECODE_BASE64:
case OPTYPE_ENCVALUE_UNICHAR:
case OPTYPE_DECVALUE_UNICHAR:
+ case OPTYPE_CHECKSTATE_ANY:
+ case OPTYPE_CHECKSTATE_ALL:
+ case OPTYPE_HOSTID:
break;
case OPTYPE_TESTCASENAME: { // -
if (!my_scope) FATAL_ERROR("Value::evaluate_value()");
case OPTYPE_DECODE_BASE64:
case OPTYPE_ENCVALUE_UNICHAR:
case OPTYPE_DECVALUE_UNICHAR:
+ case OPTYPE_CHECKSTATE_ANY:
+ case OPTYPE_CHECKSTATE_ALL:
+ case OPTYPE_HOSTID:
return true;
case OPTYPE_COMP_NULL: // -
return false;
case OPTYPE_ISCHOSEN_V:
return u.expr.v1->is_unfoldable(refch, exp_val);
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
case OPTYPE_TTCN2STRING:
return true;
default:
u.expr.t1->chk_recursions(refch);
refch.prev_state();
break;
+ case OPTYPE_HOSTID: // [v1]
+ if (u.expr.v1) {
+ refch.mark_state();
+ u.expr.v1->chk_recursions(refch);
+ refch.prev_state();
+ }
+ break;
case OPTYPE_ADD: // v1 v2
case OPTYPE_SUBTRACT:
case OPTYPE_MULTIPLY:
refch.prev_state();
break;
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
u.expr.logargs->chk_recursions(refch);
break;
default:
break; // self-ref can't happen
case Ttcn::Template::TEMPLATE_INVOKE:
break; // assume self-ref can't happen
+ case Ttcn::Template::DECODE_MATCH:
+ self_ref |= chk_expr_self_ref_templ(t->get_decode_target()->get_Template(), lhs);
+ break;
case Ttcn::Template::TEMPLATE_ERROR:
//FATAL_ERROR("Value::chk_expr_self_ref_templ()");
break;
}
}
return gov->chk_this_value(v, lhs, Type::EXPECTED_DYNAMIC_VALUE,
- INCOMPLETE_NOT_ALLOWED, OMIT_NOT_ALLOWED, NO_SUB_CHK, NOT_IMPLICIT_OMIT,
+ INCOMPLETE_NOT_ALLOWED, OMIT_ALLOWED, NO_SUB_CHK, NOT_IMPLICIT_OMIT,
is_str_elem);
}
case OPTYPE_TMR_RUNNING_ANY: // -
case OPTYPE_GETVERDICT: // -
case OPTYPE_PROF_RUNNING: // -
+ case OPTYPE_CHECKSTATE_ANY:
+ case OPTYPE_CHECKSTATE_ALL:
break; // nothing to do
case OPTYPE_MATCH: // v1 t2
case OPTYPE_REMOVE_BOM:
self_ref |= chk_expr_self_ref_val(u.expr.v1, lhs);
break;
+ case OPTYPE_HOSTID: // [v1]
+ if (u.expr.v1) self_ref |= chk_expr_self_ref_val(u.expr.v1, lhs);
+ break;
case OPTYPE_ADD: // v1 v2
case OPTYPE_SUBTRACT: // v1 v2
case OPTYPE_MULTIPLY: // v1 v2
// boolvar := a_timer.running -- assume no self-ref
break;
break;
-
+
+ case OPTYPE_ANY2UNISTR:
case OPTYPE_LOG2STR: {// logargs
for (size_t i = 0, e = u.expr.logargs->get_nof_logargs(); i < e; ++i) {
const Ttcn::LogArgument *la = u.expr.logargs->get_logarg_byIndex(i);
switch (la->get_type()) {
case Ttcn::LogArgument::L_UNDEF:
case Ttcn::LogArgument::L_ERROR:
- FATAL_ERROR("log2str argument type");
+ FATAL_ERROR("%s argument type",
+ u.expr.v_optype == OPTYPE_ANY2UNISTR ? "any2unistr" : "log2str");
break; // not reached
case Ttcn::LogArgument::L_MACRO:
if (u.expr.v2) return create_stringRepr_predef2("encvalue_unichar");
else return create_stringRepr_predef1("encvalue_unichar");
}
+ case OPTYPE_HOSTID: {
+ if (u.expr.v1) return create_stringRepr_predef1("hostid");
+ else return string("hostid()");
+ }
case OPTYPE_DECVALUE_UNICHAR: {
if (u.expr.v3) {
string ret_val("decvalue_unichar");
return ret_val; }
case OPTYPE_LOG2STR:
return string("log2str(...)");
+ case OPTYPE_ANY2UNISTR:
+ return string("any2unistr(...)");
case OPTYPE_MATCH: {
string ret_val("match(");
ret_val += u.expr.v1->get_stringRepr();
return u.expr.r1->get_dispname() + ".running";
case OPTYPE_TMR_RUNNING_ANY:
return string("any timer.running");
+ case OPTYPE_CHECKSTATE_ANY:
+ case OPTYPE_CHECKSTATE_ALL: {
+ string ret_val("");
+ if (u.expr.r1) {
+ ret_val += u.expr.r1->get_dispname();
+ } else {
+ if (u.expr.v_optype == OPTYPE_CHECKSTATE_ANY) {
+ ret_val += "any port";
+ } else if (u.expr.v_optype == OPTYPE_CHECKSTATE_ALL) {
+ ret_val += "all port";
+ }
+ }
+ ret_val += "checkstate(";
+ ret_val += u.expr.v2->get_stringRepr();
+ ret_val += ")";
+ return ret_val; }
case OPTYPE_GETVERDICT:
return string("getverdict");
case OPTYPE_ACTIVATE: {
break;
case OPTYPE_DECODE: {
Ttcn::ActualParList *parlist = u.expr.r1->get_parlist();
- Common::Assignment *ass = u.expr.r1->get_refd_assignment();
if (parlist) str = parlist->rearrange_init_code(str, usage_mod);
parlist = u.expr.r2->get_parlist();
- ass = u.expr.r2->get_refd_assignment();
if (parlist) str = parlist->rearrange_init_code(str, usage_mod);
break; }
+ case OPTYPE_HOSTID:
+ if (u.expr.v1) str = u.expr.v1->rearrange_init_code(str, usage_mod);
+ break;
case OPTYPE_ADD:
case OPTYPE_SUBTRACT:
case OPTYPE_MULTIPLY:
case OPTYPE_DECVALUE_UNICHAR:
generate_code_expr_decvalue_unichar(expr);
break;
+ case OPTYPE_HOSTID:
+ generate_code_expr_hostid(expr);
+ break;
case OPTYPE_OCT2HEX:
generate_code_expr_predef1(expr, "oct2hex", u.expr.v1);
break;
case OPTYPE_ACTIVATE: // r1
generate_code_expr_activate(expr);
break;
+ case OPTYPE_CHECKSTATE_ANY: // [r1] v2
+ case OPTYPE_CHECKSTATE_ALL:
+ generate_code_expr_checkstate(expr);
+ break;
case OPTYPE_ACTIVATE_REFD: // v1 ap_list2
generate_code_expr_activate_refd(expr);
break;
generate_code_expr_execute_refd(expr);
break;
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
u.expr.logargs->generate_code_expr(expr);
break;
case OPTYPE_TTCN2STRING: {
Code::free_expr(&expr2);
}
+ void Value::generate_code_expr_checkstate(expression_struct *expr)
+ {
+ if (u.expr.r1) {
+ // It is a port if r1 is not null
+ u.expr.r1->generate_code_const_ref(expr);
+ expr->expr = mputstr(expr->expr, ".");
+ } else {
+ // it is an any or all port if r1 is null
+ if (u.expr.v_optype == OPTYPE_CHECKSTATE_ANY) {
+ expr->expr = mputstr(expr->expr, "PORT::any_");
+ } else if (u.expr.v_optype == OPTYPE_CHECKSTATE_ALL) {
+ expr->expr = mputstr(expr->expr, "PORT::all_");
+ } else {
+ FATAL_ERROR("Value::generate_code_expr_checkstate()");
+ }
+ }
+ expr->expr = mputstr(expr->expr, "check_port_state(");
+ u.expr.v2->generate_code_expr_mandatory(expr);
+ expr->expr = mputstr(expr->expr, ")");
+ }
+
+ void Value::generate_code_expr_hostid(expression_struct *expr)
+ {
+ expr->expr = mputstr(expr->expr, "TTCN_Runtime::get_host_address(");
+ if (u.expr.v1) u.expr.v1->generate_code_expr_mandatory(expr);
+ else expr->expr = mputstr(expr->expr, "CHARSTRING(\"Ipv4orIpv6\")");
+ expr->expr = mputstr(expr->expr, ")");
+ }
+
char* Value::generate_code_char_coding_check(expression_struct *expr, Value *v, const char *name)
{
expression_struct expr2;
case OPTYPE_GETVERDICT:
case OPTYPE_TESTCASENAME:
case OPTYPE_PROF_RUNNING:
+ case OPTYPE_CHECKSTATE_ANY:
+ case OPTYPE_CHECKSTATE_ALL:
+ case OPTYPE_HOSTID:
return true;
case OPTYPE_ENCODE:
case OPTYPE_DECODE:
case OPTYPE_VALUEOF: // ti1
return u.expr.ti1->has_single_expr();
case OPTYPE_LOG2STR:
+ case OPTYPE_ANY2UNISTR:
return u.expr.logargs->has_single_expr();
case OPTYPE_MATCH: // v1 t2
return u.expr.v1->has_single_expr() &&