use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Sequence_Type method isPresentAnyvalueEmbeddedField.
@Override
public /**
* {@inheritDoc}
*/
boolean isPresentAnyvalueEmbeddedField(final ExpressionStruct expression, final List<ISubReference> subreferences, final int beginIndex) {
if (subreferences == null || getIsErroneous(CompilationTimeStamp.getBaseTimestamp())) {
return true;
}
if (beginIndex >= subreferences.size()) {
return true;
}
final ISubReference subReference = subreferences.get(beginIndex);
if (!(subReference instanceof FieldSubReference)) {
ErrorReporter.INTERNAL_ERROR("Code generator reached erroneous type reference `" + getFullName() + "''");
expression.expression.append("FATAL_ERROR encountered");
return true;
}
final Identifier fieldId = ((FieldSubReference) subReference).getId();
final CompField compField = getComponentByName(fieldId.getName());
if (compField.isOptional()) {
return false;
}
return compField.getType().isPresentAnyvalueEmbeddedField(expression, subreferences, beginIndex + 1);
}
use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_Set_Seq_Choice_BaseType method getSubrefsAsArray.
@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:
final Identifier id = subreference.getId();
final CompField compField = compFieldMap.getCompWithName(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 = compFieldMap.fields.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.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class TTCN3_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:
if (compFieldMap == null) {
return false;
}
final Identifier id = subreference.getId();
final CompField compField = compFieldMap.getCompWithName(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.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class PortTypeBody method addProposal.
/**
* Adds the port related proposals.
*
* handles the following proposals:
*
* <ul>
* <li>in message mode:
* <ul>
* <li>send(template), receive, trigger
* </ul>
* <li>in procedure mode:
* <ul>
* <li>call, getcall, reply, raise, getreply, catch
* </ul>
* <li>general:
* <ul>
* <li>check
* <li>clear, start, stop, halt
* </ul>
* </ul>
*
* @param propCollector the proposal collector.
* @param i the index of a part of the full reference, for which we wish to find completions.
*/
public void addProposal(final ProposalCollector propCollector, final int i) {
final List<ISubReference> subrefs = propCollector.getReference().getSubreferences();
if (subrefs.size() != i + 1 || Subreference_type.arraySubReference.equals(subrefs.get(i).getReferenceType())) {
return;
}
if (OperationModes.OP_Message.equals(operationMode) || OperationModes.OP_Mixed.equals(operationMode)) {
propCollector.addTemplateProposal("send", new Template("send( templateInstance )", "", propCollector.getContextIdentifier(), "send( ${templateInstance} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("send", new Template("send( templateInstance ) to location", "", propCollector.getContextIdentifier(), "send( ${templateInstance} ) to ${location};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
addReceiveProposals(propCollector, i);
addTriggerProposals(propCollector, i);
}
if (OperationModes.OP_Procedure.equals(operationMode) || OperationModes.OP_Mixed.equals(operationMode)) {
propCollector.addTemplateProposal("call", new Template("call( templateInstance )", "", propCollector.getContextIdentifier(), "call( ${templateInstance} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("call", new Template("call( templateInstance , callTimer )", "with timer", propCollector.getContextIdentifier(), "call( ${templateInstance} , ${callTimer} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("call", new Template("call( templateInstance ) to location", "with to clause", propCollector.getContextIdentifier(), "call( ${templateInstance} ) to ${location};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("call", new Template("call( templateInstance , callTimer ) to location", "with timer and to clause", propCollector.getContextIdentifier(), "call( ${templateInstance} , ${callTimer} ) to ${location};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
addGetcallProposals(propCollector, i);
propCollector.addTemplateProposal("reply", new Template("reply( templateInstance )", "", propCollector.getContextIdentifier(), "reply( ${templateInstance} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("reply", new Template("reply( templateInstance ) to location", "", propCollector.getContextIdentifier(), "reply( ${templateInstance} ) to ${location};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
addGetreplyProposals(propCollector, i);
propCollector.addTemplateProposal("raise", new Template("raise( signature, templateInstance )", "", propCollector.getContextIdentifier(), "raise( ${signature}, ${templateInstance} );", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
propCollector.addTemplateProposal("raise", new Template("raise( signature, templateInstance ) to location", "with to clause", propCollector.getContextIdentifier(), "raise( ${signature}, ${templateInstance} ) to ${location};", false), TTCN3CodeSkeletons.SKELETON_IMAGE);
addCatchProposals(propCollector, i);
}
addCheckProposals(propCollector, i);
propCollector.addProposal("clear;", "clear", ImageCache.getImage("port.gif"), "");
propCollector.addProposal("start;", "start", ImageCache.getImage("port.gif"), "");
propCollector.addProposal("stop;", "stop", ImageCache.getImage("port.gif"), "");
propCollector.addProposal("halt;", "halt", ImageCache.getImage("port.gif"), "");
}
use of org.eclipse.titan.designer.AST.ISubReference in project titan.EclipsePlug-ins by eclipse.
the class TemplateInstance method reArrangeInitCode.
/**
* Walks through the templateinstance recursively and appends the java
* initialization sequence of all (directly or indirectly) referenced
* non-parameterized templates and the default values of all
* parameterized templates to source and returns the resulting string.
* Only objects belonging to module usageModule are initialized.
*
* @param aData the structure to put imports into and get temporal variable names from.
* @param source the source for code generated
* @param usageModule the module where the template is to be used.
*/
public void reArrangeInitCode(final JavaGenData aData, final StringBuilder source, final Module usageModule) {
if (derivedReference != null) {
final List<ISubReference> subreferences = derivedReference.getSubreferences();
if (subreferences != null && !subreferences.isEmpty() && subreferences.get(0) instanceof ParameterisedSubReference) {
final ParameterisedSubReference subreference = (ParameterisedSubReference) subreferences.get(0);
final ActualParameterList actualParameterList = subreference.getActualParameters();
if (actualParameterList != null) {
actualParameterList.reArrangeInitCode(aData, source, usageModule);
}
}
final Assignment assignment = derivedReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
if (assignment == null) {
return;
}
if (assignment.getAssignmentType() == Assignment_type.A_TEMPLATE) {
final ITTCN3Template template = ((Def_Template) assignment).getTemplate(CompilationTimeStamp.getBaseTimestamp());
final FormalParameterList formalParameterList = ((Def_Template) assignment).getFormalParameterList();
if (formalParameterList != null) {
// the referred template is parameterized
// the embedded referenced templates shall be visited
template.reArrangeInitCode(aData, source, usageModule);
// FIXME implement
} else {
// its entire body has to be initialized now
if (assignment.getMyScope().getModuleScope() == usageModule) {
template.generateCodeInit(aData, source, template.get_lhs_name());
}
}
}
}
if (templateBody != null) {
templateBody.reArrangeInitCode(aData, source, usageModule);
}
}
Aggregations