Search in sources :

Example 1 with Identifier

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

the class TestCase_Function_Visit_Handler method leave.

public void leave(IVisitableNode node) {
    if (waitForTC || waitForFunction) {
        if (node instanceof Definition_Statement) {
            if (!waitForRecord) {
                nodeVarIsRecord.add(false);
            }
            waitForRecord = false;
            waitForValue = false;
            evaluateExpression();
        }
        if (node instanceof Undefined_LowerIdentifier_Value) {
            blockReferenceListing = false;
        }
        if ((node instanceof Assignment_Statement) || ((node instanceof If_Clause))) {
            waitForValue = false;
            // if assignment is a createExpression
            if (node instanceof Assignment_Statement) {
                if (((Assignment_Statement) node).getTemplate() instanceof SpecificValue_Template) {
                    SpecificValue_Template specValTemplate = (SpecificValue_Template) ((Assignment_Statement) node).getTemplate();
                    if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
                        isCreate = true;
                    }
                }
            }
            evaluateExpression();
        }
        if (node instanceof SequenceOf_Value) {
            evaluateExpression();
        }
        if ((waitForFunction && (node instanceof Return_Statement)) || (waitForTC && (node instanceof ComponentCreateExpression)) || (node instanceof Send_Statement) || (node instanceof Receive_Port_Statement)) {
            evaluateExpression();
        }
        if (waitForTcStartValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
            myASTVisitor.blockIdListing = false;
        }
        if (waitForTcStopValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
            myASTVisitor.blockIdListing = false;
        }
        if (node instanceof Connect_Statement) {
            waitForTcConnectValues = false;
        }
        if (node instanceof Disconnect_Statement) {
            waitForTcDisconnectValues = false;
        }
        if (node instanceof Unknown_Start_Statement) {
            waitForTcStartValues = false;
        }
        if (node instanceof Unknown_Stop_Statement) {
            waitForTcStopValues = false;
        }
        if (node instanceof Definition_Statement) {
            waitForDefStatement = false;
            if (waitForValue) {
                nodeVarValues.add(null);
                nodeVarIsAValueReference.add(false);
                waitForValue = false;
            }
        }
        if (node instanceof Map_Statement) {
            waitForMapIdentifiers = false;
        }
        if (node instanceof ComponentCreateExpression) {
            // switch first two values
            testCaseCreateValues.add(testCaseCreateCharValues.get(0));
            testCaseCreateValues.add(testCaseCreateRefValues.get(0));
            for (int i = 1; i < testCaseCreateCharValues.size(); i++) {
                testCaseCreateValues.add(testCaseCreateCharValues.get(i));
            }
            testCaseCreateCharValues.clear();
            testCaseCreateRefValues.clear();
            waitForTcCreateValues = false;
        }
        if (node instanceof Assignment_Statement) {
            waitForAssignmentIdentifiers = false;
            waitForValue = true;
        }
        if (waitForTcIfCondition && (node instanceof If_Clause)) {
            waitForTcIfCondition = false;
        }
        if (waitForTcStartParameter && (node instanceof Unknown_Start_Statement)) {
            testCaseStartValueParameters.add(null);
        }
        if (waitForTcStopParameter && (node instanceof Unknown_Stop_Statement)) {
            testCaseStopValueParameters.add(null);
        }
        if (isAltGuards && (node instanceof Operation_Altguard)) {
            altGuardConditions.add(null);
        }
        if (node instanceof Operation_Altguard) {
            waitForAltStatements = false;
            isAltGuards = false;
            isReceiveValue = false;
        }
        handleAltCases(node);
        if (node instanceof Unknown_Start_Statement) {
            waitForUnknownStartStatement = false;
        }
        if (node instanceof Unknown_Stop_Statement) {
            waitForUnknownStopStatement = false;
        }
        if (node instanceof Receive_Port_Statement) {
            if (waitForReceiveParameter) {
                altGuardReceiveType.add("noparam");
            }
        // TODO checkAnyport = true;
        }
    }
    if (node instanceof Def_Testcase) {
        handleTestcase(node);
        waitForTC = false;
    }
    if (node instanceof Def_Function) {
        handleFunction(node);
        waitForTC = false;
    }
    if (waitForAssignmentIdentifiers && (node instanceof ArraySubReference)) {
        waitForAssignmentIdentifiers = false;
    }
}
Also used : Connect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Connect_Statement) Definition_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Definition_Statement) Def_Testcase(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Testcase) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) ComponentCreateExpression(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ComponentCreateExpression) If_Clause(org.eclipse.titan.designer.AST.TTCN3.statements.If_Clause) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function) Operation_Altguard(org.eclipse.titan.designer.AST.TTCN3.statements.Operation_Altguard) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) Receive_Port_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Receive_Port_Statement) Assignment_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Assignment_Statement) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Identifier(org.eclipse.titan.designer.AST.Identifier) Unknown_Stop_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Stop_Statement) Return_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Return_Statement) Send_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Send_Statement) Disconnect_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Disconnect_Statement) Unknown_Start_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Unknown_Start_Statement) Map_Statement(org.eclipse.titan.designer.AST.TTCN3.statements.Map_Statement) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Example 2 with Identifier

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

the class ConstantParser method process.

@Override
public Scope process(IVisitableNode node) {
    if (node instanceof Identifier) {
        name = node.toString();
    }
    if (node instanceof Type) {
        type = Util.getTypeName((Type) node);
        value = new Value(type, Writable.NULL);
        return Action.skip(Type.class, this);
    }
    if (node instanceof org.eclipse.titan.designer.AST.Value) {
        ValueHolder holder = v -> value = v;
        return dispatch(this, type, holder, node);
    }
    return this;
}
Also used : IVisitableNode(org.eclipse.titan.designer.AST.IVisitableNode) Writable(org.eclipse.titan.codegenerator.Writable) Iterator(java.util.Iterator) ValueHolder(org.eclipse.titan.codegenerator.template.ValueHolder) Identifier(org.eclipse.titan.designer.AST.Identifier) Util(org.eclipse.titan.codegenerator.template.Util) NamedValue(org.eclipse.titan.designer.AST.TTCN3.values.NamedValue) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) HashMap(java.util.HashMap) Def_Const(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const) ArrayList(java.util.ArrayList) SourceCode(org.eclipse.titan.codegenerator.SourceCode) List(java.util.List) Sequence_Value(org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value) Type(org.eclipse.titan.designer.AST.Type) Scope(org.eclipse.titan.codegenerator.Scope) org.eclipse.titan.codegenerator.myASTVisitor(org.eclipse.titan.codegenerator.myASTVisitor) Action(org.eclipse.titan.codegenerator.template.Action) Value(org.eclipse.titan.codegenerator.template.Value) Type(org.eclipse.titan.designer.AST.Type) Identifier(org.eclipse.titan.designer.AST.Identifier) NamedValue(org.eclipse.titan.designer.AST.TTCN3.values.NamedValue) SequenceOf_Value(org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value) Sequence_Value(org.eclipse.titan.designer.AST.TTCN3.values.Sequence_Value) Value(org.eclipse.titan.codegenerator.template.Value) ValueHolder(org.eclipse.titan.codegenerator.template.ValueHolder)

Example 3 with Identifier

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

the class AssignmentHandlerAFTRerences method visit.

@Override
public int visit(final IVisitableNode node) {
    if (node instanceof ASN1Assignment) {
        final ASN1Assignment assignment = (ASN1Assignment) node;
        if (assignment.getAssPard() != null) {
            return V_SKIP;
        }
    }
    if (node instanceof StatementBlock) {
        final ReferenceCollector referenceCollector = new ReferenceCollector();
        node.accept(referenceCollector);
        // TODO: broken if reference does not point anywhere
        final Set<Reference> references = referenceCollector.getReferences();
        addNonContagiousReferences(computeReferences(references));
        if (containsErroneousReference(references)) {
            setIsInfected(true);
        }
        return V_SKIP;
    }
    if (node instanceof Reference) {
        final Identifier identifier = ((Reference) node).getId();
        if (identifier != null) {
            addContagiousReference(identifier.getDisplayName());
        }
        if (((Reference) node).getIsErroneous(CompilationTimeStamp.getBaseTimestamp())) {
            setIsInfected(true);
            setIsContagious(true);
            return V_CONTINUE;
        }
        final Assignment assignment = ((Reference) node).getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false, null);
        if (assignment == null || assignment.getIdentifier() == null || !assignment.getIdentifier().equals(identifier)) {
            setIsInfected(true);
            setIsContagious(true);
            return V_CONTINUE;
        }
    }
    return V_CONTINUE;
}
Also used : ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) Identifier(org.eclipse.titan.designer.AST.Identifier) Reference(org.eclipse.titan.designer.AST.Reference) ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment) StatementBlock(org.eclipse.titan.designer.AST.TTCN3.statements.StatementBlock)

Example 4 with Identifier

use of org.eclipse.titan.designer.AST.Identifier 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 5 with Identifier

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

the class Sequence_Value method evaluateIspresent.

@Override
public /**
 * {@inheritDoc}
 */
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
        return true;
    }
    if (convertedValue != null && convertedValue != this) {
        return convertedValue.evaluateIsbound(timestamp, reference, actualSubReference);
    }
    final IType type = myGovernor.getTypeRefdLast(timestamp);
    if (type.getIsErroneous(timestamp)) {
        return false;
    }
    final ISubReference subreference = subreferences.get(actualSubReference);
    switch(subreference.getReferenceType()) {
        case arraySubReference:
            return false;
        case fieldSubReference:
            final Identifier fieldId = ((FieldSubReference) subreference).getId();
            switch(type.getTypetype()) {
                case TYPE_TTCN3_SEQUENCE:
                    if (!((TTCN3_Sequence_Type) type).hasComponentWithName(fieldId.getName())) {
                        return false;
                    }
                    break;
                case TYPE_ASN1_SEQUENCE:
                    if (!((ASN1_Sequence_Type) type).hasComponentWithName(fieldId)) {
                        return false;
                    }
                    break;
                default:
                    return false;
            }
            if (values.hasNamedValueWithName(fieldId)) {
                // we can move on with the check
                return values.getNamedValueByName(fieldId).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
            }
            if (Type_type.TYPE_TTCN3_SEQUENCE.equals(type.getTypetype())) {
                return false;
            }
            final CompField compField = ((ASN1_Sequence_Type) type).getComponentByName(fieldId);
            if (compField.isOptional()) {
                // create an explicit omit value
                final Value result = new Omit_Value();
                final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
                result.setFullNameParent(bridge);
                result.setMyScope(getMyScope());
                return result.evaluateIspresent(timestamp, reference, actualSubReference + 1);
            } else if (compField.hasDefault()) {
                return compField.getDefault().evaluateIspresent(timestamp, reference, actualSubReference + 1);
            }
            return false;
        case parameterisedSubReference:
            return false;
        default:
            return false;
    }
}
Also used : ISubReference(org.eclipse.titan.designer.AST.ISubReference) Identifier(org.eclipse.titan.designer.AST.Identifier) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Value(org.eclipse.titan.designer.AST.Value) IValue(org.eclipse.titan.designer.AST.IValue) ASN1_Sequence_Type(org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type) BridgingNamedNode(org.eclipse.titan.designer.AST.BridgingNamedNode) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Identifier (org.eclipse.titan.designer.AST.Identifier)176 IType (org.eclipse.titan.designer.AST.IType)75 ISubReference (org.eclipse.titan.designer.AST.ISubReference)57 IValue (org.eclipse.titan.designer.AST.IValue)39 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)38 Type (org.eclipse.titan.designer.AST.Type)35 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)33 Assignment (org.eclipse.titan.designer.AST.Assignment)25 ArrayList (java.util.ArrayList)24 Location (org.eclipse.titan.designer.AST.Location)24 Reference (org.eclipse.titan.designer.AST.Reference)22 Module (org.eclipse.titan.designer.AST.Module)21 HashMap (java.util.HashMap)16 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)15 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)12 Value (org.eclipse.titan.designer.AST.Value)12 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)11 IASN1Type (org.eclipse.titan.designer.AST.ASN1.IASN1Type)10 ASN1_Sequence_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Sequence_Type)10 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)10