Search in sources :

Example 6 with Function_Reference_Value

use of org.eclipse.titan.designer.AST.TTCN3.values.Function_Reference_Value in project titan.EclipsePlug-ins by eclipse.

the class SpecificValue_Template method isValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean isValue(final CompilationTimeStamp timestamp) {
    if (lengthRestriction != null || isIfpresent || getIsErroneous(timestamp)) {
        return false;
    }
    if (realTemplate != null && realTemplate != this) {
        return realTemplate.isValue(timestamp);
    }
    if (Value_type.FUNCTION_REFERENCE_VALUE.equals(specificValue.getValuetype())) {
        final IType governor = ((Function_Reference_Value) specificValue).getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        if (governor == null) {
            return true;
        }
        final IType last = governor.getTypeRefdLast(timestamp);
        if (Type_type.TYPE_FUNCTION.equals(last.getTypetype()) && ((Function_Type) last).returnsTemplate()) {
            return false;
        }
    } else if (Value_type.REFERENCED_VALUE.equals(specificValue.getValuetype())) {
        final Reference reference = ((Referenced_Value) specificValue).getReference();
        final Assignment assignment = reference.getRefdAssignment(timestamp, true);
        if (assignment == null) {
            return true;
        }
        switch(assignment.getAssignmentType()) {
            case A_CONST:
            case A_TIMER:
            case A_EXT_CONST:
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_OUT:
            case A_PAR_VAL_INOUT:
            case A_VAR:
            case A_FUNCTION_RVAL:
            case A_EXT_FUNCTION_RVAL:
            case A_MODULEPAR:
            case A_MODULEPAR_TEMPLATE:
                // runtime evaluation!
                return true;
            case A_TEMPLATE:
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_INOUT:
            case A_FUNCTION_RTEMP:
            case A_VAR_TEMPLATE:
                boolean result = true;
                final Restriction_type rt = ((Definition) assignment).getTemplateRestriction();
                if (TemplateRestriction.Restriction_type.TR_OMIT.equals(rt) || TemplateRestriction.Restriction_type.TR_PRESENT.equals(rt)) {
                    result = false;
                }
                final TTCN3Template ttemplate = getTemplateReferencedLast(timestamp);
                if ((!ttemplate.equals(this)) && (ttemplate.isValue(timestamp))) {
                    // ok
                    return result;
                } else {
                    return false;
                }
            default:
                return false;
        }
    }
    return true;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Reference(org.eclipse.titan.designer.AST.Reference) Restriction_type(org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type) Function_Reference_Value(org.eclipse.titan.designer.AST.TTCN3.values.Function_Reference_Value) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)4 Function_Reference_Value (org.eclipse.titan.designer.AST.TTCN3.values.Function_Reference_Value)4 IType (org.eclipse.titan.designer.AST.IType)3 Assignment (org.eclipse.titan.designer.AST.Assignment)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)2 Restriction_type (org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type)2 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)2 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)2 Reference (org.eclipse.titan.designer.AST.Reference)1 Scope (org.eclipse.titan.designer.AST.Scope)1 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)1 Def_Extfunction (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Extfunction)1 Def_Testcase (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase)1 RunsOnScope (org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)1 Altstep_Reference_Value (org.eclipse.titan.designer.AST.TTCN3.values.Altstep_Reference_Value)1 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)1 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)1 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)1 Hexstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value)1 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)1