use of org.eclipse.titan.designer.AST.BridgingNamedNode in project titan.EclipsePlug-ins by eclipse.
the class DecodeExpression method checkFirstExpressionOperand.
private void checkFirstExpressionOperand(final CompilationTimeStamp timestamp) {
final Assignment temporalAssignment = reference1.getRefdAssignment(timestamp, true);
if (temporalAssignment == null) {
setIsErroneous(true);
return;
}
switch(temporalAssignment.getAssignmentType()) {
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_TEMPLATE:
reference1.getLocation().reportSemanticError(MessageFormat.format("Reference to `{0}'' cannot be used as the first operand of the `decvalue'' operation", temporalAssignment.getAssignmentName()));
setIsErroneous(true);
break;
case A_VAR:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
break;
case A_VAR_TEMPLATE:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
{
final Referenced_Template template = new Referenced_Template(reference1);
template.setMyScope(getMyScope());
template.setFullNameParent(new BridgingNamedNode(this, ".<operand>"));
final ITTCN3Template last = template.getTemplateReferencedLast(timestamp);
if (!Template_type.SPECIFIC_VALUE.equals(last.getTemplatetype()) && last != template) {
reference1.getLocation().reportSemanticError(MessageFormat.format("Specific value template was expected instead of `{0}''", last.getTemplateTypeName()));
setIsErroneous(true);
return;
}
break;
}
default:
reference1.getLocation().reportSemanticError(MessageFormat.format("Reference to `{0}'' cannot be used as the first operand of the `decvalue' operation", temporalAssignment.getAssignmentName()));
setIsErroneous(true);
return;
}
final IType temporalType = temporalAssignment.getType(timestamp).getFieldType(timestamp, reference1, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (temporalType == null) {
setIsErroneous(true);
return;
}
if (temporalType.getTypeRefdLast(timestamp).getTypetype() != Type_type.TYPE_BITSTRING) {
if (!isErroneous) {
reference1.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous(true);
}
return;
}
}
use of org.eclipse.titan.designer.AST.BridgingNamedNode in project titan.EclipsePlug-ins by eclipse.
the class SubType method addTtcnLength.
private boolean addTtcnLength(final CompilationTimeStamp timestamp, final LengthRestriction lengthRestriction, final int restrictionIndex) {
lengthRestriction.setMyScope(myOwner.getMyScope());
final BridgingNamedNode bridge = new BridgingNamedNode(myOwner, myOwner.getFullName() + ".<length_restriction_" + restrictionIndex + ">");
lengthRestriction.setFullNameParent(bridge);
lengthRestriction.check(timestamp, Expected_Value_type.EXPECTED_CONSTANT);
IValue lower = null, upper = null;
if (lengthRestriction instanceof SingleLenghtRestriction) {
lower = ((SingleLenghtRestriction) lengthRestriction).getRestriction(timestamp);
if (lower == null || lower.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(lower.getValuetype()) || lower.isUnfoldable(timestamp)) {
return false;
}
if (!checkBoundaryValid(lower, "length restriction value")) {
return false;
}
final SizeLimit boundaryLimit = new SizeLimit(((Integer_Value) lower).getValueValue());
return setTtcnLength(boundaryLimit, boundaryLimit);
}
lower = ((RangeLenghtRestriction) lengthRestriction).getLowerValue(timestamp);
if (lower == null || lower.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(lower.getValuetype()) || lower.isUnfoldable(timestamp)) {
return false;
}
if (!checkBoundaryValid(lower, "lower boundary")) {
return false;
}
upper = ((RangeLenghtRestriction) lengthRestriction).getUpperValue(timestamp);
if (upper != null) {
if (upper.getMyScope() == null) {
upper.setMyScope(myOwner.getMyScope());
}
if (upper.getIsErroneous(timestamp) || !Value_type.INTEGER_VALUE.equals(upper.getValuetype()) || upper.isUnfoldable(timestamp)) {
return false;
}
if (!checkBoundaryValid(upper, "upper boundary")) {
return false;
}
return setTtcnLength(new SizeLimit(((Integer_Value) lower).getValueValue()), new SizeLimit(((Integer_Value) upper).getValueValue()));
}
// upper is infinity
return setTtcnLength(new SizeLimit(((Integer_Value) lower).getValueValue()), SizeLimit.MAXIMUM);
}
use of org.eclipse.titan.designer.AST.BridgingNamedNode in project titan.EclipsePlug-ins by eclipse.
the class IsChoosenExpression method checkExpressionOperands.
/**
* Checks the parameters of the expression and if they are valid in
* their position in the expression or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expectedValue
* the kind of value expected.
* @param referenceChain
* a reference chain to detect cyclic references.
*/
private void checkExpressionOperands(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeoperandsChecked != null && !lastTimeoperandsChecked.isLess(timestamp)) {
return;
}
lastTimeoperandsChecked = timestamp;
value = null;
identifier = null;
if (reference == null || reference.getSubreferences().size() < 2) {
setIsErroneous(true);
return;
}
final Reference tempReference = reference.newInstance();
tempReference.setFullNameParent(this);
tempReference.setMyScope(getMyScope());
final ISubReference subreference = tempReference.removeLastSubReference();
if (Subreference_type.fieldSubReference.equals(subreference.getReferenceType())) {
identifier = ((FieldSubReference) subreference).getId();
} else {
setIsErroneous(true);
return;
}
final Assignment assignment = tempReference.getRefdAssignment(timestamp, true);
if (assignment == null) {
setIsErroneous(true);
return;
}
IType governor;
switch(assignment.getAssignmentType()) {
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
{
value = new Referenced_Value(tempReference);
value.setLocation(tempReference.getLocation());
value.setMyScope(getMyScope());
final BridgingNamedNode tempNamedNode = new BridgingNamedNode(this, OPERAND);
value.setFullNameParent(tempNamedNode);
governor = value.getExpressionGovernor(timestamp, expectedValue);
if (governor == null) {
setIsErroneous(true);
} else {
value.setMyGovernor(governor);
final IValue tempValue2 = governor.checkThisValueRef(timestamp, value);
if (tempValue2.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
}
break;
}
case A_TEMPLATE:
case A_VAR_TEMPLATE:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
{
template = new Referenced_Template(tempReference);
template.setLocation(tempReference.getLocation());
template.setMyScope(getMyScope());
final BridgingNamedNode tempNamedNode = new BridgingNamedNode(this, OPERAND);
template.setFullNameParent(tempNamedNode);
if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) || Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
governor = template.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
} else {
governor = template.getExpressionGovernor(timestamp, expectedValue);
}
if (governor == null) {
setIsErroneous(true);
} else {
template.setMyGovernor(governor);
final TTCN3Template last = template.getTemplateReferencedLast(timestamp, referenceChain);
if (last.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
}
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue) && !Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(expectedValue)) {
template.getLocation().reportSemanticError(MessageFormat.format(CONSTANTREFERENCEEXPECTED, assignment.getDescription()));
} else {
template.getLocation().reportSemanticError(MessageFormat.format(STATICREFERENCEEXPECTED, assignment.getDescription()));
}
setIsErroneous(true);
}
break;
}
default:
tempReference.getLocation().reportSemanticError(MessageFormat.format(VALUETEMPLATEEXPECTED, assignment.getDescription()));
setIsErroneous(true);
return;
}
if (governor != null) {
governor = governor.getTypeRefdLast(timestamp);
if (!governor.getIsErroneous(timestamp)) {
CompField field = null;
switch(governor.getTypetype()) {
case TYPE_ASN1_CHOICE:
if (((ASN1_Choice_Type) governor).hasComponentWithName(identifier)) {
field = ((ASN1_Choice_Type) governor).getComponentByName(identifier);
}
break;
case TYPE_TTCN3_CHOICE:
if (((TTCN3_Choice_Type) governor).hasComponentWithName(identifier.getName())) {
field = ((TTCN3_Choice_Type) governor).getComponentByName(identifier.getName());
}
break;
case TYPE_OPENTYPE:
if (((Open_Type) governor).hasComponentWithName(identifier)) {
field = ((Open_Type) governor).getComponentByName(identifier);
}
break;
case TYPE_ANYTYPE:
if (((Anytype_Type) governor).hasComponentWithName(identifier.getName())) {
field = ((Anytype_Type) governor).getComponentByName(identifier.getName());
}
break;
default:
location.reportSemanticError(MessageFormat.format(OPERANDERROR, governor.getTypename()));
setIsErroneous(true);
return;
}
if (null == field) {
location.reportSemanticError(MessageFormat.format(MISSINGFIELD, governor.getTypename(), identifier.getDisplayName()));
setIsErroneous(true);
}
}
}
}
use of org.eclipse.titan.designer.AST.BridgingNamedNode in project titan.EclipsePlug-ins by eclipse.
the class PortTypeBody method addUserAttribute.
/**
* Marks that this port type body belongs to a user port.
* Also sets all mappings using the provided data.
*
* @param providerReference the reference pointing to the provider port
* @param inMappings the incoming mappings.
* @param outMappings the outgoing mappings.
*/
public void addUserAttribute(final Reference providerReference, final TypeMappings inMappings, final TypeMappings outMappings) {
portType = PortType_type.PT_USER;
this.providerReference = providerReference;
this.providerReference.setFullNameParent(new BridgingNamedNode(this, ".<provider_ref>"));
this.providerReference.setMyScope(myType.getMyScope());
providerType = null;
this.inMappings = inMappings;
if (inMappings != null) {
this.inMappings.setFullNameParent(new BridgingNamedNode(this, ".<inMappings>"));
this.inMappings.setMyScope(myType.getMyScope());
}
this.outMappings = outMappings;
if (outMappings != null) {
this.outMappings.setFullNameParent(new BridgingNamedNode(this, ".<outMappings>"));
this.outMappings.setMyScope(myType.getMyScope());
}
}
use of org.eclipse.titan.designer.AST.BridgingNamedNode in project titan.EclipsePlug-ins by eclipse.
the class ComponentTypeBody method collectExtensionAttributes.
/**
* Collects the extends extension attributes, from the with attributes assigned to the component type.
*
* @param timestamp the timestamp of the actual semantic check cycle
*/
private void collectExtensionAttributes(final CompilationTimeStamp timestamp) {
if (withAttributesPath == null) {
return;
}
final List<SingleWithAttribute> realAttributes = withAttributesPath.getRealAttributes(timestamp);
SingleWithAttribute attribute;
List<AttributeSpecification> specifications = null;
for (int i = 0; i < realAttributes.size(); i++) {
attribute = realAttributes.get(i);
if (Attribute_Type.Extension_Attribute.equals(attribute.getAttributeType())) {
final Qualifiers qualifiers = attribute.getQualifiers();
if (qualifiers == null || qualifiers.getNofQualifiers() == 0) {
if (specifications == null) {
specifications = new ArrayList<AttributeSpecification>();
}
specifications.add(attribute.getAttributeSpecification());
}
}
}
if (specifications == null) {
return;
}
final List<ExtensionAttribute> attributes = new ArrayList<ExtensionAttribute>();
AttributeSpecification specification;
for (int i = 0; i < specifications.size(); i++) {
specification = specifications.get(i);
final ExtensionAttributeAnalyzer analyzer = new ExtensionAttributeAnalyzer();
analyzer.parse(specification);
final List<ExtensionAttribute> temp = analyzer.getAttributes();
if (temp != null) {
attributes.addAll(temp);
}
}
if (attributes.isEmpty()) {
return;
}
attrExtendsReferences = new ComponentTypeReferenceList();
for (int i = 0, size = attributes.size(); i < size; i++) {
final ExtensionAttribute tempAttribute = attributes.get(i);
if (ExtensionAttribute_type.EXTENDS.equals(tempAttribute.getAttributeType())) {
final ExtensionsAttribute extensionsAttribute = (ExtensionsAttribute) tempAttribute;
for (int j = 0, size2 = extensionsAttribute.getNofTypes(); j < size2; j++) {
final IType tempType = extensionsAttribute.getType(j);
if (Type_type.TYPE_REFERENCED.equals(tempType.getTypetype())) {
attrExtendsReferences.addReference(((Referenced_Type) tempType).getReference());
}
}
}
}
attrExtendsReferences.setFullNameParent(new BridgingNamedNode(this, ".<extends attribute>"));
attrExtendsReferences.setMyScope(parentScope);
}
Aggregations