Search in sources :

Example 16 with Function_Type

use of org.eclipse.titan.designer.AST.TTCN3.types.Function_Type 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

IType (org.eclipse.titan.designer.AST.IType)14 Function_Type (org.eclipse.titan.designer.AST.TTCN3.types.Function_Type)12 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)4 FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)4 Type (org.eclipse.titan.designer.AST.Type)4 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)3 Expression_Value (org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value)3 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)2 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)2 Component_Type (org.eclipse.titan.designer.AST.TTCN3.types.Component_Type)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Value_Assignment (org.eclipse.titan.designer.AST.ASN1.Value_Assignment)1 Assignment (org.eclipse.titan.designer.AST.Assignment)1 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)1 IValue (org.eclipse.titan.designer.AST.IValue)1 Reference (org.eclipse.titan.designer.AST.Reference)1 Restriction_type (org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type)1 Def_Var_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)1 RunsOnScope (org.eclipse.titan.designer.AST.TTCN3.definitions.RunsOnScope)1