Search in sources :

Example 1 with NameReStarter

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

Aggregations

ArrayList (java.util.ArrayList)1 Assignment (org.eclipse.titan.designer.AST.Assignment)1 FieldSubReference (org.eclipse.titan.designer.AST.FieldSubReference)1 ISubReference (org.eclipse.titan.designer.AST.ISubReference)1 Module (org.eclipse.titan.designer.AST.Module)1 NameReStarter (org.eclipse.titan.designer.AST.NameReStarter)1 CompilationTimeStamp (org.eclipse.titan.designer.parsers.CompilationTimeStamp)1