Search in sources :

Example 1 with Type_Assignment

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

the class Undefined_Assignment_T_or_OC method classifyAssignment.

@Override
protected void classifyAssignment(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    final boolean newChain = null == referenceChain;
    IReferenceChain temporalReferenceChain;
    if (newChain) {
        temporalReferenceChain = ReferenceChain.getInstance(CIRCULARASSIGNMENTCHAIN, true);
    } else {
        temporalReferenceChain = referenceChain;
        temporalReferenceChain.markState();
    }
    realAssignment = null;
    if (temporalReferenceChain.add(this)) {
        reference.setMyScope(rightScope);
        if (identifier.isvalidAsnObjectClassReference() && reference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
            final ObjectClass_refd oc = new ObjectClass_refd(reference);
            oc.setLocation(reference.getLocation());
            realAssignment = new ObjectClass_Assignment(identifier, assPard, oc);
        // assPard = null;
        // asstype = Assignment.A_OC;
        } else if (identifier.isvalidAsnTyperef() && (reference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || reference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
            final Referenced_Type type = new Referenced_Type(reference);
            type.setLocation(reference.getLocation());
            realAssignment = new Type_Assignment(identifier, assPard, type);
        // assPard = null;
        // asstype = A_TYPE;
        }
    }
    if (null == realAssignment) {
        location.reportSemanticError(UNRECOGNISABLEASSIGNMENT);
        isErroneous = true;
    } else {
        realAssignment.setLocation(location);
        realAssignment.setMyScope(myScope);
        realAssignment.setRightScope(rightScope);
        realAssignment.setFullNameParent(this);
    }
    if (newChain) {
        temporalReferenceChain.release();
    } else {
        temporalReferenceChain.previousState();
    }
}
Also used : IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) ObjectClass_refd(org.eclipse.titan.designer.AST.ASN1.Object.ObjectClass_refd) Referenced_Type(org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)

Example 2 with Type_Assignment

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

the class Float_Type method checkThisValue.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
    final boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
    IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
    if (last == null || last.getIsErroneous(timestamp)) {
        return selfReference;
    }
    // already handled ones
    switch(value.getValuetype()) {
        case OMIT_VALUE:
        case REFERENCED_VALUE:
            return selfReference;
        case UNDEFINED_LOWERIDENTIFIER_VALUE:
            if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
                return selfReference;
            }
            break;
        default:
            break;
    }
    if (value.isAsn()) {
        if (Value_type.REFERENCED_VALUE.equals(value.getValuetype())) {
            final IType lastType = last.getMyGovernor().getTypeRefdLast(timestamp);
            if (!lastType.getIsErroneous(timestamp) && !Type_type.TYPE_REAL.equals(lastType.getTypetype())) {
                value.getLocation().reportSemanticError(REALVALUEEXPECTED);
                value.setIsErroneous(true);
                return selfReference;
            }
        }
        switch(last.getValuetype()) {
            case REAL_VALUE:
                break;
            case UNDEFINED_BLOCK:
                {
                    last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
                    final Identifier identifier = new Identifier(Identifier_type.ID_ASN, "REAL");
                    final Assignment assignment = getMyScope().getAssignmentsScope().getLocalAssignmentByID(timestamp, identifier);
                    ((Type_Assignment) assignment).getType(timestamp).checkThisValue(timestamp, last, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_CONSTANT, false, false, true, false, valueCheckingOptions.str_elem));
                    last = last.setValuetype(timestamp, Value_type.REAL_VALUE);
                    break;
                }
            case INTEGER_VALUE:
                last.setValuetype(timestamp, Value_type.REAL_VALUE);
                break;
            case EXPRESSION_VALUE:
            case MACRO_VALUE:
                // already checked
                break;
            default:
                last.getLocation().reportSemanticError(REALVALUEEXPECTED);
                last.setIsErroneous(true);
                break;
        }
    } else {
        switch(last.getValuetype()) {
            case REAL_VALUE:
                break;
            case EXPRESSION_VALUE:
            case MACRO_VALUE:
                // already checked
                break;
            default:
                value.getLocation().reportSemanticError(FLOATVALUEEXPECTED);
                value.setIsErroneous(true);
        }
    }
    if (valueCheckingOptions.sub_check) {
        // there is no parent type to check
        if (subType != null) {
            subType.checkThisValue(timestamp, last);
        }
    }
    value.setLastTimeChecked(timestamp);
    return selfReference;
}
Also used : Type_Assignment(org.eclipse.titan.designer.AST.ASN1.Type_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) IValue(org.eclipse.titan.designer.AST.IValue) Identifier(org.eclipse.titan.designer.AST.Identifier) Type_Assignment(org.eclipse.titan.designer.AST.ASN1.Type_Assignment) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

ObjectClass_refd (org.eclipse.titan.designer.AST.ASN1.Object.ObjectClass_refd)1 Type_Assignment (org.eclipse.titan.designer.AST.ASN1.Type_Assignment)1 Assignment (org.eclipse.titan.designer.AST.Assignment)1 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)1 IType (org.eclipse.titan.designer.AST.IType)1 IValue (org.eclipse.titan.designer.AST.IValue)1 Identifier (org.eclipse.titan.designer.AST.Identifier)1 Referenced_Type (org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type)1