use of org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value in project titan.EclipsePlug-ins by eclipse.
the class ValueListAndSizeConstraint method isElement.
@Override
public /**
* {@inheritDoc}
*/
boolean isElement(final Object o) {
final IValue v = (IValue) o;
SizeLimit sl;
switch(v.getValuetype()) {
case ARRAY_VALUE:
sl = new SizeLimit(((Array_Value) v).getNofComponents());
break;
case SEQUENCEOF_VALUE:
sl = new SizeLimit(((SequenceOf_Value) v).getNofComponents());
break;
case SETOF_VALUE:
sl = new SizeLimit(((SetOf_Value) v).getNofComponents());
break;
default:
ErrorReporter.INTERNAL_ERROR();
return true;
}
if (sizeConstraint.isElement(sl)) {
return !notValues.isElement(v);
}
return hasValues.isElement(v);
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value in project titan.EclipsePlug-ins by eclipse.
the class Undefined_Block_Value method parseBlockSetofValue.
private SetOf_Value parseBlockSetofValue() {
if (null == mBlock) {
return null;
}
final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock);
if (null == parser) {
return null;
}
final SetOf_Value value = parser.pr_special_SetOfValue().value;
final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
if (null != errors && !errors.isEmpty()) {
isErroneous = true;
for (int i = 0; i < errors.size(); i++) {
ParserMarkerSupport.createOnTheFlyMixedMarker((IFile) mBlock.getLocation().getFile(), errors.get(i), IMarker.SEVERITY_ERROR);
}
return null;
}
return value;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value in project titan.EclipsePlug-ins by eclipse.
the class All_From_Template method getNofValues.
/**
* Gets the number of values If the value is type of SEQUENCEOF_VALUE or
* type of SETOF_VALUE then returns their size otherwise returns 1
*/
private int getNofValues(final IValue value, final CompilationTimeStamp timestamp) {
int result = 0;
if (value == null) {
return result;
}
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue lastValue = value.getValueRefdLast(timestamp, chain);
chain.release();
if (lastValue.getIsErroneous(timestamp)) {
return result;
}
if (Value_type.SEQUENCEOF_VALUE.equals(lastValue.getValuetype())) {
final SequenceOf_Value lvalue = (SequenceOf_Value) lastValue;
result = lvalue.getNofComponents();
return result;
} else if (Value_type.SETOF_VALUE.equals(lastValue.getValuetype())) {
final SetOf_Value svalue = (SetOf_Value) lastValue;
result = svalue.getNofComponents();
return result;
} else {
// this value is calculated as 1 in an all from
return 1;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value in project titan.EclipsePlug-ins by eclipse.
the class RotateLeftExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
Type_type tempType1 = null;
Type_type tempType2 = null;
long valueSize = 0;
long rotationSize = 0;
IValue tempValue;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_BITSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Bitstring_Value) tempValue).getValueLength();
}
break;
case TYPE_HEXSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Hexstring_Value) tempValue).getValueLength();
}
break;
case TYPE_OCTETSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Octetstring_Value) tempValue).getValueLength();
}
break;
case TYPE_CHARSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.CHARSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Charstring_Value) tempValue).getValueLength();
}
break;
case TYPE_UCHARSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((UniversalCharstring_Value) tempValue).getValueLength();
}
break;
case TYPE_SET_OF:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
tempValue = tempValue.setValuetype(timestamp, Value_type.SETOF_VALUE);
}
if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SetOf_Value) tempValue).getNofComponents();
}
break;
case TYPE_SEQUENCE_OF:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SequenceOf_Value) tempValue).getNofComponents();
} else if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SetOf_Value) tempValue).getNofComponents();
}
break;
case TYPE_ARRAY:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
tempValue = tempValue.setValuetype(timestamp, Value_type.ARRAY_VALUE);
}
if (Value_type.ARRAY_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Array_Value) tempValue).getNofComponents();
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(FIRSTOPERANDERROR);
setIsErroneous(true);
break;
}
}
if (value2 != null) {
value2.setLoweridToReference(timestamp);
tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_INTEGER:
tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
if (!((Integer_Value) tempValue).isNative()) {
value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
setIsErroneous(true);
break;
}
rotationSize = ((Integer_Value) tempValue).getValue();
if (value1 != null && !value1.isUnfoldable(timestamp)) {
final String severtiy = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
if (valueSize == 0 || valueSize == 1) {
location.reportConfigurableSemanticProblem(severtiy, EFFECTLESSROTATION);
} else if (rotationSize < 0) {
location.reportConfigurableSemanticProblem(severtiy, NEGATIVEROTATEPROBLEM);
} else if (rotationSize == 0) {
location.reportConfigurableSemanticProblem(severtiy, ZEROROTATEPROBLEM);
} else if (rotationSize > valueSize) {
location.reportConfigurableSemanticProblem(severtiy, MessageFormat.format(TOOBIGROTATEPROBLEM, valueSize, rotationSize, rotationSize % valueSize));
}
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SetOf_Value in project titan.EclipsePlug-ins by eclipse.
the class RotateRightExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
Type_type tempType1 = null;
Type_type tempType2 = null;
long valueSize = 0;
long rotationSize = 0;
IValue tempValue;
if (value1 != null) {
value1.setLoweridToReference(timestamp);
tempType1 = value1.getExpressionReturntype(timestamp, expectedValue);
switch(tempType1) {
case TYPE_BITSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.BITSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Bitstring_Value) tempValue).getValueLength();
}
break;
case TYPE_HEXSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.HEXSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Hexstring_Value) tempValue).getValueLength();
}
break;
case TYPE_OCTETSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.OCTETSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Octetstring_Value) tempValue).getValueLength();
}
break;
case TYPE_CHARSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.CHARSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Charstring_Value) tempValue).getValueLength();
}
break;
case TYPE_UCHARSTRING:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((UniversalCharstring_Value) tempValue).getValueLength();
}
break;
case TYPE_SET_OF:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
tempValue = tempValue.setValuetype(timestamp, Value_type.SETOF_VALUE);
}
if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SetOf_Value) tempValue).getNofComponents();
}
break;
case TYPE_SEQUENCE_OF:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SequenceOf_Value) tempValue).getNofComponents();
} else if (Value_type.SETOF_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((SetOf_Value) tempValue).getNofComponents();
}
break;
case TYPE_ARRAY:
tempValue = value1.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.SEQUENCEOF_VALUE.equals(tempValue.getValuetype())) {
tempValue = tempValue.setValuetype(timestamp, Value_type.ARRAY_VALUE);
}
if (Value_type.ARRAY_VALUE.equals(tempValue.getValuetype())) {
valueSize = ((Array_Value) tempValue).getNofComponents();
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(FIRSTOPERANDERROR);
setIsErroneous(true);
break;
}
}
if (value2 != null) {
value2.setLoweridToReference(timestamp);
tempType2 = value2.getExpressionReturntype(timestamp, expectedValue);
switch(tempType2) {
case TYPE_INTEGER:
tempValue = value2.getValueRefdLast(timestamp, expectedValue, referenceChain);
if (Value_type.INTEGER_VALUE.equals(tempValue.getValuetype()) && !getIsErroneous(timestamp)) {
if (!((Integer_Value) tempValue).isNative()) {
value2.getLocation().reportSemanticError(MessageFormat.format(LARGEINTEGERSECONDOPERANDERROR, ((Integer_Value) tempValue).getValueValue()));
setIsErroneous(true);
break;
}
rotationSize = ((Integer_Value) tempValue).getValue();
if (value1 != null && !value1.isUnfoldable(timestamp)) {
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINCORRECTSHIFTROTATESIZE, GeneralConstants.WARNING, null);
if (valueSize == 0 || valueSize == 1) {
location.reportConfigurableSemanticProblem(severity, EFFECTLESSROTATION);
} else if (rotationSize < 0) {
location.reportConfigurableSemanticProblem(severity, NEGATIVEROTATEPROBLEM);
} else if (rotationSize == 0) {
location.reportConfigurableSemanticProblem(severity, ZEROROTATEPROBLEM);
} else if (rotationSize > valueSize) {
location.reportConfigurableSemanticProblem(severity, MessageFormat.format(TOOBIGROTATEPROBLEM, valueSize, rotationSize, rotationSize % valueSize));
}
}
}
break;
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
location.reportSemanticError(SECONDOPERANDERROR);
setIsErroneous(true);
break;
}
}
}
Aggregations