use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class Open_Type method checkRecursions.
@Override
public /**
* {@inheritDoc}
*/
void checkRecursions(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
final Map<String, CompField> map = compFieldMap.getComponentFieldMap(timestamp);
if (referenceChain.add(this) && 1 == map.size()) {
for (CompField compField : map.values()) {
final IType type = compField.getType();
if (null != type) {
referenceChain.markState();
type.checkRecursions(timestamp, referenceChain);
referenceChain.previousState();
}
}
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class Open_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;
final Map<String, CompField> map = compFieldMap.getComponentFieldMap(CompilationTimeStamp.getBaseTimestamp());
for (final CompField compField : map.values()) {
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 : map.values()) {
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);
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class Open_Type method checkThisValueChoice.
private boolean checkThisValueChoice(final CompilationTimeStamp timestamp, final Choice_Value value, final Assignment lhs, final Expected_Value_type expectedValue, final boolean incompleteAllowed, final boolean strElem) {
boolean selfReference = false;
final Identifier name = value.getName();
final CompField field = getComponentByName(name);
if (field == null) {
if (value.isAsn()) {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTCHOICE, name.getDisplayName(), getFullName()));
} else {
value.getLocation().reportSemanticError(MessageFormat.format(NONEXISTENTUNION, name.getDisplayName(), getFullName()));
}
} else {
IValue alternativeValue = value.getValue();
if (null == alternativeValue) {
return selfReference;
}
final Type alternativeType = field.getType();
alternativeValue.setMyGovernor(alternativeType);
alternativeValue = alternativeType.checkThisValueRef(timestamp, alternativeValue);
selfReference = alternativeType.checkThisValue(timestamp, alternativeValue, lhs, new ValueCheckingOptions(expectedValue, incompleteAllowed, false, true, false, strElem));
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class ComponentsOfComponentType method trCompsof.
@Override
public /**
* {@inheritDoc}
*/
void trCompsof(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain, final boolean isSet) {
if (null != trCompsofTimestamp && !trCompsofTimestamp.isLess(timestamp)) {
return;
}
if (null == componentsOfType) {
return;
}
final IType type = componentsOfType.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return;
}
CTs_EE_CTs tempCtss;
switch(type.getTypetype()) {
case TYPE_ASN1_SET:
if (!isSet) {
getLocation().reportSemanticError(MessageFormat.format(SEQUENCEEXPECTED, type.getFullName()));
trCompsofTimestamp = timestamp;
return;
}
referenceChain.markState();
if (referenceChain.add(componentsOfType)) {
((ASN1_Set_Type) type).trCompsof(timestamp, referenceChain);
}
referenceChain.previousState();
tempCtss = ((ASN1_Set_Type) type).components;
break;
case TYPE_ASN1_SEQUENCE:
if (isSet) {
getLocation().reportSemanticError(MessageFormat.format(SETEXPECTED, type.getFullName()));
trCompsofTimestamp = timestamp;
return;
}
referenceChain.markState();
if (referenceChain.add(componentsOfType)) {
((ASN1_Sequence_Type) type).trCompsof(timestamp, referenceChain);
}
referenceChain.previousState();
tempCtss = ((ASN1_Sequence_Type) type).components;
break;
default:
trCompsofTimestamp = timestamp;
return;
}
// emergency exit for the case of infinite recursion
if (timestamp.equals(trCompsofTimestamp)) {
return;
}
componentTypes = new ComponentTypeList();
type.check(timestamp);
for (int i = 0; i < tempCtss.getNofRootComps(); i++) {
final CompField compfield = tempCtss.getRootCompByIndex(i).newInstance();
compfield.setLocation(location);
final RegularComponentType componentType = new RegularComponentType(compfield);
componentType.setLocation(location);
componentTypes.addComponentType(componentType);
}
componentTypes.setMyScope(componentsOfType.getMyScope());
componentTypes.setFullNameParent(this);
trCompsofTimestamp = timestamp;
}
use of org.eclipse.titan.designer.AST.TTCN3.types.CompField in project titan.EclipsePlug-ins by eclipse.
the class Sequence_Value method checkEquality.
@Override
public /**
* {@inheritDoc}
*/
boolean checkEquality(final CompilationTimeStamp timestamp, final IValue other) {
if (convertedValue != null && convertedValue != this) {
return convertedValue.checkEquality(timestamp, other);
}
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = other.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!Value_type.SEQUENCE_VALUE.equals(last.getValuetype())) {
return false;
}
if (myGovernor == null) {
return false;
}
final Sequence_Value otherSequence = (Sequence_Value) last;
if (values.getSize() != otherSequence.values.getSize()) {
return false;
}
int nofComps = 0;
final IType leftGovernor = myGovernor.getTypeRefdLast(timestamp);
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
nofComps = ((TTCN3_Sequence_Type) leftGovernor).getNofComponents();
break;
case TYPE_ASN1_SEQUENCE:
nofComps = ((ASN1_Sequence_Type) leftGovernor).getNofComponents(timestamp);
break;
default:
return false;
}
CompField compField = null;
for (int i = 0; i < nofComps; i++) {
switch(leftGovernor.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
compField = ((TTCN3_Sequence_Type) leftGovernor).getComponentByIndex(i);
break;
case TYPE_ASN1_SEQUENCE:
compField = ((ASN1_Sequence_Type) leftGovernor).getComponentByIndex(i);
break;
default:
return false;
}
final Identifier fieldName = compField.getIdentifier();
if (hasComponentWithName(fieldName)) {
final IValue leftValue = getComponentByName(fieldName).getValue();
if (otherSequence.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSequence.getComponentByName(fieldName).getValue();
if ((Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && !Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) || (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype()) && Value_type.OMIT_VALUE.equals(otherValue.getValuetype()))) {
return false;
}
if (!leftValue.checkEquality(timestamp, otherValue)) {
return false;
}
} else {
if (compField.hasDefault()) {
if (!leftValue.checkEquality(timestamp, compField.getDefault())) {
return false;
}
} else {
if (!Value_type.OMIT_VALUE.equals(leftValue.getValuetype())) {
return false;
}
}
}
} else {
if (otherSequence.hasComponentWithName(fieldName)) {
final IValue otherValue = otherSequence.getComponentByName(fieldName).getValue();
if (compField.hasDefault()) {
if (Value_type.OMIT_VALUE.equals(otherValue.getValuetype())) {
return false;
}
if (!compField.getDefault().checkEquality(timestamp, otherValue)) {
return false;
}
}
}
}
}
return true;
}
Aggregations