Search in sources :

Example 36 with IReferenceChain

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

the class ObjectSet_definition method getRefdLast.

@Override
public final /**
 * {@inheritDoc}
 */
ObjectSet_definition getRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    if (1 != objectSetElements.size()) {
        return this;
    }
    final IObjectSet_Element element = objectSetElements.get(0);
    if (!(element instanceof Referenced_ObjectSet)) {
        return this;
    }
    final boolean newChain = null == referenceChain;
    IReferenceChain temporalReferenceChain;
    if (newChain) {
        temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    } else {
        temporalReferenceChain = referenceChain;
    }
    temporalReferenceChain.add(this);
    final ObjectSet_definition result = ((Referenced_ObjectSet) element).getRefdLast(timestamp, temporalReferenceChain);
    if (newChain) {
        temporalReferenceChain.release();
    }
    return result;
}
Also used : IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) IObjectSet_Element(org.eclipse.titan.designer.AST.ASN1.IObjectSet_Element)

Example 37 with IReferenceChain

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

the class ReferencedObject method getRefdLast.

@Override
public /**
 * {@inheritDoc}
 */
Object_Definition getRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    final boolean newChain = null == referenceChain;
    IReferenceChain temporalReferenceChain;
    if (newChain) {
        temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    } else {
        temporalReferenceChain = referenceChain;
    }
    referencedLast = getRefd(timestamp, temporalReferenceChain).getRefdLast(timestamp, temporalReferenceChain);
    if (newChain) {
        temporalReferenceChain.release();
    }
    return referencedLast;
}
Also used : IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Example 38 with IReferenceChain

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

the class FieldSetting_Type method check.

@Override
public /**
 * {@inheritDoc}
 */
void check(final CompilationTimeStamp timestamp, final FieldSpecification fieldSpecification) {
    if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
        return;
    }
    if (!Fieldspecification_types.FS_T.equals(fieldSpecification.getFieldSpecificationType())) {
        location.reportSemanticError(TYPESETTINGEXPECTED);
        type = new Boolean_Type();
        type.setIsErroneous(true);
        type.setFullNameParent(this);
    }
    lastTimeChecked = timestamp;
    type.check(timestamp);
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    type.checkRecursions(timestamp, referenceChain);
    referenceChain.release();
}
Also used : Boolean_Type(org.eclipse.titan.designer.AST.TTCN3.types.Boolean_Type) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain)

Example 39 with IReferenceChain

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

the class Indexed_Template_List method getReferencedArrayTemplate.

@Override
protected /**
 * {@inheritDoc}
 */
ITTCN3Template getReferencedArrayTemplate(final CompilationTimeStamp timestamp, final IValue arrayIndex, final IReferenceChain referenceChain) {
    IValue indexValue = arrayIndex.setLoweridToReference(timestamp);
    indexValue = indexValue.getValueRefdLast(timestamp, referenceChain);
    if (indexValue.getIsErroneous(timestamp)) {
        return null;
    }
    long index = 0;
    if (!indexValue.isUnfoldable(timestamp)) {
        if (Value_type.INTEGER_VALUE.equals(indexValue.getValuetype())) {
            index = ((Integer_Value) indexValue).getValue();
        } else {
            arrayIndex.getLocation().reportSemanticError("An integer value was expected as index");
            return null;
        }
    } else {
        return null;
    }
    final IType tempType = myGovernor.getTypeRefdLast(timestamp);
    if (tempType.getIsErroneous(timestamp)) {
        return null;
    }
    switch(tempType.getTypetype()) {
        case TYPE_SEQUENCE_OF:
            {
                if (index < 0) {
                    final String message = MessageFormat.format("A non-negative integer value was expected instead of {0} for indexing a template of `sequence of'' type `{1}''", index, tempType.getTypename());
                    arrayIndex.getLocation().reportSemanticError(message);
                    return null;
                }
                break;
            }
        case TYPE_SET_OF:
            {
                if (index < 0) {
                    final String message = MessageFormat.format("A non-negative integer value was expected instead of {0} for indexing a template of `set of'' type `{1}''", index, tempType.getTypename());
                    arrayIndex.getLocation().reportSemanticError(message);
                    return null;
                }
                break;
            }
        case TYPE_ARRAY:
            {
                final ArrayDimension dimension = ((Array_Type) tempType).getDimension();
                dimension.checkIndex(timestamp, indexValue, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
                if (!dimension.getIsErroneous(timestamp)) {
                    // re-base the index
                    index -= dimension.getOffset();
                    if (index < 0 || index > getNofTemplates()) {
                        arrayIndex.getLocation().reportSemanticError(MessageFormat.format("The index value {0} is outside the array indexable range", index + dimension.getOffset()));
                        return null;
                    }
                } else {
                    return null;
                }
                break;
            }
        default:
            arrayIndex.getLocation().reportSemanticError(MessageFormat.format("Invalid array element reference: type `{0}'' cannot be indexed", tempType.getTypename()));
            return null;
    }
    for (int i = 0, size = indexedTemplates.getNofTemplates(); i < size; i++) {
        final IndexedTemplate template = indexedTemplates.getTemplateByIndex(i);
        IValue lastValue = template.getIndex().getValue();
        final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
        lastValue = lastValue.getValueRefdLast(timestamp, chain);
        chain.release();
        if (Value_type.INTEGER_VALUE.equals(lastValue.getValuetype())) {
            final long tempIndex = ((Integer_Value) lastValue).getValue();
            if (index == tempIndex) {
                final ITTCN3Template realTemplate = template.getTemplate();
                if (Template_type.TEMPLATE_NOTUSED.equals(realTemplate.getTemplatetype())) {
                    if (baseTemplate != null) {
                        return baseTemplate.getTemplateReferencedLast(timestamp, referenceChain).getReferencedArrayTemplate(timestamp, indexValue, referenceChain);
                    }
                    return null;
                }
                return realTemplate;
            }
        }
    }
    switch(tempType.getTypetype()) {
        case TYPE_SEQUENCE_OF:
        case TYPE_SET_OF:
        case TYPE_ARRAY:
            // unfoldable (for now)
            break;
        default:
            // the error was reported earlier
            break;
    }
    return null;
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Integer_Value(org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value) ArrayDimension(org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimension) IType(org.eclipse.titan.designer.AST.IType)

Example 40 with IReferenceChain

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

the class Invoke_Template method generateCodeExpressionInvoke.

private void generateCodeExpressionInvoke(final JavaGenData aData, final ExpressionStruct expression) {
    if (value == null || actualParameter_list == null) {
        return;
    }
    final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
    final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
    referenceChain.release();
    if (last.getValuetype() == Value_type.FUNCTION_REFERENCE_VALUE) {
        final Definition function = ((Function_Reference_Value) last).getReferredFunction();
        expression.expression.append(MessageFormat.format("{0}(", function.getGenNameFromScope(aData, expression.expression, myScope, "")));
        actualParameter_list.generateCodeAlias(aData, expression);
    } else {
        value.generateCodeExpressionMandatory(aData, expression, true);
        expression.expression.append(".invoke(");
        IType governor = value.getMyGovernor();
        if (governor == null) {
            governor = value.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
        }
        if (governor == null) {
            return;
        }
        actualParameter_list.generateCodeAlias(aData, expression);
    }
    expression.expression.append(')');
}
Also used : IValue(org.eclipse.titan.designer.AST.IValue) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) Definition(org.eclipse.titan.designer.AST.TTCN3.definitions.Definition) Function_Reference_Value(org.eclipse.titan.designer.AST.TTCN3.values.Function_Reference_Value) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)154 IValue (org.eclipse.titan.designer.AST.IValue)102 IType (org.eclipse.titan.designer.AST.IType)55 Integer_Value (org.eclipse.titan.designer.AST.TTCN3.values.Integer_Value)21 ISubReference (org.eclipse.titan.designer.AST.ISubReference)18 Value (org.eclipse.titan.designer.AST.Value)18 Assignment (org.eclipse.titan.designer.AST.Assignment)16 BigInteger (java.math.BigInteger)15 IReferencingType (org.eclipse.titan.designer.AST.IReferencingType)14 ArraySubReference (org.eclipse.titan.designer.AST.ArraySubReference)13 Identifier (org.eclipse.titan.designer.AST.Identifier)12 Reference (org.eclipse.titan.designer.AST.Reference)9 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)8 ValueCheckingOptions (org.eclipse.titan.designer.AST.IType.ValueCheckingOptions)7 Expression_Value (org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value)7 HashMap (java.util.HashMap)6 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)6 Referenced_Type (org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)6 Real_Value (org.eclipse.titan.designer.AST.TTCN3.values.Real_Value)6 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)5