use of org.eclipse.titan.designer.AST.TTCN3.types.CompField 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);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_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 (info == null || noStructuredTypeCompatibility) {
return this == temp;
}
switch(temp.getTypetype()) {
case TYPE_ASN1_SET:
{
final ASN1_Set_Type tempType = (ASN1_Set_Type) temp;
if (this == tempType) {
return true;
}
if (getNofComponents(timestamp) != tempType.getNofComponents(timestamp)) {
info.setErrorStr(NOFFIELDSDONTMATCH);
return false;
}
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(tempType);
}
for (int i = 0, size = getNofComponents(timestamp); i < size; i++) {
final CompField cf = getComponentByIndex(i);
final CompField tempTypeCompField = tempType.getComponentByIndex(i);
final IType compFieldType = cf.getType().getTypeRefdLast(timestamp);
final IType tempTypeCompFieldType = tempTypeCompField.getType().getTypeRefdLast(timestamp);
if (cf.isOptional() != tempTypeCompField.isOptional()) {
final String compFieldName = cf.getIdentifier().getDisplayName();
final String tempTypeCompFieldName = tempTypeCompField.getIdentifier().getDisplayName();
info.appendOp1Ref("." + compFieldName);
info.appendOp2Ref("." + tempTypeCompFieldName);
info.setOp1Type(compFieldType);
info.setOp2Type(tempTypeCompFieldType);
info.setErrorStr(BADOPTIONALITY);
return false;
}
lChain.markState();
rChain.markState();
lChain.add(compFieldType);
rChain.add(tempTypeCompFieldType);
final TypeCompatibilityInfo infoTemp = new TypeCompatibilityInfo(compFieldType, tempTypeCompFieldType, false);
if (!compFieldType.equals(tempTypeCompFieldType) && !(lChain.hasRecursion() && rChain.hasRecursion()) && !compFieldType.isCompatible(timestamp, tempTypeCompFieldType, infoTemp, lChain, rChain)) {
final String compFieldName = cf.getIdentifier().getDisplayName();
final String tempTypeCompFieldName = tempTypeCompField.getIdentifier().getDisplayName();
info.appendOp1Ref("." + compFieldName + infoTemp.getOp1RefStr());
info.appendOp2Ref("." + tempTypeCompFieldName + infoTemp.getOp2RefStr());
info.setOp1Type(infoTemp.getOp1Type());
info.setOp2Type(infoTemp.getOp2Type());
info.setErrorStr(infoTemp.getErrorStr());
lChain.previousState();
rChain.previousState();
return false;
}
lChain.previousState();
rChain.previousState();
}
info.setNeedsConversion(true);
return true;
}
case TYPE_TTCN3_SET:
{
final TTCN3_Set_Type tempType = (TTCN3_Set_Type) temp;
if (getNofComponents(timestamp) != tempType.getNofComponents()) {
info.setErrorStr(NOFFIELDSDONTMATCH);
return false;
}
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(tempType);
}
for (int i = 0, size = getNofComponents(timestamp); i < size; i++) {
final CompField compField = getComponentByIndex(i);
final CompField tempTypeCompField = tempType.getComponentByIndex(i);
final IType compFieldType = compField.getType().getTypeRefdLast(timestamp);
final IType tempTypeCompFieldType = tempTypeCompField.getType().getTypeRefdLast(timestamp);
if (compField.isOptional() != tempTypeCompField.isOptional()) {
final String compFieldName = compField.getIdentifier().getDisplayName();
final String tempTypeCompFieldName = tempTypeCompField.getIdentifier().getDisplayName();
info.appendOp1Ref("." + compFieldName);
info.appendOp2Ref("." + tempTypeCompFieldName);
info.setOp1Type(compFieldType);
info.setOp2Type(tempTypeCompFieldType);
info.setErrorStr(BADOPTIONALITY);
return false;
}
lChain.markState();
rChain.markState();
lChain.add(compFieldType);
rChain.add(tempTypeCompFieldType);
final TypeCompatibilityInfo infoTemp = new TypeCompatibilityInfo(compFieldType, tempTypeCompFieldType, false);
if (!compFieldType.equals(tempTypeCompFieldType) && !(lChain.hasRecursion() && rChain.hasRecursion()) && !compFieldType.isCompatible(timestamp, tempTypeCompFieldType, infoTemp, lChain, rChain)) {
final String compFieldName = compField.getIdentifier().getDisplayName();
final String tempTypeCompFieldName = tempTypeCompField.getIdentifier().getDisplayName();
info.appendOp1Ref("." + compFieldName + infoTemp.getOp1RefStr());
info.appendOp2Ref("." + tempTypeCompFieldName + infoTemp.getOp2RefStr());
info.setOp1Type(infoTemp.getOp1Type());
info.setOp2Type(infoTemp.getOp2Type());
info.setErrorStr(infoTemp.getErrorStr());
lChain.previousState();
rChain.previousState();
return false;
}
lChain.previousState();
rChain.previousState();
}
info.setNeedsConversion(true);
return true;
}
case TYPE_SET_OF:
{
final SetOf_Type tempType = (SetOf_Type) temp;
if (!tempType.isSubtypeCompatible(timestamp, this)) {
info.setErrorStr("Incompatible set of/SET OF subtypes");
return false;
}
final int nofComps = getNofComponents(timestamp);
if (nofComps == 0) {
return false;
}
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(tempType);
}
for (int i = 0; i < nofComps; i++) {
final CompField compField = getComponentByIndex(i);
final IType compFieldType = compField.getType().getTypeRefdLast(timestamp);
final IType temporalTypeOfType = tempType.getOfType().getTypeRefdLast(timestamp);
lChain.markState();
rChain.markState();
lChain.add(compFieldType);
rChain.add(temporalTypeOfType);
final TypeCompatibilityInfo infoTemp = new TypeCompatibilityInfo(compFieldType, temporalTypeOfType, false);
if (!compFieldType.equals(temporalTypeOfType) && !(lChain.hasRecursion() && rChain.hasRecursion()) && !compFieldType.isCompatible(timestamp, temporalTypeOfType, infoTemp, lChain, rChain)) {
info.appendOp1Ref("." + compField.getIdentifier().getDisplayName() + infoTemp.getOp1RefStr());
if (infoTemp.getOp2RefStr().length() > 0) {
info.appendOp2Ref("[]");
}
info.appendOp2Ref(infoTemp.getOp2RefStr());
info.setOp1Type(infoTemp.getOp1Type());
info.setOp2Type(infoTemp.getOp2Type());
info.setErrorStr(infoTemp.getErrorStr());
lChain.previousState();
rChain.previousState();
return false;
}
lChain.previousState();
rChain.previousState();
}
info.setNeedsConversion(true);
return true;
}
case TYPE_ASN1_CHOICE:
case TYPE_TTCN3_CHOICE:
case TYPE_ANYTYPE:
info.setErrorStr(NOTCOMPATIBLEUNIONANYTYPE);
return false;
case TYPE_ASN1_SEQUENCE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_SEQUENCE_OF:
case TYPE_ARRAY:
info.setErrorStr(NOTCOMPATIBLESETSETOF);
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class CTs_EE_CTs method getEnclosingField.
public void getEnclosingField(final int offset, final ReferenceFinder rf) {
for (final CompField field : components) {
if (field.getLocation().containsOffset(offset) || // starts to work (location problem)
field.getIdentifier().getLocation().containsOffset(offset)) {
rf.type = myType;
rf.fieldId = field.getIdentifier();
field.getType().getEnclosingField(offset, rf);
return;
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class CTs_EE_CTs method check.
public void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (null != myScope && null != lastTimeChecked) {
final Module module = myScope.getModuleScope();
if (null != module) {
if (module.getSkippedFromSemanticChecking()) {
lastTimeChecked = timestamp;
return;
}
}
}
if (null == myType) {
return;
} else if (null == components) {
components = new ArrayList<CompField>();
componentsMap = new HashMap<String, CompField>();
}
lastTimeChecked = timestamp;
components.clear();
componentsMap.clear();
String typeName;
String componentName;
switch(myType.getTypetype()) {
case TYPE_ASN1_SEQUENCE:
typeName = "SEQUENCE";
componentName = "Component";
break;
case TYPE_ASN1_SET:
typeName = "SET";
componentName = "Component";
break;
case TYPE_ASN1_CHOICE:
typeName = "CHOICE";
componentName = "Alternative";
break;
default:
// some INTERNAL ERROR
typeName = "<unknown>";
componentName = "component";
break;
}
for (int i = 0; i < componentTypeList1.getNofComps(); i++) {
checkComponentField(componentTypeList1.getCompByIndex(i), typeName, componentName);
}
if (null != extensionAndException) {
for (int i = 0; i < extensionAndException.getNofComps(); i++) {
checkComponentField(extensionAndException.getCompByIndex(i), typeName, componentName);
}
final ExceptionSpecification es = extensionAndException.getExceptionSpecification();
if (es != null) {
es.getType().check(timestamp);
}
}
for (int i = 0; i < componentTypeList2.getNofComps(); i++) {
checkComponentField(componentTypeList2.getCompByIndex(i), typeName, componentName);
}
components.trimToSize();
IType type;
for (final CompField componentField : components) {
type = componentField.getType();
type.setGenName(myType.getGenNameOwn(), componentField.getIdentifier().getName());
type.setParentType(myType);
componentField.check(timestamp);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField 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);
}
Aggregations