use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_Type method getFieldType.
// This is the same as in ASN1_Sequence_Type
@Override
public /**
* {@inheritDoc}
*/
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return this;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
return null;
case fieldSubReference:
final Identifier id = subreference.getId();
final CompField compField = components.getCompByName(id);
if (compField == null) {
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.NONEXISTENTSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
}
if (interruptIfOptional && compField.isOptional()) {
return null;
}
final Expected_Value_type internalExpectation = (expectedIndex == Expected_Value_type.EXPECTED_TEMPLATE) ? Expected_Value_type.EXPECTED_DYNAMIC_VALUE : expectedIndex;
return compField.getType().getFieldType(timestamp, reference, actualSubReference + 1, internalExpectation, refChain, interruptIfOptional);
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class BMPString_Type method getFieldType.
@Override
public /**
* {@inheritDoc}
*/
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return this;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
if (subreferences.size() > actualSubReference + 1) {
subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
return null;
} else if (subreferences.size() == actualSubReference + 1) {
reference.setStringElementReferencing();
}
final Value indexValue = ((ArraySubReference) subreference).getValue();
checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
return this;
case fieldSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Open_Type method checkThisValueChoice.
private boolean checkThisValueChoice(final CompilationTimeStamp timestamp, final Choice_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean strElem) {
boolean selfReference = false;
final Identifier name = value.getName();
final CompField field = getComponentByName(name);
if (field == null) {
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTCHOICE, name.getDisplayName(), getFullName()));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
}
} else {
IValue alternativeValue = value.getValue();
if (null == alternativeValue) {
return selfReference;
}
final Type alternativeType = field.getType();
alternativeValue.setMyGovernor(alternativeType);
alternativeValue = alternativeType.checkThisValueRef(timestamp, alternativeValue);
selfReference = alternativeType.checkThisValue(timestamp, alternativeValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, false, strElem));
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class UTF8String_Type method getFieldType.
@Override
public /**
* {@inheritDoc}
*/
IType getFieldType(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final Expected_Value_type expectedIndex, final IReferenceChain refChain, final boolean interruptIfOptional) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return this;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
if (subreferences.size() > actualSubReference + 1) {
subreference.getLocation().reportSemanticError(ArraySubReference.INVALIDSTRINGELEMENTINDEX);
return null;
} else if (subreferences.size() == actualSubReference + 1) {
reference.setStringElementReferencing();
}
final Value indexValue = ((ArraySubReference) subreference).getValue();
checkStringIndex(timestamp, indexValue, expectedIndex, refChain);
return this;
case fieldSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class ActivateDereferedExpression 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) {
value.setLoweridToReference(timestamp);
IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null || type.getIsErroneous(timestamp)) {
setIsErroneous(true);
return;
}
if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
value.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPEXPECTED, type.getTypename()));
setIsErroneous(true);
return;
}
actualParameters = new ActualParameterList();
final FormalParameterList formalParameterList = ((Altstep_Type) type).getFormalParameters();
if (formalParameterList.checkActualParameterList(timestamp, actualParameterList, actualParameters)) {
setIsErroneous(true);
return;
}
actualParameters.setFullNameParent(this);
actualParameters.setMyScope(getMyScope());
if (!formalParameterList.checkActivateArgument(timestamp, actualParameters, createStringRepresentation())) {
setIsErroneous(true);
}
checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
Aggregations