Search in sources :

Example 6 with ValueCheckingOptions

use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.

the class Port_Utility method checkToClause.

/**
 * Checks a to clause reference to see if it really references valid
 * component type.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param source
 *                the source statement of this check.
 * @param portType
 *                the type of the port used in the statement. Used to
 *                find the address type in effect.
 * @param toClause
 *                the to clause to check
 */
public static void checkToClause(final CompilationTimeStamp timestamp, final Statement source, final Port_Type portType, final IValue toClause) {
    if (toClause == null) {
        return;
    }
    IType addressType = null;
    if (portType != null) {
        addressType = portType.getPortBody().getAddressType(timestamp);
    } else if (source != null) {
        final Module module = source.getMyStatementBlock().getModuleScope();
        if (module != null && module_type.TTCN3_MODULE.equals(module.getModuletype())) {
            addressType = ((TTCN3Module) module).getAddressType(timestamp);
        }
    }
    if (addressType == null) {
        checkComponentReference(timestamp, source, toClause, true, true);
    } else {
        // detect possible enumerated values (address may be an
        // enumerated type)
        final IValue temp = addressType.checkThisValueRef(timestamp, toClause);
        // try to figure out whether the argument is a component
        // reference or an SUT address
        boolean isAddress;
        final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        if (governor == null) {
            isAddress = !Type_type.TYPE_COMPONENT.equals(temp.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE));
        } else {
            isAddress = addressType.isCompatible(timestamp, governor, null, null, null);
        }
        if (isAddress) {
            addressType.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
        } else {
            checkComponentReference(timestamp, source, temp, true, true);
        }
    }
}
Also used : TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) IValue(org.eclipse.titan.designer.AST.IValue) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions) Module(org.eclipse.titan.designer.AST.Module) TTCN3Module(org.eclipse.titan.designer.AST.TTCN3.definitions.TTCN3Module) IType(org.eclipse.titan.designer.AST.IType)

Example 7 with ValueCheckingOptions

use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.

the class SelectCase_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (expression == null) {
        return;
    }
    IValue temp = expression.setLoweridToReference(timestamp);
    final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (governor == null) {
        if (!temp.getIsErroneous(timestamp)) {
            expression.getLocation().reportSemanticError(UNDETERMINABLETYPE);
        }
        return;
    }
    temp = governor.checkThisValueRef(timestamp, expression);
    governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
    selectcases.check(timestamp, governor);
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions) IType(org.eclipse.titan.designer.AST.IType)

Example 8 with ValueCheckingOptions

use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.

the class SelectUnionCase_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (expression == null) {
        return;
    }
    IValue temp = expression.setLoweridToReference(timestamp);
    final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (governor == null) {
        if (!temp.getIsErroneous(timestamp)) {
            expression.getLocation().reportSemanticError(UNDETERMINABLETYPE);
        }
        return;
    }
    temp = governor.checkThisValueRef(timestamp, expression);
    governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
    // referenced type
    final IType refd = governor.getTypeRefdLast(timestamp);
    if (refd instanceof TTCN3_Choice_Type) {
        // referenced union type to check
        final TTCN3_Choice_Type unionType = (TTCN3_Choice_Type) refd;
        checkUnionType(timestamp, unionType);
    } else if (refd instanceof Anytype_Type) {
        // referenced anytype type to check
        final Anytype_Type anytypeType = (Anytype_Type) refd;
        checkAnytypeType(timestamp, anytypeType);
    } else {
        expression.getLocation().reportSemanticError(TYPE_MUST_BE_UNION_OR_ANYTYPE);
        // special operations to check the body of the cases even if the select expression is erroneous
        for (int i = 0; i < selectUnionCases.getSize(); i++) {
            selectUnionCases.getSelectUnionCase(i).checkStatementBlock(timestamp);
        }
        return;
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions) TTCN3_Choice_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type) IType(org.eclipse.titan.designer.AST.IType) Anytype_Type(org.eclipse.titan.designer.AST.TTCN3.types.Anytype_Type)

Example 9 with ValueCheckingOptions

use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.

the class LogArgument method checkValue.

/**
 * Does the semantic checking of the log argument. Once it was
 * determined that it is a value.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 * @param value
 *                the value contained in the log argument.
 */
private void checkValue(final CompilationTimeStamp timestamp, final IValue value) {
    final IValue temp = value.setLoweridToReference(timestamp);
    switch(temp.getValuetype()) {
        case CHARSTRING_VALUE:
            internalLogArgument = new String_InternalLogArgument(((Charstring_Value) temp).getValue());
            break;
        case REFERENCED_VALUE:
            final Reference reference = ((Referenced_Value) temp).getReference();
            internalLogArgument = new Reference_InternalLogArgument(reference);
            checkReference(timestamp, reference);
            return;
        case EXPRESSION_VALUE:
            final Expression_Value castedValue = (Expression_Value) temp;
            if (Operation_type.MATCH_OPERATION.equals(castedValue.getOperationType())) {
                internalLogArgument = new Match_InternalLogArgument((MatchExpression) castedValue);
            } else {
                internalLogArgument = new Value_InternalLogArgument(temp);
            }
            break;
        case MACRO_VALUE:
            internalLogArgument = new Macro_InternalLogArgument((Macro_Value) temp);
            break;
        default:
            internalLogArgument = new Value_InternalLogArgument(temp);
            break;
    }
    final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
    if (governor == null) {
        getLocation().reportSemanticError("Cannot determine the type of the argument");
        isErroneous = true;
        return;
    }
    // TODO: Is the next part necessary ???
    temp.setMyGovernor(governor);
    // TODO:WHY
    governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_TEMPLATE, true, true, true, true, false));
    final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    if (ArgumentType.Value.equals(internalLogArgument.getArgumentType()) && !temp.isUnfoldable(timestamp)) {
        final IValue last = temp.getValueRefdLast(timestamp, chain);
        if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
            internalLogArgument = new String_InternalLogArgument(((Charstring_Value) last).getValue());
        }
    } else if (ArgumentType.Macro.equals(internalLogArgument.getArgumentType())) {
        final IValue last = temp.getValueRefdLast(timestamp, chain);
        switch(last.getValuetype()) {
            case CHARSTRING_VALUE:
                internalLogArgument = new String_InternalLogArgument(((Charstring_Value) last).getValue());
                break;
            case MACRO_VALUE:
                break;
            default:
                internalLogArgument = new Value_InternalLogArgument(temp);
                break;
        }
    }
    chain.release();
}
Also used : Reference(org.eclipse.titan.designer.AST.Reference) Expression_Value(org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value) Macro_Value(org.eclipse.titan.designer.AST.TTCN3.values.Macro_Value) MatchExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.MatchExpression) IType(org.eclipse.titan.designer.AST.IType) IValue(org.eclipse.titan.designer.AST.IValue) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)

Example 10 with ValueCheckingOptions

use of org.eclipse.titan.designer.AST.IType.ValueCheckingOptions in project titan.EclipsePlug-ins by eclipse.

the class SpecificValue_Template method checkThisTemplateGeneric.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplateGeneric(final CompilationTimeStamp timestamp, final IType type, final boolean isModified, final boolean allowOmit, final boolean allowAnyOrOmit, final boolean subCheck, final boolean implicitOmit, final Assignment lhs) {
    if (getIsErroneous(timestamp)) {
        return false;
    }
    if (type == null) {
        return false;
    }
    boolean selfReference = false;
    type.check(timestamp);
    if (specificValue != null) {
        specificValue.setMyGovernor(type);
        final IValue temporalValue = type.checkThisValueRef(timestamp, specificValue);
        selfReference = type.checkThisValue(timestamp, temporalValue, lhs, new ValueCheckingOptions(Expected_Value_type.EXPECTED_TEMPLATE, isModified, allowOmit, true, implicitOmit, false));
    }
    checkLengthRestriction(timestamp, type);
    if (!allowOmit && isIfpresent) {
        if (location != null && !(location instanceof NULL_Location)) {
            location.reportSemanticError("`ifpresent' is not allowed here");
        } else if (specificValue != null && !(specificValue.getLocation() instanceof NULL_Location)) {
            specificValue.getLocation().reportSemanticError("`ifpresent' is not allowed here");
        }
    }
    if (subCheck) {
        type.checkThisTemplateSubtype(timestamp, this);
    }
    return selfReference;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) NULL_Location(org.eclipse.titan.designer.AST.NULL_Location) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)

Aggregations

ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)24 IValue (org.eclipse.titan.designer.AST.IValue)22 IType (org.eclipse.titan.designer.AST.IType)18 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)7 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)5 Reference (org.eclipse.titan.designer.AST.Reference)4 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)4 ISubReference (org.eclipse.titan.designer.AST.ISubReference)3 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)3 Identifier (org.eclipse.titan.designer.AST.Identifier)3 Module (org.eclipse.titan.designer.AST.Module)3 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)3 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)2 Scope (org.eclipse.titan.designer.AST.Scope)2 ComponentTypeBody (org.eclipse.titan.designer.AST.TTCN3.types.ComponentTypeBody)2 Integer_Type (org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)2 Undefined_LowerIdentifier_Value (org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)2 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)2