use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Octetstring_Value method getReferencedSubValue.
@Override
public /**
* {@inheritDoc}
*/
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return this;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
final Value arrayIndex = ((ArraySubReference) subreference).getValue();
final IValue valueIndex = arrayIndex.getValueRefdLast(timestamp, refChain);
if (!valueIndex.isUnfoldable(timestamp)) {
if (Value_type.INTEGER_VALUE.equals(valueIndex.getValuetype())) {
final int index = ((Integer_Value) valueIndex).intValue();
return getStringElement(index, arrayIndex.getLocation());
}
arrayIndex.getLocation().reportSemanticError(ArraySubReference.INTEGERINDEXEXPECTED);
return null;
}
return null;
case fieldSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), type.getTypename()));
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Omit_Value method generateSingleExpression.
@Override
public /**
* {@inheritDoc}
*/
StringBuilder generateSingleExpression(final JavaGenData aData) {
aData.addBuiltinTypeImport("Base_Template.template_sel");
IType governor = myGovernor;
if (governor == null) {
governor = myLastSetGovernor;
}
final StringBuilder result = new StringBuilder();
result.append(MessageFormat.format("new Optional<{0}>({0}.class, template_sel.OMIT_VALUE)", governor.getGenNameValue(aData, result, myScope)));
return result;
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Real_Value method getReferencedSubValue.
@Override
public /**
* {@inheritDoc}
*/
IValue getReferencedSubValue(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference, final IReferenceChain refChain) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return this;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(ArraySubReference.INVALIDVALUESUBREFERENCE, type.getTypename()));
return null;
case fieldSubReference:
subreference.getLocation().reportSemanticError(MessageFormat.format(FieldSubReference.INVALIDSUBREFERENCE, ((FieldSubReference) subreference).getId().getDisplayName(), type.getTypename()));
return null;
case parameterisedSubReference:
subreference.getLocation().reportSemanticError(ParameterisedSubReference.INVALIDVALUESUBREFERENCE);
return null;
default:
subreference.getLocation().reportSemanticError(ISubReference.INVALIDSUBREFERENCE);
return null;
}
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Value method checkExpressionOmitComparison.
@Override
public /**
* {@inheritDoc}
*/
void checkExpressionOmitComparison(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue) {
if (getIsErroneous(timestamp)) {
return;
}
final List<ISubReference> subreferences = new ArrayList<ISubReference>();
subreferences.addAll(reference.getSubreferences());
if (subreferences.size() <= 1) {
return;
}
final ISubReference subreference = subreferences.remove(subreferences.size() - 1);
final Identifier id = subreference.getId();
if (id == null) {
getLocation().reportSemanticError("Only a reference pointing to an optional record or set field can be compared with `omit'");
setIsErroneous(true);
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
setIsErroneous(true);
return;
}
IType type = assignment.getType(timestamp);
if (type == null) {
setIsErroneous(true);
return;
}
final Reference tempReference = new Reference(null, subreferences);
tempReference.setFullNameParent(this);
tempReference.setMyScope(myScope);
type = type.getFieldType(timestamp, tempReference, 1, expectedValue, false);
if (type == null) {
setIsErroneous(true);
return;
}
type = type.getTypeRefdLast(timestamp);
if (type == null || type.getIsErroneous(timestamp)) {
setIsErroneous(true);
return;
}
switch(type.getTypetype()) {
case TYPE_ASN1_SEQUENCE:
if (!((ASN1_Sequence_Type) type).hasComponentWithName(id)) {
getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
setIsErroneous(true);
} else if (!((ASN1_Sequence_Type) type).getComponentByName(id).isOptional()) {
getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
setIsErroneous(true);
}
break;
case TYPE_TTCN3_SEQUENCE:
if (!((TTCN3_Sequence_Type) type).hasComponentWithName(id.getName())) {
getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
setIsErroneous(true);
} else if (!((TTCN3_Sequence_Type) type).getComponentByName(id.getName()).isOptional()) {
getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
setIsErroneous(true);
}
break;
case TYPE_ASN1_SET:
if (!((ASN1_Set_Type) type).hasComponentWithName(id)) {
getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
setIsErroneous(true);
} else if (!((ASN1_Set_Type) type).getComponentByName(id).isOptional()) {
getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
setIsErroneous(true);
}
break;
case TYPE_TTCN3_SET:
if (!((TTCN3_Set_Type) type).hasComponentWithName(id.getName())) {
getLocation().reportSemanticError(MessageFormat.format("Type `{0}'' does not have field named `{1}''", type.getTypename(), id.getDisplayName()));
setIsErroneous(true);
} else if (!((TTCN3_Set_Type) type).getComponentByName(id.getName()).isOptional()) {
getLocation().reportSemanticError(MessageFormat.format("Field `{0}'' is mandatory in type`{1}''. It cannot be compared with `omit''", id.getDisplayName(), type.getTypename()));
setIsErroneous(true);
}
break;
default:
getLocation().reportSemanticError("Only a reference pointing to an optional record or set field can be compared with `omit'");
setIsErroneous(true);
break;
}
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Value method checkExpressionSelfReferenceValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkExpressionSelfReferenceValue(final CompilationTimeStamp timestamp, final Assignment lhs) {
IType governor = myGovernor;
if (governor == null) {
governor = getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
}
if (governor == null) {
return false;
}
final boolean isStringElement = reference.refersToStringElement();
return governor.checkThisValue(timestamp, this, lhs, new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, true, false, false, isStringElement));
}
Aggregations