use of org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value in project titan.EclipsePlug-ins by eclipse.
the class Signature_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case SEQUENCE_VALUE:
selfReference = checkThisValueSequence(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case SEQUENCEOF_VALUE:
last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
selfReference = checkThisValueSequence(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
value.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXPECTED, getTypename()));
value.setIsErroneous(true);
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Sequence_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case SEQUENCE_VALUE:
if (last.isAsn()) {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
break;
case SEQUENCEOF_VALUE:
if (((SequenceOf_Value) last).isIndexed()) {
value.getLocation().reportSemanticError(MessageFormat.format("Indexed assignment notation cannot be used for record type `{0}''", getFullName()));
value.setIsErroneous(true);
} else {
last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
if (last.isAsn()) {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
} else {
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
}
}
break;
case UNDEFINED_BLOCK:
last = last.setValuetype(timestamp, Value_type.SEQUENCE_VALUE);
selfReference = checkThisValueSeq(timestamp, (Sequence_Value) last, lhs, valueCheckingOptions.expected_value, false, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
value.getLocation().reportSemanticError(MessageFormat.format(SEQUANCEEPECTED, getFullName()));
value.setIsErroneous(true);
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, last);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value in project titan.EclipsePlug-ins by eclipse.
the class SetOf_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
if (getIsErroneous(timestamp)) {
return false;
}
boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
if (Value_type.UNDEFINED_BLOCK.equals(last.getValuetype())) {
last = last.setValuetype(timestamp, Value_type.SETOF_VALUE);
}
if (last.getIsErroneous(timestamp)) {
return selfReference;
}
switch(last.getValuetype()) {
case SEQUENCEOF_VALUE:
last = last.setValuetype(timestamp, Value_type.SETOF_VALUE);
selfReference = checkThisValueSetOf(timestamp, (SetOf_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case SETOF_VALUE:
selfReference = checkThisValueSetOf(timestamp, (SetOf_Value) last, lhs, valueCheckingOptions.expected_value, valueCheckingOptions.incomplete_allowed, valueCheckingOptions.implicit_omit, valueCheckingOptions.str_elem);
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
if (value.isAsn()) {
value.getLocation().reportSemanticError(SETOFVALUEEXPECTED1);
} else {
value.getLocation().reportSemanticError(SETOFVALUEEXPECTED2);
}
value.setIsErroneous(true);
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, last);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value in project titan.EclipsePlug-ins by eclipse.
the class Template_List method getValue.
@Override
public /**
* {@inheritDoc}
*/
IValue getValue() {
if (asValue != null) {
return asValue;
}
if (converted != null) {
return converted.getValue();
}
final Values values = new Values(false);
for (int i = 0, size = getNofTemplates(); i < size; i++) {
values.addValue(templates.getTemplateByIndex(i).getValue());
}
asValue = new SequenceOf_Value(values);
asValue.setLocation(getLocation());
asValue.setMyScope(getMyScope());
asValue.setFullNameParent(getNameParent());
asValue.setMyGovernor(getMyGovernor());
return asValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.SequenceOf_Value in project titan.EclipsePlug-ins by eclipse.
the class SubType method checkThisValue.
/**
* Checks if a given value is valid according to this sub-type.
*
* @param timestamp
* the time stamp of the actual semantic check cycle.
* @param value
* the value to be checked
*/
public void checkThisValue(final CompilationTimeStamp timestamp, final IValue value) {
if (getIsErroneous(timestamp) || (subtypeConstraint == null)) {
return;
}
if (value.getIsErroneous(timestamp)) {
return;
}
final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (last.getIsErroneous(timestamp)) {
return;
}
boolean isValid = true;
switch(last.getValuetype()) {
case INTEGER_VALUE:
if (subtypeType != SubType_type.ST_INTEGER) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(new IntegerLimit(((Integer_Value) last).getValueValue()));
break;
case REAL_VALUE:
if (subtypeType == SubType_type.ST_FLOAT) {
isValid = subtypeConstraint.isElement(((Real_Value) last).getValue());
break;
} else if (subtypeType == SubType_type.ST_INTEGER) {
final Real_Value real = (Real_Value) last;
if (real.isNegativeInfinity()) {
isValid = subtypeConstraint.isElement(IntegerLimit.MINIMUM);
break;
} else if (real.isPositiveInfinity()) {
isValid = subtypeConstraint.isElement(IntegerLimit.MAXIMUM);
break;
}
}
ErrorReporter.INTERNAL_ERROR();
return;
case BOOLEAN_VALUE:
if (subtypeType != SubType_type.ST_BOOLEAN) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Boolean_Value) last).getValue());
break;
case VERDICT_VALUE:
if (subtypeType != SubType_type.ST_VERDICTTYPE) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Verdict_Value) last).getValue());
break;
case BITSTRING_VALUE:
if (subtypeType != SubType_type.ST_BITSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Bitstring_Value) last).getValue());
break;
case HEXSTRING_VALUE:
if (subtypeType != SubType_type.ST_HEXSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Hexstring_Value) last).getValue());
break;
case OCTETSTRING_VALUE:
if (subtypeType != SubType_type.ST_OCTETSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Octetstring_Value) last).getValue());
break;
case CHARSTRING_VALUE:
switch(subtypeType) {
case ST_CHARSTRING:
isValid = subtypeConstraint.isElement(((Charstring_Value) last).getValue());
break;
case ST_UNIVERSAL_CHARSTRING:
isValid = subtypeConstraint.isElement(new UniversalCharstring(((Charstring_Value) last).getValue()));
break;
default:
ErrorReporter.INTERNAL_ERROR();
return;
}
break;
case UNIVERSALCHARSTRING_VALUE:
if (subtypeType != SubType_type.ST_UNIVERSAL_CHARSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((UniversalCharstring_Value) last).getValue());
break;
case SEQUENCEOF_VALUE:
case SETOF_VALUE:
case OBJECTID_VALUE:
case ENUMERATED_VALUE:
case CHOICE_VALUE:
case SEQUENCE_VALUE:
case SET_VALUE:
case FUNCTION_REFERENCE_VALUE:
case ALTSTEP_REFERENCE_VALUE:
case TESTCASE_REFERENCE_VALUE:
if (value.isUnfoldable(timestamp)) {
return;
}
isValid = subtypeConstraint.isElement(last);
break;
default:
return;
}
if (!isValid) {
value.getLocation().reportSemanticError(MessageFormat.format("{0} is not a valid value for type `{1}'' which has subtype {2}", last.createStringRepresentation(), myOwner.getTypename(), subtypeConstraint.toString()));
}
}
Aggregations