use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type in project titan.EclipsePlug-ins by eclipse.
the class TableConstraint method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
parseBlocks();
if (null == myType) {
return;
}
objectSet.setMyScope(myType.getMyScope());
BridgingNamedNode bridge = new BridgingNamedNode(this, FULLNAMEPART);
objectSet.setFullNameParent(bridge);
// search the constrained type (not the reference to it)
constrainedType = myType;
while (true) {
if (constrainedType.getIsErroneous(timestamp)) {
return;
}
if (Type_type.TYPE_OPENTYPE.equals(constrainedType.getTypetype()) || Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(constrainedType.getTypetype())) {
break;
} else if (constrainedType instanceof IReferencingType) {
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
constrainedType = ((IReferencingType) constrainedType).getTypeRefd(timestamp, chain);
chain.release();
} else {
myType.getLocation().reportSemanticError(OCFTEXPECTED);
return;
}
}
if (Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(constrainedType.getTypetype())) {
ObjectClassField_Type ocfType = (ObjectClassField_Type) constrainedType;
objectClassFieldname = ocfType.getObjectClassFieldName();
objectSet.setMyGovernor(ocfType.getMyObjectClass());
objectSet.check(timestamp);
return;
}
// opentype
final Open_Type openType = (Open_Type) constrainedType;
openType.setMyTableConstraint(this);
objectClassFieldname = openType.getObjectClassFieldName();
objectSet.setMyGovernor(openType.getMyObjectClass());
objectSet.check(timestamp);
if (null == atNotationList) {
return;
}
// componentrelationconstraint...
// search the outermost textually enclosing seq, set or choice
IType outermostParent = null;
IType tempType = myType;
do {
switch(tempType.getTypetype()) {
case TYPE_ASN1_CHOICE:
case TYPE_TTCN3_CHOICE:
case TYPE_OPENTYPE:
case TYPE_ASN1_SEQUENCE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_ASN1_SET:
case TYPE_TTCN3_SET:
outermostParent = tempType;
break;
default:
break;
}
tempType = tempType.getParentType();
} while (null != tempType);
if (null == outermostParent) {
myType.getLocation().reportSemanticError(CANNOTDETERMINEPARENT);
return;
}
// outermostparent->set_opentype_outermost();
// TODO implement the setting of set_has_openType
AtNotation atNotation;
for (int i = 0; i < atNotationList.getNofAtNotations(); i++) {
atNotation = atNotationList.getAtNotationByIndex(i);
IType parent = null;
if (0 == atNotation.getLevels()) {
parent = outermostParent;
} else {
parent = myType;
for (int level = atNotation.getLevels(); level > 0; level--) {
parent = parent.getParentType();
if (null == parent) {
myType.getLocation().reportSemanticError(MessageFormat.format(TOOMANYDOTS, atNotation.getLevels()));
return;
}
}
}
tempType = parent;
atNotation.setFirstComponent(parent);
// component identifiers... do they exist? yes, if the refd type is constrained
FieldName componentIdentifiers = atNotation.getComponentIdentifiers();
for (int j = 0; j < componentIdentifiers.getNofFields(); j++) {
Identifier identifier = componentIdentifiers.getFieldByIndex(i);
switch(tempType.getTypetype()) {
case TYPE_ASN1_CHOICE:
{
final ASN1_Choice_Type temp2 = (ASN1_Choice_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_CHOICE:
{
final TTCN3_Choice_Type temp2 = (TTCN3_Choice_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_OPENTYPE:
{
final Open_Type temp2 = (Open_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_ASN1_SEQUENCE:
{
final ASN1_Sequence_Type temp2 = (ASN1_Sequence_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_SEQUENCE:
{
final TTCN3_Sequence_Type temp2 = (TTCN3_Sequence_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_ASN1_SET:
{
final ASN1_Set_Type temp2 = (ASN1_Set_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_SET:
{
final TTCN3_Set_Type temp2 = (TTCN3_Set_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
default:
myType.getLocation().reportSemanticError(MessageFormat.format(SECHOEXPECTED, tempType.getFullName()));
return;
}
}
atNotation.setLastComponent(tempType);
/*
* check if the referenced component is constrained by the same objectset...
*/
boolean ok = false;
final Constraints constraints = tempType.getConstraints();
if (constraints != null) {
constraints.check(timestamp);
final TableConstraint tableConstraint = constraints.getTableConstraint();
if (tableConstraint != null) {
IType ocft = tableConstraint.constrainedType;
if (Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(ocft.getTypetype())) {
atNotation.setObjectClassFieldname(((ObjectClassField_Type) ocft).getObjectClassFieldName());
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
ObjectSet_definition osdef1 = tableConstraint.objectSet.getRefdLast(timestamp, chain);
chain.release();
chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final ObjectSet_definition osdef2 = objectSet.getRefdLast(timestamp, chain);
chain.release();
if (osdef1 == osdef2) {
ok = true;
} else {
ok = false;
}
}
}
}
if (!ok) {
myType.getLocation().reportSemanticError(SAMECONSTRAINTEXPECTED);
return;
}
}
if (objectSet instanceof Referenced_ObjectSet) {
final Identifier objectSetId = ((Referenced_ObjectSet) objectSet).getId();
collectTypesOfOpenType(timestamp, objectSet, openType, objectSetId);
} else {
// TODO: is it posssible? Perhaps log error!
return;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type in project titan.EclipsePlug-ins by eclipse.
the class SelectUnionCase_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
if (expression == null) {
return;
}
IValue temp = expression.setLoweridToReference(timestamp);
final IType governor = temp.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (governor == null) {
if (!temp.getIsErroneous(timestamp)) {
expression.getLocation().reportSemanticError(UNDETERMINABLETYPE);
}
return;
}
temp = governor.checkThisValueRef(timestamp, expression);
governor.checkThisValue(timestamp, temp, null, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
// referenced type
final IType refd = governor.getTypeRefdLast(timestamp);
if (refd instanceof TTCN3_Choice_Type) {
// referenced union type to check
final TTCN3_Choice_Type unionType = (TTCN3_Choice_Type) refd;
checkUnionType(timestamp, unionType);
} else if (refd instanceof Anytype_Type) {
// referenced anytype type to check
final Anytype_Type anytypeType = (Anytype_Type) refd;
checkAnytypeType(timestamp, anytypeType);
} else {
expression.getLocation().reportSemanticError(TYPE_MUST_BE_UNION_OR_ANYTYPE);
// special operations to check the body of the cases even if the select expression is erroneous
for (int i = 0; i < selectUnionCases.getSize(); i++) {
selectUnionCases.getSelectUnionCase(i).checkStatementBlock(timestamp);
}
return;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Choice_Type method isCompatible.
@Override
public /**
* {@inheritDoc}
*/
boolean isCompatible(final CompilationTimeStamp timestamp, final IType otherType, final TypeCompatibilityInfo info, final TypeCompatibilityInfo.Chain leftChain, final TypeCompatibilityInfo.Chain rightChain) {
check(timestamp);
otherType.check(timestamp);
final IType temp = otherType.getTypeRefdLast(timestamp);
if (getIsErroneous(timestamp) || temp.getIsErroneous(timestamp) || this == temp) {
return true;
}
if (null == info || noStructuredTypeCompatibility) {
return this == temp;
}
switch(temp.getTypetype()) {
case TYPE_ASN1_CHOICE:
{
final ASN1_Choice_Type temporalType = (ASN1_Choice_Type) temp;
if (this == temporalType) {
return true;
}
TypeCompatibilityInfo.Chain lChain = leftChain;
TypeCompatibilityInfo.Chain rChain = rightChain;
if (null == lChain) {
lChain = info.getChain();
lChain.add(this);
}
if (null == rChain) {
rChain = info.getChain();
rChain.add(temporalType);
}
for (int i = 0, size = getNofComponents(timestamp); i < size; i++) {
final CompField cf = getComponentByIndex(i);
final IType cfType = cf.getType().getTypeRefdLast(timestamp);
for (int j = 0, size2 = temporalType.getNofComponents(timestamp); j < size2; j++) {
final CompField temporalCompField = temporalType.getComponentByIndex(j);
final IType tempTypeCompFieldType = temporalCompField.getType().getTypeRefdLast(timestamp);
if (!cf.getIdentifier().getDisplayName().equals(temporalCompField.getIdentifier().getDisplayName())) {
continue;
}
lChain.markState();
rChain.markState();
lChain.add(cfType);
rChain.add(tempTypeCompFieldType);
if (cfType.equals(tempTypeCompFieldType) || (lChain.hasRecursion() && rChain.hasRecursion()) || cfType.isCompatible(timestamp, tempTypeCompFieldType, info, lChain, rChain)) {
info.setNeedsConversion(true);
lChain.previousState();
rChain.previousState();
return true;
}
lChain.previousState();
rChain.previousState();
}
}
info.setErrorStr(MessageFormat.format(NOCOMPATIBLEFIELD, temp.getTypename(), getTypename()));
return false;
}
case TYPE_TTCN3_CHOICE:
{
final TTCN3_Choice_Type temporalType = (TTCN3_Choice_Type) temp;
TypeCompatibilityInfo.Chain lChain = leftChain;
TypeCompatibilityInfo.Chain rChain = rightChain;
if (lChain == null) {
lChain = info.getChain();
lChain.add(this);
}
if (rChain == null) {
rChain = info.getChain();
rChain.add(temporalType);
}
for (int i = 0, size = getNofComponents(timestamp); i < size; i++) {
final CompField cf = getComponentByIndex(i);
final IType compFieldType = cf.getType().getTypeRefdLast(timestamp);
for (int j = 0, size2 = temporalType.getNofComponents(); j < size2; j++) {
final CompField temporalCompField = temporalType.getComponentByIndex(j);
final IType tempTypeCompFieldType = temporalCompField.getType().getTypeRefdLast(timestamp);
if (!cf.getIdentifier().getDisplayName().equals(temporalCompField.getIdentifier().getDisplayName())) {
continue;
}
lChain.markState();
rChain.markState();
lChain.add(compFieldType);
rChain.add(tempTypeCompFieldType);
if (compFieldType.equals(tempTypeCompFieldType) || (lChain.hasRecursion() && rChain.hasRecursion()) || compFieldType.isCompatible(timestamp, tempTypeCompFieldType, info, lChain, rChain)) {
info.setNeedsConversion(true);
lChain.previousState();
rChain.previousState();
return true;
}
lChain.previousState();
rChain.previousState();
}
}
info.setErrorStr(MessageFormat.format(NOCOMPATIBLEFIELD, temp.getTypename(), getTypename()));
return false;
}
case TYPE_ASN1_SEQUENCE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_SEQUENCE_OF:
case TYPE_ARRAY:
case TYPE_ASN1_SET:
case TYPE_TTCN3_SET:
case TYPE_SET_OF:
case TYPE_ANYTYPE:
info.setErrorStr(NOTCOMPATIBLEUNION);
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type in project titan.EclipsePlug-ins by eclipse.
the class IsChoosenExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeoperandsChecked != null && !lastTimeoperandsChecked.isLess(timestamp)) {
return;
}
lastTimeoperandsChecked = timestamp;
value = null;
identifier = null;
if (reference == null || reference.getSubreferences().size() < 2) {
setIsErroneous(true);
return;
}
final Reference tempReference = reference.newInstance();
tempReference.setFullNameParent(this);
tempReference.setMyScope(getMyScope());
final ISubReference subreference = tempReference.removeLastSubReference();
if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType())) {
identifier = ((FieldSubReference) subreference).getId();
} else {
setIsErroneous(true);
return;
}
final Assignment assignment = tempReference.getRefdAssignment(timestamp, true);
if (assignment == null) {
setIsErroneous(true);
return;
}
IType governor;
switch(assignment.getAssignmentType()) {
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
{
value = new Referenced_Value(tempReference);
value.setLocation(tempReference.getLocation());
value.setMyScope(getMyScope());
final BridgingNamedNode tempNamedNode = new BridgingNamedNode(this, OPERAND);
value.setFullNameParent(tempNamedNode);
governor = value.getExpressionGovernor(timestamp, expectedValue);
if (governor == null) {
setIsErroneous(true);
} else {
value.setMyGovernor(governor);
final IValue tempValue2 = governor.checkThisValueRef(timestamp, value);
if (tempValue2.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
}
break;
}
case A_TEMPLATE:
case A_VAR_TEMPLATE:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
{
template = new Referenced_Template(tempReference);
template.setLocation(tempReference.getLocation());
template.setMyScope(getMyScope());
final BridgingNamedNode tempNamedNode = new BridgingNamedNode(this, OPERAND);
template.setFullNameParent(tempNamedNode);
if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) || Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
governor = template.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
} else {
governor = template.getExpressionGovernor(timestamp, expectedValue);
}
if (governor == null) {
setIsErroneous(true);
} else {
template.setMyGovernor(governor);
final TTCN3Template last = template.getTemplateReferencedLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
}
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue) && !Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(expectedValue)) {
template.getLocation().reportSemanticError(MessageFormat.format(CONSTANTREFERENCEEXPECTED, assignment.getDescription()));
} else {
template.getLocation().reportSemanticError(MessageFormat.format(STATICREFERENCEEXPECTED, assignment.getDescription()));
}
setIsErroneous(true);
}
break;
}
default:
tempReference.getLocation().reportSemanticError(MessageFormat.format(VALUETEMPLATEEXPECTED, assignment.getDescription()));
setIsErroneous(true);
return;
}
if (governor != null) {
governor = governor.getTypeRefdLast(timestamp);
if (!governor.getIsErroneous(timestamp)) {
CompField field = null;
switch(governor.getTypetype()) {
case TYPE_ASN1_CHOICE:
if (((ASN1_Choice_Type) governor).hasComponentWithName(identifier)) {
field = ((ASN1_Choice_Type) governor).getComponentByName(identifier);
}
break;
case TYPE_TTCN3_CHOICE:
if (((TTCN3_Choice_Type) governor).hasComponentWithName(identifier.getName())) {
field = ((TTCN3_Choice_Type) governor).getComponentByName(identifier.getName());
}
break;
case TYPE_OPENTYPE:
if (((Open_Type) governor).hasComponentWithName(identifier)) {
field = ((Open_Type) governor).getComponentByName(identifier);
}
break;
case TYPE_ANYTYPE:
if (((Anytype_Type) governor).hasComponentWithName(identifier.getName())) {
field = ((Anytype_Type) governor).getComponentByName(identifier.getName());
}
break;
default:
location.reportSemanticError(MessageFormat.format(OPERANDERROR, governor.getTypename()));
setIsErroneous(true);
return;
}
if (null == field) {
location.reportSemanticError(MessageFormat.format(MISSINGFIELD, governor.getTypename(), identifier.getDisplayName()));
setIsErroneous(true);
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.TTCN3_Choice_Type 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);
}
Aggregations