Search in sources :

Example 1 with Template_ActualParameter

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

the class All_From_Template method checkThisTemplateParameterizedReference.

private boolean checkThisTemplateParameterizedReference(final Reference reference, final Assignment lhs) {
    final List<ISubReference> subreferences = reference.getSubreferences();
    if (subreferences.isEmpty() || !(subreferences.get(0) instanceof ParameterisedSubReference)) {
        return false;
    }
    final ParameterisedSubReference subReference = (ParameterisedSubReference) subreferences.get(0);
    final ActualParameterList actualParameterList = subReference.getActualParameters();
    if (actualParameterList == null) {
        return false;
    }
    final int nofParameters = actualParameterList.getNofParameters();
    for (int i = 0; i < nofParameters; i++) {
        Reference parameterReference = null;
        final ActualParameter actualParameter = actualParameterList.getParameter(i);
        if (actualParameter instanceof Template_ActualParameter) {
            TemplateInstance templateInstance = ((Template_ActualParameter) actualParameter).getTemplateInstance();
            ITTCN3Template template = templateInstance.getTemplateBody();
            template = template.setLoweridToReference(CompilationTimeStamp.getBaseTimestamp());
            if (template.getTemplatetype() == Template_type.TEMPLATE_REFD) {
                parameterReference = ((Referenced_Template) template).getReference();
            }
        } else if (actualParameter instanceof Referenced_ActualParameter) {
            parameterReference = ((Referenced_ActualParameter) actualParameter).getReference();
        }
        if (parameterReference != null) {
            final Assignment assignment = parameterReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
            if (assignment == lhs) {
                return true;
            }
            // check their parameters as well
            switch(assignment.getAssignmentType()) {
                case A_TEMPLATE:
                case A_FUNCTION_RVAL:
                case A_FUNCTION_RTEMP:
                case A_EXT_FUNCTION_RVAL:
                case A_EXT_FUNCTION_RTEMP:
                    if (checkThisTemplateParameterizedReference(parameterReference, lhs)) {
                        return true;
                    }
                    break;
                default:
                    break;
            }
        }
    }
    return false;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) Template_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Template_ActualParameter) ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameter) Referenced_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Referenced_ActualParameter) Template_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Template_ActualParameter) Reference(org.eclipse.titan.designer.AST.Reference) ISubReference(org.eclipse.titan.designer.AST.ISubReference) ParameterisedSubReference(org.eclipse.titan.designer.AST.ParameterisedSubReference) ActualParameterList(org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList) Referenced_ActualParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.Referenced_ActualParameter)

Example 2 with Template_ActualParameter

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

the class FormalParameter method checkActualParameterTemplate.

private ActualParameter checkActualParameterTemplate(final CompilationTimeStamp timestamp, final TemplateInstance actualParameter) {
    actualParameter.check(timestamp, type);
    final TemplateInstance instance = new TemplateInstance(actualParameter.getType(), actualParameter.getDerivedReference(), actualParameter.getTemplateBody());
    final ActualParameter returnValue = new Template_ActualParameter(instance);
    if (!Restriction_type.TR_NONE.equals(templateRestriction)) {
        instance.checkRestriction(timestamp, this);
    }
    return returnValue;
}
Also used : TemplateInstance(org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)

Example 3 with Template_ActualParameter

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

the class FormalParameterList method setGenName.

public void setGenName(final String prefix) {
    for (final FormalParameter parameter : parameters) {
        final String parameterName = parameter.getIdentifier().getName();
        if (!Assignment_type.A_TIMER.equals(parameter.getAssignmentType())) {
            final Type parameterType = parameter.getType(CompilationTimeStamp.getBaseTimestamp());
            if (parameterType != null) {
                parameterType.setGenName(prefix, parameterName);
            }
        }
        if (parameter.hasDefaultValue()) {
            final StringBuilder embeddedName = new StringBuilder(prefix);
            embeddedName.append('_');
            embeddedName.append(parameterName);
            embeddedName.append("_defval");
            final ActualParameter defaultValue = parameter.getDefaultValue();
            if (defaultValue instanceof Value_ActualParameter) {
                final IValue value = ((Value_ActualParameter) defaultValue).getValue();
                // value.setGenNamePrefix("const_");//currently does not need the prefix
                value.setGenNameRecursive(embeddedName.toString());
            } else if (defaultValue instanceof Template_ActualParameter) {
                final TemplateInstance instance = ((Template_ActualParameter) defaultValue).getTemplateInstance();
                final TTCN3Template template = instance.getTemplateBody();
                // template.setGenNamePrefix("template_");//currently does not need the prefix
                template.setGenNameRecursive(embeddedName.toString());
            }
        }
    }
}
Also used : Type(org.eclipse.titan.designer.AST.Type) IType(org.eclipse.titan.designer.AST.IType) IValue(org.eclipse.titan.designer.AST.IValue) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) TemplateInstance(org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)

Aggregations

TemplateInstance (org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)2 Assignment (org.eclipse.titan.designer.AST.Assignment)1 ISubReference (org.eclipse.titan.designer.AST.ISubReference)1 IType (org.eclipse.titan.designer.AST.IType)1 IValue (org.eclipse.titan.designer.AST.IValue)1 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)1 Reference (org.eclipse.titan.designer.AST.Reference)1 ActualParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameter)1 ActualParameterList (org.eclipse.titan.designer.AST.TTCN3.definitions.ActualParameterList)1 Referenced_ActualParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.Referenced_ActualParameter)1 Template_ActualParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.Template_ActualParameter)1 TTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)1 Type (org.eclipse.titan.designer.AST.Type)1