use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class FormalParameter method checkActualParameterTimer.
/**
* Checks if the actual parameter paired with this formal parameter is
* semantically correct as a timer parameter.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param actualParameter
* the template instance assigned as actual parameter to
* this formal parameter
* @param expectedValue
* the value kind expected from the actual parameter.
*
* @return the actual parameter created from the value, or null if there
* was an error.
*/
private ActualParameter checkActualParameterTimer(final CompilationTimeStamp timestamp, final TemplateInstance actualParameter, final Expected_Value_type expectedValue) {
final IType parameterType = actualParameter.getType();
if (parameterType != null) {
actualParameter.getLocation().reportSemanticError(EXPLICITESPECIFICATIONFORTIMER);
actualParameter.checkType(timestamp, null);
}
final Reference derivedReference = actualParameter.getDerivedReference();
if (derivedReference != null) {
derivedReference.getLocation().reportSemanticError(INLINETEMPLATEFORTIMER);
actualParameter.checkDerivedReference(timestamp, null);
}
final ITTCN3Template template = actualParameter.getTemplateBody();
if (Template_type.SPECIFIC_VALUE.equals(template.getTemplatetype()) && ((SpecificValue_Template) template).isReference()) {
final Reference reference = ((SpecificValue_Template) template).getReference();
final Assignment assignment = reference.getRefdAssignment(timestamp, true, null);
if (assignment == null) {
final ActualParameter temp = new Value_ActualParameter(null);
temp.setIsErroneous();
return temp;
}
switch(assignment.getAssignmentType()) {
case A_TIMER:
final ArrayDimensions dimensions = ((Def_Timer) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, reference, "timer", false, expectedValue);
} else if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(SUBREFERENCEERROR1, assignment.getDescription()));
}
break;
case A_PAR_TIMER:
if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(SUBREFERENCEERROR2, assignment.getDescription()));
}
break;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(TIMEREXPECTED1, assignment.getAssignmentName()));
break;
}
return new Referenced_ActualParameter(reference);
}
actualParameter.getLocation().reportSemanticError(TIMEREXPECTED2);
final ActualParameter temp = new Value_ActualParameter(null);
temp.setIsErroneous();
return temp;
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class Assignment_Statement method checkTemplateAssignment.
private void checkTemplateAssignment(final CompilationTimeStamp timestamp, final Assignment assignment, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
IType type = getType(timestamp, assignment);
if (type == null) {
isErroneous = true;
return;
}
// temp
type.check(timestamp);
type = type.getFieldType(timestamp, reference, 1, expectedValue, false);
if (type == null) {
isErroneous = true;
return;
}
template.setMyGovernor(type);
final ITTCN3Template temporalTemplate = type.checkThisTemplateRef(timestamp, template, expectedValue, referenceChain);
selfReference = temporalTemplate.checkThisTemplateGeneric(timestamp, type, true, true, true, true, false, assignment);
checkTemplateRestriction(timestamp);
if (reference.refersToStringElement()) {
if (!template.isValue(timestamp)) {
template.getLocation().reportSemanticError(TEMPLATEASSIGNMENTTOVALUE);
template.setIsErroneous(true);
// isErroneous = true; //????
return;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.Expected_Value_type in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method checkThisValueSeq.
/**
* Checks the Sequence_Value kind value against this type.
* <p>
* Please note, that this function can only be called once we know for
* sure that the value is of sequence type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param value
* the value to be checked
* @param expectedValue
* the expected kind of the value.
* @param incompleteAllowed
* wheather incomplete value is allowed or not.
* @param implicitOmit
* true if the implicit omit optional attribute was set
* for the value, false otherwise
*/
private boolean checkThisValueSeq(final CompilationTimeStamp timestamp, final Sequence_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean implicitOmit, final boolean strElem) {
boolean selfReference = false;
final Map<String, NamedValue> componentMap = new HashMap<String, NamedValue>();
final CompilationTimeStamp valueTimeStamp = value.getLastTimeChecked();
if (valueTimeStamp == null || valueTimeStamp.isLess(timestamp)) {
value.removeGeneratedValues();
}
final boolean isAsn = value.isAsn();
boolean inSnyc = true;
final int nofTypeComponents = getNofComponents(timestamp);
final int nofValueComponents = value.getNofComponents();
int nextIndex = 0;
CompField lastCompField = null;
int sequenceIndex = 0;
for (int i = 0; i < nofValueComponents; i++, sequenceIndex++) {
final NamedValue namedValue = value.getSeqValueByIndex(i);
final Identifier valueId = namedValue.getName();
if (!hasComponentWithName(valueId)) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? NONEXISTENTFIELDERRORASN1 : NONEXISTENTFIELDERRORTTCN3, namedValue.getName().getDisplayName(), getTypename()));
inSnyc = false;
} else {
if (componentMap.containsKey(valueId.getName())) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? DUBLICATEDFIELDAGAINASN1 : DUBLICATEDFIELDAGAINTTCN3, valueId.getDisplayName()));
final Location tempLocation = componentMap.get(valueId.getName()).getLocation();
tempLocation.reportSingularSemanticError(MessageFormat.format(isAsn ? DUPLICATEDFIELDFIRSTASN1 : DUPLICATEDFIELDFIRSTTTCN3, valueId.getDisplayName()));
inSnyc = false;
} else {
componentMap.put(valueId.getName(), namedValue);
}
final CompField componentField = getComponentByName(valueId);
if (inSnyc) {
if (incompleteAllowed) {
boolean found = false;
for (int j = nextIndex; j < nofTypeComponents && !found; j++) {
final CompField field2 = getComponentByIndex(j);
if (valueId.getName().equals(field2.getIdentifier().getName())) {
lastCompField = field2;
nextIndex = j + 1;
found = true;
}
}
if (lastCompField != null && !found) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? WRONGFIELDORDERASN1 : WRONGFIELDORDERTTCN3, valueId.getDisplayName(), lastCompField.getIdentifier().getDisplayName()));
}
} else {
CompField field2 = getComponentByIndex(sequenceIndex);
final CompField field2Original = field2;
boolean isOptional = field2.isOptional();
if (!isOptional && field2.hasDefault() && defaultAsOptional) {
isOptional = true;
}
while (implicitOmit && sequenceIndex < getNofComponents(timestamp) && componentField != field2 && isOptional) {
++sequenceIndex;
field2 = getComponentByIndex(sequenceIndex);
}
if (sequenceIndex >= getNofComponents(timestamp) || componentField != field2) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? UNEXPECTEDFIELDASN1 : UNEXPECTEDFIELDTTCN3, valueId.getDisplayName(), field2Original.getIdentifier().getDisplayName()));
}
}
}
final Type type = componentField.getType();
final IValue componentValue = namedValue.getValue();
if (componentValue != null) {
componentValue.setMyGovernor(type);
final IValue temporalValue = type.checkThisValueRef(timestamp, componentValue);
boolean isOptional = componentField.isOptional();
if (!isOptional && componentField.hasDefault() && defaultAsOptional) {
isOptional = true;
}
selfReference |= type.checkThisValue(timestamp, temporalValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, isOptional, true, implicitOmit, strElem));
}
}
}
if (!incompleteAllowed || strictConstantCheckingSeverity) {
for (int i = 0; i < nofTypeComponents; i++) {
final Identifier id = getComponentByIndex(i).getIdentifier();
if (!componentMap.containsKey(id.getName())) {
if (getComponentByIndex(i).isOptional() && implicitOmit) {
value.addNamedValue(new NamedValue(new Identifier(Identifier_type.ID_TTCN, id.getDisplayName()), new Omit_Value(), false));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(isAsn ? MISSINGFIELDASN1 : MISSINGFIELDTTCN3, id.getDisplayName()));
}
}
}
}
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 ASN1_Set_Type method checkThisValueSet.
/**
* Checks the Set_Value kind value against this type.
* <p>
* Please note, that this function can only be called once we know for
* sure that the value is of set type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param value
* the value to be checked
* @param expectedValue
* the kind of value expected here.
* @param incompleteAllowed
* wheather incomplete value is allowed or not.
* @param implicitOmit
* true if the implicit omit optional attribute was set
* for the value, false otherwise
*/
private boolean checkThisValueSet(final CompilationTimeStamp timestamp, final Set_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean implicitOmit, final boolean strElem) {
boolean selfReference = false;
final Map<String, NamedValue> componentMap = new HashMap<String, NamedValue>();
value.removeGeneratedValues();
final boolean isAsn = value.isAsn();
final int nofValueComponents = value.getNofComponents();
for (int i = 0; i < nofValueComponents; i++) {
final NamedValue namedValue = value.getSequenceValueByIndex(i);
final Identifier valueId = namedValue.getName();
if (!hasComponentWithName(valueId)) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? NONEXISTENTFIELDASN1 : NONEXISTENTFIELDTTCN3, namedValue.getName().getDisplayName(), getTypename()));
} else {
if (componentMap.containsKey(valueId.getName())) {
namedValue.getLocation().reportSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDAGAINASN1 : DUPLICATEFIELDAGAINTTCN3, valueId.getDisplayName()));
componentMap.get(valueId.getName()).getLocation().reportSingularSemanticError(MessageFormat.format(isAsn ? DUPLICATEFIELDFIRSTASN1 : DUPLICATEFIELDFIRSTTTCN3, valueId.getDisplayName()));
} else {
componentMap.put(valueId.getName(), namedValue);
}
final CompField componentField = getComponentByName(valueId);
final Type type = componentField.getType();
final IValue componentValue = namedValue.getValue();
if (componentValue != null) {
componentValue.setMyGovernor(type);
final IValue temporalValue = type.checkThisValueRef(timestamp, componentValue);
boolean isOptional = componentField.isOptional();
if (!isOptional && componentField.hasDefault() && defaultAsOptional) {
isOptional = true;
}
selfReference |= type.checkThisValue(timestamp, temporalValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, isOptional, true, implicitOmit, strElem));
}
}
}
if (!incompleteAllowed || strictConstantCheckingSeverity) {
final int nofTypeComponents = getNofComponents(timestamp);
CompField field;
for (int i = 0; i < nofTypeComponents; i++) {
field = getComponentByIndex(i);
final Identifier id = field.getIdentifier();
if (!componentMap.containsKey(id.getName())) {
if (field.isOptional() && implicitOmit) {
value.addNamedValue(new NamedValue(new Identifier(Identifier_type.ID_TTCN, id.getDisplayName()), new Omit_Value(), false));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(isAsn ? MISSINGFIELDASN1 : MISSINGFIELDTTCN3, id.getDisplayName()));
}
}
}
}
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 ASN1_Choice_Type method checkThisValueChoice.
private boolean checkThisValueChoice(final CompilationTimeStamp timestamp, final Choice_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed) {
boolean selfReference = false;
final Identifier name = value.getName();
if (!hasComponentWithName(name)) {
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTCHOICE, name.getDisplayName(), getFullName()));
value.setIsErroneous(true);
} else {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
value.setIsErroneous(true);
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
IValue alternativeValue = value.getValue();
if (alternativeValue == null) {
return selfReference;
}
final Type alternativeType = getComponentByName(name).getType();
alternativeValue.setMyGovernor(alternativeType);
alternativeValue = alternativeType.checkThisValueRef(timestamp, alternativeValue);
selfReference = alternativeType.checkThisValue(timestamp, alternativeValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, false, false));
value.setLastTimeChecked(timestamp);
return selfReference;
}
Aggregations