use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Set_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.SET_VALUE.equals(last.getValuetype())) {
return false;
}
if (myGovernor == null) {
return false;
}
final Set_Value otherSet = (Set_Value) last;
if (values.getSize() != otherSet.values.getSize()) {
return false;
}
int nofComps = 0;
final IType leftGovernor = myGovernor.getTypeRefdLast(timestamp);
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SET:
nofComps = ((TTCN3_Set_Type) leftGovernor).getNofComponents();
break;
case TYPE_ASN1_SET:
nofComps = ((ASN1_Set_Type) leftGovernor).getNofComponents(timestamp);
break;
default:
return false;
}
CompField compField = null;
for (int i = 0; i < nofComps; i++) {
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SET:
compField = ((TTCN3_Set_Type) leftGovernor).getComponentByIndex(i);
break;
case TYPE_ASN1_SET:
compField = ((ASN1_Set_Type) leftGovernor).getComponentByIndex(i);
break;
default:
return false;
}
final Identifier fieldName = compField.getIdentifier();
if (hasComponentWithName(fieldName)) {
final IValue leftValue = getComponentByName(fieldName).getValue();
if (otherSet.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSet.getComponentByName(fieldName).getValue();
if ((Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && !Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) || (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && Value_type.OMIT_VALUE.equals(otherValue.getValuetype()))) {
return false;
}
if (!leftValue.checkEquality(timestamp, otherValue)) {
return false;
}
} else {
if (compField.hasDefault()) {
if (!leftValue.checkEquality(timestamp, compField.getDefault())) {
return false;
}
} else {
if (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype())) {
return false;
}
}
}
} else {
if (otherSet.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSet.getComponentByName(fieldName).getValue();
if (compField.hasDefault()) {
if (Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) {
return false;
}
if (!compField.getDefault().checkEquality(timestamp, otherValue)) {
return false;
}
}
}
}
}
return true;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class UniversalCharstring_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();
switch(last.getValuetype()) {
case CHARSTRING_VALUE:
return value.checkEquality(((Charstring_Value) last).getValue());
case UNIVERSALCHARSTRING_VALUE:
return value.checkEquality(((UniversalCharstring_Value) last).getValue());
case ISO2022STRING_VALUE:
return value.checkEquality(((ISO2022String_Value) last).getValueISO2022String());
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Verdict_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.VERDICT_VALUE.equals(last.getValuetype()) && value.equals(((Verdict_Value) last).getValue());
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ComponentCreateExpression method generateCodeExpressionExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
aData.addCommonLibraryImport("TTCN_Runtime");
expression.expression.append("TTCN_Runtime.create_component(");
// the type of the component (module name and identifier)
final Assignment assignment = componentReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
if (assignment == null || !Assignment_type.A_TYPE.equals(assignment.getAssignmentType())) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
IType componentType = assignment.getType(CompilationTimeStamp.getBaseTimestamp()).getFieldType(CompilationTimeStamp.getBaseTimestamp(), componentReference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (componentType == null) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
componentType = componentType.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
if (!Type_type.TYPE_COMPONENT.equals(componentType.getTypetype())) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
((Component_Type) componentType).getComponentBody().generateCodeComponentTypeName(expression);
expression.expression.append(", ");
// third argument: component name
if (name != null) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = name.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
// TODO check why translate
expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
} else {
name.generateCodeExpressionMandatory(aData, expression, false);
}
} else {
expression.expression.append("null");
}
expression.expression.append(", ");
// fourth argument location
if (location != null) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = location.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (Value_type.CHARSTRING_VALUE.equals(last.getValuetype())) {
// TODO check why translate
expression.expression.append(MessageFormat.format("\"{0}\"", ((Charstring_Value) last).getValue()));
} else {
location.generateCodeExpressionMandatory(aData, expression, false);
}
} else {
expression.expression.append("null");
}
// fifth argument: alive flag
expression.expression.append(MessageFormat.format(", {0})", isAlive ? "true" : "false"));
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Array_Value method evaluateIspresent.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp) || !Type_type.TYPE_ARRAY.equals(type.getTypetype())) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
final Value arrayIndex = ((ArraySubReference) subreference).getValue();
IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (valueIndex.isUnfoldable(timestamp)) {
return false;
}
if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
final int index = ((Integer_Value) valueIndex).intValue();
if (isIndexed()) {
for (int i = 0; i < values.getNofIndexedValues(); i++) {
IValue indexedValue = values.getIndexedValueByIndex(i).getIndex().getValue();
referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
indexedValue = indexedValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (Value_type.INTEGER_VALUE.equals(indexedValue.getValuetype()) && ((Integer_Value) indexedValue).intValue() == index) {
return values.getIndexedValueByIndex(i).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
}
arrayIndex.getLocation().reportSemanticError(MessageFormat.format(NOINDEX, index, values.getFullName()));
} else if (index < 0 || index >= values.getNofValues()) {
// the error was already reported
} else {
return values.getValueByIndex(index).evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
}
return false;
case fieldSubReference:
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
Aggregations