Search in sources :

Example 1 with FieldInfo

use of org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Set_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String className = getGenNameOwn();
    final String classReadableName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final List<FieldInfo> namesList = new ArrayList<FieldInfo>();
    boolean hasOptional = false;
    for (int i = 0; i < components.getNofComps(); i++) {
        final CompField compField = components.getCompByIndex(i);
        final IType cfType = compField.getType();
        final FieldInfo fi = new FieldInfo(cfType.getGenNameValue(aData, source, getMyScope()), cfType.getGenNameTemplate(aData, source, getMyScope()), compField.getIdentifier().getName(), compField.getIdentifier().getDisplayName(), compField.isOptional(), false, compField.getType().getClass().getSimpleName(), cfType.getGenNameTypeDescriptor(aData, source, myScope));
        hasOptional |= compField.isOptional();
        namesList.add(fi);
    }
    for (int i = 0; i < components.getNofComps(); i++) {
        final CompField compField = components.getCompByIndex(i);
        final StringBuilder tempSource = aData.getCodeForType(compField.getType().getGenNameOwn());
        compField.getType().generateCode(aData, tempSource);
    }
    final boolean hasRaw = getGenerateCoderFunctions(MessageEncoding_type.RAW);
    RecordSetCodeGenerator.generateValueClass(aData, source, className, classReadableName, namesList, hasOptional, true, hasRaw, null);
    RecordSetCodeGenerator.generateTemplateClass(aData, source, className, classReadableName, namesList, hasOptional, true);
    generateCodeForCodingHandlers(aData, source);
}
Also used : CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) ArrayList(java.util.ArrayList) FieldInfo(org.eclipse.titan.designer.AST.TTCN3.types.RecordSetCodeGenerator.FieldInfo) IType(org.eclipse.titan.designer.AST.IType)

Example 2 with FieldInfo

use of org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo in project titan.EclipsePlug-ins by eclipse.

the class ASN1_Choice_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    if (components == null) {
        return;
    }
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final List<FieldInfo> fieldInfos = new ArrayList<FieldInfo>();
    boolean hasOptional = false;
    for (int i = 0; i < components.getNofComps(); i++) {
        final CompField compField = components.getCompByIndex(i);
        final IType cfType = compField.getType();
        final FieldInfo fi = new FieldInfo(cfType.getGenNameValue(aData, source, getMyScope()), cfType.getGenNameTemplate(aData, source, getMyScope()), compField.getIdentifier().getName(), compField.getIdentifier().getDisplayName(), cfType.getGenNameTypeDescriptor(aData, source, myScope));
        hasOptional |= compField.isOptional();
        fieldInfos.add(fi);
    }
    for (int i = 0; i < components.getNofComps(); i++) {
        final CompField compField = components.getCompByIndex(i);
        final StringBuilder tempSource = aData.getCodeForType(compField.getType().getGenNameOwn());
        compField.getType().generateCode(aData, tempSource);
    }
    UnionGenerator.generateValueClass(aData, source, genName, displayName, fieldInfos, hasOptional, getGenerateCoderFunctions(MessageEncoding_type.RAW), null);
    UnionGenerator.generateTemplateClass(aData, source, genName, displayName, fieldInfos, hasOptional);
    generateCodeForCodingHandlers(aData, source);
}
Also used : CompField(org.eclipse.titan.designer.AST.TTCN3.types.CompField) ArrayList(java.util.ArrayList) FieldInfo(org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo) IType(org.eclipse.titan.designer.AST.IType)

Example 3 with FieldInfo

use of org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo in project titan.EclipsePlug-ins by eclipse.

the class Anytype_Type method generateCode.

@Override
public /**
 * {@inheritDoc}
 */
void generateCode(final JavaGenData aData, final StringBuilder source) {
    final String genName = getGenNameOwn();
    final String displayName = getFullName();
    generateCodeTypedescriptor(aData, source);
    final List<FieldInfo> fieldInfos = new ArrayList<FieldInfo>();
    boolean hasOptional = false;
    for (final CompField compField : compFieldMap.fields) {
        final IType cfType = compField.getType();
        final FieldInfo fi = new FieldInfo(cfType.getGenNameValue(aData, source, getMyScope()), cfType.getGenNameTemplate(aData, source, getMyScope()), compField.getIdentifier().getName(), compField.getIdentifier().getDisplayName(), cfType.getGenNameTypeDescriptor(aData, source, myScope));
        hasOptional |= compField.isOptional();
        fieldInfos.add(fi);
    }
    for (final CompField compField : compFieldMap.fields) {
        final StringBuilder tempSource = aData.getCodeForType(compField.getType().getGenNameOwn());
        compField.getType().generateCode(aData, tempSource);
    }
    // FIXME can have raw attributes
    UnionGenerator.generateValueClass(aData, source, genName, displayName, fieldInfos, hasOptional, getGenerateCoderFunctions(MessageEncoding_type.RAW), null);
    UnionGenerator.generateTemplateClass(aData, source, genName, displayName, fieldInfos, hasOptional);
    if (hasDoneAttribute()) {
        generateCodeDone(aData, source);
    }
    if (subType != null) {
        subType.generateCode(aData, source);
    }
    generateCodeForCodingHandlers(aData, source);
}
Also used : ArrayList(java.util.ArrayList) FieldInfo(org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo) IType(org.eclipse.titan.designer.AST.IType)

Example 4 with FieldInfo

use of org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo in project titan.EclipsePlug-ins by eclipse.

the class RecordSetCodeGenerator method set_raw_options.

// FIXME comment
private static void set_raw_options(final boolean isSet, final List<FieldInfo> fieldInfos, final boolean hasRaw, final RawASTStruct raw, final ArrayList<raw_option_struct> raw_options, final AtomicBoolean hasLengthto, final AtomicBoolean hasPointer, final AtomicBoolean hasCrosstag, final AtomicBoolean has_ext_bit) {
    for (int i = 0; i < fieldInfos.size(); i++) {
        final raw_option_struct tempRawOption = new raw_option_struct();
        raw_options.add(tempRawOption);
        tempRawOption.lengthto = false;
        tempRawOption.lengthof = 0;
        tempRawOption.lengthofField = null;
        tempRawOption.pointerto = false;
        tempRawOption.pointerof = 0;
        tempRawOption.ptrbase = false;
        tempRawOption.extbitgroup = 0;
        tempRawOption.tag_type = 0;
        tempRawOption.delayedDecode = false;
        tempRawOption.dependentFields = null;
    }
    hasLengthto.set(false);
    hasPointer.set(false);
    hasCrosstag.set(false);
    has_ext_bit.set(hasRaw && raw.extension_bit != RawASTStruct.XDEFNO && raw.extension_bit != RawASTStruct.XDEFDEFAULT);
    for (int i = 0; i < fieldInfos.size(); i++) {
        if (fieldInfos.get(i).hasRaw && fieldInfos.get(i).raw.crosstaglist != null) {
            hasCrosstag.set(true);
        }
    }
    if (hasRaw) {
        final int taglistSize = raw.taglist == null || raw.taglist.list == null ? 0 : raw.taglist.list.size();
        for (int i = 0; i < taglistSize; i++) {
            raw_options.get(raw.taglist.list.get(i).fieldnum).tag_type = i + 1;
        }
        final int extBitGroupsSize = raw.ext_bit_groups == null ? 0 : raw.ext_bit_groups.size();
        for (int i = 0; i < extBitGroupsSize; i++) {
            final rawAST_coding_ext_group tempExtGroup = raw.ext_bit_groups.get(i);
            for (int k = tempExtGroup.from; k <= tempExtGroup.to; k++) {
                raw_options.get(k).extbitgroup = i + 1;
            }
        }
    }
    for (int i = 0; i < fieldInfos.size(); i++) {
        final FieldInfo tempFieldInfo = fieldInfos.get(i);
        final int lengthSize = tempFieldInfo.raw == null || tempFieldInfo.raw.lengthto == null ? 0 : tempFieldInfo.raw.lengthto.size();
        if (tempFieldInfo.hasRaw && lengthSize > 0) {
            hasLengthto.set(true);
            raw_options.get(i).lengthto = true;
            for (int j = 0; j < lengthSize; j++) {
                final int fieldIndex = tempFieldInfo.raw.lengthto.get(j);
                final raw_option_struct tempOptions = raw_options.get(fieldIndex);
                if (tempOptions.lengthofField == null) {
                    tempOptions.lengthofField = new ArrayList<Integer>();
                }
                tempOptions.lengthofField.add(i);
                tempOptions.lengthof++;
            }
        }
        if (tempFieldInfo.hasRaw && tempFieldInfo.raw.pointerto != -1) {
            raw_options.get(i).pointerto = true;
            raw_options.get(fieldInfos.get(i).raw.pointerto).pointerof = i + 1;
            hasPointer.set(true);
            raw_options.get(fieldInfos.get(i).raw.pointerbase).ptrbase = true;
        }
    }
    if (!isSet && hasCrosstag.get()) {
        for (int i = 0; i < fieldInfos.size(); i++) {
            final FieldInfo tempFieldInfo = fieldInfos.get(i);
            int maxIndex = i;
            if (!tempFieldInfo.hasRaw) {
                continue;
            }
            final int crosstagSize = tempFieldInfo.raw.crosstaglist == null || tempFieldInfo.raw.crosstaglist.list == null ? 0 : tempFieldInfo.raw.crosstaglist.list.size();
            for (int j = 0; j < crosstagSize; j++) {
                final rawAST_coding_taglist crosstag = tempFieldInfo.raw.crosstaglist.list.get(j);
                final int fieldsSize = crosstag == null || crosstag.fields == null ? 0 : crosstag.fields.size();
                for (int k = 0; k < fieldsSize; k++) {
                    final rawAST_coding_field_list keyid = crosstag.fields.get(k);
                    if (keyid.fields.size() >= 1) {
                        final int fieldIndex = keyid.fields.get(0).nthfield;
                        if (fieldIndex > maxIndex) {
                            maxIndex = fieldIndex;
                        }
                    }
                }
            }
            if (maxIndex > i) {
                raw_options.get(i).delayedDecode = true;
                if (raw_options.get(maxIndex).dependentFields == null) {
                    raw_options.get(maxIndex).dependentFields = new ArrayList<Integer>();
                }
                raw_options.get(maxIndex).dependentFields.add(i);
            }
        }
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) RawASTStruct.rawAST_coding_field_list(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_field_list) RawASTStruct.rawAST_coding_taglist(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_taglist) RawASTStruct.rawAST_coding_ext_group(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_ext_group)

Example 5 with FieldInfo

use of org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo in project titan.EclipsePlug-ins by eclipse.

the class RecordSetCodeGenerator method genRawDecodeRecordField.

/**
 * This function generates the code for decoding a record field.
 *
 * @param aData only used to update imports if needed.
 * @param source where the source code is to be generated.
 * @param fieldInfos the list of field informations.
 * @param i the index of the field to generate for.
 * @param raw the raw attribute of the record/set.
 * @param raw_options the pre-calculated raw options.
 * @param delayed_decode true to generated for delayed decoding.
 * @param prev_ext_group the index of the previous extension group.
 */
private static void genRawDecodeRecordField(final JavaGenData aData, final StringBuilder source, final List<FieldInfo> fieldInfos, final int i, final RawASTStruct raw, final ArrayList<raw_option_struct> raw_options, final boolean delayed_decode, final AtomicInteger prev_ext_group) {
    final raw_option_struct tempRawOption = raw_options.get(i);
    if (tempRawOption.ptrbase) {
        source.append(MessageFormat.format("start_pos_of_field{0} = buff.get_pos_bit();\n", i));
    }
    if (prev_ext_group.get() != tempRawOption.extbitgroup) {
        prev_ext_group.set(tempRawOption.extbitgroup);
        if (prev_ext_group.get() > 0 && raw.ext_bit_groups.get(tempRawOption.extbitgroup - 1).ext_bit != RawAST.XDEFNO) {
            if (tempRawOption.pointerof > 0) {
                final FieldInfo pointedField = fieldInfos.get(tempRawOption.pointerof - 1);
                source.append("{\n");
                source.append("int old_pos = buff.get_pos_bit();\n");
                source.append(MessageFormat.format("if (start_of_field{0} != -1 && start_pos_of_field{1} != -1) '{'\n", i, pointedField.raw.pointerbase));
                source.append(MessageFormat.format("start_of_field{0} = start_pos_of_field{1} + get{2}(){3}.getInt() * {4} + {5};\n", i, pointedField.raw.pointerbase, pointedField.mVarName, pointedField.isOptional ? ".get()" : "", pointedField.raw.unit, pointedField.raw.ptroffset));
                source.append(MessageFormat.format("buff.set_pos_bit(start_of_field{0});\n", i));
                source.append(MessageFormat.format("limit = end_of_available_data - start_of_field{0};\n", i));
            }
            source.append("{\n");
            source.append("char[] data = buff.get_read_data();\n");
            source.append("int count = 1;\n");
            source.append("int rot = local_top_order == raw_order_t.ORDER_LSB ? 0: 7;\n");
            source.append(MessageFormat.format("while (((data[count - 1] >> rot) & 0x01) == {0} && count * 8 < limit) '{'\n", raw.ext_bit_groups.get(tempRawOption.extbitgroup - 1).ext_bit == RawAST.XDEFYES ? 0 : 1));
            source.append("count++;\n");
            source.append("}\n");
            source.append(" if (limit > 0) {\n");
            source.append("group_limit = count * 8;\n");
            source.append("}\n");
            source.append("}\n");
            if (tempRawOption.pointerof > 0) {
                source.append(" } else {\n");
                source.append("group_limit = 0;\n");
                source.append("}\n");
                source.append("buff.set_pos_bit(old_pos);\n");
                source.append("limit = end_of_available_data - old_pos;\n");
                source.append("}\n");
            }
        }
    }
    final FieldInfo fieldInfo = fieldInfos.get(i);
    final int crosstagsize = fieldInfo.raw == null || fieldInfo.raw.crosstaglist == null || fieldInfo.raw.crosstaglist.list == null ? 0 : fieldInfo.raw.crosstaglist.list.size();
    if (crosstagsize > 0) {
        int other = -1;
        boolean first_value = true;
        for (int j = 0; j < crosstagsize; j++) {
            final rawAST_coding_taglist cur_choice = fieldInfo.raw.crosstaglist.list.get(j);
            if (cur_choice.fields != null && cur_choice.fields.size() > 0) {
                if (first_value) {
                    source.append("if (");
                    first_value = false;
                } else {
                    source.append(" else if (");
                }
                genRawFieldChecker(source, cur_choice, true);
                source.append(") {\n");
                source.append(MessageFormat.format("selected_field = {0};\n", cur_choice.fieldnum));
                source.append("}");
            } else {
                other = cur_choice.fieldnum;
            }
        }
        source.append(" else {\n");
        source.append(MessageFormat.format("selected_field = {0};\n", other));
        source.append("}\n");
    }
    /* check the presence of optional field*/
    if (fieldInfo.isOptional) {
        /* check if enough bits to decode the field*/
        source.append("if ( limit > 0");
        for (int a = 0; a < tempRawOption.lengthof; a++) {
            final int field_index = tempRawOption.lengthofField.get(a);
            if (i > field_index) {
                source.append(MessageFormat.format(" && value_of_length_field{0} > 0", field_index));
            }
        }
        if (tempRawOption.extbitgroup > 0 && raw.ext_bit_groups.get(tempRawOption.extbitgroup - 1).ext_bit != RawAST.XDEFNO) {
            source.append(" && group_limit > 0");
        }
        if (tempRawOption.pointerof > 0) {
            source.append(MessageFormat.format(" && start_of_field{0} != -1 && start_pos_of_field{1} != -1", i, fieldInfos.get(tempRawOption.pointerof - 1).raw.pointerbase));
        }
        final int presenceSize = fieldInfo.raw == null || fieldInfo.raw.presence == null || fieldInfo.raw.presence.fields == null ? 0 : fieldInfo.raw.presence.fields.size();
        if (presenceSize > 0) {
            source.append(" && ");
            if (presenceSize > 1) {
                source.append('(');
            }
            genRawFieldChecker(source, fieldInfo.raw.presence, true);
            if (presenceSize > 1) {
                source.append(')');
            }
        }
        if (crosstagsize > 0) {
            source.append("&& selected_field != -1");
        }
        source.append(") {\n");
    }
    if (tempRawOption.pointerof > 0) {
        final FieldInfo tempPointed = fieldInfos.get(tempRawOption.pointerof - 1);
        source.append(MessageFormat.format("start_of_field{0} = start_pos_of_field{1} + get{2}(){3}.getInt() * {4} + {5};\n", i, tempPointed.raw.pointerbase, tempPointed.mJavaVarName, tempPointed.isOptional ? ".get()" : "", tempPointed.raw.unit, tempPointed.raw.ptroffset));
        source.append(MessageFormat.format("buff.set_pos_bit(start_of_field{0});\n", i));
        source.append(MessageFormat.format("limit = end_of_available_data - start_of_field{0};\n", i));
    }
    if (fieldInfo.isOptional) {
        source.append("int fl_start_pos = buff.get_pos_bit();\n");
    }
    final ExpressionStruct expression = new ExpressionStruct();
    if (delayed_decode) {
        /* the fixed field length is used as limit in case of delayed decoding */
        expression.expression.append(fieldInfo.raw.length);
    } else {
        genRawFieldDecodeLimit(aData, expression, fieldInfos, i, raw, raw_options);
    }
    if (expression.preamble.length() > 0) {
        source.append(expression.preamble);
    }
    source.append(MessageFormat.format("decoded_field_length = get{0}(){1}.RAW_decode({2}_descr_, buff, ", fieldInfo.mJavaVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.mTypeDescriptorName));
    source.append(expression.expression);
    source.append(MessageFormat.format(", local_top_order, {0}", fieldInfo.isOptional ? "true" : "no_err"));
    if (crosstagsize > 0) {
        source.append(", selected_field");
    } else {
        source.append(", -1");
    }
    boolean found = false;
    for (int a = 0; a < tempRawOption.lengthof && !found; a++) {
        final int field_index = tempRawOption.lengthofField.get(a);
        if (fieldInfos.get(field_index).raw.unit == -1) {
            source.append(MessageFormat.format(", value_of_length_field{0}", field_index));
            found = true;
        }
    }
    if (!found) {
        source.append(", true");
    }
    source.append(");\n");
    if (delayed_decode) {
        source.append(MessageFormat.format("if ( decoded_field_length != {0}) '{'\n", fieldInfo.raw.length));
        source.append("return -1;\n");
        source.append("}\n");
    } else if (fieldInfo.isOptional) {
        source.append("if (decoded_field_length < 1) {\n");
        source.append(MessageFormat.format("{0}.assign(template_sel.OMIT_VALUE);\n", fieldInfo.mVarName));
        source.append("buff.set_pos_bit(fl_start_pos);\n");
        source.append(" } else {\n");
    } else {
        source.append("if (decoded_field_length < 0) {\n");
        source.append("return decoded_field_length;\n");
        source.append("}\n");
    }
    if (tempRawOption.tag_type > 0 && raw.taglist.list.get(tempRawOption.tag_type - 1).fields.size() > 0) {
        final rawAST_coding_taglist cur_choice = raw.taglist.list.get(tempRawOption.tag_type - 1);
        source.append("if (");
        genRawFieldChecker(source, cur_choice, false);
        source.append(") {\n");
        if (fieldInfo.isOptional) {
            source.append(MessageFormat.format("{0}.assign(template_sel.OMIT_VALUE);\n", fieldInfo.mVarName));
            source.append("buff.set_pos_bit(fl_start_pos);\n");
            source.append(" } else {");
        } else {
            source.append("return -1;\n");
            source.append("}\n");
        }
    }
    if (!delayed_decode) {
        source.append("decoded_length += decoded_field_length;\n");
        source.append("limit -= decoded_field_length;\n");
        source.append("last_decoded_pos = Math.max(last_decoded_pos, buff.get_pos_bit());\n");
    }
    if (tempRawOption.extbitgroup > 0 && raw.ext_bit_groups.get(tempRawOption.extbitgroup - 1).ext_bit != RawAST.XDEFNO) {
        source.append("group_limit -= decoded_field_length;\n");
    }
    if (tempRawOption.lengthto) {
        if (fieldInfo.raw.lengthindex != null) {
            if (fieldInfo.raw.lengthindex.fieldtype == rawAST_coding_field_type.OPTIONAL_FIELD) {
                source.append(MessageFormat.format("if ({0}{1}.get{2}().isPresent()) '{'\n", fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.lengthindex.nthfieldname));
            }
            if (fieldInfo.raw.lengthto_offset != 0) {
                source.append(MessageFormat.format("{0}{1}.get{2}(){3}.assign({0}{1}.get{2}(){3} - {4});\n", fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.lengthindex.nthfieldname, fieldInfo.raw.lengthindex.fieldtype == rawAST_coding_field_type.OPTIONAL_FIELD ? ".get()" : "", fieldInfo.raw.lengthto_offset));
            }
            source.append(MessageFormat.format("value_of_length_field{0} += {1}{2}.get{3}(){4}.getInt() * {5};\n", i, fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.lengthindex.nthfieldname, fieldInfo.raw.lengthindex.fieldtype == rawAST_coding_field_type.OPTIONAL_FIELD ? ".get()" : "", fieldInfo.raw.unit == -1 ? 1 : fieldInfo.raw.unit));
            if (fieldInfo.raw.lengthindex.fieldtype == rawAST_coding_field_type.OPTIONAL_FIELD) {
                source.append("}\n");
            }
        } else if (fieldInfo.raw.union_member_num > 0) {
            source.append(MessageFormat.format("switch ({0}{1}.get_selection()) '{'\n", fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : ""));
            for (int m = 0; m < fieldInfo.raw.member_name.size(); m++) {
                source.append(MessageFormat.format("case {0}.{1}", fieldInfo.raw.member_name.get(0), fieldInfo.raw.member_name.get(m)));
                if (fieldInfo.raw.lengthto_offset != 0) {
                    source.append(MessageFormat.format("{0}{1}.get{2}().assign({0}{1}.get{2}() - {3});\n", fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.member_name.get(m), fieldInfo.raw.lengthto_offset));
                }
                source.append(MessageFormat.format("value_of_length_field{0} += {1}{2}.get{3}().getInt() * {4};\n", i, fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.member_name.get(m), fieldInfo.raw.unit == -1 ? 1 : fieldInfo.raw.unit));
                source.append("break;\n");
            }
            source.append("default:\n");
            source.append(MessageFormat.format("value_of_length_field{0} = 0;\n", i));
            source.append("}\n");
        } else {
            if (fieldInfo.raw.lengthto_offset != 0) {
                source.append(MessageFormat.format("{0}{1}.assign({0}{1}.getInt() - {2});\n", fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.lengthto_offset));
            }
            source.append(MessageFormat.format("value_of_length_field{0} += {1}{2}.getInt() * {3};\n", i, fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.unit == -1 ? 1 : fieldInfo.raw.unit));
        }
    }
    if (tempRawOption.pointerto) {
        source.append(MessageFormat.format("start_of_field{0} = {1}{2}.getInt() {3};\n ", fieldInfo.raw.pointerto, fieldInfo.mVarName, fieldInfo.isOptional ? ".get()" : "", fieldInfo.raw.ptroffset > 0 ? " + 1" : "- 1"));
    }
    if (!delayed_decode) {
        /* mark the used bits in length area*/
        for (int a = 0; a < tempRawOption.lengthof; a++) {
            final int field_index = tempRawOption.lengthofField.get(a);
            source.append(MessageFormat.format("value_of_length_field{0} -= decoded_field_length;\n", field_index));
            if (i == field_index) {
                source.append(MessageFormat.format("if (value_of_length_field{0} < 0) '{'\n", field_index));
                source.append("return -1;\n");
                source.append("}\n");
            }
        }
    }
    if (fieldInfo.isOptional) {
        source.append("}\n");
        source.append("}");
        if (tempRawOption.tag_type > 0) {
            source.append("\n}");
        }
        source.append(" else {\n");
        source.append(MessageFormat.format("{0}.assign(template_sel.OMIT_VALUE);\n", fieldInfo.mVarName));
        source.append("}\n");
    }
}
Also used : RawASTStruct.rawAST_coding_taglist(org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_taglist) ExpressionStruct(org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)

Aggregations

ArrayList (java.util.ArrayList)10 IType (org.eclipse.titan.designer.AST.IType)9 RawASTStruct.rawAST_coding_taglist (org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_taglist)6 FieldInfo (org.eclipse.titan.designer.AST.TTCN3.types.RecordSetCodeGenerator.FieldInfo)5 RawASTStruct (org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct)4 RawASTStruct.rawAST_coding_field_list (org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_field_list)4 CompField (org.eclipse.titan.designer.AST.TTCN3.types.CompField)4 FieldInfo (org.eclipse.titan.designer.AST.TTCN3.types.UnionGenerator.FieldInfo)4 ExpressionStruct (org.eclipse.titan.designer.AST.TTCN3.values.expressions.ExpressionStruct)4 RawASTStruct.rawAST_coding_ext_group (org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_ext_group)3 RawASTStruct.rawAST_coding_fields (org.eclipse.titan.designer.AST.TTCN3.attributes.RawASTStruct.rawAST_coding_fields)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ASN1_Choice_Type (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Choice_Type)2 Identifier (org.eclipse.titan.designer.AST.Identifier)2 RawAST (org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST)2 RawAST.rawAST_single_tag (org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_single_tag)2 RawAST.rawAST_tag_field_value (org.eclipse.titan.designer.AST.TTCN3.attributes.RawAST.rawAST_tag_field_value)2 Type (org.eclipse.titan.designer.AST.Type)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1 ASN1_Set_Seq_Choice_BaseType (org.eclipse.titan.designer.AST.ASN1.types.ASN1_Set_Seq_Choice_BaseType)1