Commit 816b1942 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

fixed possible null exception


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 9fabbe68
...@@ -287,52 +287,54 @@ public final class SubstrExpression extends Expression_Value { ...@@ -287,52 +287,54 @@ public final class SubstrExpression extends Expression_Value {
value1 = ((SpecificValue_Template) temp).getSpecificValue(); value1 = ((SpecificValue_Template) temp).getSpecificValue();
value1.setLoweridToReference(timestamp); value1.setLoweridToReference(timestamp);
final IType templateGovernor = templateInstance1.getExpressionGovernor(timestamp, expectedValue); final IType templateGovernor = templateInstance1.getExpressionGovernor(timestamp, expectedValue);
final IType lastTemplateGovernor = templateGovernor.getTypeRefdLast(timestamp); if(templateGovernor != null) {
final IType lastTemplateGovernor = templateGovernor.getTypeRefdLast(timestamp);
switch (lastTemplateGovernor.getTypetype()) {
case TYPE_BITSTRING: switch (lastTemplateGovernor.getTypetype()) {
case TYPE_HEXSTRING: case TYPE_BITSTRING:
case TYPE_OCTETSTRING: case TYPE_HEXSTRING:
case TYPE_CHARSTRING: case TYPE_OCTETSTRING:
case TYPE_UCHARSTRING: case TYPE_CHARSTRING:
value1.getValueRefdLast(timestamp, internalExpectation, referenceChain); case TYPE_UCHARSTRING:
break; value1.getValueRefdLast(timestamp, internalExpectation, referenceChain);
case TYPE_SET_OF: break;
case TYPE_SEQUENCE_OF: { case TYPE_SET_OF:
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, lastTemplateGovernor, referenceChain, expectedValue); case TYPE_SEQUENCE_OF: {
if (getIsErroneous(timestamp)) { IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, lastTemplateGovernor, referenceChain, expectedValue);
return; if (getIsErroneous(timestamp)) {
} return;
}
templateInstance1.getTemplateBody().checkSpecificValue(timestamp, false);
templateInstance1.getTemplateBody().checkSpecificValue(timestamp, false);
final TypeCompatibilityInfo info = new TypeCompatibilityInfo(myGovernor, lastTemplateGovernor, true);
if (myGovernor != null && !myGovernor.isCompatible(timestamp, lastTemplateGovernor , info, null, null)) { final TypeCompatibilityInfo info = new TypeCompatibilityInfo(myGovernor, lastTemplateGovernor, true);
if (info.getSubtypeError() == null) { if (myGovernor != null && !myGovernor.isCompatible(timestamp, lastTemplateGovernor , info, null, null)) {
final String errorString = info.getErrorStringString(); if (info.getSubtypeError() == null) {
if (errorString == null) { final String errorString = info.getErrorStringString();
getLocation().reportSemanticError(MessageFormat.format("First operand of operation `substr'' is of type `{0}'', but a value of type `{1}'' was expected here", lastTemplateGovernor.getTypename(), myGovernor.getTypename())); if (errorString == null) {
getLocation().reportSemanticError(MessageFormat.format("First operand of operation `substr'' is of type `{0}'', but a value of type `{1}'' was expected here", lastTemplateGovernor.getTypename(), myGovernor.getTypename()));
} else {
getLocation().reportSemanticError(errorString);
}
} else { } else {
getLocation().reportSemanticError(errorString); // this is ok.
} if (info.getNeedsConversion()) {
} else { set_needs_conversion();
// this is ok. }
if (info.getNeedsConversion()) {
set_needs_conversion();
} }
} else if (info.getNeedsConversion()) {
set_needs_conversion();
} }
} else if (info.getNeedsConversion()) { break;
set_needs_conversion(); }
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
templateInstance1.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
break;
} }
break;
}
case TYPE_UNDEFINED:
setIsErroneous(true);
break;
default:
templateInstance1.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
break;
} }
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment