Search in sources :

Example 11 with IType

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

the class Octetstring_Value method getReferencedSubValue.

@Override
public /**
 * {@inheritDoc}
 */
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return this;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            final Value arrayIndex = ((ArraySubReference) subreference).getValue();
            final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, refChain);
            if (!valueIndex.isUnfoldable(timestamp)) {
                if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
                    final int index = ((Integer_Value) valueIndex).intValue();
                    return getStringElement(index, arrayIndex.getLocation());
                }
                arrayIndex.getLocation().reportSemanticError(ArraySubReference.INTEGERINDEXEXPECTED);
                return null;
            }
            return null;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), type.getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) IValue(org.eclipse.titan.designer.AST.IValue) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) IType(org.eclipse.titan.designer.AST.IType) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 12 with IType

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

the class Omit_Value method generateSingleExpression.

@Override
public /**
 * {@inheritDoc}
 */
StringBuilder generateSingleExpression(final JavaGenData aData) {
    aData.addBuiltinTypeImport("Base_Template.template_sel");
    IType governor = myGovernor;
    if (governor == null) {
        governor = myLastSetGovernor;
    }
    final StringBuilder result = new StringBuilder();
    result.append(MessageFormat.format("new Optional<{0}>({0}.class, template_sel.OMIT_VALUE)", governor.getGenNameValue(aData, result, myScope)));
    return result;
}
Also used : IType(org.eclipse.titan.designer.AST.IType)

Example 13 with IType

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

the class Real_Value method getReferencedSubValue.

@Override
public /**
 * {@inheritDoc}
 */
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return this;
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
            return null;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), type.getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) IType(org.eclipse.titan.designer.AST.IType)

Example 14 with IType

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

the class Referenced_Value method checkExpressionOmitComparison.

@Override
public /**
 * {@inheritDoc}
 */
void checkExpressionOmitComparison(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
    if (getIsErroneous(timestamp)) {
        return;
    }
    final List<ISubReference> subreferences = new ArrayList<ISubReference>();
    subreferences.addAll(reference.getSubreferences());
    if (subreferences.size() <= 1) {
        return;
    }
    final ISubReference subreference = subreferences.remove(subreferences.size() - 1);
    final Identifier id = subreference.getId();
    if (id == null) {
        getLocation().reportSemanticError("Only a reference pointing to an optional record or set field can be compared with `omit'");
        setIsErroneous(true);
        return;
    }
    final Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
        setIsErroneous(true);
        return;
    }
    IType type = assignment.getType(timestamp);
    if (type == null) {
        setIsErroneous(true);
        return;
    }
    final Reference tempReference = new Reference(null, subreferences);
    tempReference.setFullNameParent(this);
    tempReference.setMyScope(myScope);
    type = type.getFieldType(timestamp, tempReference, 1, expectedValue, false);
    if (type == null) {
        setIsErroneous(true);
        return;
    }
    type = type.getTypeRefdLast(timestamp);
    if (type == null || type.getIsErroneous(timestamp)) {
        setIsErroneous(true);
        return;
    }
    switch(type.getTypetype()) {
        case TYPE_ASN1_SEQUENCE:
            if (!((ASN1_Sequence_Type) type).hasComponentWithName(id)) {
                getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
                setIsErroneous(true);
            } else if (!((ASN1_Sequence_Type) type).getComponentByName(id).isOptional()) {
                getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
                setIsErroneous(true);
            }
            break;
        case TYPE_TTCN3_SEQUENCE:
            if (!((TTCN3_Sequence_Type) type).hasComponentWithName(id.getName())) {
                getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
                setIsErroneous(true);
            } else if (!((TTCN3_Sequence_Type) type).getComponentByName(id.getName()).isOptional()) {
                getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
                setIsErroneous(true);
            }
            break;
        case TYPE_ASN1_SET:
            if (!((ASN1_Set_Type) type).hasComponentWithName(id)) {
                getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
                setIsErroneous(true);
            } else if (!((ASN1_Set_Type) type).getComponentByName(id).isOptional()) {
                getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
                setIsErroneous(true);
            }
            break;
        case TYPE_TTCN3_SET:
            if (!((TTCN3_Set_Type) type).hasComponentWithName(id.getName())) {
                getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
                setIsErroneous(true);
            } else if (!((TTCN3_Set_Type) type).getComponentByName(id.getName()).isOptional()) {
                getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
                setIsErroneous(true);
            }
            break;
        default:
            getLocation().reportSemanticError("Only a reference pointing to an optional record or set field can be compared with `omit'");
            setIsErroneous(true);
            break;
    }
}
Also used : Value_Assignment(org.eclipse.titan.designer.AST.ASN1.Value_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) ArrayList(java.util.ArrayList) IType(org.eclipse.titan.designer.AST.IType)

Example 15 with IType

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

the class Referenced_Value method checkExpressionSelfReferenceValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkExpressionSelfReferenceValue(final CompilationTimeStamp timestamp, final Assignment lhs) {
    IType governor = myGovernor;
    if (governor == null) {
        governor = getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    }
    if (governor == null) {
        return false;
    }
    final boolean isStringElement = reference.refersToStringElement();
    return governor.checkThisValue(timestamp, this, lhs, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, true, false, false, isStringElement));
}
Also used : ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IType (org.eclipse.titan.designer.AST.IType)414 IValue (org.eclipse.titan.designer.AST.IValue)94 ISubReference (org.eclipse.titan.designer.AST.ISubReference)82 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)65 Identifier (org.eclipse.titan.designer.AST.Identifier)49 Assignment (org.eclipse.titan.designer.AST.Assignment)40 Value (org.eclipse.titan.designer.AST.Value)34 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)33 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)27 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)21 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)21 Reference (org.eclipse.titan.designer.AST.Reference)21 Type (org.eclipse.titan.designer.AST.Type)20 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)18 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)17 ArrayList (java.util.ArrayList)16 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)15 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)14 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)14 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)13