use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Value method evaluateIsvalue.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIsvalue(final boolean fromSequence) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (last == this) {
return false;
}
return last.evaluateIsvalue(false);
}
use of org.eclipse.titan.designer.AST.IReferenceChain 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.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class SequenceOf_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!Value_type.SEQUENCEOF_VALUE.equals(last.getValuetype())) {
return false;
}
final SequenceOf_Value otherSequence = (SequenceOf_Value) last;
if (values.isIndexed()) {
if (otherSequence.isIndexed()) {
if (values.getNofIndexedValues() != otherSequence.values.getNofIndexedValues()) {
return false;
}
for (int i = 0, size = values.getNofIndexedValues(); i < size; i++) {
final IndexedValue localTemp = values.getIndexedValueByIndex(i);
final IValue indexValue = localTemp.getIndex().getValue();
if (Value_type.INTEGER_VALUE.equals(indexValue.getValuetype())) {
final Integer_Value integerValue = (Integer_Value) indexValue;
final IValue otherValue = otherSequence.values.getIndexedValueByRealIndex(integerValue.intValue());
if (otherValue == null || !localTemp.getValue().checkEquality(timestamp, otherValue)) {
return false;
}
} else {
return false;
}
}
} else {
if (values.getNofIndexedValues() != otherSequence.values.getNofValues()) {
return false;
}
for (int i = 0, size = otherSequence.values.getNofValues(); i < size; i++) {
final IValue value = values.getIndexedValueByRealIndex(i);
if (value == null || !otherSequence.values.getValueByIndex(i).checkEquality(timestamp, value)) {
return false;
}
}
}
} else {
if (otherSequence.isIndexed()) {
if (values.getNofValues() != otherSequence.values.getNofIndexedValues()) {
return false;
}
for (int i = 0, size = values.getNofValues(); i < size; i++) {
final IValue otherValue = otherSequence.values.getIndexedValueByRealIndex(i);
if (otherValue == null || !values.getValueByIndex(i).checkEquality(timestamp, otherValue)) {
return false;
}
}
} else {
if (values.getNofValues() != otherSequence.values.getNofValues()) {
return false;
}
for (int i = 0, size = values.getNofValues(); i < size; i++) {
if (!values.getValueByIndex(i).checkEquality(timestamp, otherSequence.values.getValueByIndex(i))) {
return false;
}
}
}
}
return true;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class SetOf_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!Value_type.SETOF_VALUE.equals(last.getValuetype())) {
return false;
}
final SetOf_Value otherSetof = (SetOf_Value) last;
if (isIndexed()) {
if (otherSetof.isIndexed()) {
if (values.getNofIndexedValues() != otherSetof.values.getNofIndexedValues()) {
return false;
}
final List<Integer> indicesuncovered = new ArrayList<Integer>();
for (int i = 0; i < values.getNofIndexedValues(); i++) {
indicesuncovered.add(i);
}
for (int i = values.getNofIndexedValues() - 1; i >= 0; i--) {
final IndexedValue localTemp = values.getIndexedValueByIndex(i);
boolean found = false;
for (int j = indicesuncovered.size() - 1; j >= 0 && !found; j--) {
final IValue otherTemp = otherSetof.values.getIndexedValueByRealIndex(indicesuncovered.get(j));
if (localTemp.getValue().checkEquality(timestamp, otherTemp)) {
found = true;
indicesuncovered.remove(j);
}
}
if (!found) {
return false;
}
}
} else {
if (values.getNofIndexedValues() != otherSetof.values.getNofValues()) {
return false;
}
final List<Integer> indicesuncovered = new ArrayList<Integer>();
for (int i = 0; i < values.getNofIndexedValues(); i++) {
indicesuncovered.add(i);
}
for (int i = values.getNofIndexedValues() - 1; i >= 0; i--) {
final IndexedValue localTemp = values.getIndexedValueByIndex(i);
boolean found = false;
for (int j = indicesuncovered.size() - 1; j >= 0 && !found; j--) {
final IValue otherTemp = otherSetof.values.getValueByIndex(indicesuncovered.get(j));
if (localTemp.getValue().checkEquality(timestamp, otherTemp)) {
found = true;
indicesuncovered.remove(j);
}
}
if (!found) {
return false;
}
}
}
} else {
if (otherSetof.isIndexed()) {
if (values.getNofValues() != otherSetof.values.getNofIndexedValues()) {
return false;
}
final List<Integer> indicesuncovered = new ArrayList<Integer>();
for (int i = 0; i < values.getNofValues(); i++) {
indicesuncovered.add(i);
}
for (int i = 0, size = values.getNofValues(); i < size; i++) {
final IValue localTemp = values.getValueByIndex(i);
boolean found = false;
for (int j = indicesuncovered.size() - 1; j >= 0 && !found; j--) {
final IndexedValue otherTemp = otherSetof.values.getIndexedValueByIndex(indicesuncovered.get(j));
if (localTemp.checkEquality(timestamp, otherTemp.getValue())) {
found = true;
indicesuncovered.remove(j);
}
}
if (!found) {
return false;
}
}
} else {
if (values.getNofValues() != otherSetof.values.getNofValues()) {
return false;
}
final List<Integer> indicesuncovered = new ArrayList<Integer>();
for (int i = 0; i < values.getNofValues(); i++) {
indicesuncovered.add(i);
}
for (int i = 0, size = values.getNofValues(); i < size; i++) {
final IValue localTemp = values.getValueByIndex(i);
boolean found = false;
for (int j = indicesuncovered.size() - 1; j >= 0 && !found; j--) {
final IValue otherTemp = otherSetof.values.getValueByIndex(indicesuncovered.get(j));
if (localTemp.checkEquality(timestamp, otherTemp)) {
found = true;
indicesuncovered.remove(j);
}
}
if (!found) {
return false;
}
}
}
}
return true;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Hexstring_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
return Value_type.HEXSTRING_VALUE.equals(last.getValuetype()) && value.equals(((Hexstring_Value) last).getValue());
}
Aggregations