Search in sources :

Example 31 with Value

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

the class ConvertToEnum method process.

@Override
protected void process(final IVisitableNode node, final Problems problems) {
    if (!(node instanceof SelectCase_Statement)) {
        return;
    }
    final SelectCase_Statement s = (SelectCase_Statement) node;
    final Value v = s.getExpression();
    if (v == null || v.getIsErroneous(timestamp)) {
        return;
    }
    final IType.Type_type type = v.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (!type.equals(Type_type.TYPE_TTCN3_ENUMERATED)) {
        final IType governor = v.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
        if (governor != null && !governor.getIsErroneous(timestamp)) {
            problems.report(v.getLocation(), MessageFormat.format(ERROR_MSG_SELECT, governor.getTypename()));
        }
    }
    final SelectCases scs = s.getSelectCases();
    if (scs == null || scs.getSelectCaseArray() == null) {
        return;
    }
    for (final SelectCase sc : scs.getSelectCaseArray()) {
        if (sc.hasElse()) {
            continue;
        }
        final CaseVisitor visitor = new CaseVisitor(problems);
        sc.accept(visitor);
    }
}
Also used : SelectCase_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.SelectCase_Statement) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) Value(org.eclipse.titan.designer.AST.Value) SelectCases(org.eclipse.titan.designer.AST.TTCN3.statements.SelectCases) SelectCase(org.eclipse.titan.designer.AST.TTCN3.statements.SelectCase) IType(org.eclipse.titan.designer.AST.IType)

Example 32 with Value

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

the class IfInsteadAltguard method process.

@Override
public void process(final IVisitableNode node, final Problems problems) {
    if (node instanceof AltGuard) {
        final AltGuard ag = (AltGuard) node;
        final StatementBlock statements = ag.getStatementBlock();
        if (statements != null && !statements.isEmpty()) {
            final Statement firstStatement = statements.getStatementByIndex(0);
            if (firstStatement instanceof If_Statement) {
                final Value condition = ((If_Statement) firstStatement).getIfClauses().getClauses().get(0).getExpression();
                Location reportAt;
                if (condition != null) {
                    reportAt = condition.getLocation();
                } else {
                    reportAt = firstStatement.getLocation();
                }
                problems.report(reportAt, MIGHT_ALTGUARD);
            }
        }
    }
}
Also used : AltGuard(org.eclipse.titan.designer.AST.TTCN3.statements.AltGuard) Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Statement) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) Value(org.eclipse.titan.designer.AST.Value) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock) Location(org.eclipse.titan.designer.AST.Location)

Example 33 with Value

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

the class ContainsRef method visit.

@Override
public int visit(final IVisitableNode node) {
    if (node instanceof If_Statement) {
        final List<If_Clause> ifs = ((If_Statement) node).getIfClauses().getClauses();
        for (final If_Clause clause : ifs) {
            final Value cond = clause.getExpression();
            if (cond != null) {
                final RefUsedInMatching mv = new RefUsedInMatching(redirectValue);
                cond.accept(mv);
                if (mv.getUsed()) {
                    smells = true;
                    suspicious = clause;
                }
            }
        }
        return V_SKIP;
    }
    return V_CONTINUE;
}
Also used : Value(org.eclipse.titan.designer.AST.Value) If_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.If_Statement) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause)

Example 34 with Value

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

the class BMPString_Type method getFieldType.

@Override
public /**
 * {@inheritDoc}
 */
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return this;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) UniversalCharstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Example 35 with Value

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

the class GraphicString_Type method getFieldType.

@Override
public /**
 * {@inheritDoc}
 */
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.size() <= actualSubReference) {
        return this;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            if (subreferences.size() > actualSubReference + 1) {
                subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
                return null;
            } else if (subreferences.size() == actualSubReference + 1) {
                reference.setStringElementReferencing();
            }
            final Value indexValue = ((ArraySubReference) subreference).getValue();
            checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
            return this;
        case fieldSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        case parameterisedSubReference:
            subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
            return null;
        default:
            subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
            return null;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference)

Aggregations

Value (org.eclipse.titan.designer.AST.Value)71 IValue (org.eclipse.titan.designer.AST.IValue)63 ISubReference (org.eclipse.titan.designer.AST.ISubReference)50 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)41 IType (org.eclipse.titan.designer.AST.IType)34 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)18 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)18 Identifier (org.eclipse.titan.designer.AST.Identifier)12 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)8 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)6 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)6 BigInteger (java.math.BigInteger)5 SequenceOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value)5 Undefined_LowerIdentifier_Value (org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)5 HashMap (java.util.HashMap)4 SelectCase_Statement (org.eclipse.titan.designer.AST.TTCN3.statements.SelectCase_Statement)4 SetOf_Value (org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value)4 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)3 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)3 Reference (org.eclipse.titan.designer.AST.Reference)3