Search in sources :

Example 31 with SpecificValue_Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template in project titan.EclipsePlug-ins by eclipse.

the class ReplaceExpression method isUnfoldable.

@Override
public /**
 * {@inheritDoc}
 */
boolean isUnfoldable(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (templateInstance1 == null || templateInstance4 == null || getIsErroneous(timestamp)) {
        return true;
    }
    final ITTCN3Template template1 = templateInstance1.getTemplateBody();
    if (template1 == null || !Template_type.SPECIFIC_VALUE.equals(template1.getTemplatetype())) {
        return true;
    }
    final ITTCN3Template template4 = templateInstance4.getTemplateBody();
    if (template4 == null || !Template_type.SPECIFIC_VALUE.equals(template4.getTemplatetype())) {
        return true;
    }
    final IValue value1 = ((SpecificValue_Template) template1).getSpecificValue();
    final IValue value4 = ((SpecificValue_Template) template4).getSpecificValue();
    if (value1 == null || value4 == null) {
        return true;
    }
    if (value2 == null || value3 == null) {
        return true;
    }
    if (value1.isUnfoldable(timestamp, expectedValue, referenceChain) || value2.isUnfoldable(timestamp, expectedValue, referenceChain) || value3.isUnfoldable(timestamp, expectedValue, referenceChain) || value4.isUnfoldable(timestamp, expectedValue, referenceChain)) {
        return true;
    }
    value1.setLoweridToReference(timestamp);
    final Type_type tempType = value1.getExpressionReturntype(timestamp, expectedValue);
    switch(tempType) {
        case TYPE_BITSTRING:
        case TYPE_HEXSTRING:
        case TYPE_OCTETSTRING:
        case TYPE_CHARSTRING:
        case TYPE_UCHARSTRING:
            return false;
        default:
            return true;
    }
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) IValue(org.eclipse.titan.designer.AST.IValue) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Type_type(org.eclipse.titan.designer.AST.IType.Type_type)

Example 32 with SpecificValue_Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template in project titan.EclipsePlug-ins by eclipse.

the class ReplaceExpression method checkExpressionOperands.

/**
 * Checks the parameters of the expression and if they are valid in
 * their position in the expression or not.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param expectedValue
 *                the kind of value expected.
 * @param referenceChain
 *                a reference chain to detect cyclic references.
 */
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
    Type_type tempType1 = null;
    IValue value1 = null;
    if (templateInstance1 != null) {
        final ITTCN3Template temp = templateInstance1.getTemplateBody();
        switch(temp.getTemplatetype()) {
            case SPECIFIC_VALUE:
                break;
            case TEMPLATE_LIST:
            case NAMED_TEMPLATE_LIST:
            case INDEXED_TEMPLATE_LIST:
                templateInstance1.getLocation().reportSemanticError(OPERANDERROR13);
                setIsErroneous(true);
                return;
            default:
                templateInstance1.getLocation().reportSemanticError(OPERANDERROR5);
                setIsErroneous(true);
                return;
        }
        // temp is specific value:
        value1 = ((SpecificValue_Template) temp).getSpecificValue();
        value1.setLoweridToReference(timestamp);
        tempType1 = value1.getExpressionReturntype(timestamp, internalExpectation);
        switch(tempType1) {
            case TYPE_BITSTRING:
            case TYPE_HEXSTRING:
            case TYPE_OCTETSTRING:
            case TYPE_CHARSTRING:
            case TYPE_UCHARSTRING:
            case TYPE_SET_OF:
            case TYPE_SEQUENCE_OF:
                value1.getValueRefdLast(timestamp, internalExpectation, referenceChain);
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                templateInstance1.getLocation().reportSemanticError(OPERANDERROR5);
                setIsErroneous(true);
                break;
        }
    }
    if (value2 != null) {
        value2.setLoweridToReference(timestamp);
        final Type_type tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType2) {
            case TYPE_INTEGER:
                final IValue last2 = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (!last2.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last2.getValuetype())) {
                    if (((Integer_Value) last2).isNative()) {
                        final long i = ((Integer_Value) last2).getValue();
                        if (i < 0) {
                            value2.getLocation().reportSemanticError(OPERANDERROR3);
                            setIsErroneous(true);
                        }
                    } else {
                        value2.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR11, ((Integer_Value) last2).getValueValue()));
                        setIsErroneous(true);
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                value2.getLocation().reportSemanticError(OPERANDERROR1);
                setIsErroneous(true);
                break;
        }
    }
    if (value3 != null) {
        value3.setLoweridToReference(timestamp);
        final Type_type tempType3 = value3.getExpressionReturntype(timestamp, expectedValue);
        switch(tempType3) {
            case TYPE_INTEGER:
                final IValue last3 = value3.getValueRefdLast(timestamp, expectedValue, referenceChain);
                if (!last3.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last3.getValuetype())) {
                    if (((Integer_Value) last3).isNative()) {
                        final long i = ((Integer_Value) last3).getValue();
                        if (i < 0) {
                            value3.getLocation().reportSemanticError(OPERANDERROR4);
                            setIsErroneous(true);
                        }
                    } else {
                        value3.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR12, ((Integer_Value) last3).getValueValue()));
                        setIsErroneous(true);
                    }
                }
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                value3.getLocation().reportSemanticError(OPERANDERROR2);
                setIsErroneous(true);
                break;
        }
    }
    Type_type tempType4 = null;
    IValue value4 = null;
    if (templateInstance4 != null) {
        final ITTCN3Template temp = templateInstance4.getTemplateBody();
        switch(temp.getTemplatetype()) {
            case SPECIFIC_VALUE:
                value4 = ((SpecificValue_Template) temp).getSpecificValue();
                break;
            case TEMPLATE_LIST:
                if (!((Template_List) temp).isValue(timestamp)) {
                    templateInstance4.getLocation().reportSemanticError(OPERANDERROR6);
                    setIsErroneous(true);
                    return;
                }
            case NAMED_TEMPLATE_LIST:
            case INDEXED_TEMPLATE_LIST:
                tempType4 = templateInstance4.getExpressionReturntype(timestamp, expectedValue);
                if (Type_type.TYPE_UNDEFINED.equals(tempType4)) {
                    templateInstance4.getLocation().reportSemanticError(OPERANDERROR13);
                }
                return;
            default:
                templateInstance4.getLocation().reportSemanticError(OPERANDERROR6);
                setIsErroneous(true);
                return;
        }
        value4.setLoweridToReference(timestamp);
        tempType4 = value4.getExpressionReturntype(timestamp, internalExpectation);
        switch(tempType4) {
            case TYPE_BITSTRING:
            case TYPE_HEXSTRING:
            case TYPE_OCTETSTRING:
            case TYPE_CHARSTRING:
            case TYPE_UCHARSTRING:
            case TYPE_SET_OF:
            case TYPE_SEQUENCE_OF:
                value4.getValueRefdLast(timestamp, internalExpectation, referenceChain);
                break;
            case TYPE_UNDEFINED:
                setIsErroneous(true);
                break;
            default:
                location.reportSemanticError(OPERANDERROR6);
                setIsErroneous(true);
                break;
        }
    }
    if (tempType1 != null && tempType4 != null && !tempType1.equals(tempType4) && !getIsErroneous(timestamp)) {
        location.reportSemanticError(OPERANDERROR7);
        setIsErroneous(true);
    }
    checkExpressionOperandsHelper(timestamp, value1, expectedValue, referenceChain);
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)

Example 33 with SpecificValue_Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template in project titan.EclipsePlug-ins by eclipse.

the class ReplaceExpression method evaluateValue.

@Override
public /**
 * {@inheritDoc}
 */
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return lastValue;
    }
    isErroneous = false;
    lastTimeChecked = timestamp;
    lastValue = this;
    if (templateInstance1 == null || value2 == null || value3 == null || templateInstance4 == null) {
        setIsErroneous(true);
        return lastValue;
    }
    checkExpressionOperands(timestamp, expectedValue, referenceChain);
    if (getIsErroneous(timestamp)) {
        return lastValue;
    }
    if (isUnfoldable(timestamp, referenceChain)) {
        return lastValue;
    }
    ITTCN3Template temp = templateInstance1.getTemplateBody();
    final IValue value1 = ((SpecificValue_Template) temp).getSpecificValue();
    final IValue v1 = value1.getValueRefdLast(timestamp, referenceChain);
    final IValue v2 = value2.getValueRefdLast(timestamp, referenceChain);
    final IValue v3 = value3.getValueRefdLast(timestamp, referenceChain);
    temp = templateInstance4.getTemplateBody();
    final IValue value4 = ((SpecificValue_Template) temp).getSpecificValue();
    final IValue v4 = value4.getValueRefdLast(timestamp, referenceChain);
    final Value_type vt = v1.getValuetype();
    final int index = ((Integer_Value) v2).intValue();
    final int len = ((Integer_Value) v3).intValue();
    switch(vt) {
        case BITSTRING_VALUE:
            {
                final String v1Str = ((Bitstring_Value) v1).getValue();
                final String v4Str = ((Bitstring_Value) v4).getValue();
                String result = v1Str.substring(0, index);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring(index + len));
                lastValue = new Bitstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case HEXSTRING_VALUE:
            {
                final String v1Str = ((Hexstring_Value) v1).getValue();
                final String v4Str = ((Hexstring_Value) v4).getValue();
                String result = v1Str.substring(0, index);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring(index + len));
                lastValue = new Hexstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case OCTETSTRING_VALUE:
            {
                final String v1Str = ((Octetstring_Value) v1).getValue();
                final String v4Str = ((Octetstring_Value) v4).getValue();
                String result = v1Str.substring(0, index * 2);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring((index + len) * 2));
                lastValue = new Octetstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case CHARSTRING_VALUE:
            {
                final String v1Str = ((Charstring_Value) v1).getValue();
                final String v4Str = ((Charstring_Value) v4).getValue();
                String result = v1Str.substring(0, index);
                result = result.concat(v4Str);
                result = result.concat(v1Str.substring(index + len));
                lastValue = new Charstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        case UNIVERSALCHARSTRING_VALUE:
            {
                final UniversalCharstring v1Str = ((UniversalCharstring_Value) v1).getValue();
                final UniversalCharstring v4Str = ((UniversalCharstring_Value) v4).getValue();
                final UniversalCharstring result = v1Str.substring(0, index);
                // This append() is not like concat().
                result.append(v4Str);
                result.append(v1Str.substring(index + len));
                lastValue = new UniversalCharstring_Value(result);
                lastValue.copyGeneralProperties(this);
                break;
            }
        default:
            setIsErroneous(true);
            break;
    }
    return lastValue;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Hexstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Hexstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) UniversalCharstring(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring) Octetstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value) IValue(org.eclipse.titan.designer.AST.IValue) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Expected_Value_type(org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type) Bitstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)

Example 34 with SpecificValue_Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template in project titan.EclipsePlug-ins by eclipse.

the class ExpressionUtilities method checkExpressionOperatorCompatibilityInternal.

// the same as the previous but the last arg is template
private static void checkExpressionOperatorCompatibilityInternal(final CompilationTimeStamp timestamp, final Expression_Value expression, final IReferenceChain referenceChain, final Expected_Value_type expectedValue, final IValue param1, final TemplateInstance param2) {
    if (expression == null || param1 == null || param2 == null) {
        return;
    }
    if (param1.getIsErroneous(timestamp) || param2.getTemplateBody().getIsErroneous(timestamp)) {
        expression.setIsErroneous(true);
        return;
    }
    IValue operand1 = param1;
    final TemplateInstance operand2 = param2;
    final Type_type tempType1 = operand1.getExpressionReturntype(timestamp, expectedValue);
    final Type_type tempType2 = operand2.getExpressionReturntype(timestamp, expectedValue);
    ITTCN3Template temp2 = operand2.getTemplateBody();
    if (Type_type.TYPE_UNDEFINED.equals(tempType1)) {
        if (Type_type.TYPE_UNDEFINED.equals(tempType2)) {
            if (Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE.equals(operand1.getValuetype())) {
                if (Template_type.SPECIFIC_VALUE.equals(temp2.getTemplatetype()) && Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE.equals(((SpecificValue_Template) temp2).getSpecificValue().getValuetype())) {
                    final Scope scope = expression.getMyScope();
                    final Module module = scope.getModuleScope();
                    final Identifier identifier = ((Undefined_LowerIdentifier_Value) operand1).getIdentifier();
                    if (scope.hasAssignmentWithId(timestamp, identifier) || module.hasImportedAssignmentWithID(timestamp, identifier)) {
                        operand1 = operand1.setLoweridToReference(timestamp);
                        checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, operand1, operand2);
                        return;
                    }
                    final Identifier identifier2 = ((Undefined_LowerIdentifier_Value) ((SpecificValue_Template) temp2).getSpecificValue()).getIdentifier();
                    if (scope.hasAssignmentWithId(timestamp, identifier2) || module.hasImportedAssignmentWithID(timestamp, identifier2)) {
                        temp2 = temp2.setLoweridToReference(timestamp);
                        checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, operand1, operand2);
                        return;
                    }
                } else {
                    operand1 = operand1.setLoweridToReference(timestamp);
                    checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, operand1, operand2);
                    return;
                }
            } else if (Template_type.SPECIFIC_VALUE.equals(temp2.getTemplatetype()) && Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE.equals(((SpecificValue_Template) temp2).getSpecificValue().getValuetype())) {
                temp2 = temp2.setLoweridToReference(timestamp);
                // To avoid infinite loop:
                final TemplateInstance tempTemplateInstance2 = new TemplateInstance(operand2.getType(), operand2.getDerivedReference(), (TTCN3Template) temp2);
                if (operand2 == tempTemplateInstance2) {
                    return;
                }
                checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, operand1, tempTemplateInstance2);
                return;
            }
            if (operand1.getIsErroneous(timestamp) || temp2.getIsErroneous(timestamp)) {
                expression.setIsErroneous(true);
                return;
            }
            expression.getLocation().reportSemanticError(UNDETERMINABLEOPERANDSERROR);
            expression.setIsErroneous(true);
            return;
        }
        if (Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE.equals(operand1.getValuetype()) && !Type_type.TYPE_TTCN3_ENUMERATED.equals(tempType2)) {
            operand1 = operand1.setLoweridToReference(timestamp);
            checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, operand1, operand2);
            return;
        }
    } else if (Type_type.TYPE_UNDEFINED.equals(tempType2)) {
        if (Template_type.SPECIFIC_VALUE.equals(temp2.getTemplatetype()) && Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE.equals(((SpecificValue_Template) temp2).getSpecificValue().getValuetype()) && !Type_type.TYPE_TTCN3_ENUMERATED.equals(tempType1)) {
            temp2 = temp2.setLoweridToReference(timestamp);
            // To avoid infinite loop:
            final TemplateInstance tempTemplateInstance2 = new TemplateInstance(operand2.getType(), operand2.getDerivedReference(), (TTCN3Template) temp2);
            if (operand2 == tempTemplateInstance2) {
                return;
            }
            checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, operand1, tempTemplateInstance2);
            return;
        }
    }
    final IType type1 = operand1.getExpressionGovernor(timestamp, expectedValue);
    final IType type2 = operand2.getExpressionGovernor(timestamp, expectedValue);
    if (operand1.getIsErroneous(timestamp) || temp2.getIsErroneous(timestamp)) {
        expression.setIsErroneous(true);
        return;
    }
    if (type1 != null) {
        if (type2 != null) {
            final TypeCompatibilityInfo info1 = new TypeCompatibilityInfo(type1, type2, true);
            final TypeCompatibilityInfo info2 = new TypeCompatibilityInfo(type2, type1, true);
            final boolean retVal1 = type1.isCompatible(timestamp, type2, info1, null, null);
            final boolean retVal2 = type2.isCompatible(timestamp, type1, info2, null, null);
            if (!retVal1 && !retVal2) {
                expression.getLocation().reportSemanticError(info1.toString());
                expression.setIsErroneous(true);
                return;
            }
            if (GeneralConstants.WARNING.equals(typeCompatibilitySeverity)) {
                if (info1.getNeedsConversion()) {
                    expression.getLocation().reportSemanticWarning(MessageFormat.format(TYPECOMPATWARNING, type1.getTypename(), type2.getTypename()));
                } else if (info2.getNeedsConversion()) {
                    expression.getLocation().reportSemanticWarning(MessageFormat.format(TYPECOMPATWARNING, type2.getTypename(), type1.getTypename()));
                }
            }
        } else {
            temp2.setMyGovernor(type1);
            final ITTCN3Template tempValue = type1.checkThisTemplateRef(timestamp, temp2);
            if (Template_type.OMIT_VALUE.equals(temp2.getTemplatetype()) || (Template_type.SPECIFIC_VALUE.equals(temp2.getTemplatetype()) && Value_type.OMIT_VALUE.equals(((SpecificValue_Template) temp2).getSpecificValue().getValuetype()))) {
                operand1.checkExpressionOmitComparison(timestamp, expectedValue);
            } else {
                type1.checkThisTemplate(timestamp, tempValue, false, false, null);
                final TemplateInstance tempTemplateInstance2 = new TemplateInstance(operand2.getType(), operand2.getDerivedReference(), (TTCN3Template) tempValue);
                if (operand2 == tempTemplateInstance2) {
                    return;
                }
                checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, operand1, tempTemplateInstance2);
                return;
            }
        }
    } else if (type2 != null) {
        operand1.setMyGovernor(type2);
        final IValue tempValue = type2.checkThisValueRef(timestamp, operand1);
        if (Value_type.OMIT_VALUE.equals(operand1.getValuetype())) {
        // temp2.check_expression_omit_comparison(timestamp,
        // expectedValue); ???
        } else {
            type2.checkThisValue(timestamp, tempValue, null, new ValueCheckingOptions(expectedValue, false, false, false, false, false));
            checkExpressionOperatorCompatibilityInternal(timestamp, expression, referenceChain, expectedValue, tempValue, operand2);
            return;
        }
    } else {
        if (Type_type.TYPE_UNDEFINED.equals(tempType1) || Type_type.TYPE_UNDEFINED.equals(tempType2)) {
            expression.getLocation().reportSemanticError(PLEASEUSEREFERENCES);
            expression.setIsErroneous(true);
            return;
        }
        if (!Type.isCompatible(timestamp, tempType1, tempType2, false, false) && !Type.isCompatible(timestamp, tempType2, tempType1, false, false)) {
            expression.getLocation().reportSemanticError(INCOMPATIBLEOPERANDERROR);
            expression.setIsErroneous(true);
        }
    }
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) TemplateInstance(org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance) IType(org.eclipse.titan.designer.AST.IType) IValue(org.eclipse.titan.designer.AST.IValue) Identifier(org.eclipse.titan.designer.AST.Identifier) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Scope(org.eclipse.titan.designer.AST.Scope) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) TypeCompatibilityInfo(org.eclipse.titan.designer.AST.TypeCompatibilityInfo) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions) Module(org.eclipse.titan.designer.AST.Module) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Example 35 with SpecificValue_Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template in project titan.EclipsePlug-ins by eclipse.

the class IsValueExpression method generateCodeExpressionExpression.

@Override
public /**
 * {@inheritDoc}
 */
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
    final TTCN3Template templateBody = templateInstance.getTemplateBody();
    // FIXME actually a bit more complex
    if (templateInstance.getDerivedReference() == null && Template_type.SPECIFIC_VALUE.equals(templateBody.getTemplatetype()) && ((SpecificValue_Template) templateBody).isValue(CompilationTimeStamp.getBaseTimestamp())) {
        final IValue value = ((SpecificValue_Template) templateBody).getValue();
        // FIXME implement support for cast
        value.generateCodeExpression(aData, expression, true);
    } else {
        templateInstance.generateCode(aData, expression, Restriction_type.TR_NONE);
    }
    expression.expression.append(".isValue()");
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)

Aggregations

SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)30 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)27 IValue (org.eclipse.titan.designer.AST.IValue)26 Assignment (org.eclipse.titan.designer.AST.Assignment)15 Reference (org.eclipse.titan.designer.AST.Reference)15 TTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)12 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)10 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)9 IType (org.eclipse.titan.designer.AST.IType)7 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)7 ISubReference (org.eclipse.titan.designer.AST.ISubReference)6 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)6 ArrayList (java.util.ArrayList)5 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)5 Referenced_Template (org.eclipse.titan.designer.AST.TTCN3.templates.Referenced_Template)5 Boolean_Value (org.eclipse.titan.designer.AST.TTCN3.values.Boolean_Value)4 Array_Type (org.eclipse.titan.designer.AST.TTCN3.types.Array_Type)3 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)3 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)3 Octetstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Octetstring_Value)3