Commit 2b38f45d authored by Kristof Szabados's avatar Kristof Szabados

some comparision operator still needed to follow the naming convention.

Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent f46c8ce0
......@@ -757,7 +757,7 @@ public abstract class AbstractOfType extends ASN1Type {
expression.expression.append(MessageFormat.format("final TitanInteger {0} = ", temporalIndexId));
last.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(";\n");
expression.expression.append(MessageFormat.format("{0} = {1}.isGreaterThanOrEqual(0) && {1}.isLessThan({2}.{3});\n",
expression.expression.append(MessageFormat.format("{0} = {1}.is_greater_than_or_equal(0) && {1}.is_less_than({2}.{3});\n",
globalId, temporalIndexId, externalId, isTemplate?"n_elem()":"size_of()"));
expression.expression.append(MessageFormat.format("if({0}) '{'\n", globalId));
......
......@@ -1381,7 +1381,7 @@ public final class Array_Type extends Type implements IReferenceableElement {
expression.expression.append(MessageFormat.format("final TitanInteger {0} = ", temporalIndexId));
last.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(";\n");
expression.expression.append(MessageFormat.format("{0} = {1}.isGreaterThanOrEqual(0) && {1}.isLessThan({2}.{3});\n",
expression.expression.append(MessageFormat.format("{0} = {1}.is_greater_than_or_equal(0) && {1}.is_less_than({2}.{3});\n",
globalId, temporalIndexId, externalId, isTemplate?"n_elem()":"size_of()"));
expression.expression.append(MessageFormat.format("if({0}) '{'\n", globalId));
......
......@@ -152,10 +152,10 @@ public final class EnumeratedGenerator {
generateValueoperator_assign(aData, source, e_defs.name);
generateValueoperator_equals(aData, source, e_defs.name, e_defs.displayName);
generateValueoperator_not_equals(aData, source, e_defs.name);
generateValueIsLessThan(source, e_defs.name);
generateValueIsLessThanOrEqual(source, e_defs.name);
generateValueIsGreaterThan(source, e_defs.name);
generateValueIsGreaterThanOrEqual(source, e_defs.name);
generateValueIsLessThan(aData, source, e_defs.name);
generateValueIsLessThanOrEqual(aData, source, e_defs.name);
generateValueIsGreaterThan(aData, source, e_defs.name);
generateValueIsGreaterThanOrEqual(aData, source, e_defs.name);
generateValueIsPresent(source);
generateValueIsBound(source);
generateValueIsValue(source);
......@@ -734,69 +734,149 @@ public final class EnumeratedGenerator {
source.append("}\n\n");
}
private static void generateValueIsLessThan(final StringBuilder source, final String name) {
private static void generateValueIsLessThan(final JavaGenData aData, final StringBuilder source, final String name) {
// arg: enum_type
source.append("// originally operator<\n");
source.append(MessageFormat.format("public boolean isLessThan(final {0}.enum_type otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is less than the provided one.\n");
source.append(" *\n");
source.append(" * operator< in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is less than the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_less_than(final {0}.enum_type otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num < otherValue.enum_num;\n");
source.append("}\n\n");
//arg: own type
source.append("// originally operator<\n");
source.append(MessageFormat.format("public boolean isLessThan(final {0} otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is less than the provided one.\n");
source.append(" *\n");
source.append(" * operator< in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is less than the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_less_than(final {0} otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("otherValue.must_bound(\"The right operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num < otherValue.enum_value.enum_num ;\n");
source.append("}\n\n");
}
private static void generateValueIsLessThanOrEqual(final StringBuilder source, final String name) {
private static void generateValueIsLessThanOrEqual(final JavaGenData aData, final StringBuilder source, final String name) {
// arg: enum_type
source.append("// originally operator<=\n");
source.append(MessageFormat.format("public boolean isLessThanOrEqual(final {0}.enum_type otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is less than or equivalent to the provided one.\n");
source.append(" *\n");
source.append(" * operator<= in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is less than or equivalent to the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_less_than_or_equal(final {0}.enum_type otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num <= otherValue.enum_num;\n");
source.append("}\n\n");
// own type
source.append("// originally operator<=\n");
source.append(MessageFormat.format("public boolean isLessThanOrEqual(final {0} otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is less than or equivalent to the provided one.\n");
source.append(" *\n");
source.append(" * operator<= in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is less than or equivalent to the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_less_than_or_equal(final {0} otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("otherValue.must_bound(\"The right operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num <= otherValue.enum_value.enum_num ;\n");
source.append("}\n\n");
}
private static void generateValueIsGreaterThan(final StringBuilder source, final String name) {
private static void generateValueIsGreaterThan(final JavaGenData aData, final StringBuilder source, final String name) {
// arg: enum_type
source.append("// originally operator>\n");
source.append(MessageFormat.format("public boolean isGreaterThan(final {0}.enum_type otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is greater than the provided one.\n");
source.append(" *\n");
source.append(" * operator> in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is greater than the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_greater_than(final {0}.enum_type otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num > otherValue.enum_num;\n");
source.append("}\n\n");
// own type
source.append("// originally operator>\n");
source.append(MessageFormat.format("public boolean isGreaterThan(final {0} otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is greater than the provided one.\n");
source.append(" *\n");
source.append(" * operator> in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is greater than the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_greater_than(final {0} otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("otherValue.must_bound(\"The right operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num > otherValue.enum_value.enum_num ;\n");
source.append("}\n\n");
}
private static void generateValueIsGreaterThanOrEqual(final StringBuilder source, final String name) {
private static void generateValueIsGreaterThanOrEqual(final JavaGenData aData, final StringBuilder source, final String name) {
// arg: enum_type
source.append("// originally operator>=\n");
source.append(MessageFormat.format("public boolean isGreaterThanOrEqual(final {0}.enum_type otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is greater than or equivalent to the provided one.\n");
source.append(" *\n");
source.append(" * operator>= in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is greater than or equivalent to the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_greater_than_or_equal(final {0}.enum_type otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num >= otherValue.enum_num;\n");
source.append("}\n\n");
// arg: own type
source.append("// originally operator>=\n");
source.append(MessageFormat.format("public boolean isGreaterThanOrEqual(final {0} otherValue)'{'\n", name));
if ( aData.isDebug() ) {
source.append("/**\n");
source.append(" * Checks if the current value is greater than or equivalent to the provided one.\n");
source.append(" *\n");
source.append(" * operator>= in the core\n");
source.append(" *\n");
source.append(" * @param otherValue\n");
source.append(" * the other value to check against.\n");
source.append(" * @return {@code true} if the value is greater than or equivalent to the provided.\n");
source.append(" */\n");
}
source.append(MessageFormat.format("public boolean is_greater_than_or_equal(final {0} otherValue)'{'\n", name));
source.append("must_bound(\"The left operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("otherValue.must_bound(\"The right operand of comparison is an unbound value of enumerated type "+ name +". \");\n");
source.append("return enum_value.enum_num >= otherValue.enum_value.enum_num ;\n");
......
......@@ -356,7 +356,7 @@ public final class GreaterThanExpression extends Expression_Value {
/** {@inheritDoc} */
public void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
value1.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".isGreaterThan( ");
expression.expression.append(".is_greater_than( ");
value2.generateCodeExpressionMandatory(aData, expression, false);
expression.expression.append(" )");
}
......
......@@ -354,7 +354,7 @@ public final class GreaterThanOrEqualExpression extends Expression_Value {
/** {@inheritDoc} */
public void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
value1.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".isGreaterThanOrEqual( ");
expression.expression.append(".is_greater_than_or_equal( ");
value2.generateCodeExpressionMandatory(aData, expression, false);
expression.expression.append(" )");
}
......
......@@ -355,7 +355,7 @@ public final class LessThanExpression extends Expression_Value {
public void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
//TODO actually a bit more complicated
value1.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append( ".isLessThan( " );
expression.expression.append( ".is_less_than( " );
value2.generateCodeExpressionMandatory(aData, expression, false);
expression.expression.append( " )" );
}
......
......@@ -354,7 +354,7 @@ public final class LessThanOrEqualExpression extends Expression_Value {
/** {@inheritDoc} */
public void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression){
value1.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".isLessThanOrEqual( ");
expression.expression.append(".is_less_than_or_equal( ");
value2.generateCodeExpressionMandatory(aData, expression, false);
expression.expression.append(" )");
}
......
......@@ -3232,7 +3232,7 @@ public abstract class Type extends Governor implements IType, IIncrementallyUpda
expression.expression.append(MessageFormat.format("final TitanInteger {0} = ", temporalIndexId));
last.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(";\n");
expression.expression.append(MessageFormat.format("{0} = {1}.isGreaterThanOrEqual(0) && {1}.isLessThan({2}.lengthof());\n",
expression.expression.append(MessageFormat.format("{0} = {1}.is_greater_than_or_equal(0) && {1}.is_less_than({2}.lengthof());\n",
globalId, temporalIndexId, externalId));
final String temporalId = aData.getTemporaryVariableName();
......
......@@ -245,7 +245,7 @@ public final class AdditionalFunctions {
public static TitanBitString int2bit(final TitanInteger value, final int length) {
value.must_bound("The first argument (value) of function int2bit() is an unbound integer value.");
if (value.isLessThan(0)) {
if (value.is_less_than(0)) {
throw new TtcnError(MessageFormat.format("The first argument (value) of function int2bit() is a negative integer value: {0}.", value));
}
if (length < 0) {
......@@ -322,7 +322,7 @@ public final class AdditionalFunctions {
public static TitanHexString int2hex(final TitanInteger value, final int length) {
value.must_bound("The first argument (value) of function int2hex() is an unbound integer value.");
if (value.isLessThan(0)) {
if (value.is_less_than(0)) {
throw new TtcnError(MessageFormat.format("The first argument (value) of function int2hex() is a negative integer value: {0}.", value));
}
if (length < 0) {
......@@ -407,7 +407,7 @@ public final class AdditionalFunctions {
return int2oct(value.getInt(), length);
} else {
BigInteger tmp_val = value.getBigInteger();
if (value.isLessThan(0)) {
if (value.is_less_than(0)) {
throw new TtcnError(MessageFormat.format("The first argument (value) of function int2oct() is a negative integer value: {0}.", value));
}
if (length < 0) {
......
......@@ -890,7 +890,7 @@ public class LegacyLogger implements ILoggerPlugin {
}
case ALT_defaultopDeactivate: {
final DefaultOp dflt = choice.get_field_defaultopDeactivate();
if (dflt.get_field_name().lengthof().isGreaterThan(0)) {
if (dflt.get_field_name().lengthof().is_greater_than(0)) {
returnValue.append(MessageFormat.format("Default with id {0} (altstep {1}) was deactivated.", dflt.get_field_id().getInt(), dflt.get_field_name().getValue()));
} else {
returnValue.append("Deactivate operation on a null default reference was ignored.");
......@@ -1132,7 +1132,7 @@ public class LegacyLogger implements ILoggerPlugin {
final int localOrdinal = set.get_field_localVerdict().enum_value.ordinal();
final String localVerdictName = VerdictTypeEnum.values()[localOrdinal].getName();
if (set.get_field_newVerdict().isGreaterThan(set.get_field_oldVerdict())) {
if (set.get_field_newVerdict().is_greater_than(set.get_field_oldVerdict())) {
if (!set.get_field_oldReason().is_present() || !set.get_field_newReason().is_present()) {
returnValue.append(MessageFormat.format("setverdict({0}): {1} -> {2}", newVerdictName, oldVerdictName, localVerdictName));
} else {
......
......@@ -2087,7 +2087,7 @@ public final class TTCN_Runtime {
}
}
if (hasTimer && timerValue.isLessThan(0.0)) {
if (hasTimer && timerValue.is_less_than(0.0)) {
throw new TtcnError(MessageFormat.format("The test case supervisor timer has negative duration ({0} s).", timerValue.getValue()));
}
}
......
......@@ -442,7 +442,7 @@ public final class Text_Buf {
final TitanInteger msg_len = new TitanInteger();
boolean returnValue = false;
if (safe_pull_int(msg_len)) {
if (msg_len.isLessThan(0)) {
if (msg_len.is_less_than(0)) {
throw new TtcnError(MessageFormat.format("Text decoder: Negative message length ({0}).", msg_len.getInt()));
}
returnValue = buf_pos + msg_len.getInt() <= buf_begin + buf_len;
......
......@@ -422,78 +422,174 @@ public class TitanFloat extends Base_Type {
return !operator_equals(otherValue);
}
// originally operator <
public boolean isLessThan(final double otherValue) {
/**
* Checks if the current value is less than the provided one.
*
* operator< in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is less than the provided.
*/
public boolean is_less_than(final double otherValue) {
must_bound("Unbound left operand of float comparison.");
return float_value.isLessThan(otherValue);
return float_value.is_less_than(otherValue);
}
// originally operator <
public boolean isLessThan(final Ttcn3Float otherValue) {
/**
* Checks if the current value is less than the provided one.
*
* operator< in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is less than the provided.
*/
public boolean is_less_than(final Ttcn3Float otherValue) {
must_bound("Unbound left operand of float comparison.");
return float_value.isLessThan(otherValue.getValue());
return float_value.is_less_than(otherValue.getValue());
}
// originally operator <
public boolean isLessThan(final TitanFloat otherValue) {
/**
* Checks if the current value is less than the provided one.
*
* operator< in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is less than the provided.
*/
public boolean is_less_than(final TitanFloat otherValue) {
must_bound("Unbound left operand of float comparison.");
otherValue.must_bound("Unbound right operand of float comparison.");
return float_value.isLessThan(otherValue.float_value.getValue());
return float_value.is_less_than(otherValue.float_value.getValue());
}
// originally operator >
public boolean isGreaterThan(final double otherValue) {
/**
* Checks if the current value is greater than the provided one.
*
* operator> in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is greater than the provided.
*/
public boolean is_greater_than(final double otherValue) {
must_bound("Unbound left operand of float comparison.");
return float_value.isGreaterThan(otherValue);
return float_value.is_greater_than(otherValue);
}
// originally operator >
public boolean isGreaterThan(final Ttcn3Float otherValue) {
/**
* Checks if the current value is greater than the provided one.
*
* operator> in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is greater than the provided.
*/
public boolean is_greater_than(final Ttcn3Float otherValue) {
must_bound("Unbound left operand of float comparison.");
return float_value.isGreaterThan(otherValue.getValue());
return float_value.is_greater_than(otherValue.getValue());
}
// originally operator >
public boolean isGreaterThan(final TitanFloat otherValue) {
/**
* Checks if the current value is greater than the provided one.
*
* operator> in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is greater than the provided.
*/
public boolean is_greater_than(final TitanFloat otherValue) {
must_bound("Unbound left operand of float comparison.");
otherValue.must_bound("Unbound right operand of float comparison.");
return float_value.isGreaterThan(otherValue.float_value.getValue());
return float_value.is_greater_than(otherValue.float_value.getValue());
}
// originally operator <=
public boolean isLessThanOrEqual(final double otherValue) {
return !isGreaterThan(otherValue);
/**
* Checks if the current value is less than or equivalent to the provided one.
*
* operator<= in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is less than or equivalent to the provided.
*/
public boolean is_less_than_or_equal(final double otherValue) {
return !is_greater_than(otherValue);
}
// originally operator <=
public boolean isLessThanOrEqual(final Ttcn3Float otherValue) {
return !isGreaterThan(otherValue);
/**
* Checks if the current value is less than or equivalent to the provided one.
*
* operator<= in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is less than or equivalent to the provided.
*/
public boolean is_less_than_or_equal(final Ttcn3Float otherValue) {
return !is_greater_than(otherValue);
}
// originally operator <=
public boolean isLessThanOrEqual(final TitanFloat otherValue) {
return !isGreaterThan(otherValue);
/**
* Checks if the current value is less than or equivalent to the provided one.
*
* operator<= in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is less than or equivalent to the provided.
*/
public boolean is_less_than_or_equal(final TitanFloat otherValue) {
return !is_greater_than(otherValue);
}
// originally operator >=
public boolean isGreaterThanOrEqual(final double otherValue) {
return !isLessThan(otherValue);
/**
* Checks if the current value is greater than or equivalent to the provided one.
*
* operator>= in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is greater than or equivalent to the provided.
*/
public boolean is_greater_than_or_equal(final double otherValue) {
return !is_less_than(otherValue);
}
// originally operator >=
public boolean isGreaterThanOrEqual(final Ttcn3Float otherValue) {
return !isLessThan(otherValue);
/**
* Checks if the current value is greater than or equivalent to the provided one.
*
* operator>= in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is greater than or equivalent to the provided.
*/
public boolean is_greater_than_or_equal(final Ttcn3Float otherValue) {
return !is_less_than(otherValue);
}
// originally operator >=
public boolean isGreaterThanOrEqual(final TitanFloat otherValue) {
return !isLessThan(otherValue);
/**
* Checks if the current value is greater than or equivalent to the provided one.
*
* operator>= in the core
*
* @param otherValue
* the other value to check against.
* @return {@code true} if the value is greater than or equivalent to the provided.
*/
public boolean is_greater_than_or_equal(final TitanFloat otherValue) {
return !is_less_than(otherValue);
}
@Override
......@@ -606,31 +702,31 @@ public class TitanFloat extends Base_Type {
}
// static isLess
public static TitanBoolean isLessThan(final double doubleValue, final TitanFloat otherValue) {
public static TitanBoolean is_less_than(final double doubleValue, final TitanFloat otherValue) {
otherValue.must_bound("Unbound right operand of float comparison.");
return new TitanBoolean(otherValue.isGreaterThan(new TitanFloat(doubleValue)));
return new TitanBoolean(otherValue.is_greater_than(new TitanFloat(doubleValue)));
}
// static isGreaterThan
public static TitanBoolean isGreaterThan(final double doubleValue, final TitanFloat otherValue) {
public static TitanBoolean is_greater_than(final double doubleValue, final TitanFloat otherValue) {
otherValue.must_bound("Unbound right operand of float comparison.");
return new TitanBoolean(otherValue.is