use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ObjectSet_definition method getRefdLast.
@Override
public final /**
* {@inheritDoc}
*/
ObjectSet_definition getRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (1 != objectSetElements.size()) {
return this;
}
final IObjectSet_Element element = objectSetElements.get(0);
if (!(element instanceof Referenced_ObjectSet)) {
return this;
}
final boolean newChain = null == referenceChain;
IReferenceChain temporalReferenceChain;
if (newChain) {
temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
temporalReferenceChain = referenceChain;
}
temporalReferenceChain.add(this);
final ObjectSet_definition result = ((Referenced_ObjectSet) element).getRefdLast(timestamp, temporalReferenceChain);
if (newChain) {
temporalReferenceChain.release();
}
return result;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class ReferencedObject method getRefdLast.
@Override
public /**
* {@inheritDoc}
*/
Object_Definition getRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
final boolean newChain = null == referenceChain;
IReferenceChain temporalReferenceChain;
if (newChain) {
temporalReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
temporalReferenceChain = referenceChain;
}
referencedLast = getRefd(timestamp, temporalReferenceChain).getRefdLast(timestamp, temporalReferenceChain);
if (newChain) {
temporalReferenceChain.release();
}
return referencedLast;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class FieldSetting_Type method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final FieldSpecification fieldSpecification) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (!Fieldspecification_types.FS_T.equals(fieldSpecification.getFieldSpecificationType())) {
location.reportSemanticError(TYPESETTINGEXPECTED);
type = new Boolean_Type();
type.setIsErroneous(true);
type.setFullNameParent(this);
}
lastTimeChecked = timestamp;
type.check(timestamp);
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
type.checkRecursions(timestamp, referenceChain);
referenceChain.release();
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Indexed_Template_List method getReferencedArrayTemplate.
@Override
protected /**
* {@inheritDoc}
*/
ITTCN3Template getReferencedArrayTemplate(final CompilationTimeStamp timestamp, final IValue arrayIndex, final IReferenceChain referenceChain) {
IValue indexValue = arrayIndex.setLoweridToReference(timestamp);
indexValue = indexValue.getValueRefdLast(timestamp, referenceChain);
if (indexValue.getIsErroneous(timestamp)) {
return null;
}
long index = 0;
if (!indexValue.isUnfoldable(timestamp)) {
if (Value_type.INTEGER_VALUE.equals(indexValue.getValuetype())) {
index = ((Integer_Value) indexValue).getValue();
} else {
arrayIndex.getLocation().reportSemanticError("An integer value was expected as index");
return null;
}
} else {
return null;
}
final IType tempType = myGovernor.getTypeRefdLast(timestamp);
if (tempType.getIsErroneous(timestamp)) {
return null;
}
switch(tempType.getTypetype()) {
case TYPE_SEQUENCE_OF:
{
if (index < 0) {
final String message = MessageFormat.format("A non-negative integer value was expected instead of {0} for indexing a template of `sequence of'' type `{1}''", index, tempType.getTypename());
arrayIndex.getLocation().reportSemanticError(message);
return null;
}
break;
}
case TYPE_SET_OF:
{
if (index < 0) {
final String message = MessageFormat.format("A non-negative integer value was expected instead of {0} for indexing a template of `set of'' type `{1}''", index, tempType.getTypename());
arrayIndex.getLocation().reportSemanticError(message);
return null;
}
break;
}
case TYPE_ARRAY:
{
final ArrayDimension dimension = ((Array_Type) tempType).getDimension();
dimension.checkIndex(timestamp, indexValue, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (!dimension.getIsErroneous(timestamp)) {
// re-base the index
index -= dimension.getOffset();
if (index < 0 || index > getNofTemplates()) {
arrayIndex.getLocation().reportSemanticError(MessageFormat.format("The index value {0} is outside the array indexable range", index + dimension.getOffset()));
return null;
}
} else {
return null;
}
break;
}
default:
arrayIndex.getLocation().reportSemanticError(MessageFormat.format("Invalid array element reference: type `{0}'' cannot be indexed", tempType.getTypename()));
return null;
}
for (int i = 0, size = indexedTemplates.getNofTemplates(); i < size; i++) {
final IndexedTemplate template = indexedTemplates.getTemplateByIndex(i);
IValue lastValue = template.getIndex().getValue();
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
lastValue = lastValue.getValueRefdLast(timestamp, chain);
chain.release();
if (Value_type.INTEGER_VALUE.equals(lastValue.getValuetype())) {
final long tempIndex = ((Integer_Value) lastValue).getValue();
if (index == tempIndex) {
final ITTCN3Template realTemplate = template.getTemplate();
if (Template_type.TEMPLATE_NOTUSED.equals(realTemplate.getTemplatetype())) {
if (baseTemplate != null) {
return baseTemplate.getTemplateReferencedLast(timestamp, referenceChain).getReferencedArrayTemplate(timestamp, indexValue, referenceChain);
}
return null;
}
return realTemplate;
}
}
}
switch(tempType.getTypetype()) {
case TYPE_SEQUENCE_OF:
case TYPE_SET_OF:
case TYPE_ARRAY:
// unfoldable (for now)
break;
default:
// the error was reported earlier
break;
}
return null;
}
use of org.eclipse.titan.designer.AST.IReferenceChain in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Template method generateCodeExpressionInvoke.
private void generateCodeExpressionInvoke(final JavaGenData aData, final ExpressionStruct expression) {
if (value == null || actualParameter_list == null) {
return;
}
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), referenceChain);
referenceChain.release();
if (last.getValuetype() == Value_type.FUNCTION_REFERENCE_VALUE) {
final Definition function = ((Function_Reference_Value) last).getReferredFunction();
expression.expression.append(MessageFormat.format("{0}(", function.getGenNameFromScope(aData, expression.expression, myScope, "")));
actualParameter_list.generateCodeAlias(aData, expression);
} else {
value.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".invoke(");
IType governor = value.getMyGovernor();
if (governor == null) {
governor = value.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
}
if (governor == null) {
return;
}
actualParameter_list.generateCodeAlias(aData, expression);
}
expression.expression.append(')');
}
Aggregations