Search in sources :

Example 1 with FormalParameterList

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

the class Activate_Referenced_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    isErroneous = false;
    lastTimeChecked = timestamp;
    if (dereferredValue == null) {
        setIsErroneous();
        return;
    }
    dereferredValue.setLoweridToReference(timestamp);
    IType type = dereferredValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (type != null) {
        type = type.getTypeRefdLast(timestamp);
    }
    if (type == null || type.getIsErroneous(timestamp)) {
        setIsErroneous();
        return;
    }
    if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
        dereferredValue.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, type.getTypename()));
        setIsErroneous();
        return;
    }
    if (((Altstep_Type) type).isRunsOnSelf()) {
        dereferredValue.getLocation().reportSemanticError(RUNONSELFERROR);
        setIsErroneous();
        return;
    }
    if (myStatementBlock != null) {
        myStatementBlock.checkRunsOnScope(timestamp, type, this, STATEMENT_NAME);
    }
    actualParameterList2 = new ActualParameterList();
    final FormalParameterList formalParameterList = ((Altstep_Type) type).getFormalParameters();
    if (formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameterList2)) {
        setIsErroneous();
        return;
    }
    actualParameterList2.setFullNameParent(this);
    actualParameterList2.setMyScope(getMyScope());
    if (!formalParameterList.checkActivateArgument(timestamp, actualParameterList2, getFullName())) {
        setIsErroneous();
    }
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Altstep_Type(org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 2 with FormalParameterList

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

the class Invoke_Template method checkInvoke.

public void checkInvoke(final CompilationTimeStamp timestamp) {
    if (getIsErroneous(timestamp) || actualParameterList == null || value == null) {
        return;
    }
    value.setLoweridToReference(timestamp);
    IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
    if (type != null) {
        type = type.getTypeRefdLast(timestamp);
    }
    if (type == null) {
        if (!value.getIsErroneous(timestamp)) {
            value.getLocation().reportSemanticError("A value of type function was expected in the argument");
        }
        setIsErroneous(true);
        return;
    }
    if (!Type_type.TYPE_FUNCTION.equals(type.getTypetype())) {
        value.getLocation().reportSemanticError(MessageFormat.format("A value of type function was expected in the argument instead of `{0}''", type.getTypename()));
        setIsErroneous(true);
        return;
    }
    if (myScope == null) {
        return;
    }
    myScope.checkRunsOnScope(timestamp, type, this, "call");
    final FormalParameterList formalParameterList = ((Function_Type) type).getFormalParameters();
    actualParameter_list = new ActualParameterList();
    if (!formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameter_list)) {
        actualParameter_list.setFullNameParent(this);
        actualParameter_list.setMyScope(getMyScope());
    }
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) Function_Type(org.eclipse.titan.designer.AST.TTCN3.types.Function_Type) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) IType(org.eclipse.titan.designer.AST.IType)

Example 3 with FormalParameterList

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

the class Referenced_Template method reArrangeInitCode.

@Override
public /**
 * {@inheritDoc}
 */
void reArrangeInitCode(final JavaGenData aData, final StringBuilder source, final Module usageModule) {
    final ISubReference tempSubreference = reference.getSubreferences().get(0);
    if (tempSubreference instanceof ParameterisedSubReference) {
        // generate code for the templates that are used in the actual parameter
        // list of the reference
        final ActualParameterList actualParameterList = ((ParameterisedSubReference) tempSubreference).getActualParameters();
        if (actualParameterList != null) {
            actualParameterList.reArrangeInitCode(aData, source, usageModule);
        }
    }
    final Assignment assignment = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
    if (assignment.getAssignmentType() != Assignment_type.A_TEMPLATE) {
        return;
    }
    ITTCN3Template template = ((Def_Template) assignment).getTemplate(CompilationTimeStamp.getBaseTimestamp());
    final FormalParameterList formalParameterList = ((Def_Template) assignment).getFormalParameterList();
    if (formalParameterList != null) {
        // the reference points to a parameterized template
        // we must perform the rearrangement for all non-parameterized templates
        // that are referred by the parameterized template regardless of the
        // sub-references of reference
        template.reArrangeInitCode(aData, source, usageModule);
        // be generated when the template's definition is reached)
        if (assignment.getMyScope().getModuleScope() == usageModule) {
            formalParameterList.generateCodeDefaultValues(aData, source);
        }
    } else {
        // the reference points to a non-parameterized template
        final List<ISubReference> subReferences = reference.getSubreferences();
        if (subReferences != null && subReferences.size() > 1) {
            // and perform the rearrangement for the referred field only
            for (int i = 1; i < subReferences.size(); i++) {
                final ISubReference subReference = subReferences.get(i);
                if (subReference instanceof FieldSubReference) {
                    // stop if the body does not have fields
                    if (template.getTemplatetype() != Template_type.NAMED_TEMPLATE_LIST) {
                        break;
                    }
                    // the field reference can be followed
                    final Identifier fieldId = ((FieldSubReference) subReference).getId();
                    template = ((Named_Template_List) template).getNamedTemplate(fieldId).getTemplate();
                } else {
                    // stop if the body is not a list
                    if (template.getTemplatetype() != Template_type.TEMPLATE_LIST) {
                        break;
                    }
                    IValue arrayIndex = ((ArraySubReference) subReference).getValue();
                    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
                    arrayIndex = arrayIndex.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
                    referenceChain.release();
                    if (arrayIndex.getValuetype() != Value_type.INTEGER_VALUE) {
                        break;
                    }
                    // the index is available at compilation time
                    long index = ((Integer_Value) arrayIndex).getValue();
                    // index transformation in case of arrays
                    if (template.getMyGovernor().getTypetype() == Type_type.TYPE_ARRAY) {
                        index = index - ((Array_Type) template.getMyGovernor()).getDimension().getOffset();
                    }
                    template = ((Template_List) template).getTemplateByIndex((int) index);
                }
            }
        }
        // we should initialize its entire body
        if (assignment.getMyScope().getModuleScope() == usageModule) {
            template.generateCodeInit(aData, source, template.get_lhs_name());
        }
    }
    if (lengthRestriction != null) {
        lengthRestriction.reArrangeInitCode(aData, source, usageModule);
    }
}
Also used : FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) ArraySubReference(org.eclipse.titan.designer.AST.ArraySubReference) Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) Def_Template(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template) Identifier(org.eclipse.titan.designer.AST.Identifier) IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)

Example 4 with FormalParameterList

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

the class Referenced_Testcase_Instance_Statement method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    if (dereferredValue == null) {
        return;
    }
    final IValue temporalValue = dereferredValue.setLoweridToReference(timestamp);
    IType type = temporalValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
    if (type != null) {
        type = type.getTypeRefdLast(timestamp);
    }
    if (type == null) {
        return;
    }
    if (!Type_type.TYPE_TESTCASE.equals(type.getTypetype())) {
        dereferredValue.getLocation().reportSemanticError(MessageFormat.format("A value of type testcase was expected in the argument of `derefers()'' instead of `{0}''", type.getTypename()));
        return;
    }
    if (myStatementBlock.getScopeRunsOn() != null) {
        dereferredValue.getLocation().reportSemanticError(DEFINITIONWITHOUTRUNSONEXPECTED);
        return;
    }
    actualParameterList2 = new ActualParameterList();
    final FormalParameterList formalParameterList = ((Testcase_Type) type).getFormalParameters();
    formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameterList2);
    if (timerValue != null) {
        timerValue.setLoweridToReference(timestamp);
        final Type_type temporalType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
        switch(temporalType) {
            case TYPE_REAL:
                final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
                if (!last.isUnfoldable(timestamp)) {
                    final Real_Value real = (Real_Value) last;
                    final double i = real.getValue();
                    if (i < 0.0) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real.createStringRepresentation()));
                    } else if (real.isPositiveInfinity()) {
                        timerValue.getLocation().reportSemanticError(MessageFormat.format(FLOATEXPECTED2, real.createStringRepresentation()));
                    }
                }
                break;
            default:
                timerValue.getLocation().reportSemanticError(FLOATEXPECTED);
                break;
        }
    }
}
Also used : FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) IValue(org.eclipse.titan.designer.AST.IValue) Type_type(org.eclipse.titan.designer.AST.IType.Type_type) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Testcase_Type(org.eclipse.titan.designer.AST.TTCN3.types.Testcase_Type) IType(org.eclipse.titan.designer.AST.IType) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Example 5 with FormalParameterList

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

the class Start_Component_Statement method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final ExpressionStruct expression = new ExpressionStruct();
    final Assignment func = functionInstanceReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
    final Def_Function function = (Def_Function) func;
    expression.expression.append(MessageFormat.format("{0}(", func.getGenNameFromScope(aData, source, myScope, "start_")));
    componentReference.generateCodeExpression(aData, expression, false);
    FormalParameterList formalParameterList = function.getFormalParameterList();
    if (formalParameterList.getNofParameters() > 0) {
        expression.expression.append(',');
        ISubReference subReference = functionInstanceReference.getSubreferences().get(0);
        ((ParameterisedSubReference) subReference).getActualParameters().generateCodeNoAlias(aData, expression);
    }
    expression.expression.append(')');
    expression.mergeExpression(source);
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) FormalParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct) Def_Function(org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)

Aggregations

FormalParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameterList)22 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)14 IType (org.eclipse.titan.designer.AST.IType)10 Assignment (org.eclipse.titan.designer.AST.Assignment)4 IValue (org.eclipse.titan.designer.AST.IValue)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 Def_Template (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Template)3 IParameterisedAssignment (org.eclipse.titan.designer.AST.TTCN3.definitions.IParameterisedAssignment)3 Altstep_Type (org.eclipse.titan.designer.AST.TTCN3.types.Altstep_Type)3 Function_Type (org.eclipse.titan.designer.AST.TTCN3.types.Function_Type)3 ASN1Assignment (org.eclipse.titan.designer.AST.ASN1.ASN1Assignment)2 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)2 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)2 Reference (org.eclipse.titan.designer.AST.Reference)2 Def_Altstep (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Altstep)2 Def_Function (org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Function)2 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)2 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)2