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;
}
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;
}
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;
}
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;
}
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;
}
Aggregations