use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Connect_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
IType portType1;
IType portType2;
PortTypeBody body1;
PortTypeBody body2;
portType1 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference1, portReference1, false);
if (portType1 == null) {
body1 = null;
} else {
body1 = ((Port_Type) portType1).getPortBody();
}
portType2 = Port_Utility.checkConnectionEndpoint(timestamp, this, componentReference2, portReference2, false);
if (portType2 == null) {
body2 = null;
} else {
body2 = ((Port_Type) portType2).getPortBody();
}
if (portType1 == null || portType2 == null || body1 == null || body2 == null) {
lastTimeChecked = timestamp;
return;
}
if (!body1.isConnectable(timestamp, body2) || (body1 != body2 && !body2.isConnectable(timestamp, body1))) {
location.reportSemanticError(MessageFormat.format(INCONSISTENTCONNECTION, portType1.getTypename(), portType2.getTypename()));
body1.reportConnectionErrors(timestamp, body2, location);
if (body1 != body2) {
body2.reportConnectionErrors(timestamp, body1, location);
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Qualifier method findReferences.
@Override
public /**
* {@inheritDoc}
*/
void findReferences(final ReferenceFinder referenceFinder, final List<Hit> foundIdentifiers) {
if (definition != null && subReferences != null) {
// qualifiers were not semantically analyzed
for (ISubReference sr : subReferences) {
sr.findReferences(referenceFinder, foundIdentifiers);
}
if (referenceFinder.fieldId != null) {
// we are searching for a field of a type
final IType t = definition.getType(CompilationTimeStamp.getBaseTimestamp());
if (t == null) {
return;
}
final List<IType> typeArray = new ArrayList<IType>();
final Reference reference = new Reference(null);
reference.addSubReference(new FieldSubReference(definition.getIdentifier()));
for (ISubReference sr : subReferences) {
reference.addSubReference(sr);
}
reference.setLocation(location);
reference.setMyScope(definition.getMyScope());
final boolean success = t.getFieldTypesAsArray(reference, 1, typeArray);
if (!success) {
// TODO: maybe a partially erroneous reference could be searched too
return;
}
if (subReferences.size() != typeArray.size()) {
ErrorReporter.INTERNAL_ERROR();
return;
}
for (int i = 0; i < subReferences.size(); i++) {
if (typeArray.get(i) == referenceFinder.type && !(subReferences.get(i) instanceof ArraySubReference) && subReferences.get(i).getId().equals(referenceFinder.fieldId)) {
foundIdentifiers.add(new Hit(subReferences.get(i).getId()));
}
}
}
}
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Sequence_Type method getSubrefsAsArray.
// This is the same as in ASN1_Set_type
@Override
public /**
* {@inheritDoc}
*/
boolean getSubrefsAsArray(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final List<Integer> subrefsArray, final List<IType> typeArray) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return true;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDSUBREFERENCE, getTypename()));
return false;
case fieldSubReference:
{
if (components == null) {
return false;
}
final Identifier id = subreference.getId();
final CompField compField = components.getCompByName(id);
if (compField == null) {
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.NONEXISTENTSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), getTypename()));
return false;
}
final IType fieldType = compField.getType();
if (fieldType == null) {
return false;
}
final int fieldIndex = components.indexOf(compField);
subrefsArray.add(fieldIndex);
typeArray.add(this);
return fieldType.getSubrefsAsArray(timestamp, reference, actualSubReference + 1, subrefsArray, typeArray);
}
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((ParameterisedSubReference) subreference).getId().getDisplayName(), getTypename()));
return false;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return false;
}
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Set_Seq_Choice_BaseType method getFieldTypesAsArray.
@Override
public /**
* {@inheritDoc}
*/
boolean getFieldTypesAsArray(final Reference reference, final int actualSubReference, final List<IType> typeArray) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (subreferences.size() <= actualSubReference) {
return true;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
{
final Identifier id = subreference.getId();
final CompField compField = components.getCompByName(id);
if (compField == null) {
return false;
}
final IType fieldType = compField.getType();
if (fieldType == null) {
return false;
}
typeArray.add(this);
return fieldType.getFieldTypesAsArray(reference, actualSubReference + 1, typeArray);
}
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.IType 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);
}
Aggregations