use of org.eclipse.titan.designer.AST.ASN1.Object.FixedTypeValue_FieldSpecification in project titan.EclipsePlug-ins by eclipse.
the class InformationFromObj method getRefdSetting.
@Override
public /**
* {@inheritDoc}
*/
ISetting getRefdSetting(final CompilationTimeStamp timestamp) {
setIsErroneous(false);
ISetting temporalSetting = reference.getRefdSetting(timestamp);
if (null == temporalSetting) {
setIsErroneous(true);
return new Error_Setting();
}
SettingDetectionState currentState;
ObjectClass_Definition objectClass = null;
ObjectSet_definition objectSet = null;
Object_Definition object = null;
object = new Object_Definition(null);
ObjectSet_definition fromObjectSet = newObjectSetDefinitionInstance();
/* the first part */
switch(temporalSetting.getSettingtype()) {
case S_OS:
currentState = SettingDetectionState.ObjectSet;
objectSet = ((ObjectSet) temporalSetting).getRefdLast(timestamp, null);
objectClass = objectSet.getMyGovernor().getRefdLast(timestamp, null);
final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(objectSet.getLocation(), objectClass, timestamp);
objectCollector.visitObjectSet(objectSet, false);
fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
fromObjectSet.setMyGovernor(objectClass);
break;
case S_O:
currentState = SettingDetectionState.Object;
object = ((ASN1Object) temporalSetting).getRefdLast(timestamp, null);
objectClass = object.getMyGovernor().getRefdLast(timestamp, null);
break;
case S_OC:
currentState = SettingDetectionState.ObjectClass;
objectClass = ((ObjectClass) temporalSetting).getRefdLast(timestamp, null);
break;
case S_ERROR:
setIsErroneous(true);
return new Error_Setting();
default:
location.reportSemanticError(MessageFormat.format(INVALIDREFERENCE, getDisplayName()));
setIsErroneous(true);
return new Error_Setting();
}
final int nofFields = fieldName.getNofFields();
/* the middle part */
Identifier currentFieldName;
FieldSpecification currentFieldSpecification;
for (int i = 0; i < nofFields - 1; i++) {
currentFieldName = fieldName.getFieldByIndex(i);
currentFieldSpecification = objectClass.getFieldSpecifications().getFieldSpecificationByIdentifier(currentFieldName).getLast();
if (Fieldspecification_types.FS_ERROR.equals(currentFieldSpecification.getFieldSpecificationType())) {
setIsErroneous(true);
return new Error_Setting();
}
switch(currentState) {
case ObjectClass:
switch(currentFieldSpecification.getFieldSpecificationType()) {
case FS_O:
{
final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
}
break;
case FS_OS:
{
final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
}
break;
case FS_ERROR:
setIsErroneous(true);
return new Error_Setting();
default:
location.reportSemanticError(INVALIDNOTATION1);
setIsErroneous(true);
return new Error_Setting();
}
break;
case ObjectSet:
switch(currentFieldSpecification.getFieldSpecificationType()) {
case FS_O:
{
final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
final ASN1Objects temporalObjects = fromObjectSet.getObjs();
temporalObjects.trimToSize();
for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
continue;
}
temporalSetting = object.getSettingByNameDefault(currentFieldName);
object = ((Object_Definition) temporalSetting).getRefdLast(timestamp, null);
objectCollector.visitObject(object);
}
fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
fromObjectSet.setLocation(location);
fromObjectSet.setMyGovernor(objectClass);
}
break;
case FS_OS:
{
final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
final ObjectSetElementVisitor_objectCollector objectCollector2 = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
final ASN1Objects temporalObjects = fromObjectSet.getObjs();
for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
continue;
}
temporalSetting = object.getSettingByNameDefault(currentFieldName);
objectSet = ((ObjectSet_definition) temporalSetting).getRefdLast(timestamp, null);
objectCollector2.visitObjectSet(objectSet, false);
}
fromObjectSet = newObjectSetDefinitionInstance(objectCollector2.giveObjects());
fromObjectSet.setLocation(location);
fromObjectSet.setMyGovernor(objectClass);
}
break;
case FS_ERROR:
setIsErroneous(true);
return new Error_Setting();
default:
location.reportSemanticError(INVALIDNOTATION1);
setIsErroneous(true);
return new Error_Setting();
}
break;
case Object:
switch(currentFieldSpecification.getFieldSpecificationType()) {
case FS_O:
{
final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
temporalSetting = object.getSettingByNameDefault(currentFieldName);
object = ((Object_Definition) temporalSetting).getRefdLast(timestamp, null);
}
break;
case FS_OS:
{
currentState = SettingDetectionState.ObjectSet;
final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(fromObjectSet, timestamp);
final ASN1Objects temporalObjects = fromObjectSet.getObjs();
for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
continue;
}
temporalSetting = object.getSettingByNameDefault(currentFieldName);
objectSet = ((ObjectSet_definition) temporalSetting).getRefdLast(timestamp, null);
objectCollector.visitObjectSet(objectSet, false);
}
fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
fromObjectSet.setLocation(location);
fromObjectSet.setMyGovernor(objectClass);
}
break;
case FS_ERROR:
setIsErroneous(true);
return new Error_Setting();
default:
location.reportSemanticError(INVALIDNOTATION1);
setIsErroneous(true);
return new Error_Setting();
}
break;
default:
// if this could happen it would be FATAL ERROR
break;
}
}
/* and the last part... */
currentFieldName = fieldName.getFieldByIndex(nofFields - 1);
currentFieldSpecification = objectClass.getFieldSpecifications().getFieldSpecificationByIdentifier(currentFieldName).getLast();
temporalSetting = null;
switch(currentState) {
case ObjectClass:
switch(currentFieldSpecification.getFieldSpecificationType()) {
case FS_T:
{
final Open_Type type = new Open_Type(objectClass, currentFieldName);
type.setLocation(location);
type.setMyScope(myScope);
temporalSetting = type;
}
break;
case FS_V_FT:
{
final FixedTypeValue_FieldSpecification temporalFielspecification = (FixedTypeValue_FieldSpecification) currentFieldSpecification;
final ObjectClassField_Type type = new ObjectClassField_Type(temporalFielspecification.getType(), objectClass, currentFieldName);
type.setLocation(location);
temporalSetting = type;
}
break;
case FS_V_VT:
case FS_VS_FT:
case FS_VS_VT:
location.reportSemanticError(UNSUPPORTEDCONSTRUCT);
setIsErroneous(true);
break;
case FS_O:
case FS_OS:
location.reportSemanticError(INVALIDNOTATION2);
setIsErroneous(true);
break;
default:
setIsErroneous(true);
break;
}
break;
case ObjectSet:
switch(currentFieldSpecification.getFieldSpecificationType()) {
case FS_O:
{
final Object_FieldSpecification temporalFieldspec = (Object_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
final ObjectSetElementVisitor_objectCollector objectCollector = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
final ASN1Objects temporalObjects = fromObjectSet.getObjs();
for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
continue;
}
temporalSetting = object.getSettingByNameDefault(currentFieldName);
object = ((Object_Definition) temporalSetting).getRefdLast(timestamp, null);
objectCollector.visitObject(object);
}
fromObjectSet = newObjectSetDefinitionInstance(objectCollector.giveObjects());
fromObjectSet.setLocation(location);
fromObjectSet.setMyGovernor(objectClass);
fromObjectSet.setMyScope(myScope);
temporalSetting = fromObjectSet;
}
break;
case FS_OS:
{
final ObjectSet_FieldSpecification temporalFieldspec = (ObjectSet_FieldSpecification) currentFieldSpecification;
objectClass = temporalFieldspec.getObjectClass().getRefdLast(timestamp, null);
final ObjectSetElementVisitor_objectCollector objectCollector2 = new ObjectSetElementVisitor_objectCollector(location, objectClass, timestamp);
final ASN1Objects temporalObjects = fromObjectSet.getObjs();
for (int j = 0; j < temporalObjects.getNofObjects(); j++) {
object = temporalObjects.getObjectByIndex(j).getRefdLast(timestamp, null);
if (!object.hasFieldSettingWithNameDefault(currentFieldName)) {
continue;
}
temporalSetting = object.getSettingByNameDefault(currentFieldName);
objectSet = ((ObjectSet_definition) temporalSetting).getRefdLast(timestamp, null);
objectCollector2.visitObjectSet(objectSet, false);
}
fromObjectSet = newObjectSetDefinitionInstance(objectCollector2.giveObjects());
fromObjectSet.setLocation(location);
fromObjectSet.setMyGovernor(objectClass);
fromObjectSet.setMyScope(myScope);
temporalSetting = fromObjectSet;
}
break;
case FS_V_FT:
case FS_VS_FT:
location.reportSemanticError(VALUESETFROMOBJECTS_NOT_SUPPORTED);
setIsErroneous(true);
break;
case FS_ERROR:
setIsErroneous(true);
break;
default:
location.reportSemanticError(INVALIDNOTATION3);
setIsErroneous(true);
break;
}
break;
case Object:
temporalSetting = object.getSettingByNameDefault(currentFieldName);
break;
default:
setIsErroneous(true);
break;
}
return temporalSetting;
}
use of org.eclipse.titan.designer.AST.ASN1.Object.FixedTypeValue_FieldSpecification 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();
}
Aggregations