use of org.eclipse.titan.designer.AST.ASN1.Object.ReferencedObject in project titan.EclipsePlug-ins by eclipse.
the class TableConstraint method collectTypesOfOpenType.
private void collectTypesOfOpenType(final CompilationTimeStamp aTimestamp, ObjectSet aObjectSet, final Open_Type aOpenType, final Identifier aObjectSetId) {
if (aObjectSet instanceof Referenced_ObjectSet) {
if (((Referenced_ObjectSet) aObjectSet).isReferencedDefinedReference()) {
aObjectSet = aObjectSet.getRefdLast(aTimestamp, null);
} else if (((Referenced_ObjectSet) aObjectSet).isReferencedInformationFromObj()) {
// TODO: How to handle this?
return;
} else {
// impossible, try it
return;
}
}
// now aObjectSet is instanceof ObjectSet_definition:
List<IObjectSet_Element> oses = ((ObjectSet_definition) aObjectSet).getObjectSetElements();
for (IObjectSet_Element ose : oses) {
if (ose instanceof ReferencedObject) {
// fspec
ose = ((ReferencedObject) ose).getRefdLast(aTimestamp);
}
if (ose instanceof Object_Definition) {
final Object_Definition od = (Object_Definition) ose;
FieldSetting fs = od.getFieldSettingWithNameDefault(objectClassFieldname, false);
if (fs != null) {
// TODO: handle FieldSetting options: FieldSetting_Type, FieldSetting_ObjectSet, FieldSetting_Value
if (fs instanceof FieldSetting_Type) {
final FieldSetting_Type fst = (FieldSetting_Type) fs;
final IASN1Type type = fst.getSetting();
final AtomicBoolean isStrange = new AtomicBoolean();
Identifier id = getOpenTypeAlternativeName(aTimestamp, (Type) type, isStrange);
if (!aOpenType.hasComponentWithName(id)) {
aOpenType.addComponent(new CompField(id, (Type) type, false, null));
if (isStrange.get()) {
aOpenType.getLocation().reportSemanticWarning(MessageFormat.format("Strange alternative name (`{0}') was added to open type `{1}'", id.getDisplayName(), aOpenType.getFullName()));
}
}
} else {
// TODO: is it possible FieldSetting_ObjectSet, FieldSetting_Value ??
continue;
}
} else {
fs = od.getFieldSettingWithNameDefault(aObjectSetId, false);
if (fs == null) {
continue;
}
if (fs instanceof FieldSetting_ObjectSet) {
final ISetting objectSet1 = fs.getSetting();
ObjectSet objectSet2;
if (objectSet1 instanceof ObjectSet) {
objectSet2 = (ObjectSet) objectSet1;
} else {
// unexpected case
continue;
}
if (objectSet2 == aObjectSet) {
// to prevent infinite loop
continue;
}
collectTypesOfOpenType(aTimestamp, objectSet2, aOpenType, aObjectSetId);
} else {
// TODO: is it possible??
continue;
}
}
}
}
// for
aOpenType.check(aTimestamp);
}
use of org.eclipse.titan.designer.AST.ASN1.Object.ReferencedObject in project titan.EclipsePlug-ins by eclipse.
the class Undefined_Assignment_O_or_V 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)) {
if (null != reference && !reference.refersToSettingType(timestamp, Setting_type.S_ERROR, temporalReferenceChain)) {
reference.setMyScope(myScope);
if (null != objectReference) {
objectReference.setMyScope(rightScope);
}
if (identifier.isvalidAsnObjectReference() && reference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
final ObjectClass_refd oc = new ObjectClass_refd(reference);
oc.setLocation(reference.getLocation());
if (null != mBlock) {
final Object_Definition obj = new Object_Definition(mBlock);
// obj.setLocation(right1);
realAssignment = new Object_Assignment(identifier, assPard, oc, obj);
} else if (null != objectReference) {
final ReferencedObject obj = new ReferencedObject(objectReference);
obj.setLocation(objectReference.getLocation());
realAssignment = new Object_Assignment(identifier, assPard, oc, obj);
}
} else if (identifier.isvalidAsnValueReference() && (reference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || reference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
final Referenced_Type type = new Referenced_Type(reference);
if (null != mBlock) {
final Value value = new Undefined_Block_Value(mBlock);
value.setLocation(mBlock.getLocation());
realAssignment = new Value_Assignment(identifier, assPard, type, value);
} else if (null != objectReference) {
final Value value = new Undefined_LowerIdentifier_Value(objectReference.getId().newInstance());
value.setLocation(objectReference.getLocation());
realAssignment = new Value_Assignment(identifier, assPard, type, value);
}
}
}
}
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();
}
}
use of org.eclipse.titan.designer.AST.ASN1.Object.ReferencedObject in project titan.EclipsePlug-ins by eclipse.
the class Undefined_FieldSpecification method classifyFieldSpecification.
private void classifyFieldSpecification(final CompilationTimeStamp timestamp) {
final IReferenceChain temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
if (isOptional && (null != defaultSetting1 || null != mDefaultSetting)) {
location.reportSemanticError("OPTIONAL and DEFAULT are mutually exclusive");
isOptional = false;
}
if (temporalReferenceChain.add(this) && null != governorReference) {
governorReference.setMyScope(myObjectClass.getMyScope());
if (null != defaultSetting1) {
defaultSetting1.setMyScope(myObjectClass.getMyScope());
}
if (identifier.isvalidAsnObjectSetFieldReference() && governorReference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
ObjectSet defaultObjectset = null;
if (null != mDefaultSetting) {
defaultObjectset = new ObjectSet_definition(mDefaultSetting);
}
final ObjectClass_refd oc = new ObjectClass_refd(governorReference);
oc.setLocation(governorReference.getLocation());
fieldSpecification = new ObjectSet_FieldSpecification(identifier, oc, isOptional, defaultObjectset);
} else if (identifier.isvalidAsnObjectFieldReference() && governorReference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
ASN1Object defaultObject = null;
if (null != defaultSetting1) {
defaultObject = new ReferencedObject(defaultSetting1);
} else if (null != mDefaultSetting) {
defaultObject = new Object_Definition(mDefaultSetting);
}
fieldSpecification = new Object_FieldSpecification(identifier, new ObjectClass_refd(governorReference), isOptional, defaultObject);
} else if (identifier.isvalidAsnValueFieldReference() && (governorReference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || governorReference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
IValue defaultValue = null;
if (null != defaultSetting1) {
if (defaultSetting1 instanceof Defined_Reference && null == defaultSetting1.getModuleIdentifier()) {
defaultValue = new Undefined_LowerIdentifier_Value(defaultSetting1.getId().newInstance());
} else {
defaultValue = new Referenced_Value(defaultSetting1);
}
} else if (null != mDefaultSetting) {
defaultValue = new Undefined_Block_Value(mDefaultSetting);
}
fieldSpecification = new FixedTypeValue_FieldSpecification(identifier, new Referenced_Type(governorReference), false, isOptional, null != defaultSetting1 && null != mDefaultSetting, defaultValue);
}
}
if (null == fieldSpecification) {
location.reportSemanticError(CANNOTRECOGNISE);
fieldSpecification = new Erroneous_FieldSpecification(identifier, isOptional, null != defaultSetting1 || null != mDefaultSetting);
} else {
if (null != myObjectClass) {
fieldSpecification.setMyObjectClass(myObjectClass);
}
}
fieldSpecification.setFullNameParent(getNameParent());
fieldSpecification.setLocation(location);
temporalReferenceChain.release();
}
use of org.eclipse.titan.designer.AST.ASN1.Object.ReferencedObject in project titan.EclipsePlug-ins by eclipse.
the class ReferencedObject method getRefdLast.
public Object_Definition getRefdLast(final CompilationTimeStamp timestamp) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(CIRCULAROBJECTREFERENCE, true);
ASN1Object object = this;
while (object instanceof ReferencedObject && !object.getIsErroneous(timestamp)) {
object = ((ReferencedObject) object).getRefd(timestamp, referenceChain);
}
referenceChain.release();
return (Object_Definition) object;
}
Aggregations