Search in sources :

Example 1 with Def_Var

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var in project titan.EclipsePlug-ins by eclipse.

the class Def_Type_Visit_Handler method visitDefTypeChildrenNodes.

public void visitDefTypeChildrenNodes(IVisitableNode node) {
    if (node instanceof Def_Port) {
        Def_Port port = (Def_Port) node;
        componentPortNames.add(port.getIdentifier().toString());
    }
    if (node instanceof Def_Var) {
        Def_Var var = (Def_Var) node;
        componentVarNames.add(var.getIdentifier().toString());
        if (var.getType(compilationCounter) instanceof Integer_Type) {
            componentVarTypes.add("INTEGER");
        }
    }
    if (waitForCompReference && (node instanceof Reference)) {
        componentPortTypes.add(((Reference) node).getId().toString());
    }
    if (waitForSetOfFieldType) {
        if (node instanceof Reference) {
            setOfFieldType = node.toString();
            myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
            waitForSetOfFieldType = false;
        } else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SetOf_Type)) {
            Type type = (Type) node;
            setOfFieldType = TypeMapper.map(type.getTypename());
            myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
            waitForSetOfFieldType = false;
        }
    }
    if (waitForRecordOfFieldType) {
        if (node instanceof Reference) {
            recordOfFieldType = node.toString();
            myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
            waitForRecordOfFieldType = false;
        } else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SequenceOf_Type)) {
            Type type = (Type) node;
            recordOfFieldType = TypeMapper.map(type.getTypename());
            myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
            waitForRecordOfFieldType = false;
        }
    }
    if (node instanceof CompField) {
        // component
        CompField compFieldNode = (CompField) node;
        if (compFieldNode.getType() instanceof Referenced_Type) {
            compFieldTypes.add(((Referenced_Type) compFieldNode.getType()).getReference().getId().toString());
        } else {
            compFieldTypes.add(myASTVisitor.cutModuleNameFromBeginning(compFieldNode.getType().getTypename()));
        }
        compFieldNames.add(compFieldNode.getIdentifier().toString());
    }
    if (node instanceof Charstring_Value) {
        // charstring
        Charstring_Value singleValuedNode = (Charstring_Value) node;
        charstringValue = singleValuedNode.getValue();
    }
    if (node instanceof Integer_Value) {
        String value = ((Integer_Value) node).toString();
        if (myASTVisitor.isNextIntegerNegative) {
            value = "-" + value;
        }
        expressionValue.add("new INTEGER(\"" + value + "\")");
    }
    if (node instanceof Real_Value) {
        String value = ((Real_Value) node).toString();
        if (myASTVisitor.isNextIntegerNegative) {
            value = "-" + value;
        }
        if (value.equals("-Infinity") || value.equals("Infinity")) {
            value = "null";
        }
        expressionValue.add(value);
    }
    if (node instanceof Undefined_LowerIdentifier_Value) {
        String value = ((Undefined_LowerIdentifier_Value) node).getIdentifier().toString();
        if (myASTVisitor.isNextIntegerNegative) {
            value = "-" + value;
        }
        expressionValue.add(value);
    }
    if (node instanceof EnumerationItems) {
        for (int i = 0; i < ((EnumerationItems) node).getItems().size(); i++) {
            enumItems.add(((EnumerationItems) node).getItems().get(i).getId().toString());
            if (((EnumerationItems) node).getItems().get(i).getValue() != null) {
                enumItemValues.add(((EnumerationItems) node).getItems().get(i).getValue().toString());
            } else {
                enumItemValues.add(null);
            }
        }
    }
    if (waitingForPortAttriburtes && (node instanceof Referenced_Type)) {
        isPortTypeAReferencedType = true;
    }
    if (waitingForPortAttriburtes && (node instanceof PortTypeBody)) {
        PortTypeBody body = (PortTypeBody) node;
        int inCount = body.getInMessages().getNofTypes();
        int outCount = body.getOutMessage().getNofTypes();
        for (int i = 0; i < inCount; i++) {
            inMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getInMessages().getTypeByIndex(i).getTypename()));
        }
        for (int i = 0; i < outCount; i++) {
            outMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getOutMessage().getTypeByIndex(i).getTypename()));
        }
        int shorterListSize = inMessageName.size() <= outMessageName.size() ? inMessageName.size() : outMessageName.size();
        // if inout delete from both lists and add to inout
        for (int i = 0; i < inMessageName.size(); i++) {
            for (int j = 0; j < outMessageName.size(); j++) {
                if (inMessageName.get(i).equals(outMessageName.get(j))) {
                    inOutMessageName.add(inMessageName.get(i));
                    inMessageName.remove(i);
                    if (j == (outMessageName.size() - 1)) {
                        i--;
                    }
                    outMessageName.remove(j);
                    j--;
                }
            }
        }
        myASTVisitor.portNamePortTypeHashMap.put(currentPortName, body.getTestportType().toString());
        portTypeList.add(body.getTestportType().toString());
    }
}
Also used : Def_Var(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var) Reference(org.eclipse.titan.designer.AST.Reference) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) Def_Port(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Port) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value) Range_ParsedSubType(org.eclipse.titan.designer.AST.TTCN3.types.subtypes.Range_ParsedSubType) SequenceOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) TTCN3_Enumerated_Type(org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Enumerated_Type) SetOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) Type(org.eclipse.titan.designer.AST.Type) Def_Type(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Type) CharString_Type(org.eclipse.titan.designer.AST.TTCN3.types.CharString_Type) SetOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type) Integer_Type(org.eclipse.titan.designer.AST.TTCN3.types.Integer_Type) CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) Charstring_Value(org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value) EnumerationItems(org.eclipse.titan.designer.AST.TTCN3.types.EnumerationItems) PortTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.PortTypeBody) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type) SequenceOf_Type(org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type) Undefined_LowerIdentifier_Value(org.eclipse.titan.designer.AST.TTCN3.values.Undefined_LowerIdentifier_Value)

Example 2 with Def_Var

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var in project titan.EclipsePlug-ins by eclipse.

the class Assignment_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    isErroneous = false;
    selfReference = false;
    templateRestriction = Restriction_type.TR_NONE;
    generateRestrictionCheck = false;
    if (reference == null) {
        return;
    }
    reference.setUsedOnLeftHandSide();
    final Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null || assignment.getIsErroneous()) {
        isErroneous = true;
        return;
    }
    if (template == null) {
        return;
    }
    switch(assignment.getAssignmentType()) {
        case A_PAR_VAL_IN:
            ((FormalParameter) assignment).useAsLValue(reference);
            if (template.isValue(timestamp)) {
                // TODO: isValue should be checked within the previous line! This is double check!
                final IValue temporalValue = template.getValue();
                checkVarAssignment(timestamp, assignment, temporalValue);
                template.setMyGovernor(temporalValue.getMyGovernor());
                break;
            } else if (Template_type.VALUE_LIST.equals(template.getTemplatetype()) && ((ValueList_Template) template).getNofTemplates() == 1) {
                // TODO: convert (x) to x to compilation!
                break;
            } else {
                template.getLocation().reportSemanticError(TEMPLATEASSIGNMENTTOVALUE);
                template.setIsErroneous(true);
                return;
            }
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
        case A_PAR_VAL:
            ((FormalParameter) assignment).setWritten();
            if (template.isValue(timestamp)) {
                // TODO: isValue should be checked within the previous line! This is double check!
                final IValue temporalValue = template.getValue();
                checkVarAssignment(timestamp, assignment, temporalValue);
                template.setMyGovernor(temporalValue.getMyGovernor());
                break;
            } else if (Template_type.VALUE_LIST.equals(template.getTemplatetype()) && ((ValueList_Template) template).getNofTemplates() == 1) {
                // TODO: convert (x) to x to compilation!
                break;
            } else {
                template.getLocation().reportSemanticError(TEMPLATEASSIGNMENTTOVALUE);
                template.setIsErroneous(true);
                return;
            }
        // break
        case A_VAR:
            ((Def_Var) assignment).setWritten();
            if (template.getIsErroneous(timestamp)) {
                return;
            }
            final IValue temporalValue = template.getValue();
            if (temporalValue != null) {
                checkVarAssignment(timestamp, assignment, temporalValue);
                template.setMyGovernor(temporalValue.getMyGovernor());
                break;
            } else if (Template_type.VALUE_LIST.equals(template.getTemplatetype()) && ((ValueList_Template) template).getNofTemplates() == 1) {
                break;
            } else {
                template.getLocation().reportSemanticError(TEMPLATEASSIGNMENTTOVALUE);
                template.setIsErroneous(true);
                return;
            }
        case A_PAR_TEMP_IN:
            ((FormalParameter) assignment).useAsLValue(reference);
            checkTemplateAssignment(timestamp, assignment, Expected_Value_type.EXPECTED_TEMPLATE, null);
            break;
        case A_PAR_TEMP_OUT:
        case A_PAR_TEMP_INOUT:
            ((FormalParameter) assignment).setWritten();
            checkTemplateAssignment(timestamp, assignment, Expected_Value_type.EXPECTED_TEMPLATE, null);
            break;
        case A_VAR_TEMPLATE:
            ((Def_Var_Template) assignment).setWritten();
            checkTemplateAssignment(timestamp, assignment, Expected_Value_type.EXPECTED_TEMPLATE, null);
            break;
        default:
            reference.getLocation().reportSemanticError(MessageFormat.format(VARIABLEREFERENCEEXPECTED, assignment.getAssignmentName()));
            reference.setIsErroneous(true);
            isErroneous = true;
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) IValue(org.eclipse.titan.designer.AST.IValue) Def_Var(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var) Def_Var_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)

Example 3 with Def_Var

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var in project titan.EclipsePlug-ins by eclipse.

the class Reference method checkVariableReference.

/**
 * Checks and returns the type of the variable referred to by this
 * reference.
 * <p>
 * This is used to detect the type of value redirects.
 *
 * @param timestamp
 *                the timestamp of the actual semantic check cycle.
 *
 * @return the type of the referred variable or null in case of
 *         problems.
 */
public IType checkVariableReference(final CompilationTimeStamp timestamp) {
    final Assignment assignment = getRefdAssignment(timestamp, true);
    if (assignment == null) {
        return null;
    }
    IType type;
    switch(assignment.getAssignmentType()) {
        case A_PAR_VAL_IN:
            ((FormalParameter) assignment).useAsLValue(this);
            type = ((FormalParameter) assignment).getType(timestamp);
            ((FormalParameter) assignment).setUsed();
            break;
        case A_PAR_VAL:
        case A_PAR_VAL_OUT:
        case A_PAR_VAL_INOUT:
            type = ((FormalParameter) assignment).getType(timestamp);
            ((FormalParameter) assignment).setUsed();
            break;
        case A_VAR:
            type = ((Def_Var) assignment).getType(timestamp);
            ((Def_Var) assignment).setUsed();
            break;
        default:
            getLocation().reportSemanticError(MessageFormat.format(VARIABLEXPECTED, assignment.getDescription()));
            setIsErroneous(true);
            return null;
    }
    final IType result = type.getFieldType(timestamp, this, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null, false);
    if (result != null && subReferences != null && refersToStringElement()) {
        getLocation().reportSemanticError(MessageFormat.format(STRINGELEMENTUNUSABLE, result.getTypename()));
        setIsErroneous(true);
    }
    return result;
}
Also used : IParameterisedAssignment(org.eclipse.titan.designer.AST.TTCN3.definitions.IParameterisedAssignment) ASN1Assignment(org.eclipse.titan.designer.AST.ASN1.ASN1Assignment) FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) Def_Var(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var)

Example 4 with Def_Var

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var in project titan.EclipsePlug-ins by eclipse.

the class PortTypeBody method generateCode.

/**
 * Add generated java code on this level.
 * @param aData only used to update imports if needed
 * @param source the source code generated
 *
 * FIXME the implementation only serves as a minimal testing setup
 */
public void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = myType.getGenNameOwn();
    final Scope myScope = myType.getMyScope();
    final PortDefinition portDefinition = new PortDefinition(genName, getFullName());
    if (inMessages != null) {
        for (int i = 0; i < inMessages.getNofTypes(); i++) {
            final IType inType = inMessages.getTypeByIndex(i);
            final messageTypeInfo info = new messageTypeInfo(inType.getGenNameValue(aData, source, myScope), inType.getGenNameTemplate(aData, source, myScope), inType.getTypename());
            portDefinition.inMessages.add(info);
        }
    }
    if (outMessages != null) {
        for (int i = 0; i < outMessages.getNofTypes(); i++) {
            final IType outType = outMessages.getTypeByIndex(i);
            final messageTypeInfo info = new messageTypeInfo(outType.getGenNameValue(aData, source, myScope), outType.getGenNameTemplate(aData, source, myScope), outType.getTypename());
            portDefinition.outMessages.add(info);
        }
    }
    if (inSignatures != null) {
        for (int i = 0; i < inSignatures.getNofTypes(); i++) {
            final IType outType = inSignatures.getTypeByIndex(i);
            final Signature_Type signature = (Signature_Type) outType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
            final procedureSignatureInfo info = new procedureSignatureInfo(outType.getGenNameValue(aData, source, myScope), outType.getTypename(), signature.isNonblocking(), signature.getSignatureExceptions() != null, false);
            portDefinition.inProcedures.add(info);
        }
    }
    if (outSignatures != null) {
        for (int i = 0; i < outSignatures.getNofTypes(); i++) {
            final IType outType = outSignatures.getTypeByIndex(i);
            final Signature_Type signature = (Signature_Type) outType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
            final procedureSignatureInfo info = new procedureSignatureInfo(outType.getGenNameValue(aData, source, myScope), outType.getTypename(), signature.isNonblocking(), signature.getSignatureExceptions() != null, signature.getSignatureReturnType() != null);
            portDefinition.outProcedures.add(info);
        }
    }
    switch(testportType) {
        case TP_REGULAR:
            portDefinition.testportType = TestportType.NORMAL;
            break;
        case TP_INTERNAL:
            portDefinition.testportType = TestportType.INTERNAL;
            break;
        case TP_ADDRESS:
            portDefinition.testportType = TestportType.ADDRESS;
            portDefinition.addressName = "TitanAddress";
            break;
        default:
            portDefinition.testportType = TestportType.NORMAL;
    }
    if (vardefs != null) {
        portDefinition.varDefs = new StringBuilder();
        portDefinition.varInit = new StringBuilder();
        for (int i = 0; i < vardefs.getNofAssignments(); i++) {
            final Definition def = vardefs.getAssignmentByIndex(i);
            String type = "";
            switch(def.getAssignmentType()) {
                case A_VAR:
                    type = def.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameValue(aData, source, myScope);
                    if (((Def_Var) def).getInitialValue() == null) {
                        portDefinition.varInit.append(MessageFormat.format("{0}.cleanUp();\n", def.getGenName()));
                    } else {
                        def.generateCodeInitComp(aData, portDefinition.varInit, def);
                    }
                    break;
                case A_CONST:
                    type = def.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameValue(aData, source, myScope);
                    def.generateCodeInitComp(aData, portDefinition.varInit, def);
                    break;
                case A_VAR_TEMPLATE:
                    type = def.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameTemplate(aData, source, myScope);
                    if (((Def_Var_Template) def).getInitialValue() == null) {
                        portDefinition.varInit.append(MessageFormat.format("{0}.cleanUp();\n", def.getGenName()));
                    } else {
                        def.generateCodeInitComp(aData, portDefinition.varInit, def);
                    }
                    break;
                default:
                    // FATAL ERROR
                    break;
            }
            portDefinition.varDefs.append(MessageFormat.format("private {0} {1} = new {0}();\n", type, def.getGenName()));
        }
    }
    PortGenerator.generateClass(aData, source, portDefinition);
}
Also used : PortGenerator.messageTypeInfo(org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator.messageTypeInfo) PortDefinition(org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator.PortDefinition) Scope(org.eclipse.titan.designer.AST.Scope) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) PortDefinition(org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator.PortDefinition) IType(org.eclipse.titan.designer.AST.IType) PortGenerator.procedureSignatureInfo(org.eclipse.titan.designer.AST.TTCN3.types.PortGenerator.procedureSignatureInfo)

Example 5 with Def_Var

use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var in project titan.EclipsePlug-ins by eclipse.

the class Component_Type method checkExpressionOperandComponentRefernce.

/**
 * Checks if the provided value is a reference to a component or not.
 *
 * @param timestamp the timestamp of the actual semantic check cycle.
 * @param value the value to be checked
 * @param expected_value the value kind expected from the actual parameter.
 */
public static void checkExpressionOperandComponentRefernce(final CompilationTimeStamp timestamp, final IValue value, final String operationName) {
    switch(value.getValuetype()) {
        case EXPRESSION_VALUE:
            {
                final Expression_Value expression = (Expression_Value) value;
                if (Operation_type.APPLY_OPERATION.equals(expression.getOperationType())) {
                    final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                    final IValue last = value.getValueRefdLast(timestamp, chain);
                    chain.release();
                    if (last == null || last.getIsErroneous(timestamp)) {
                        value.setIsErroneous(true);
                        return;
                    }
                    IType type = last.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
                    if (type == null) {
                        value.setIsErroneous(true);
                        return;
                    }
                    type = type.getTypeRefdLast(timestamp);
                    if (type.getIsErroneous(timestamp)) {
                        value.setIsErroneous(true);
                        // don't let spread an earlier mistake
                        return;
                    }
                    if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                        value.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                        value.setIsErroneous(true);
                        return;
                    }
                }
                break;
            }
        case REFERENCED_VALUE:
            {
                final Reference reference = ((Referenced_Value) value).getReference();
                final Assignment assignment = reference.getRefdAssignment(timestamp, true);
                if (assignment == null) {
                    value.setIsErroneous(true);
                    return;
                }
                switch(assignment.getAssignmentType()) {
                    case A_CONST:
                        {
                            IType type = ((Def_Const) assignment).getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                            if (type == null) {
                                value.setIsErroneous(true);
                                return;
                            }
                            type = type.getTypeRefdLast(timestamp);
                            if (type.getIsErroneous(timestamp)) {
                                value.setIsErroneous(true);
                                // don't let spread an earlier mistake
                                return;
                            }
                            if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                                value.setIsErroneous(true);
                                return;
                            }
                            IValue tempValue = ((Def_Const) assignment).getValue();
                            if (tempValue == null) {
                                return;
                            }
                            IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                            tempValue = tempValue.getReferencedSubValue(timestamp, reference, 1, chain);
                            chain.release();
                            if (tempValue == null) {
                                return;
                            }
                            chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                            tempValue = tempValue.getValueRefdLast(timestamp, chain);
                            chain.release();
                            if (Value_type.TTCN3_NULL_VALUE.equals(tempValue.getValuetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'' refers to the `null'' component reference", operationName));
                                value.setIsErroneous(true);
                                return;
                            }
                            if (!Value_type.EXPRESSION_VALUE.equals(tempValue.getValuetype())) {
                                return;
                            }
                            switch(((Expression_Value) tempValue).getOperationType()) {
                                case MTC_COMPONENT_OPERATION:
                                    reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'' refers to the component reference of the `mtc''", operationName));
                                    value.setIsErroneous(true);
                                    return;
                                case COMPONENT_NULL_OPERATION:
                                    reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'' refers to the `null'' component reference", operationName));
                                    value.setIsErroneous(true);
                                    return;
                                case SYSTEM_COMPONENT_OPERATION:
                                    reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'' refers to the component reference of the `system''", operationName));
                                    value.setIsErroneous(true);
                                    return;
                                default:
                                    break;
                            }
                            break;
                        }
                    case A_EXT_CONST:
                        {
                            IType type = ((Def_ExternalConst) assignment).getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                            if (type == null) {
                                value.setIsErroneous(true);
                                return;
                            }
                            type = type.getTypeRefdLast(timestamp);
                            if (type.getIsErroneous(timestamp)) {
                                value.setIsErroneous(true);
                                // don't let spread an earlier mistake
                                return;
                            }
                            if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                                value.setIsErroneous(true);
                                return;
                            }
                            break;
                        }
                    case A_MODULEPAR:
                        {
                            IType type = ((Def_ModulePar) assignment).getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                            if (type == null) {
                                value.setIsErroneous(true);
                                return;
                            }
                            type = type.getTypeRefdLast(timestamp);
                            if (type.getIsErroneous(timestamp)) {
                                value.setIsErroneous(true);
                                // don't let spread an earlier mistake
                                return;
                            }
                            if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                                value.setIsErroneous(true);
                                return;
                            }
                            break;
                        }
                    case A_VAR:
                        {
                            IType type = ((Def_Var) assignment).getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                            if (type == null) {
                                value.setIsErroneous(true);
                                return;
                            }
                            type = type.getTypeRefdLast(timestamp);
                            if (type.getIsErroneous(timestamp)) {
                                value.setIsErroneous(true);
                                // don't let spread an earlier mistake
                                return;
                            }
                            if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                                value.setIsErroneous(true);
                                return;
                            }
                            break;
                        }
                    case A_FUNCTION_RVAL:
                        {
                            IType type = ((Def_Function) assignment).getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                            if (type == null) {
                                value.setIsErroneous(true);
                                return;
                            }
                            type = type.getTypeRefdLast(timestamp);
                            if (type.getIsErroneous(timestamp)) {
                                value.setIsErroneous(true);
                                // don't let spread an earlier mistake
                                return;
                            }
                            if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                                value.setIsErroneous(true);
                                return;
                            }
                            break;
                        }
                    case A_EXT_FUNCTION_RVAL:
                        {
                            IType type = ((Def_Extfunction) assignment).getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                            if (type == null) {
                                value.setIsErroneous(true);
                                return;
                            }
                            type = type.getTypeRefdLast(timestamp);
                            if (type.getIsErroneous(timestamp)) {
                                value.setIsErroneous(true);
                                // don't let spread an earlier mistake
                                return;
                            }
                            if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                                value.setIsErroneous(true);
                                return;
                            }
                            break;
                        }
                    case A_PAR_VAL:
                    case A_PAR_VAL_IN:
                    case A_PAR_VAL_OUT:
                    case A_PAR_VAL_INOUT:
                        {
                            IType type = ((FormalParameter) assignment).getType(timestamp).getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
                            if (type == null) {
                                value.setIsErroneous(true);
                                return;
                            }
                            type = type.getTypeRefdLast(timestamp);
                            if (type.getIsErroneous(timestamp)) {
                                value.setIsErroneous(true);
                                // don't let spread an earlier mistake
                                return;
                            }
                            if (!Type_type.TYPE_COMPONENT.equals(type.getTypetype())) {
                                reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'': Type mismatch: component reference was expected instead of `{1}''", operationName, type.getTypename()));
                                value.setIsErroneous(true);
                                return;
                            }
                            break;
                        }
                    default:
                        reference.getLocation().reportSemanticError(MessageFormat.format("The first operand of operation `{0}'' should be a component reference instead of `{1}''", operationName, assignment.getDescription()));
                        value.setIsErroneous(true);
                        return;
                }
                break;
            }
        default:
            // the error was already reported if possible.
            return;
    }
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Expression_Value(org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value) Def_Const(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Def_Var (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var)6 Assignment (org.eclipse.titan.designer.AST.Assignment)5 IType (org.eclipse.titan.designer.AST.IType)5 Def_Var_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Var_Template)4 FormalParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)4 Reference (org.eclipse.titan.designer.AST.Reference)3 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 IValue (org.eclipse.titan.designer.AST.IValue)2 Def_Const (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const)2 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)2 ASN1Assignment (org.eclipse.titan.designer.AST.ASN1.ASN1Assignment)1 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)1 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)1 CodeSectionType (org.eclipse.titan.designer.AST.GovernedSimple.CodeSectionType)1 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)1 Scope (org.eclipse.titan.designer.AST.Scope)1 TemplateRestriction (org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction)1 Restriction_type (org.eclipse.titan.designer.AST.TTCN3.TemplateRestriction.Restriction_type)1 Def_ExternalConst (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_ExternalConst)1