Commit 7f637d16 authored by Kristof Szabados's avatar Kristof Szabados

the parameter can be negative as well.

Signed-off-by: Kristof Szabados's avatarKristof Szabados <Kristof.Szabados@ericsson.com>
parent c8e7f452
......@@ -1210,9 +1210,8 @@ public final class EnumeratedGenerator {
source.append("}\n");
source.append("if (list_index < 0) {\n");
source.append(MessageFormat.format("throw new TtcnError(\"Index underflow in a value list template of enumerated type {0}.\");\n", name));
source.append("}\n");
source.append("if(list_index >= value_list.size()) {\n");
source.append(MessageFormat.format("throw new TtcnError(MessageFormat.format(\"Internal error: Accessing a value list template of type {0} using a negative index ('{'0'}').\", list_index));\n", name));
source.append("} else if(list_index >= value_list.size()) {\n");
source.append(MessageFormat.format("throw new TtcnError(\"Index overflow in a value list template of enumerated type {0}.\");\n", name));
source.append("}\n");
source.append("return value_list.get(list_index);\n");
......
......@@ -928,7 +928,9 @@ public final class FunctionReferenceGenerator {
source.append("!template_sel.COMPLEMENTED_LIST.equals(template_selection)) {\n");
source.append(MessageFormat.format("throw new TtcnError(\"Accessing a list element of a non-list template of type {0}.\");\n", def.displayName));
source.append("}\n");
source.append("if (listIndex > value_list.size()) {\n");
source.append("if (listIndex < 0) {\n");
source.append(MessageFormat.format("throw new TtcnError(MessageFormat.format(\"Internal error: Accessing a value list template of type {0} using a negative index ('{'0'}').\", listIndex));\n", def.displayName));
source.append("} else if (listIndex > value_list.size()) {\n");
source.append(MessageFormat.format("throw new TtcnError(\"Index overflow in a value list template of type {0}.\");\n", def.displayName));
source.append("}\n");
source.append("return value_list.get(listIndex);\n");
......
......@@ -2416,12 +2416,14 @@ public final class RecordOfGenerator {
*/
private static void generateTemplateListItem( final StringBuilder aSb, final String genName, final String displayName ) {
aSb.append('\n');
aSb.append("@Override\n");
aSb.append("\t\t@Override\n");
aSb.append( MessageFormat.format( "\t\tpublic {0}_template list_item(final int list_index) '{'\n", genName ) );
aSb.append("\t\t\tif (template_selection != template_sel.VALUE_LIST && template_selection != template_sel.COMPLEMENTED_LIST) {\n");
aSb.append( MessageFormat.format( "\t\t\t\tthrow new TtcnError(\"Accessing a list element of a non-list template of type {0}.\");\n", displayName ) );
aSb.append("\t\t\t}\n");
aSb.append("\t\t\tif (list_index >= list_value.size()) {\n");
aSb.append("\t\t\tif (list_index < 0) {\n");
aSb.append(MessageFormat.format("\t\t\t\tthrow new TtcnError(MessageFormat.format(\"Internal error: Accessing a value list template of type {0} using a negative index ('{'0'}').\", list_index));\n", displayName));
aSb.append("\t\t\t} else if (list_index >= list_value.size()) {\n");
aSb.append( MessageFormat.format( "\t\t\t\tthrow new TtcnError(\"Index overflow in a value list template of type {0}.\");\n", displayName ) );
aSb.append("\t\t\t}\n");
aSb.append("\t\t\treturn list_value.get(list_index);\n");
......@@ -2446,9 +2448,8 @@ public final class RecordOfGenerator {
source.append( MessageFormat.format( "\t\t\tthrow new TtcnError(\"Internal error: Accessing a list element of a non-list template of type {0}.\");\n", displayName ) );
source.append("\t\t}\n");
source.append("\t\tif (list_index < 0) {\n");
source.append("\t\t\tthrow new TtcnError( MessageFormat.format( \"Internal error: Accessing a value list template of type "+displayName+" using a negative index ({0}).\", list_index ) );\n");
source.append("\t\t}\n");
source.append("\t\tif (list_index >= list_value.size()) {\n");
source.append(MessageFormat.format("\t\t\tthrow new TtcnError(MessageFormat.format(\"Internal error: Accessing a value list template of type {0} using a negative index ('{'0'}').\", list_index));\n", displayName));
source.append("\t\t} else if (list_index >= list_value.size()) {\n");
source.append( MessageFormat.format( "\t\t\tthrow new TtcnError(\"Internal error: Index overflow in a value list template of type {0}.\");\n", displayName ) );
source.append("\t\t}\n");
source.append("\t\treturn list_value.get( list_index );\n");
......
......@@ -2229,7 +2229,9 @@ public final class RecordSetCodeGenerator {
aSb.append("\t\t\tif (template_selection != template_sel.VALUE_LIST && template_selection != template_sel.COMPLEMENTED_LIST) {\n");
aSb.append( MessageFormat.format( "\t\t\t\tthrow new TtcnError(\"Accessing a list element of a non-list template of type {0}.\");\n", displayName ) );
aSb.append("\t\t\t}\n");
aSb.append("\t\t\tif (list_index >= list_value.size()) {\n");
aSb.append("\t\t\tif (list_index < 0) {\n");
aSb.append(MessageFormat.format("\t\t\t\tthrow new TtcnError(MessageFormat.format(\"Internal error: Accessing a value list template of type {0} using a negative index ('{'0'}').\", list_index));\n", displayName));
aSb.append("\t\t\t} else if (list_index >= list_value.size()) {\n");
aSb.append( MessageFormat.format( "\t\t\t\tthrow new TtcnError(\"Index overflow in a value list template of type {0}.\");\n", displayName ) );
aSb.append("\t\t\t}\n");
aSb.append("\t\t\treturn list_value.get(list_index);\n");
......@@ -3305,7 +3307,9 @@ public final class RecordSetCodeGenerator {
source.append("\t\t\tif (template_selection != template_sel.VALUE_LIST && template_selection != template_sel.COMPLEMENTED_LIST) {\n");
source.append( MessageFormat.format( "\t\t\t\tthrow new TtcnError(\"Accessing a list element of a non-list template of type {0}.\");\n", classDisplayName ) );
source.append("\t\t\t}\n");
source.append("\t\t\tif (list_index >= list_value.size()) {\n");
source.append("\t\t\tif (list_index < 0) {\n");
source.append(MessageFormat.format("\t\t\t\tthrow new TtcnError(MessageFormat.format(\"Internal error: Accessing a value list template of type {0} using a negative index ('{'0'}').\", list_index));\n", classDisplayName));
source.append("\t\t\t} else if (list_index >= list_value.size()) {\n");
source.append( MessageFormat.format( "\t\t\t\tthrow new TtcnError(\"Index overflow in a value list template of type {0}.\");\n", classDisplayName ) );
source.append("\t\t\t}\n");
source.append("\t\t\treturn list_value.get(list_index);\n");
......
......@@ -1574,9 +1574,8 @@ public final class UnionGenerator {
source.append("}\n");
source.append("if (list_index < 0) {\n");
source.append(MessageFormat.format("throw new TtcnError(\"Internal error: Index underflow in a value list template of union type {0}.\");\n", displayName));
source.append("}\n");
source.append("if(list_index >= value_list.size()) {\n");
source.append(MessageFormat.format("throw new TtcnError(MessageFormat.format(\"Internal error: Accessing a value list template of type {0} using a negative index ('{'0'}').\", list_index));\n", displayName));
source.append("} else if(list_index >= value_list.size()) {\n");
source.append(MessageFormat.format("throw new TtcnError(\"Internal error: Index overflow in a value list template of union type {0}.\");\n", displayName));
source.append("}\n");
source.append("return value_list.get(list_index);\n");
......
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