use of org.eclipse.titan.designer.AST.ISetting in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Value method getValueRefdLast.
@Override
public /**
* {@inheritDoc}
*/
IValue getValueRefdLast(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return referencedValue;
}
final boolean newChain = null == referenceChain;
IReferenceChain tempReferenceChain;
if (newChain) {
tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
tempReferenceChain = referenceChain;
}
referencedValue = this;
isErroneous = false;
if (reference == null) {
return referencedValue;
}
reference.setIsErroneous(false);
final Assignment ass = reference.getRefdAssignment(timestamp, true);
if (ass == null) {
isErroneous = true;
return referencedValue;
}
switch(ass.getAssignmentType()) {
case A_OBJECT:
case A_OS:
{
final ISetting setting = reference.getRefdSetting(timestamp);
if (setting == null || setting.getIsErroneous(timestamp)) {
isErroneous = true;
} else if (!Setting_type.S_V.equals(setting.getSettingtype())) {
reference.getLocation().reportSemanticError(MessageFormat.format(INFORMATIONFROMOBJECTNOTVALUE, reference));
isErroneous = true;
} else {
tempReferenceChain.markState();
if (tempReferenceChain.add(this)) {
referencedValue = ((IValue) setting).getValueRefdLast(timestamp, expectedValue, referenceChain);
} else {
isErroneous = true;
}
tempReferenceChain.previousState();
}
break;
}
case A_CONST:
{
tempReferenceChain.markState();
if (tempReferenceChain.add(this)) {
if (ass instanceof Def_Const) {
referencedValue = ((Def_Const) ass).getValue();
} else if (ass instanceof Value_Assignment) {
referencedValue = ((Value_Assignment) ass).getValue();
} else {
isErroneous = true;
}
if (referencedValue != null && !isErroneous) {
referencedValue = referencedValue.getReferencedSubValue(timestamp, reference, 1, tempReferenceChain);
} else {
referencedValue = this;
tempReferenceChain.previousState();
return referencedValue;
}
if (referencedValue != null) {
referencedValue = referencedValue.getValueRefdLast(timestamp, tempReferenceChain);
} else if (reference.hasUnfoldableIndexSubReference(timestamp)) {
referencedValue = this;
tempReferenceChain.previousState();
return referencedValue;
} else if (reference.getUsedInIsbound()) {
referencedValue = this;
tempReferenceChain.previousState();
return referencedValue;
} else {
isErroneous = true;
}
} else {
isErroneous = true;
}
tempReferenceChain.previousState();
break;
}
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_FUNCTION_RVAL:
case A_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RVAL:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
case A_MODULEPAR_TEMPLATE:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_INOUT:
case A_PAR_TEMP_OUT:
referencedValue = this;
break;
case A_TEMPLATE:
case A_VAR_TEMPLATE:
// the referred definition is not a constant
// errors will be reported in Types.java
referencedValue = this;
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT2, ass.getDescription()));
}
break;
case A_FUNCTION:
case A_EXT_FUNCTION:
reference.getLocation().reportSemanticError(MessageFormat.format(VALUERETURNEXPECTED, ass.getDescription()));
isErroneous = true;
break;
default:
if (Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT1, ass.getDescription()));
} else {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT2, ass.getDescription()));
}
isErroneous = true;
break;
}
if (newChain) {
tempReferenceChain.release();
}
lastTimeChecked = timestamp;
if (referencedValue == null) {
referencedValue = this;
isErroneous = true;
}
return referencedValue;
}
use of org.eclipse.titan.designer.AST.ISetting in project titan.EclipsePlug-ins by eclipse.
the class ReferencedObject method getRefd.
public ASN1Object getRefd(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (referenceChain.add(this)) {
if (objectReferenced != null && lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return objectReferenced;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true, referenceChain);
if (null != assignment) {
final ISetting setting = reference.getRefdSetting(timestamp);
if (null != setting && !Setting_type.S_ERROR.equals(setting.getSettingtype())) {
if (Setting_type.S_O.equals(setting.getSettingtype())) {
objectReferenced = (ASN1Object) setting;
return objectReferenced;
}
location.reportSemanticError(OBJECTEXPECTED);
}
}
}
objectReferenced = new Object_Definition(null);
objectReferenced.setMyGovernor(myGovernor);
return objectReferenced;
}
use of org.eclipse.titan.designer.AST.ISetting 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.ISetting 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.ISetting in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Type method getTypeRefd.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefd(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (refChain.add(this) && reference != null && !getIsErroneous(timestamp)) {
if (refd != null) {
return refd;
}
Assignment ass = reference.getRefdAssignment(timestamp, true, refChain);
if (ass != null && Assignment_type.A_UNDEF.semanticallyEquals(ass.getAssignmentType())) {
ass = ((Undefined_Assignment) ass).getRealAssignment(timestamp);
}
if (ass == null || ass.getIsErroneous()) {
// The referenced assignment was not found, or is erroneous
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
switch(ass.getAssignmentType()) {
case A_TYPE:
{
IType tempType = ass.getType(timestamp);
if (tempType != null) {
if (!tempType.getIsErroneous(timestamp)) {
tempType.check(timestamp);
tempType = tempType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, refChain, false);
if (tempType == null) {
setIsErroneous(true);
return this;
}
refd = tempType;
return refd;
}
}
break;
}
case A_VS:
{
final IType tempType = ass.getType(timestamp);
if (tempType == null) {
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
refd = tempType;
return refd;
}
case A_OC:
case A_OBJECT:
case A_OS:
final ISetting setting = reference.getRefdSetting(timestamp);
if (setting == null || setting.getIsErroneous(timestamp)) {
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
if (!Setting_type.S_T.equals(setting.getSettingtype())) {
reference.getLocation().reportSemanticError(MessageFormat.format(TYPEREFERENCEEXPECTED, reference.getDisplayName()));
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
refd = (Type) setting;
if (refd.getOwnertype() == TypeOwner_type.OT_UNKNOWN) {
refd.setOwnertype(TypeOwner_type.OT_REF, this);
}
return refd;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(TYPEREFERENCEEXPECTED, reference.getDisplayName()));
break;
}
}
isErroneous = true;
lastTimeChecked = timestamp;
return this;
}
Aggregations