Search in sources :

Example 6 with TTCN3Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template in project titan.EclipsePlug-ins by eclipse.

the class IsPresentExpression method generateCodeExpressionExpression.

@Override
public /**
 * {@inheritDoc}
 */
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
    final TTCN3Template template = templateInstance.getTemplateBody();
    if (Template_type.SPECIFIC_VALUE.equals(template.getTemplatetype())) {
        final IValue value = ((SpecificValue_Template) template).getSpecificValue();
        if (Value_type.REFERENCED_VALUE.equals(value.getValuetype())) {
            final Reference reference = ((Referenced_Value) value).getReference();
            if (reference != null) {
                final Assignment assignment = reference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
                if (assignment != null) {
                    switch(assignment.getAssignmentType()) {
                        case A_TEMPLATE:
                        case A_VAR_TEMPLATE:
                        case A_MODULEPAR_TEMPLATE:
                        case A_EXT_FUNCTION_RTEMP:
                        case A_FUNCTION_RTEMP:
                        case A_PAR_TEMP_IN:
                        case A_PAR_TEMP_OUT:
                        case A_PAR_TEMP_INOUT:
                            reference.generateCodeIsPresentBoundChosen(aData, expression, true, getOperationType(), null);
                            return;
                        default:
                            break;
                    }
                }
                reference.generateCodeIsPresentBoundChosen(aData, expression, false, getOperationType(), null);
                return;
            }
        } else {
            // FIXME cast_needed case
            value.generateCodeExpressionMandatory(aData, expression, true);
        }
    } else if (Template_type.TEMPLATE_REFD.equals(template.getTemplatetype())) {
        final Reference reference = ((Referenced_Template) template).getReference();
        if (reference != null) {
            reference.generateCodeIsPresentBoundChosen(aData, expression, true, getOperationType(), null);
            return;
        }
    } else {
        templateInstance.generateCode(aData, expression, Restriction_type.TR_NONE);
    }
    expression.expression.append(".isPresent()");
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Reference(org.eclipse.titan.designer.AST.Reference) ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)

Example 7 with TTCN3Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template in project titan.EclipsePlug-ins by eclipse.

the class IsPresentExpression method isUnfoldable.

@Override
public /**
 * {@inheritDoc}
 */
boolean isUnfoldable(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
    if (templateInstance == null) {
        return true;
    }
    final ITTCN3Template template = templateInstance.getTemplateBody().setLoweridToReference(timestamp);
    if (templateInstance.getDerivedReference() != null) {
        return true;
    }
    if (template.getIfPresent()) {
        return false;
    }
    if (Template_type.SPECIFIC_VALUE.equals(template.getTemplatetype())) {
        final IValue specificValue = ((SpecificValue_Template) template).getValue();
        if (Value_type.REFERENCED_VALUE.equals(specificValue.getValuetype())) {
            final Reference reference = ((Referenced_Value) specificValue).getReference();
            final Assignment ass = reference.getRefdAssignment(timestamp, false);
            if (ass == null) {
                return true;
            }
            switch(ass.getAssignmentType()) {
                case A_OBJECT:
                case A_OS:
                case A_CONST:
                case A_EXT_CONST:
                case A_MODULEPAR:
                case A_VAR:
                case A_FUNCTION_RVAL:
                case A_EXT_FUNCTION_RVAL:
                case A_PAR_VAL:
                case A_PAR_VAL_IN:
                case A_PAR_VAL_OUT:
                case A_PAR_VAL_INOUT:
                    break;
                default:
                    return true;
            }
            // TODO improve to better detect unbound
            // elements
            final IValue last = specificValue.getValueRefdLast(timestamp, expectedValue, null);
            if (last == null) {
                return true;
            }
            if (last == this) {
                return getIsErroneous(timestamp);
            }
            return last.isUnfoldable(timestamp, expectedValue, referenceChain);
        }
        return specificValue.isUnfoldable(timestamp, expectedValue, referenceChain);
    } else if (Template_type.TEMPLATE_REFD.equals(template.getTemplatetype())) {
        final Reference reference = ((Referenced_Template) template).getReference();
        final Assignment ass = reference.getRefdAssignment(timestamp, true);
        if (ass == null) {
            return true;
        }
        switch(ass.getAssignmentType()) {
            case A_CONST:
                // const is foldable
                return false;
            case A_TEMPLATE:
                break;
            default:
                return true;
        }
        // TODO improve to better detect unbound elements
        final TTCN3Template last = template.getTemplateReferencedLast(timestamp);
        if (last == null) {
            return true;
        }
        if (last == template) {
            return last.getIsErroneous(timestamp);
        }
        if (last.getIfPresent()) {
            return false;
        }
        if (Template_type.SPECIFIC_VALUE.equals(last.getTemplatetype())) {
            return ((SpecificValue_Template) last).getValue().isUnfoldable(timestamp, expectedValue, referenceChain);
        }
    }
    return true;
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) SpecificValue_Template(org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template) Reference(org.eclipse.titan.designer.AST.Reference) ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) Referenced_Value(org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)

Example 8 with TTCN3Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template in project titan.EclipsePlug-ins by eclipse.

the class NamedTemplateListParser method process.

@Override
public Scope process(IVisitableNode node) {
    if (node instanceof NamedTemplate) {
        NamedTemplate nt = (NamedTemplate) node;
        name = nt.getName().toString();
    }
    if (node instanceof TTCN3Template) {
        ValueHolder holder = list.getHolder(name);
        String type = list.getType(name);
        return TemplateValueParser.getScope(this, holder, type, node);
    }
    return this;
}
Also used : NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)

Example 9 with TTCN3Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template in project titan.EclipsePlug-ins by eclipse.

the class UnionValueParser method process.

@Override
public Scope process(IVisitableNode node) {
    if (node instanceof NamedTemplate) {
        NamedTemplate nt = (NamedTemplate) node;
        String name = nt.getName().toString();
        subtype = map.get(name);
    }
    if (node instanceof TTCN3Template) {
        return TemplateValueParser.getScope(this, union, subtype, node);
    }
    return this;
}
Also used : NamedTemplate(org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)

Example 10 with TTCN3Template

use of org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template in project titan.EclipsePlug-ins by eclipse.

the class Def_Var_Template method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    isUsed = false;
    wasAssigned = false;
    NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_LOCAL_VARTEMPLATE, identifier, this);
    NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
    if (type == null) {
        lastTimeChecked = timestamp;
        return;
    }
    type.setGenName("_T_", getGenName());
    type.check(timestamp);
    if (initialValue == null) {
        return;
    }
    final IType lastType = type.getTypeRefdLast(timestamp);
    switch(lastType.getTypetype()) {
        case TYPE_PORT:
            location.reportSemanticError(MessageFormat.format(PORTNOTALLOWED, lastType.getFullName()));
            break;
        default:
            break;
    }
    TTCN3Template realInitialValue = initialValue;
    initialValue.setMyGovernor(type);
    // Needed in case of universal charstring templates
    if (initialValue.getTemplatetype() == Template_type.CSTR_PATTERN && lastType.getTypetype() == Type.Type_type.TYPE_UCHARSTRING) {
        realInitialValue = initialValue.setTemplatetype(timestamp, Template_type.USTR_PATTERN);
    // FIXME implement setting the pattern type, once
    // universal charstring pattern are supported.
    }
    final ITTCN3Template temporalValue = type.checkThisTemplateRef(timestamp, realInitialValue);
    temporalValue.checkThisTemplateGeneric(timestamp, type, true, true, true, true, false, this);
    generateRestrictionCheck = TemplateRestriction.check(timestamp, this, realInitialValue, null);
    realInitialValue.setCodeSection(CodeSectionType.CS_INLINE);
    // here
    if (withAttributesPath != null) {
        withAttributesPath.checkGlobalAttributes(timestamp, false);
        withAttributesPath.checkAttributes(timestamp);
    }
    if (mFormalParList != null) {
        mFormalParList.reset();
        mFormalParList.check(timestamp, getAssignmentType());
        // template variable is always local
        location.reportSemanticError(MessageFormat.format(PARAMETRIZED_LOCAL_TEMPLATE_VAR, getIdentifier()));
    }
    initialValue.setGenNameRecursive(getGenName());
    initialValue.setCodeSection(CodeSectionType.CS_INLINE);
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) TTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

TTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.TTCN3Template)23 IValue (org.eclipse.titan.designer.AST.IValue)18 Reference (org.eclipse.titan.designer.AST.Reference)13 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)13 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)12 Assignment (org.eclipse.titan.designer.AST.Assignment)11 IType (org.eclipse.titan.designer.AST.IType)9 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)9 ArrayList (java.util.ArrayList)4 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)4 Type (org.eclipse.titan.designer.AST.Type)4 Identifier (org.eclipse.titan.designer.AST.Identifier)3 TemplateInstance (org.eclipse.titan.designer.AST.TTCN3.templates.TemplateInstance)3 Array_Type (org.eclipse.titan.designer.AST.TTCN3.types.Array_Type)3 SequenceOf_Type (org.eclipse.titan.designer.AST.TTCN3.types.SequenceOf_Type)3 SetOf_Type (org.eclipse.titan.designer.AST.TTCN3.types.SetOf_Type)3 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)2 Open_Type (org.eclipse.titan.designer.AST.ASN1.types.Open_Type)2 ISubReference (org.eclipse.titan.designer.AST.ISubReference)2 NamedTemplate (org.eclipse.titan.designer.AST.TTCN3.templates.NamedTemplate)2