Search in sources :

Example 36 with Assignment

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

the class Referenced_ObjectSet method getRefdObjectClass.

/**
 * Returns the referenced ObjectClass. The evaluation depends on the type of the reference
 * @param timestamp
 * @return the referenced ObjectClass if found. Otherwise returns null.
 */
public ObjectClass getRefdObjectClass(final CompilationTimeStamp timestamp) {
    ObjectClass refdClass = null;
    if (reference instanceof InformationFromObj) {
        final ObjectClass tempGovernor = getRefdLast(timestamp, null).getMyGovernor();
        if (tempGovernor == null) {
            return null;
        }
        refdClass = tempGovernor.getRefdLast(timestamp, null);
        final FieldName fn = ((InformationFromObj) reference).getFieldName();
        if (fn.getNofFields() == 1) {
            final Identifier fieldId = fn.getFieldByIndex(0);
            final FieldSpecifications fss = refdClass.getFieldSpecifications();
            FieldSpecification fs = fss.getFieldSpecificationByIdentifier(fieldId);
            if (fs instanceof Undefined_FieldSpecification) {
                fs = ((Undefined_FieldSpecification) fs).getRealFieldSpecification();
            }
            switch(fs.getFieldSpecificationType()) {
                case FS_OS:
                    refdClass = ((ObjectSet_FieldSpecification) fs).getObjectClass().getRefdLast(timestamp, null);
                    break;
                case FS_T:
                    // TODO: implement the other cases
                    break;
                default:
                    // TODO: implement the other cases
                    break;
            }
        }
    } else if (reference instanceof Parameterised_Reference) {
        final Defined_Reference dref = ((Parameterised_Reference) reference).getRefDefdSimple();
        if (dref == null) {
            return null;
        }
        final Assignment ass = dref.getRefdAssignment(timestamp, false, null);
        if (ass instanceof ObjectSet_Assignment) {
            ass.check(timestamp);
            // experimental
            osReferenced = ((ObjectSet_Assignment) ass).getObjectSet(timestamp);
            refdClass = ((ObjectSet_Assignment) ass).getObjectSet(timestamp).getMyGovernor().getRefdLast(timestamp, null);
        }
    } else if (reference instanceof Defined_Reference) {
        final Assignment ass = ((Defined_Reference) reference).getRefdAssignment(timestamp, false, null);
        if (ass instanceof ObjectSet_Assignment) {
            ass.check(timestamp);
            // experimental
            osReferenced = ((ObjectSet_Assignment) ass).getObjectSet(timestamp);
            refdClass = ((ObjectSet_Assignment) ass).getObjectSet(timestamp).getMyGovernor().getRefdLast(timestamp, null);
        }
    } else {
        // to debug
        return refdClass;
    }
    return refdClass;
}
Also used : ObjectSet_Assignment(org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) ObjectClass(org.eclipse.titan.designer.AST.ASN1.ObjectClass) Identifier(org.eclipse.titan.designer.AST.Identifier) Parameterised_Reference(org.eclipse.titan.designer.AST.ASN1.Parameterised_Reference) Defined_Reference(org.eclipse.titan.designer.AST.ASN1.Defined_Reference) ObjectSet_Assignment(org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment) InformationFromObj(org.eclipse.titan.designer.AST.ASN1.InformationFromObj)

Example 37 with Assignment

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

the class Referenced_ObjectSet method getRefd.

public ObjectSet getRefd(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
    if (referenceChain.add(this)) {
        if (osReferenced != null && lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
            return osReferenced;
        }
        final Assignment assignment = reference.getRefdAssignment(timestamp, true, referenceChain);
        if (null != assignment) {
            // TODO check in the compiler too !!!
            final ISetting setting = assignment.getSetting(timestamp);
            if (null != setting && !Setting_type.S_ERROR.equals(setting.getSettingtype())) {
                if (Setting_type.S_OS.equals(setting.getSettingtype())) {
                    osReferenced = (ObjectSet) setting;
                    return osReferenced;
                }
                location.reportSemanticError(OBJECTSETEXPECTED);
            }
        }
    }
    osReferenced = new ObjectSet_definition();
    osReferenced.setFullNameParent(this);
    osReferenced.setMyGovernor(getMyGovernor());
    return osReferenced;
}
Also used : ObjectSet_Assignment(org.eclipse.titan.designer.AST.ASN1.ObjectSet_Assignment) Assignment(org.eclipse.titan.designer.AST.Assignment) ISetting(org.eclipse.titan.designer.AST.ISetting)

Example 38 with Assignment

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

the class Parameterised_Reference method getRefDefdSimple.

/**
 * Resolve the formal parameters of the referenced assignment with the
 * help of the actual parameters. Instantiate a new assignment from it
 * and return a reference to this assignment.
 *
 * @return the reference to the newly instantiated assignment.
 */
public Defined_Reference getRefDefdSimple() {
    final Module module = myScope.getModuleScope();
    // This is a little trick, but otherwise we would not have the
    // true compilation timestamp
    final CompilationTimeStamp compilationTimeStamp = module.getLastImportationCheckTimeStamp();
    if (compilationTimeStamp == null) {
        // compilationTimeStamp = CompilationTimeStamp.getNewCompilationCounter(); //this forces re-check
        return null;
    }
    if (null != lastCheckTimeStamp && !lastCheckTimeStamp.isLess(compilationTimeStamp)) {
        if (isErroneous) {
            return null;
        }
        return finalReference;
    }
    lastCheckTimeStamp = compilationTimeStamp;
    final Assignment parass = assignmentReference.getRefdAssignment(compilationTimeStamp, true, null);
    if (null == parass) {
        isErroneous = true;
        return null;
    } else if (!(parass instanceof ASN1Assignment)) {
        assignmentReference.getLocation().reportSemanticError(ASSIGNMENTEXPECTED);
        isErroneous = true;
        return null;
    }
    final Ass_pard assPard = ((ASN1Assignment) parass).getAssPard();
    if (null == assPard) {
        assignmentReference.getLocation().reportSemanticError(PARAMETERISEDASSIGNMENTEXPECTED);
        isErroneous = true;
        return assignmentReference;
    }
    addAssignments(assPard, compilationTimeStamp);
    // Add the assignments made from the formal and actual
    // parameters to the actual module
    assignments.setRightScope(myScope);
    assignments.setParentScope(parass.getMyScope());
    assignments.setFullNameParent(this);
    assignments.check(compilationTimeStamp);
    // create a copy of the assignment and add it to the actual
    // module
    final ASN1Assignment newAssignment = ((ASN1Assignment) parass).newInstance(module);
    newAssignmentNameStart = new NameReStarter(new StringBuilder(module.getFullName()).append(INamedNode.DOT).append(newAssignment.getIdentifier().getDisplayName()).toString());
    newAssignmentNameStart.setFullNameParent(parass);
    newAssignment.setFullNameParent(newAssignmentNameStart);
    newAssignment.setLocation(location);
    newAssignment.getIdentifier().setLocation(assignmentReference.getLocation());
    ((ASN1Assignments) module.getAssignments()).addDynamicAssignment(compilationTimeStamp, newAssignment);
    newAssignment.setMyScope(assignments);
    newAssignment.check(compilationTimeStamp);
    final List<ISubReference> subreferences = new ArrayList<ISubReference>(1);
    subreferences.add(new FieldSubReference(newAssignment.getIdentifier()));
    finalReference = new Defined_Reference(module.getIdentifier(), subreferences);
    finalReference.setFullNameParent(this);
    finalReference.setMyScope(module);
    return finalReference;
}
Also used : FieldSubReference(org.eclipse.titan.designer.AST.FieldSubReference) ArrayList(java.util.ArrayList) NameReStarter(org.eclipse.titan.designer.AST.NameReStarter) Assignment(org.eclipse.titan.designer.AST.Assignment) ISubReference(org.eclipse.titan.designer.AST.ISubReference) CompilationTimeStamp(org.eclipse.titan.designer.parsers.CompilationTimeStamp) Module(org.eclipse.titan.designer.AST.Module)

Example 39 with Assignment

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

the class ASN1Assignments method getLocalAssignmentByID.

@Override
public /**
 * {@inheritDoc}
 */
Assignment getLocalAssignmentByID(final CompilationTimeStamp timestamp, final Identifier identifier) {
    if (null == lastUniqueNessCheckTimeStamp) {
        checkUniqueness(timestamp);
    }
    final String name = identifier.getName();
    if (assignmentMap.containsKey(name)) {
        final Assignment temp = assignmentMap.get(name);
        if (temp instanceof Undefined_Assignment) {
            final ASN1Assignment real = ((Undefined_Assignment) temp).getRealAssignment(timestamp);
            if (null != real) {
                return real;
            }
        }
        return temp;
    }
    final Assignments temp = SpecialASN1Module.getSpecialModule().getAssignments();
    if (!this.equals(temp)) {
        return temp.getLocalAssignmentByID(timestamp, identifier);
    }
    return null;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) Assignments(org.eclipse.titan.designer.AST.Assignments)

Example 40 with Assignment

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

the class Referenced_Template method checkThisTemplateGeneric.

@Override
public /**
 * {@inheritDoc}
 */
boolean checkThisTemplateGeneric(final CompilationTimeStamp timestamp, final IType type, final boolean isModified, final boolean allowOmit, final boolean allowAnyOrOmit, final boolean subCheck, final boolean implicitOmit, final Assignment lhs) {
    if (getIsErroneous(timestamp) || reference == null) {
        return false;
    }
    final Assignment assignment = reference.getRefdAssignment(timestamp, true);
    if (assignment == null) {
        return false;
    }
    final boolean selfReference = lhs == assignment;
    assignment.check(timestamp);
    IType governor = assignment.getType(timestamp);
    if (governor != null) {
        governor = governor.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
    }
    if (governor == null) {
        setIsErroneous(true);
        return selfReference;
    }
    final TypeCompatibilityInfo info = new TypeCompatibilityInfo(type, governor, true);
    if (!type.isCompatible(timestamp, governor, info, null, null)) {
        final IType last = type.getTypeRefdLast(timestamp);
        switch(last.getTypetype()) {
            case TYPE_PORT:
                // no such thing exists, remain silent
                break;
            case TYPE_SIGNATURE:
                getLocation().reportSemanticError(MessageFormat.format(TYPEMISSMATCH1, type.getTypename(), governor.getTypename()));
                setIsErroneous(true);
                break;
            default:
                getLocation().reportSemanticError(MessageFormat.format(TYPEMISSMATCH2, type.getTypename(), governor.getTypename()));
                setIsErroneous(true);
                break;
        }
    }
    // check for circular references
    final ITTCN3Template temp = getTemplateReferencedLast(timestamp);
    if (temp != this) {
        final IReferenceChain referenceChain = ReferenceChain.getInstance(CIRCULARTEMPLATEREFERENCE, true);
        final boolean referencedHasImplicitOmit = hasTemplateImpliciteOmit(timestamp, referenceChain);
        referenceChain.release();
    }
    return selfReference;
}
Also used : Assignment(org.eclipse.titan.designer.AST.Assignment) IReferenceChain(org.eclipse.titan.designer.AST.IReferenceChain) TypeCompatibilityInfo(org.eclipse.titan.designer.AST.TypeCompatibilityInfo) IType(org.eclipse.titan.designer.AST.IType)

Aggregations

Assignment (org.eclipse.titan.designer.AST.Assignment)141 Reference (org.eclipse.titan.designer.AST.Reference)48 IType (org.eclipse.titan.designer.AST.IType)41 ISubReference (org.eclipse.titan.designer.AST.ISubReference)39 IValue (org.eclipse.titan.designer.AST.IValue)31 Identifier (org.eclipse.titan.designer.AST.Identifier)25 ArrayList (java.util.ArrayList)24 Module (org.eclipse.titan.designer.AST.Module)22 IReferenceChain (org.eclipse.titan.designer.AST.IReferenceChain)16 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)14 Referenced_Value (org.eclipse.titan.designer.AST.TTCN3.values.Referenced_Value)14 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)14 Assignments (org.eclipse.titan.designer.AST.Assignments)13 ParameterisedSubReference (org.eclipse.titan.designer.AST.ParameterisedSubReference)13 ITTCN3Template (org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template)10 Location (org.eclipse.titan.designer.AST.Location)9 ArrayDimensions (org.eclipse.titan.designer.AST.TTCN3.values.ArrayDimensions)8 Type_type (org.eclipse.titan.designer.AST.IType.Type_type)7 ProjectSourceParser (org.eclipse.titan.designer.parsers.ProjectSourceParser)7 SpecificValue_Template (org.eclipse.titan.designer.AST.TTCN3.templates.SpecificValue_Template)6