use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType in project titan.EclipsePlug-ins by eclipse.
the class InsertFieldWizardInputPage method checkPosition.
public void checkPosition() {
try {
settings.setPosition(Integer.parseInt(positionField.getText().trim()));
final IType type = selection.getType(CompilationTimeStamp.getBaseTimestamp());
if (type instanceof TTCN3_Sequence_Type || type instanceof TTCN3_Set_Type) {
final TTCN3_Set_Seq_Choice_BaseType ss = (TTCN3_Set_Seq_Choice_BaseType) type;
final int noc = ss.getNofComponents();
if (settings.getPosition() < 0) {
positionErrorMessage = NEGATIVEPOSITION;
posDone = false;
} else if (settings.getPosition() > noc) {
positionErrorMessage = String.format(INVALIDUPPERBOUNDPOSITION, noc);
posDone = false;
} else {
positionErrorMessage = "";
posDone = true;
}
}
} catch (NumberFormatException ex) {
positionErrorMessage = NOTNUMBERPOSITION;
posDone = false;
}
setErrorMessage(positionErrorMessage + typeErrorMessage + nameErrorMessage + valueErrorMessage);
setPageComplete(posDone && typeDone && nameDone && valueDone);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType in project titan.EclipsePlug-ins by eclipse.
the class ErroneousAttributes method buildErroneousDescriptorTree.
private ErroneousDescriptor buildErroneousDescriptorTree(final CompilationTimeStamp timestamp, final List<FieldErr_Type> fldArray, final int level) {
final ErroneousDescriptor erroneousDescr = new ErroneousDescriptor();
Qualifier omitBeforeQualifier = null;
Qualifier omitAfterQualifier = null;
final Map<Integer, List<FieldErr_Type>> embeddedFieldArrayMap = new HashMap<Integer, List<FieldErr_Type>>();
for (FieldErr_Type actualFieldErr : fldArray) {
if (actualFieldErr.subrefsArray.size() <= level) {
ErrorReporter.INTERNAL_ERROR();
return erroneousDescr;
}
final int fieldIndex = actualFieldErr.subrefsArray.get(level);
final IType fieldType = actualFieldErr.typeArray.get(level);
if (omitBeforeQualifier != null && erroneousDescr.omitBefore != -1 && erroneousDescr.omitBefore > fieldIndex) {
final String message = MessageFormat.format("Field `{0}'' cannot be referenced because all fields before field `{1}'' have been omitted", actualFieldErr.qualifier.getDisplayName(), omitBeforeQualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
if (omitAfterQualifier != null && erroneousDescr.omitAfter != -1 && erroneousDescr.omitAfter < fieldIndex) {
final String message = MessageFormat.format("Field `{0}'' cannot be referenced because all fields after field `{1}'' have been omitted", actualFieldErr.qualifier.getDisplayName(), omitAfterQualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
final Indicator_Type actIndicator = actualFieldErr.errAttrSpec.getIndicator();
final boolean isOmit = actualFieldErr.errAttrSpec.isOmit();
if (actualFieldErr.subrefsArray.size() == level + 1) {
// erroneous value
if (actualFieldErr.typeArray.size() != level + 1) {
ErrorReporter.INTERNAL_ERROR();
return erroneousDescr;
}
if (fieldType.getTypetype() == Type_type.TYPE_ASN1_SET && isOmit && actIndicator != Indicator_Type.Value_Indicator) {
final String message = MessageFormat.format("Cannot omit all fields {0} `{1}'' which is a field of an ASN.1 SET type. " + "The order of fields in ASN.1 SET types changes depending on tagging (see X.690 9.3). " + "Fields can be omitted individually, independently of the field order which depends on tagging", actIndicator.getDisplayName(), actualFieldErr.qualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
switch(fieldType.getTypetypeTtcn3()) {
case TYPE_TTCN3_CHOICE:
if (actIndicator != Indicator_Type.Value_Indicator) {
final String message = MessageFormat.format("Indicator `{0}'' cannot be used with reference `{1}'' which points to a field of a union type", actIndicator.getDisplayName(), actualFieldErr.qualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
break;
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
if (isOmit && actIndicator == Indicator_Type.After_Indicator) {
int lastFieldIndex;
switch(fieldType.getTypetype()) {
case TYPE_ASN1_SEQUENCE:
lastFieldIndex = ((ASN1_Sequence_Type) fieldType).getNofComponents(timestamp) - 1;
break;
case TYPE_ASN1_SET:
lastFieldIndex = ((ASN1_Set_Type) fieldType).getNofComponents(timestamp) - 1;
break;
default:
lastFieldIndex = ((TTCN3_Set_Seq_Choice_BaseType) fieldType).getNofComponents() - 1;
}
if (fieldIndex == lastFieldIndex) {
final String message = MessageFormat.format("There is nothing to omit after the last field ({0}) of a record/set type", actualFieldErr.qualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
}
// $FALL-THROUGH$
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
if (isOmit && actIndicator == Indicator_Type.Before_Indicator && fieldIndex == 0) {
actualFieldErr.qualifier.getLocation().reportSemanticError(MessageFormat.format("There is nothing to omit before the first field ({0})", actualFieldErr.qualifier.getDisplayName()));
continue;
}
break;
default:
break;
}
// check for duplicate value+indicator
if (erroneousDescr.valuesMap.containsKey(fieldIndex)) {
final ErroneousValues evs = erroneousDescr.valuesMap.get(fieldIndex);
if ((evs.before != null && actIndicator == Indicator_Type.Before_Indicator) || (evs.value != null && actIndicator == Indicator_Type.Value_Indicator) || (evs.after != null && actIndicator == Indicator_Type.After_Indicator)) {
actualFieldErr.qualifier.getLocation().reportSemanticError(MessageFormat.format("Duplicate reference to field `{0}'' with indicator `{1}''", actualFieldErr.qualifier.getDisplayName(), actIndicator.getDisplayName()));
continue;
}
}
// values were used
if (actIndicator == Indicator_Type.Value_Indicator && embeddedFieldArrayMap.containsKey(fieldIndex)) {
final String message = MessageFormat.format("Reference to field `{0}'' with indicator `value'' would invalidate previously specified erroneous data", actualFieldErr.qualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
// duplication of omit before/after rule
if (actIndicator == Indicator_Type.Before_Indicator && isOmit) {
if (omitBeforeQualifier != null && erroneousDescr.omitBefore != -1) {
final String message = MessageFormat.format("Duplicate rule for omitting all fields before the specified field. " + "Used on field `{0}'' but previously already used on field `{1}''", actualFieldErr.qualifier.getDisplayName(), omitBeforeQualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
boolean isInvalid = false;
for (Integer idx : erroneousDescr.valuesMap.keySet()) {
if (idx < fieldIndex) {
isInvalid = true;
break;
}
}
if (!isInvalid) {
for (Integer idx : embeddedFieldArrayMap.keySet()) {
if (idx < fieldIndex) {
isInvalid = true;
break;
}
}
}
if (isInvalid) {
final String message = MessageFormat.format("Omitting fields before field `{0}'' would invalidate previously specified erroneous data", actualFieldErr.qualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
// save valid omit before data
omitBeforeQualifier = actualFieldErr.qualifier;
erroneousDescr.omitBefore = fieldIndex;
erroneousDescr.omitBeforeName = omitBeforeQualifier.getDisplayName();
continue;
}
if (actIndicator == Indicator_Type.After_Indicator && isOmit) {
if (omitAfterQualifier != null && erroneousDescr.omitAfter != -1) {
final String message = MessageFormat.format("Duplicate rule for omitting all fields after the specified field. " + "Used on field `{0}'' but previously already used on field `{1}''", actualFieldErr.qualifier.getDisplayName(), omitAfterQualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
boolean isInvalid = false;
for (Integer idx : erroneousDescr.valuesMap.keySet()) {
if (idx > fieldIndex) {
isInvalid = true;
break;
}
}
if (!isInvalid) {
for (Integer idx : embeddedFieldArrayMap.keySet()) {
if (idx > fieldIndex) {
isInvalid = true;
break;
}
}
}
if (isInvalid) {
final String message = MessageFormat.format("Omitting fields after field `{0}'' would invalidate previously specified erroneous data", actualFieldErr.qualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
// save valid omit after data
omitAfterQualifier = actualFieldErr.qualifier;
erroneousDescr.omitAfter = fieldIndex;
erroneousDescr.omitAfterName = omitAfterQualifier.getDisplayName();
continue;
}
// if not before/after omit then save this into
// values_m
final boolean hasKey = erroneousDescr.valuesMap.containsKey(fieldIndex);
final ErroneousValues evs = hasKey ? erroneousDescr.valuesMap.get(fieldIndex) : new ErroneousValues(actualFieldErr.qualifier.getDisplayName());
switch(actIndicator) {
case Before_Indicator:
evs.before = actualFieldErr.errAttrSpec;
break;
case Value_Indicator:
evs.value = actualFieldErr.errAttrSpec;
break;
case After_Indicator:
evs.after = actualFieldErr.errAttrSpec;
break;
default:
ErrorReporter.INTERNAL_ERROR();
}
if (!hasKey) {
erroneousDescr.valuesMap.put(fieldIndex, evs);
}
} else {
// embedded err.value
if (erroneousDescr.valuesMap.containsKey(fieldIndex) && erroneousDescr.valuesMap.get(fieldIndex).value != null) {
final String message = MessageFormat.format("Field `{0}'' is embedded into a field which was previously overwritten or omitted", actualFieldErr.qualifier.getDisplayName());
actualFieldErr.qualifier.getLocation().reportSemanticError(message);
continue;
}
// add the embedded field to the map
final boolean hasIndex = embeddedFieldArrayMap.containsKey(fieldIndex);
final List<FieldErr_Type> embeddedFieldArray = hasIndex ? embeddedFieldArrayMap.get(fieldIndex) : new ArrayList<FieldErr_Type>(1);
embeddedFieldArray.add(actualFieldErr);
if (!hasIndex) {
embeddedFieldArrayMap.put(fieldIndex, embeddedFieldArray);
}
}
}
// recursive calls to create embedded descriptors
for (Integer idx : embeddedFieldArrayMap.keySet()) {
erroneousDescr.descriptorMap.put(idx, buildErroneousDescriptorTree(timestamp, embeddedFieldArrayMap.get(idx), level + 1));
}
return erroneousDescr;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType in project titan.EclipsePlug-ins by eclipse.
the class Type method checkThisVariant.
@Override
public /**
* {@inheritDoc}
*/
void checkThisVariant(final CompilationTimeStamp timestamp, final SingleWithAttribute singleWithAttribute, final boolean global) {
final IType type = getTypeWithCodingTable(timestamp, false);
if (type == null) {
// FIXME as only RAW is supported for now, we can not report this error
// if (!global) {
// singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("No encoding rules defined for type `{0}''", getTypename()));
// }
} else {
final List<String> codingStrings = singleWithAttribute.getAttributeSpecification().getEncodings();
// gather the built-in codecs referred to by the variant's encoding strings
final ArrayList<MessageEncoding_type> codings = new ArrayList<IType.MessageEncoding_type>();
boolean erroneous = false;
if (codingStrings == null) {
if (type.getCodingTable().size() > 1) {
if (!global) {
singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("The encoding reference is mandatory for variant attributes of type `{0}''", getTypename()));
}
erroneous = true;
} else if (type.getCodingTable().get(0).builtIn) {
codings.add(type.getCodingTable().get(0).builtInCoding);
} else {
// PER or custom encoding
final MessageEncoding_type coding = "PER".equals(type.getCodingTable().get(0).customCoding.name) ? MessageEncoding_type.PER : MessageEncoding_type.CUSTOM;
singleWithAttribute.getLocation().reportSemanticWarning(MessageFormat.format("Variant attributes related to `{0}'' encoding are ignored", coding.getEncodingName()));
}
} else {
for (int i = 0; i < codingStrings.size(); i++) {
final String encodingString = codingStrings.get(i);
final MessageEncoding_type coding = getEncodingType(encodingString);
if (!hasEncoding(timestamp, coding, encodingString)) {
erroneous = true;
// FIXME RAW restriction only exists because that is the only supported encoding right now
if (!global && coding == MessageEncoding_type.RAW) {
if (coding == MessageEncoding_type.CUSTOM) {
singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not support {1} encoding", getTypename(), coding.getEncodingName()));
} else {
singleWithAttribute.getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not support custom encoding `{1}''", getTypename(), encodingString));
}
}
} else if (coding != MessageEncoding_type.PER && coding != MessageEncoding_type.CUSTOM) {
codings.add(coding);
} else {
// PER or custom encoding
singleWithAttribute.getLocation().reportSemanticWarning(MessageFormat.format("Variant attributes related to {0} encoding are ignored", coding.getEncodingName()));
}
}
}
// FIXME implement checks
// TODO only raw data is extracted
final VariantAttributeAnalyzer analyzer = new VariantAttributeAnalyzer();
boolean newRaw = false;
final AtomicBoolean rawFoud = new AtomicBoolean(false);
if (rawAttribute == null) {
IType t_refd = this;
while (t_refd.getRawAttribute() == null && t_refd instanceof Referenced_Type) {
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
t_refd = ((Referenced_Type) t_refd).getTypeRefd(timestamp, referenceChain);
referenceChain.release();
}
rawAttribute = new RawAST(t_refd.getRawAttribute(), getDefaultRawFieldLength());
newRaw = true;
}
analyzer.parse(rawAttribute, singleWithAttribute.getAttributeSpecification(), getLengthMultiplier(), rawFoud);
if (!rawFoud.get() && newRaw) {
rawAttribute = null;
}
}
if (global) {
// send global variant attributes to field/element types
switch(getTypetype()) {
case TYPE_TTCN3_CHOICE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
for (int i = 0; i < ((TTCN3_Set_Seq_Choice_BaseType) this).getNofComponents(); i++) {
((TTCN3_Set_Seq_Choice_BaseType) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_ASN1_CHOICE:
case TYPE_ASN1_SEQUENCE:
case TYPE_ASN1_SET:
for (int i = 0; i < ((ASN1_Set_Seq_Choice_BaseType) this).getNofComponents(timestamp); i++) {
((ASN1_Set_Seq_Choice_BaseType) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_ANYTYPE:
for (int i = 0; i < ((Anytype_Type) this).getNofComponents(); i++) {
((Anytype_Type) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_OPENTYPE:
for (int i = 0; i < ((Open_Type) this).getNofComponents(); i++) {
((Open_Type) this).getComponentByIndex(i).getType().checkThisVariant(timestamp, singleWithAttribute, global);
}
break;
case TYPE_ARRAY:
((Array_Type) this).getElementType().checkThisVariant(timestamp, singleWithAttribute, global);
break;
case TYPE_SEQUENCE_OF:
((SequenceOf_Type) this).getOfType().checkThisVariant(timestamp, singleWithAttribute, global);
break;
case TYPE_SET_OF:
((SetOf_Type) this).getOfType().checkThisVariant(timestamp, singleWithAttribute, global);
break;
default:
break;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Choice_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);
}
final boolean hasRaw = getGenerateCoderFunctions(MessageEncoding_type.RAW);
RawASTStruct raw = null;
if (hasRaw) {
RawAST dummy_raw;
if (rawAttribute == null) {
dummy_raw = new RawAST(getDefaultRawFieldLength());
} else {
dummy_raw = rawAttribute;
}
raw = new RawASTStruct(dummy_raw);
// building taglist
final int taglistSize = dummy_raw.taglist == null ? 0 : dummy_raw.taglist.size();
for (int c = 0; c < taglistSize; c++) {
final rawAST_single_tag singleTag = dummy_raw.taglist.get(c);
final rawAST_coding_taglist codingSingleTag = raw.taglist.list.get(c);
if (singleTag.keyList != null) {
codingSingleTag.fields = new ArrayList<RawASTStruct.rawAST_coding_field_list>(singleTag.keyList.size());
}
codingSingleTag.fieldname = singleTag.fieldName.getName();
codingSingleTag.varName = FieldSubReference.getJavaGetterName(codingSingleTag.fieldname);
final Identifier idf = singleTag.fieldName;
codingSingleTag.fieldnum = getComponentIndexByName(idf);
final int keyListSize = singleTag.keyList == null ? 0 : singleTag.keyList.size();
for (int a = 0; a < keyListSize; a++) {
final rawAST_tag_field_value key = singleTag.keyList.get(a);
final RawASTStruct.rawAST_coding_field_list codingKey = new RawASTStruct.rawAST_coding_field_list();
codingSingleTag.fields.add(codingKey);
codingKey.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(key.keyField.names.size());
// codingKey.value = key.value;
final ExpressionStruct expression = new ExpressionStruct();
key.v_value.generateCodeExpression(aData, expression, true);
codingKey.expression = expression;
codingKey.isOmitValue = key.v_value.getValuetype() == Value_type.OMIT_VALUE;
codingKey.start_pos = 0;
final CompField cf = getComponentByIndex(codingSingleTag.fieldnum);
IType t = cf.getType().getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
final RawASTStruct.rawAST_coding_fields tempField = new rawAST_coding_fields();
tempField.nthfield = codingSingleTag.fieldnum;
tempField.nthfieldname = singleTag.fieldName.getName();
tempField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
tempField.type = t.getGenNameValue(aData, source, myScope);
tempField.typedesc = t.getGenNameTypeDescriptor(aData, source, myScope);
codingKey.fields.add(tempField);
for (int b = 0; b < key.keyField.names.size(); b++) {
final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
codingKey.fields.add(newField);
final Identifier idf2 = key.keyField.names.get(b);
int comp_index = 0;
CompField cf2;
switch(t.getTypetype()) {
case TYPE_TTCN3_CHOICE:
comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
break;
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
if (cf2.isOptional()) {
newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
} else {
newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
}
break;
default:
// internal error
return;
}
final IType field_type = cf2.getType();
newField.type = field_type.getGenNameValue(aData, source, myScope);
newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
if (field_type.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE && ((TTCN3_Sequence_Type) field_type).rawAttribute != null && (((TTCN3_Sequence_Type) field_type).rawAttribute.pointerto == null || ((TTCN3_Sequence_Type) field_type).rawAttribute.lengthto != null)) {
codingKey.start_pos = -1;
}
if (t.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE) {
IType t2;
for (int i = 0; i < comp_index && codingKey.start_pos >= 0; i++) {
t2 = ((TTCN3_Sequence_Type) t).getComponentByIndex(i).getType();
if (t2.getRawLength() >= 0) {
if (((Type) t2).rawAttribute != null) {
codingKey.start_pos += ((Type) t2).rawAttribute.padding;
}
codingKey.start_pos += ((Type) t2).getRawLength();
} else {
codingKey.start_pos = -1;
}
}
}
t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
}
}
}
}
UnionGenerator.generateValueClass(aData, source, genName, displayName, fieldInfos, hasOptional, hasRaw, raw);
UnionGenerator.generateTemplateClass(aData, source, genName, displayName, fieldInfos, hasOptional);
if (hasDoneAttribute()) {
generateCodeDone(aData, source);
}
if (subType != null) {
subType.generateCode(aData, source);
}
generateCodeForCodingHandlers(aData, source);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Set_Seq_Choice_BaseType in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Set_Seq_Choice_BaseType method convertRAWCodingAttributes.
// FIXME comment
protected RawASTStruct convertRAWCodingAttributes(final JavaGenData aData, final StringBuilder source, final boolean hasRaw, final List<FieldInfo> namesList) {
RawASTStruct raw = null;
if (hasRaw) {
RawAST dummy_raw;
if (rawAttribute == null) {
dummy_raw = new RawAST(getDefaultRawFieldLength());
} else {
dummy_raw = rawAttribute;
}
raw = new RawASTStruct(dummy_raw);
// building taglist
final int taglistSize = dummy_raw.taglist == null ? 0 : dummy_raw.taglist.size();
for (int c = 0; c < taglistSize; c++) {
final rawAST_single_tag singleTag = dummy_raw.taglist.get(c);
final rawAST_coding_taglist codingSingleTag = raw.taglist.list.get(c);
if (singleTag.keyList != null) {
codingSingleTag.fields = new ArrayList<RawASTStruct.rawAST_coding_field_list>(singleTag.keyList.size());
}
codingSingleTag.fieldname = singleTag.fieldName.getName();
codingSingleTag.varName = FieldSubReference.getJavaGetterName(codingSingleTag.fieldname);
final Identifier idf = singleTag.fieldName;
codingSingleTag.fieldnum = getComponentIndexByName(idf);
final int keyListSize = singleTag.keyList == null ? 0 : singleTag.keyList.size();
for (int a = 0; a < keyListSize; a++) {
final rawAST_tag_field_value key = singleTag.keyList.get(a);
final RawASTStruct.rawAST_coding_field_list codingKey = new RawASTStruct.rawAST_coding_field_list();
codingSingleTag.fields.add(codingKey);
codingKey.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(key.keyField.names.size());
// codingKey.value = key.value;
final ExpressionStruct expression = new ExpressionStruct();
key.v_value.generateCodeExpression(aData, expression, true);
codingKey.expression = expression;
codingKey.isOmitValue = key.v_value.getValuetype() == Value_type.OMIT_VALUE;
codingKey.start_pos = 0;
final CompField cf = getComponentByIndex(codingSingleTag.fieldnum);
IType t = cf.getType().getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
final RawASTStruct.rawAST_coding_fields tempField = new rawAST_coding_fields();
tempField.nthfield = codingSingleTag.fieldnum;
tempField.nthfieldname = singleTag.fieldName.getName();
tempField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
tempField.type = t.getGenNameValue(aData, source, myScope);
tempField.typedesc = t.getGenNameTypeDescriptor(aData, source, myScope);
if (cf.isOptional()) {
tempField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
} else {
tempField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
}
codingKey.fields.add(tempField);
for (int b = 0; b < key.keyField.names.size(); b++) {
final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
codingKey.fields.add(newField);
final Identifier idf2 = key.keyField.names.get(b);
int comp_index = 0;
CompField cf2;
switch(t.getTypetype()) {
case TYPE_TTCN3_CHOICE:
comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
break;
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
if (cf2.isOptional()) {
newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
} else {
newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
}
break;
default:
// internal error
return null;
}
final IType field_type = cf2.getType();
newField.type = field_type.getGenNameValue(aData, source, myScope);
newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
if (field_type.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE && ((TTCN3_Sequence_Type) field_type).rawAttribute != null && (((TTCN3_Sequence_Type) field_type).rawAttribute.pointerto == null || ((TTCN3_Sequence_Type) field_type).rawAttribute.lengthto != null)) {
codingKey.start_pos = -1;
}
if (t.getTypetype() == Type_type.TYPE_TTCN3_SEQUENCE) {
IType t2;
for (int i = 0; i < comp_index && codingKey.start_pos >= 0; i++) {
t2 = ((TTCN3_Sequence_Type) t).getComponentByIndex(i).getType();
if (t2.getRawLength() >= 0) {
if (((Type) t2).rawAttribute != null) {
codingKey.start_pos += ((Type) t2).rawAttribute.padding;
}
codingKey.start_pos += ((Type) t2).getRawLength();
} else {
codingKey.start_pos = -1;
}
}
}
t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
}
}
}
// building presence list
final int presenceListSize = dummy_raw.presence == null || dummy_raw.presence.keyList == null ? 0 : dummy_raw.presence.keyList.size();
for (int a = 0; a < presenceListSize; a++) {
final rawAST_tag_field_value fieldValue = dummy_raw.presence.keyList.get(a);
final rawAST_coding_field_list presences = new rawAST_coding_field_list();
raw.presence.fields.add(presences);
final ExpressionStruct expression = new ExpressionStruct();
fieldValue.v_value.generateCodeExpression(aData, expression, true);
presences.expression = expression;
presences.isOmitValue = fieldValue.v_value.getValuetype() == Value_type.OMIT_VALUE;
final int keySize = fieldValue.keyField == null || fieldValue.keyField.names == null ? 0 : fieldValue.keyField.names.size();
presences.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(keySize);
IType t = this;
for (int b = 0; b < keySize; b++) {
final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
presences.fields.add(newField);
final Identifier idf2 = fieldValue.keyField.names.get(b);
int comp_index = 0;
CompField cf2;
switch(t.getTypetype()) {
case TYPE_TTCN3_CHOICE:
comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
break;
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
if (cf2.isOptional()) {
newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
} else {
newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
}
break;
default:
// internal error
return null;
}
final IType field_type = cf2.getType();
newField.type = field_type.getGenNameValue(aData, source, myScope);
newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
}
}
final int extBiGroupSize = dummy_raw.ext_bit_groups == null ? 0 : dummy_raw.ext_bit_groups.size();
for (int c = 0; c < extBiGroupSize; c++) {
final rawAST_ext_bit_group tempGroup = dummy_raw.ext_bit_groups.get(c);
final Identifier idf = tempGroup.from;
final Identifier idf2 = tempGroup.to;
final rawAST_coding_ext_group codingGroup = new rawAST_coding_ext_group();
raw.ext_bit_groups.add(codingGroup);
codingGroup.ext_bit = tempGroup.ext_bit;
codingGroup.from = getComponentIndexByName(idf);
codingGroup.to = getComponentIndexByName(idf2);
}
for (int i = 0; i < getNofComponents(); i++) {
final FieldInfo element_i = namesList.get(i);
final CompField cf = getComponentByIndex(i);
final IType t_field = cf.getType();
final IType t_field_last = t_field.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
final RawAST rawpar = t_field.getRawAttribute();
if (rawpar != null) {
element_i.raw = new RawASTStruct(rawpar);
final int lengthtoNum = rawpar.lengthto == null ? 0 : rawpar.lengthto.size();
for (int j = 0; j < lengthtoNum; j++) {
final Identifier idf = rawpar.lengthto.get(j);
element_i.raw.lengthto.add(getComponentIndexByName(idf));
}
if (lengthtoNum > 0 && rawpar.lengthindex != null) {
final Identifier idf = rawpar.lengthindex.names.get(0);
int comp_index = 0;
CompField cf2;
switch(t_field_last.getTypetype()) {
case TYPE_TTCN3_CHOICE:
comp_index = ((TTCN3_Choice_Type) t_field_last).getComponentIndexByName(idf);
cf2 = ((TTCN3_Choice_Type) t_field_last).getComponentByIndex(comp_index);
element_i.raw.lengthindex.nthfield = comp_index;
element_i.raw.lengthindex.nthfieldname = idf.getName();
break;
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentIndexByName(idf);
cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentByIndex(comp_index);
element_i.raw.lengthindex.nthfield = comp_index;
element_i.raw.lengthindex.nthfieldname = idf.getName();
break;
default:
// internal error
return null;
}
final Type t_field2 = cf2.getType();
if (t_field2.getTypetype() == Type_type.TYPE_TTCN3_CHOICE) {
element_i.raw.lengthindex.fieldtype = rawAST_coding_field_type.UNION_FIELD;
} else if (cf2.isOptional()) {
element_i.raw.lengthindex.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
} else {
element_i.raw.lengthindex.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
}
element_i.raw.lengthindex.type = t_field2.getGenNameValue(aData, source, myScope);
element_i.raw.lengthindex.typedesc = t_field2.getGenNameTypeDescriptor(aData, source, myScope);
}
if (lengthtoNum > 0 && rawpar.lengthindex == null) {
switch(t_field_last.getTypetype()) {
case TYPE_TTCN3_CHOICE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
final int componentsNumber = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getNofComponents();
element_i.raw.union_member_num = componentsNumber;
element_i.raw.member_name = new ArrayList<String>(componentsNumber + 1);
element_i.raw.member_name.add(t_field_last.getGenNameValue(aData, source, myScope));
for (int m = 1; m < componentsNumber + 1; m++) {
final CompField compf = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentByIndex(m - 1);
element_i.raw.member_name.add(compf.getIdentifier().getName());
}
break;
default:
break;
}
}
if (rawpar.pointerto != null) {
final Identifier idf = rawpar.pointerto;
element_i.raw.pointerto = getComponentIndexByName(idf);
if (rawpar.ptrbase != null) {
final Identifier idf2 = rawpar.ptrbase;
element_i.raw.pointerbase = getComponentIndexByName(idf2);
} else {
element_i.raw.pointerbase = i;
}
}
// building presence list
final int parPresenceListSize = rawpar.presence == null || rawpar.presence.keyList == null ? 0 : rawpar.presence.keyList.size();
for (int a = 0; a < parPresenceListSize; a++) {
final rawAST_coding_field_list presences = new rawAST_coding_field_list();
element_i.raw.presence.fields.add(presences);
final rawAST_tag_field_value fieldValue = rawpar.presence.keyList.get(a);
final ExpressionStruct expression = new ExpressionStruct();
fieldValue.v_value.generateCodeExpression(aData, expression, true);
presences.expression = expression;
presences.isOmitValue = fieldValue.v_value.getValuetype() == Value_type.OMIT_VALUE;
presences.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(fieldValue.keyField.names.size());
IType t = this;
for (int b = 0; b < fieldValue.keyField.names.size(); b++) {
final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
presences.fields.add(newField);
final Identifier idf2 = fieldValue.keyField.names.get(b);
int comp_index = 0;
CompField cf2;
switch(t.getTypetype()) {
case TYPE_TTCN3_CHOICE:
comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
break;
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
if (cf2.isOptional()) {
newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
} else {
newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
}
break;
default:
// internal error
return null;
}
final IType field_type = cf2.getType();
newField.type = field_type.getGenNameValue(aData, source, myScope);
newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
}
}
// building crosstaglist
final int crossTaglistSize = rawpar.crosstaglist == null ? 0 : rawpar.crosstaglist.size();
for (int c = 0; c < crossTaglistSize; c++) {
final rawAST_single_tag singleTag = rawpar.crosstaglist.get(c);
final rawAST_coding_taglist codingSingleTag = element_i.raw.crosstaglist.list.get(c);
if (singleTag.keyList != null) {
codingSingleTag.fields = new ArrayList<RawASTStruct.rawAST_coding_field_list>(singleTag.keyList.size());
}
codingSingleTag.fieldname = singleTag.fieldName.getName();
codingSingleTag.varName = FieldSubReference.getJavaGetterName(codingSingleTag.fieldname);
final Identifier idf = singleTag.fieldName;
switch(t_field_last.getTypetype()) {
case TYPE_TTCN3_CHOICE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
codingSingleTag.fieldnum = ((TTCN3_Set_Seq_Choice_BaseType) t_field_last).getComponentIndexByName(idf);
break;
case TYPE_ASN1_CHOICE:
codingSingleTag.fieldnum = ((ASN1_Set_Seq_Choice_BaseType) t_field_last).getComponentIndexByName(idf);
break;
default:
codingSingleTag.fieldnum = -1;
break;
}
final int keyListSize = singleTag.keyList == null ? 0 : singleTag.keyList.size();
for (int a = 0; a < keyListSize; a++) {
final rawAST_tag_field_value key = singleTag.keyList.get(a);
final RawASTStruct.rawAST_coding_field_list codingKey = new RawASTStruct.rawAST_coding_field_list();
codingSingleTag.fields.add(codingKey);
codingKey.fields = new ArrayList<RawASTStruct.rawAST_coding_fields>(key.keyField.names.size());
final ExpressionStruct expression = new ExpressionStruct();
key.v_value.generateCodeExpression(aData, expression, true);
codingKey.expression = expression;
codingKey.isOmitValue = key.v_value.getValuetype() == Value_type.OMIT_VALUE;
IType t = this;
for (int b = 0; b < key.keyField.names.size(); b++) {
final RawASTStruct.rawAST_coding_fields newField = new rawAST_coding_fields();
codingKey.fields.add(newField);
final Identifier idf2 = key.keyField.names.get(b);
int comp_index = 0;
CompField cf2;
switch(t.getTypetype()) {
case TYPE_TTCN3_CHOICE:
comp_index = ((TTCN3_Choice_Type) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Choice_Type) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
newField.fieldtype = rawAST_coding_field_type.UNION_FIELD;
break;
case TYPE_TTCN3_SEQUENCE:
case TYPE_TTCN3_SET:
comp_index = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentIndexByName(idf2);
cf2 = ((TTCN3_Set_Seq_Choice_BaseType) t).getComponentByIndex(comp_index);
newField.nthfield = comp_index;
newField.nthfieldname = idf2.getName();
if (cf2.isOptional()) {
newField.fieldtype = rawAST_coding_field_type.OPTIONAL_FIELD;
} else {
newField.fieldtype = rawAST_coding_field_type.MANDATORY_FIELD;
}
break;
default:
// internal error
return null;
}
final IType field_type = cf2.getType();
newField.type = field_type.getGenNameValue(aData, source, myScope);
newField.typedesc = field_type.getGenNameTypeDescriptor(aData, source, myScope);
t = field_type.getTypeRefdLast(CompilationTimeStamp.getBaseTimestamp());
}
}
}
element_i.raw.length = t_field.getRawLength();
element_i.hasRaw = true;
} else {
element_i.hasRaw = false;
}
}
}
return raw;
}
Aggregations