Search in sources :

Example 61 with IType

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

the class Def_ModulePar method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    T3Doc.check(this.getCommentLocation(), KIND);
    isUsed = false;
    NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_MODULEPAR, identifier, this);
    NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
    if (withAttributesPath != null) {
        withAttributesPath.checkGlobalAttributes(timestamp, false);
        withAttributesPath.checkAttributes(timestamp);
    }
    if (type == null) {
        return;
    }
    type.setGenName("_T_", getGenName());
    type.check(timestamp);
    final IType lastType = type.getTypeRefdLast(timestamp);
    switch(lastType.getTypetype()) {
        case TYPE_PORT:
            location.reportSemanticError(MessageFormat.format(PORTNOTALLOWED, lastType.getFullName()));
            break;
        case TYPE_SIGNATURE:
            location.reportSemanticError(MessageFormat.format(SIGNATURENOTALLOWED, lastType.getFullName()));
            break;
        case TYPE_FUNCTION:
        case TYPE_ALTSTEP:
        case TYPE_TESTCASE:
            if (((Function_Type) lastType).isRunsOnSelf()) {
                location.reportSemanticError(MessageFormat.format(RUNSONSELF_NOT_ALLOWED, lastType.getFullName()));
            }
            break;
        default:
            break;
    }
    if (defaultValue != null) {
        defaultValue.setMyGovernor(type);
        final IValue temporalValue = type.checkThisValueRef(timestamp, defaultValue);
        type.checkThisValue(timestamp, temporalValue, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, true, false, true, hasImplicitOmitAttribute(timestamp), false));
        defaultValue.setCodeSection(CodeSectionType.CS_PRE_INIT);
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Function_Type(org.eclipse.titan.designer.AST.TTCN3.types.Function_Type) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions) IType(org.eclipse.titan.designer.AST.IType)

Example 62 with IType

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

the class Def_ModulePar_Template method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    lastTimeChecked = timestamp;
    T3Doc.check(this.getCommentLocation(), KIND);
    isUsed = false;
    NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_MODULEPAR, identifier, this);
    NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
    if (withAttributesPath != null) {
        withAttributesPath.checkGlobalAttributes(timestamp, false);
        withAttributesPath.checkAttributes(timestamp);
    }
    if (type == null) {
        return;
    }
    type.setGenName("_T_", getGenName());
    type.check(timestamp);
    final IType lastType = type.getTypeRefdLast(timestamp);
    switch(lastType.getTypetype()) {
        case TYPE_PORT:
            location.reportSemanticError(MessageFormat.format(Def_ModulePar.PORTNOTALLOWED, lastType.getFullName()));
            break;
        case TYPE_SIGNATURE:
            location.reportSemanticError(MessageFormat.format(Def_ModulePar.SIGNATURENOTALLOWED, lastType.getFullName()));
            break;
        case TYPE_FUNCTION:
        case TYPE_ALTSTEP:
        case TYPE_TESTCASE:
            if (((Function_Type) lastType).isRunsOnSelf()) {
                location.reportSemanticError(MessageFormat.format(Def_ModulePar.RUNSONSELF_NOT_ALLOWED, lastType.getFullName()));
            }
            break;
        default:
            break;
    }
    if (defaultTemplate != null) {
        realTemplate = defaultTemplate;
        // Needed in case of universal charstring templates
        if (defaultTemplate.getTemplatetype() == Template_type.CSTR_PATTERN && lastType.getTypetype() == Type.Type_type.TYPE_UCHARSTRING) {
            realTemplate = defaultTemplate.setTemplatetype(timestamp, Template_type.USTR_PATTERN);
        // FIXME implement setting the pattern type,
        // once universal charstring pattern are
        // supported.
        }
        final ITTCN3Template temporalTemplate = type.checkThisTemplateRef(timestamp, realTemplate);
        temporalTemplate.checkThisTemplateGeneric(timestamp, type, false, true, true, true, false, null);
        final IReferenceChain tempReferenceChain = ReferenceChain.getInstance(Def_Template.CIRCULAREMBEDDEDRECURSION, true);
        tempReferenceChain.add(this);
        temporalTemplate.checkRecursions(timestamp, tempReferenceChain);
        tempReferenceChain.release();
        // defaultTemplate.setGenNamePrefix("modulepar_");//currently does not need the prefix
        defaultTemplate.setGenNameRecursive(getGenName());
        defaultTemplate.setCodeSection(CodeSectionType.CS_PRE_INIT);
    }
}
Also used : ITTCN3Template(org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Function_Type(org.eclipse.titan.designer.AST.TTCN3.types.Function_Type) IType(org.eclipse.titan.designer.AST.IType)

Example 63 with IType

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

the class Def_Testcase method getOutlineText.

@Override
public /**
 * {@inheritDoc}
 */
String getOutlineText() {
    if (lastTimeChecked == null) {
        check(CompilationTimeStamp.getBaseTimestamp());
    }
    final StringBuilder text = new StringBuilder(identifier.getDisplayName());
    if (formalParList == null) {
        return text.toString();
    }
    text.append('(');
    for (int i = 0; i < formalParList.getNofParameters(); i++) {
        if (i != 0) {
            text.append(", ");
        }
        final FormalParameter parameter = formalParList.getParameterByIndex(i);
        if (Assignment_type.A_PAR_TIMER.semanticallyEquals(parameter.getRealAssignmentType())) {
            text.append("timer");
        } else {
            final IType type = parameter.getType(lastTimeChecked);
            if (type == null) {
                text.append("Unknown type");
            } else {
                text.append(type.getTypename());
            }
        }
    }
    text.append(')');
    return text.toString();
}
Also used : IType(org.eclipse.titan.designer.AST.IType)

Example 64 with IType

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

the class Def_Var 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;
    if (getMyScope() instanceof ComponentTypeBody) {
        NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_COMPONENT_VARIABLE, identifier, this);
    } else {
        NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_LOCAL_VARIABLE, identifier, this);
    }
    NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
    if (type == null) {
        return;
    }
    type.setGenName("_T_", getGenName());
    type.check(timestamp);
    final IType lastType = type.getTypeRefdLast(timestamp);
    switch(lastType.getTypetype()) {
        case TYPE_PORT:
            location.reportSemanticError(MessageFormat.format(PORTNOTALLOWED, lastType.getFullName()));
            break;
        case TYPE_SIGNATURE:
            location.reportSemanticError(MessageFormat.format(SIGNATURENOTALLOWED, lastType.getFullName()));
            break;
        default:
            break;
    }
    if (initialValue != null) {
        initialValue.setMyGovernor(type);
        final IValue temporalValue = type.checkThisValueRef(timestamp, initialValue);
        if (isLocal()) {
            type.checkThisValue(timestamp, temporalValue, this, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, true, false, true, false, false));
        } else {
            type.checkThisValue(timestamp, temporalValue, this, new ValueCheckingOptions(Expected_Value_type.EXPECTED_STATIC_VALUE, true, false, true, false, false));
        }
        initialValue.setGenNameRecursive(getGenName());
        initialValue.setCodeSection(CodeSectionType.CS_INLINE);
    }
}
Also used : ComponentTypeBody(org.eclipse.titan.designer.AST.TTCN3.types.ComponentTypeBody) IValue(org.eclipse.titan.designer.AST.IValue) ValueCheckingOptions(org.eclipse.titan.designer.AST.IType.ValueCheckingOptions) IType(org.eclipse.titan.designer.AST.IType)

Example 65 with IType

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

IType (org.eclipse.titan.designer.AST.IType)414 IValue (org.eclipse.titan.designer.AST.IValue)94 ISubReference (org.eclipse.titan.designer.AST.ISubReference)82 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)65 Identifier (org.eclipse.titan.designer.AST.Identifier)49 Assignment (org.eclipse.titan.designer.AST.Assignment)40 Value (org.eclipse.titan.designer.AST.Value)34 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)33 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)27 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)21 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)21 Reference (org.eclipse.titan.designer.AST.Reference)21 Type (org.eclipse.titan.designer.AST.Type)20 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)18 Expected_Value_type (org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type)17 ArrayList (java.util.ArrayList)16 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)15 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)14 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)14 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)13