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 {
value1 = ((SpecificValue_Template) temp).getSpecificValue();
value1.setLoweridToReference(timestamp);
final IType templateGovernor = templateInstance1.getExpressionGovernor(timestamp, expectedValue);
final IType lastTemplateGovernor = templateGovernor.getTypeRefdLast(timestamp);
switch (lastTemplateGovernor.getTypetype()) {
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
value1.getValueRefdLast(timestamp, internalExpectation, referenceChain);
break;
case TYPE_SET_OF:
case TYPE_SEQUENCE_OF: {
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, lastTemplateGovernor, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
templateInstance1.getTemplateBody().checkSpecificValue(timestamp, false);
final TypeCompatibilityInfo info = new TypeCompatibilityInfo(myGovernor, lastTemplateGovernor, true);
if (myGovernor != null && !myGovernor.isCompatible(timestamp, lastTemplateGovernor , info, null, null)) {
if (info.getSubtypeError() == null) {
final String errorString = info.getErrorStringString();
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()));
if(templateGovernor != null) {
final IType lastTemplateGovernor = templateGovernor.getTypeRefdLast(timestamp);
switch (lastTemplateGovernor.getTypetype()) {
case TYPE_BITSTRING:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
value1.getValueRefdLast(timestamp, internalExpectation, referenceChain);
break;
case TYPE_SET_OF:
case TYPE_SEQUENCE_OF: {
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, lastTemplateGovernor, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
templateInstance1.getTemplateBody().checkSpecificValue(timestamp, false);
final TypeCompatibilityInfo info = new TypeCompatibilityInfo(myGovernor, lastTemplateGovernor, true);
if (myGovernor != null && !myGovernor.isCompatible(timestamp, lastTemplateGovernor , info, null, null)) {
if (info.getSubtypeError() == null) {
final String errorString = info.getErrorStringString();
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 {
getLocation().reportSemanticError(errorString);
}
} else {
// this is ok.
if (info.getNeedsConversion()) {
set_needs_conversion();
// this is ok.
if (info.getNeedsConversion()) {
set_needs_conversion();
}
}
} else if (info.getNeedsConversion()) {
set_needs_conversion();
}
} else if (info.getNeedsConversion()) {
set_needs_conversion();
break;
}
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