use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.
the class Sequence_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;
}
if (convertedValue != null && convertedValue != this) {
return convertedValue.evaluateIsbound(timestamp, reference, actualSubReference);
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
if (!((TTCN3_Sequence_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SEQUENCE:
if (!((ASN1_Sequence_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (values.hasNamedValueWithName(fieldId)) {
// we can move on with the check
return values.getNamedValueByName(fieldId).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
if (Type_type.TYPE_TTCN3_SEQUENCE.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Sequence_Type) type).getComponentByName(fieldId);
if (compField.isOptional()) {
// create an explicit omit value
final Value result = new Omit_Value();
final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
result.setFullNameParent(bridge);
result.setMyScope(getMyScope());
return result.evaluateIspresent(timestamp, reference, actualSubReference + 1);
} else if (compField.hasDefault()) {
return compField.getDefault().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.
the class Sequence_Value method evaluateIsbound.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIsbound(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
if (convertedValue != null && convertedValue != this) {
return convertedValue.evaluateIsbound(timestamp, reference, actualSubReference);
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
if (!((TTCN3_Sequence_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SEQUENCE:
if (!((ASN1_Sequence_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (values.hasNamedValueWithName(fieldId)) {
// we can move on with the check
return values.getNamedValueByName(fieldId).getValue().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
if (Type_type.TYPE_TTCN3_SEQUENCE.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Sequence_Type) type).getComponentByName(fieldId);
if (compField.isOptional()) {
// create an explicit omit value
final Value result = new Omit_Value();
final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
result.setFullNameParent(bridge);
result.setMyScope(getMyScope());
return result.evaluateIsbound(timestamp, reference, actualSubReference + 1);
} else if (compField.hasDefault()) {
return compField.getDefault().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.
the class Assignment_Statement method checkVarAssignment.
private void checkVarAssignment(final CompilationTimeStamp timestamp, final Assignment assignment, final IValue value) {
final IType varType = getType(timestamp, assignment);
if (varType == null || value == null) {
isErroneous = true;
return;
}
final IType type = varType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (type == null) {
isErroneous = true;
return;
}
value.setMyGovernor(type);
IValue lastValue = type.checkThisValueRef(timestamp, value);
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
lastValue = lastValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (Value_type.OMIT_VALUE.equals(lastValue.getValuetype())) {
final ISubReference lastReference = reference.removeLastSubReference();
if (lastReference == null || lastReference.getId() == null) {
value.getLocation().reportSemanticError(OMITTOMANDATORYASSIGNMENT1);
isErroneous = true;
reference.addSubReference(lastReference);
return;
}
final Identifier lastField = lastReference.getId();
final List<ISubReference> baseReference = reference.getSubreferences(0, reference.getSubreferences().size() - 1);
reference.addSubReference(lastReference);
final Reference newReference = new TemporalReference(null, baseReference);
newReference.clearStringElementReferencing();
IType baseType = varType.getFieldType(timestamp, newReference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (baseType == null) {
isErroneous = true;
return;
}
baseType = baseType.getTypeRefdLast(timestamp);
if (baseType.getIsErroneous(timestamp)) {
isErroneous = true;
return;
}
CompField componentField;
switch(baseType.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
componentField = ((TTCN3_Sequence_Type) baseType).getComponentByName(lastField.getName());
if (componentField != null && !componentField.isOptional()) {
value.getLocation().reportSemanticError(MessageFormat.format(OMITTOMANDATORYASSIGNMENT2, lastField.getDisplayName(), baseType.getTypename()));
value.setIsErroneous(true);
}
break;
case TYPE_ASN1_SEQUENCE:
componentField = ((ASN1_Sequence_Type) baseType).getComponentByName(lastField);
if (componentField != null && !componentField.isOptional()) {
value.getLocation().reportSemanticError(MessageFormat.format(OMITTOMANDATORYASSIGNMENT2, lastField.getDisplayName(), baseType.getTypename()));
value.setIsErroneous(true);
}
break;
case TYPE_TTCN3_SET:
componentField = ((TTCN3_Set_Type) baseType).getComponentByName(lastField.getName());
if (componentField != null && !componentField.isOptional()) {
value.getLocation().reportSemanticError(MessageFormat.format(OMITTOMANDATORYASSIGNMENT2, lastField.getDisplayName(), baseType.getTypename()));
value.setIsErroneous(true);
}
break;
case TYPE_ASN1_SET:
componentField = ((ASN1_Set_Type) baseType).getComponentByName(lastField);
if (componentField != null && !componentField.isOptional()) {
value.getLocation().reportSemanticError(MessageFormat.format(OMITTOMANDATORYASSIGNMENT2, lastField.getDisplayName(), baseType.getTypename()));
value.setIsErroneous(true);
}
break;
default:
// TODO:check this!!!
value.getLocation().reportSemanticError(OMITTOMANDATORYASSIGNMENT1);
value.setIsErroneous(true);
isErroneous = true;
break;
}
} else {
final boolean isStringElement = reference.refersToStringElement();
selfReference = type.checkThisValue(timestamp, value, assignment, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, true, false, !isStringElement, false, isStringElement));
if (isStringElement) {
// The length of the right hand side should be 1
final IType lastType = type.getTypeRefdLast(timestamp);
int stringLength = 1;
switch(lastType.getTypetype()) {
case TYPE_BITSTRING:
case TYPE_BITSTRING_A:
if (!Value_type.BITSTRING_VALUE.equals(lastValue.getValuetype())) {
return;
}
stringLength = ((Bitstring_Value) lastValue).getValueLength();
break;
case TYPE_HEXSTRING:
if (!Value_type.HEXSTRING_VALUE.equals(lastValue.getValuetype())) {
lastValue = null;
} else {
stringLength = ((Hexstring_Value) lastValue).getValueLength();
}
break;
case TYPE_OCTETSTRING:
if (!Value_type.OCTETSTRING_VALUE.equals(lastValue.getValuetype())) {
return;
}
stringLength = ((Octetstring_Value) lastValue).getValueLength();
break;
case TYPE_CHARSTRING:
case TYPE_NUMERICSTRING:
case TYPE_PRINTABLESTRING:
case TYPE_IA5STRING:
case TYPE_VISIBLESTRING:
case TYPE_UTCTIME:
case TYPE_GENERALIZEDTIME:
if (!Value_type.CHARSTRING_VALUE.equals(lastValue.getValuetype())) {
return;
}
stringLength = ((Charstring_Value) lastValue).getValueLength();
break;
case TYPE_UCHARSTRING:
case TYPE_UTF8STRING:
case TYPE_TELETEXSTRING:
case TYPE_VIDEOTEXSTRING:
case TYPE_GRAPHICSTRING:
case TYPE_GENERALSTRING:
case TYPE_UNIVERSALSTRING:
case TYPE_BMPSTRING:
case TYPE_OBJECTDESCRIPTOR:
if (Value_type.UNIVERSALCHARSTRING_VALUE.equals(lastValue.getValuetype())) {
stringLength = ((UniversalCharstring_Value) lastValue).getValueLength();
} else if (Value_type.CHARSTRING_VALUE.equals(lastValue.getValuetype())) {
stringLength = ((Charstring_Value) lastValue).getValueLength();
} else {
return;
}
break;
default:
lastValue = null;
return;
}
if (stringLength != 1) {
final String message = MessageFormat.format("The length of the string to be assigned to a string element of type `{0}'' should be 1 instead of {1}", type.getTypename(), stringLength);
value.getLocation().reportSemanticError(message);
value.setIsErroneous(true);
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.
the class TableConstraint method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
parseBlocks();
if (null == myType) {
return;
}
objectSet.setMyScope(myType.getMyScope());
BridgingNamedNode bridge = new BridgingNamedNode(this, FULLNAMEPART);
objectSet.setFullNameParent(bridge);
// search the constrained type (not the reference to it)
constrainedType = myType;
while (true) {
if (constrainedType.getIsErroneous(timestamp)) {
return;
}
if (Type_type.TYPE_OPENTYPE.equals(constrainedType.getTypetype()) || Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(constrainedType.getTypetype())) {
break;
} else if (constrainedType instanceof IReferencingType) {
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
constrainedType = ((IReferencingType) constrainedType).getTypeRefd(timestamp, chain);
chain.release();
} else {
myType.getLocation().reportSemanticError(OCFTEXPECTED);
return;
}
}
if (Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(constrainedType.getTypetype())) {
ObjectClassField_Type ocfType = (ObjectClassField_Type) constrainedType;
objectClassFieldname = ocfType.getObjectClassFieldName();
objectSet.setMyGovernor(ocfType.getMyObjectClass());
objectSet.check(timestamp);
return;
}
// opentype
final Open_Type openType = (Open_Type) constrainedType;
openType.setMyTableConstraint(this);
objectClassFieldname = openType.getObjectClassFieldName();
objectSet.setMyGovernor(openType.getMyObjectClass());
objectSet.check(timestamp);
if (null == atNotationList) {
return;
}
// componentrelationconstraint...
// search the outermost textually enclosing seq, set or choice
IType outermostParent = null;
IType tempType = myType;
do {
switch(tempType.getTypetype()) {
case TYPE_ASN1_CHOICE:
case TYPE_TTCN3_CHOICE:
case TYPE_OPENTYPE:
case TYPE_ASN1_SEQUENCE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_ASN1_SET:
case TYPE_TTCN3_SET:
outermostParent = tempType;
break;
default:
break;
}
tempType = tempType.getParentType();
} while (null != tempType);
if (null == outermostParent) {
myType.getLocation().reportSemanticError(CANNOTDETERMINEPARENT);
return;
}
// outermostparent->set_opentype_outermost();
// TODO implement the setting of set_has_openType
AtNotation atNotation;
for (int i = 0; i < atNotationList.getNofAtNotations(); i++) {
atNotation = atNotationList.getAtNotationByIndex(i);
IType parent = null;
if (0 == atNotation.getLevels()) {
parent = outermostParent;
} else {
parent = myType;
for (int level = atNotation.getLevels(); level > 0; level--) {
parent = parent.getParentType();
if (null == parent) {
myType.getLocation().reportSemanticError(MessageFormat.format(TOOMANYDOTS, atNotation.getLevels()));
return;
}
}
}
tempType = parent;
atNotation.setFirstComponent(parent);
// component identifiers... do they exist? yes, if the refd type is constrained
FieldName componentIdentifiers = atNotation.getComponentIdentifiers();
for (int j = 0; j < componentIdentifiers.getNofFields(); j++) {
Identifier identifier = componentIdentifiers.getFieldByIndex(i);
switch(tempType.getTypetype()) {
case TYPE_ASN1_CHOICE:
{
final ASN1_Choice_Type temp2 = (ASN1_Choice_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_CHOICE:
{
final TTCN3_Choice_Type temp2 = (TTCN3_Choice_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_OPENTYPE:
{
final Open_Type temp2 = (Open_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_ASN1_SEQUENCE:
{
final ASN1_Sequence_Type temp2 = (ASN1_Sequence_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_SEQUENCE:
{
final TTCN3_Sequence_Type temp2 = (TTCN3_Sequence_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_ASN1_SET:
{
final ASN1_Set_Type temp2 = (ASN1_Set_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_SET:
{
final TTCN3_Set_Type temp2 = (TTCN3_Set_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
default:
myType.getLocation().reportSemanticError(MessageFormat.format(SECHOEXPECTED, tempType.getFullName()));
return;
}
}
atNotation.setLastComponent(tempType);
/*
* check if the referenced component is constrained by the same objectset...
*/
boolean ok = false;
final Constraints constraints = tempType.getConstraints();
if (constraints != null) {
constraints.check(timestamp);
final TableConstraint tableConstraint = constraints.getTableConstraint();
if (tableConstraint != null) {
IType ocft = tableConstraint.constrainedType;
if (Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(ocft.getTypetype())) {
atNotation.setObjectClassFieldname(((ObjectClassField_Type) ocft).getObjectClassFieldName());
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
ObjectSet_definition osdef1 = tableConstraint.objectSet.getRefdLast(timestamp, chain);
chain.release();
chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final ObjectSet_definition osdef2 = objectSet.getRefdLast(timestamp, chain);
chain.release();
if (osdef1 == osdef2) {
ok = true;
} else {
ok = false;
}
}
}
}
if (!ok) {
myType.getLocation().reportSemanticError(SAMECONSTRAINTEXPECTED);
return;
}
}
if (objectSet instanceof Referenced_ObjectSet) {
final Identifier objectSetId = ((Referenced_ObjectSet) objectSet).getId();
collectTypesOfOpenType(timestamp, objectSet, openType, objectSetId);
} else {
// TODO: is it posssible? Perhaps log error!
return;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Sequence_Type in project titan.EclipsePlug-ins by eclipse.
the class InsertFieldWizardInputPage method checkName.
public void checkName() {
final Identifier id = new Identifier(Identifier_type.ID_TTCN, nameField.getText().trim());
settings.setId(id);
if (!Identifier.isValidInTtcn(settings.getId().getName())) {
nameErrorMessage = INVALIDNAME;
nameDone = false;
} else {
final IType type = selection.getType(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof TTCN3_Sequence_Type || type instanceof TTCN3_Set_Type) {
final TTCN3_Set_Seq_Choice_BaseType ss = (TTCN3_Set_Seq_Choice_BaseType) type;
if (ss.hasComponentWithName(settings.getId().getName())) {
nameErrorMessage = NAMEEXISTS;
nameDone = false;
} else {
nameErrorMessage = "";
nameDone = true;
}
}
}
setErrorMessage(positionErrorMessage + typeErrorMessage + nameErrorMessage + valueErrorMessage);
setPageComplete(posDone && typeDone && nameDone && valueDone);
}
Aggregations