Search in sources :

Example 36 with SubType

use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.

the class UniversalCharstring_Type method checkCodingAttributes.

@Override
public /**
 * {@inheritDoc}
 */
void checkCodingAttributes(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
    // check raw attributes
    if (subType != null) {
        final int restrictionLength = subType.get_length_restriction();
        if (restrictionLength != -1) {
            if (rawAttribute == null) {
                rawAttribute = new RawAST(getDefaultRawFieldLength());
            }
            if (rawAttribute.fieldlength == 0) {
                rawAttribute.fieldlength = restrictionLength * 8;
                rawAttribute.length_restriction = -1;
            } else {
                rawAttribute.length_restriction = restrictionLength;
            }
        }
    }
// TODO add checks for other encodings.
}
Also used : RawAST(org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST)

Example 37 with SubType

use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.

the class UniversalCharstring_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    generateCodeTypedescriptor(aData, source);
    if (needsAlias()) {
        final String ownName = getGenNameOwn();
        source.append(MessageFormat.format("\tpublic static class {0} extends {1} '{' '}'\n", ownName, getGenNameValue(aData, source, myScope)));
        source.append(MessageFormat.format("\tpublic static class {0}_template extends {1} '{' '}'\n", ownName, getGenNameTemplate(aData, source, myScope)));
    }
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : PatternString(org.eclipse.titan.designer.AST.TTCN3.templates.PatternString)

Example 38 with SubType

use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.

the class Function_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final FunctionReferenceDefinition def = new FunctionReferenceDefinition(genName, displayName);
    if (returnType == null) {
        def.returnType = null;
    } else {
        if (returnsTemplate) {
            def.returnType = returnType.getGenNameTemplate(aData, source, myScope);
        } else {
            def.returnType = returnType.getGenNameValue(aData, source, myScope);
        }
    }
    def.type = fatType.FUNCTION;
    def.runsOnSelf = runsOnSelf;
    def.isStartable = isStartable;
    def.formalParList = formalParList.generateCode(aData).toString();
    def.actualParList = formalParList.generateCodeActualParlist("").toString();
    def.parameterTypeNames = new ArrayList<String>(formalParList.getNofParameters());
    def.parameterNames = new ArrayList<String>(formalParList.getNofParameters());
    for (int i = 0; i < formalParList.getNofParameters(); i++) {
        final FormalParameter formalParameter = formalParList.getParameterByIndex(i);
        switch(formalParameter.getAssignmentType()) {
            case A_PAR_VAL:
            case A_PAR_VAL_IN:
            case A_PAR_VAL_INOUT:
            case A_PAR_VAL_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameValue(aData, source, getMyScope()));
                break;
            case A_PAR_TEMP_IN:
            case A_PAR_TEMP_INOUT:
            case A_PAR_TEMP_OUT:
                def.parameterTypeNames.add(formalParameter.getType(CompilationTimeStamp.getBaseTimestamp()).getGenNameTemplate(aData, source, getMyScope()));
                break;
            default:
                break;
        }
        def.parameterNames.add(formalParameter.getIdentifier().getName());
    }
    FunctionReferenceGenerator.generateValueClass(aData, source, def);
    FunctionReferenceGenerator.generateTemplateClass(aData, source, def);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : FormalParameter(org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter) FunctionReferenceDefinition(org.eclipse.titan.designer.AST.TTCN3.types.FunctionReferenceGenerator.FunctionReferenceDefinition)

Example 39 with SubType

use of org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType in project titan.EclipsePlug-ins by eclipse.

the class Integer_Type method checkThisValueLimit.

/**
 * Checks if a given value is a valid integer limit.
 * <p>
 * The special float values infinity and -infinity are valid integer range limits too.
 *
 * @param timestamp the time stamp of the actual semantic check cycle.
 * @param value the value to be checked
 * @param expectedValue the kind of the value to be expected
 * @param incompleteAllowed true if an incomplete value can be accepted at the given location, false otherwise
 * @param omitAllowed true if the omit value can be accepted at the given location, false otherwise
 * @param subCheck true if the subtypes should also be checked.
 * @param implicitOmit true if the implicit omit optional attribute was set for the value, false otherwise
 */
public void checkThisValueLimit(final CompilationTimeStamp timestamp, final IValue value, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean omitAllowed, final boolean subCheck, final boolean implicitOmit) {
    super.checkThisValue(timestamp, value, null, new ValueCheckingOptions(expectedValue, incompleteAllowed, omitAllowed, subCheck, implicitOmit, false));
    final IValue last = value.getValueRefdLast(timestamp, expectedValue, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return;
    }
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return;
            }
            break;
        default:
            break;
    }
    switch(last.getValuetype()) {
        case INTEGER_VALUE:
            break;
        case REAL_VALUE:
            {
                final Real_Value real = (Real_Value) last;
                if (!real.isNegativeInfinity() && !real.isPositiveInfinity()) {
                    value.getLocation().reportSemanticError(INTEGERVALUEEXPECTED);
                    value.setIsErroneous(true);
                }
                break;
            }
        case EXPRESSION_VALUE:
        case MACRO_VALUE:
            // already checked
            break;
        default:
            value.getLocation().reportSemanticError(INTEGERVALUEEXPECTED);
            value.setIsErroneous(true);
    }
    if (subCheck) {
        // there is no parent type to check
        if (subType != null) {
            subType.checkThisValue(timestamp, last);
        }
    }
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) Real_Value(org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)

Aggregations

IValue (org.eclipse.titan.designer.AST.IValue)14 IType (org.eclipse.titan.designer.AST.IType)11 RawAST (org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST)9 ArrayList (java.util.ArrayList)7 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)5 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)4 RawASTStruct (org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct)3 FormalParameter (org.eclipse.titan.designer.AST.TTCN3.definitions.FormalParameter)3 PatternString (org.eclipse.titan.designer.AST.TTCN3.templates.PatternString)3 SubType (org.eclipse.titan.designer.AST.TTCN3.types.subtypes.SubType)3 Bitstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Bitstring_Value)3 Charstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.Charstring_Value)3 UniversalCharstring (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring)3 UniversalCharstring_Value (org.eclipse.titan.designer.AST.TTCN3.values.UniversalCharstring_Value)3 Assignment (org.eclipse.titan.designer.AST.Assignment)2 BridgingNamedNode (org.eclipse.titan.designer.AST.BridgingNamedNode)2 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 Scope (org.eclipse.titan.designer.AST.Scope)2 Definition (org.eclipse.titan.designer.AST.TTCN3.definitions.Definition)2