use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class ASN1_BitString_Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
final boolean selfReference = super.checkThisValue(timestamp, value, lhs, valueCheckingOptions);
IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return selfReference;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return selfReference;
}
break;
default:
break;
}
if (last.isAsn()) {
if (last instanceof IReferencingType) {
final IType type = last.getMyGovernor().getTypeRefdLast(timestamp);
switch(type.getTypetype()) {
case TYPE_BITSTRING:
case TYPE_BITSTRING_A:
break;
default:
value.getLocation().reportSemanticError("(reference to) BIT STRING value was expected");
value.setIsErroneous(true);
value.setLastTimeChecked(timestamp);
return selfReference;
}
}
switch(last.getValuetype()) {
case BITSTRING_VALUE:
break;
case HEXSTRING_VALUE:
last.setValuetype(timestamp, Value_type.BITSTRING_VALUE);
break;
case UNDEFINED_BLOCK:
{
last = last.setValuetype(timestamp, Value_type.NAMED_BITS);
if (namedValues == null) {
value.getLocation().reportSemanticError(MessageFormat.format("No named bits are defined in type `{0}''", getTypename()));
value.setIsErroneous(true);
value.setLastTimeChecked(timestamp);
return selfReference;
}
final Named_Bits namedBits = (Named_Bits) last;
final StringBuilder builder = new StringBuilder(namedBits.getNofIds());
for (int i = 0; i < namedBits.getNofIds(); i++) {
final Identifier id = namedBits.getIdByIndex(i);
if (!namedValues.hasNamedValueWithName(id)) {
id.getLocation().reportSemanticError(MessageFormat.format("No named bit with name `{0}'' is defined in type `{1}''", id.getDisplayName(), getTypename()));
value.setIsErroneous(true);
value.setLastTimeChecked(timestamp);
return selfReference;
}
IValue tempValue = namedValues.getNamedValueByName(id).getValue();
final ReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
tempValue = tempValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!tempValue.getIsErroneous(timestamp) && Value_type.INTEGER_VALUE.equals(tempValue.getValuetype())) {
final int bitIndex = ((Integer_Value) tempValue).intValue();
while (builder.length() <= bitIndex) {
builder.append('0');
}
builder.setCharAt(bitIndex, '1');
} else {
// FIXME Most probably we were
// not able to build the
// semantic structure for
// something, because it is not
// yet supported, like
// referenced values in sets
}
}
last = new Bitstring_Value(builder.toString());
last.copyGeneralProperties(value);
namedBits.setRealValue((Bitstring_Value) last);
break;
}
default:
value.getLocation().reportSemanticError(BITSTRINGVALUEEXPECTED1);
value.setIsErroneous(true);
value.setLastTimeChecked(timestamp);
return selfReference;
}
} else {
switch(last.getValuetype()) {
case BITSTRING_VALUE:
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
value.getLocation().reportSemanticError(BITSTRINGVALUEEXPECTED2);
value.setIsErroneous(true);
}
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, last);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class TableConstraint method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (null != lastTimeChecked && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
parseBlocks();
if (null == myType) {
return;
}
objectSet.setMyScope(myType.getMyScope());
BridgingNamedNode bridge = new BridgingNamedNode(this, FULLNAMEPART);
objectSet.setFullNameParent(bridge);
// search the constrained type (not the reference to it)
constrainedType = myType;
while (true) {
if (constrainedType.getIsErroneous(timestamp)) {
return;
}
if (Type_type.TYPE_OPENTYPE.equals(constrainedType.getTypetype()) || Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(constrainedType.getTypetype())) {
break;
} else if (constrainedType instanceof IReferencingType) {
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
constrainedType = ((IReferencingType) constrainedType).getTypeRefd(timestamp, chain);
chain.release();
} else {
myType.getLocation().reportSemanticError(OCFTEXPECTED);
return;
}
}
if (Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(constrainedType.getTypetype())) {
ObjectClassField_Type ocfType = (ObjectClassField_Type) constrainedType;
objectClassFieldname = ocfType.getObjectClassFieldName();
objectSet.setMyGovernor(ocfType.getMyObjectClass());
objectSet.check(timestamp);
return;
}
// opentype
final Open_Type openType = (Open_Type) constrainedType;
openType.setMyTableConstraint(this);
objectClassFieldname = openType.getObjectClassFieldName();
objectSet.setMyGovernor(openType.getMyObjectClass());
objectSet.check(timestamp);
if (null == atNotationList) {
return;
}
// componentrelationconstraint...
// search the outermost textually enclosing seq, set or choice
IType outermostParent = null;
IType tempType = myType;
do {
switch(tempType.getTypetype()) {
case TYPE_ASN1_CHOICE:
case TYPE_TTCN3_CHOICE:
case TYPE_OPENTYPE:
case TYPE_ASN1_SEQUENCE:
case TYPE_TTCN3_SEQUENCE:
case TYPE_ASN1_SET:
case TYPE_TTCN3_SET:
outermostParent = tempType;
break;
default:
break;
}
tempType = tempType.getParentType();
} while (null != tempType);
if (null == outermostParent) {
myType.getLocation().reportSemanticError(CANNOTDETERMINEPARENT);
return;
}
// outermostparent->set_opentype_outermost();
// TODO implement the setting of set_has_openType
AtNotation atNotation;
for (int i = 0; i < atNotationList.getNofAtNotations(); i++) {
atNotation = atNotationList.getAtNotationByIndex(i);
IType parent = null;
if (0 == atNotation.getLevels()) {
parent = outermostParent;
} else {
parent = myType;
for (int level = atNotation.getLevels(); level > 0; level--) {
parent = parent.getParentType();
if (null == parent) {
myType.getLocation().reportSemanticError(MessageFormat.format(TOOMANYDOTS, atNotation.getLevels()));
return;
}
}
}
tempType = parent;
atNotation.setFirstComponent(parent);
// component identifiers... do they exist? yes, if the refd type is constrained
FieldName componentIdentifiers = atNotation.getComponentIdentifiers();
for (int j = 0; j < componentIdentifiers.getNofFields(); j++) {
Identifier identifier = componentIdentifiers.getFieldByIndex(i);
switch(tempType.getTypetype()) {
case TYPE_ASN1_CHOICE:
{
final ASN1_Choice_Type temp2 = (ASN1_Choice_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_CHOICE:
{
final TTCN3_Choice_Type temp2 = (TTCN3_Choice_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_OPENTYPE:
{
final Open_Type temp2 = (Open_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_ASN1_SEQUENCE:
{
final ASN1_Sequence_Type temp2 = (ASN1_Sequence_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_SEQUENCE:
{
final TTCN3_Sequence_Type temp2 = (TTCN3_Sequence_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_ASN1_SET:
{
final ASN1_Set_Type temp2 = (ASN1_Set_Type) tempType;
if (temp2.hasComponentWithName(identifier)) {
final CompField cf = temp2.getComponentByName(identifier);
tempType = cf.getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
case TYPE_TTCN3_SET:
{
final TTCN3_Set_Type temp2 = (TTCN3_Set_Type) tempType;
if (temp2.hasComponentWithName(identifier.getName())) {
tempType = temp2.getComponentByName(identifier.getName()).getType();
} else {
myType.getLocation().reportSemanticError(MessageFormat.format(NOCOMPONENTERROR, tempType.getFullName(), identifier.getDisplayName()));
return;
}
break;
}
default:
myType.getLocation().reportSemanticError(MessageFormat.format(SECHOEXPECTED, tempType.getFullName()));
return;
}
}
atNotation.setLastComponent(tempType);
/*
* check if the referenced component is constrained by the same objectset...
*/
boolean ok = false;
final Constraints constraints = tempType.getConstraints();
if (constraints != null) {
constraints.check(timestamp);
final TableConstraint tableConstraint = constraints.getTableConstraint();
if (tableConstraint != null) {
IType ocft = tableConstraint.constrainedType;
if (Type_type.TYPE_OBJECTCLASSFIELDTYPE.equals(ocft.getTypetype())) {
atNotation.setObjectClassFieldname(((ObjectClassField_Type) ocft).getObjectClassFieldName());
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
ObjectSet_definition osdef1 = tableConstraint.objectSet.getRefdLast(timestamp, chain);
chain.release();
chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final ObjectSet_definition osdef2 = objectSet.getRefdLast(timestamp, chain);
chain.release();
if (osdef1 == osdef2) {
ok = true;
} else {
ok = false;
}
}
}
}
if (!ok) {
myType.getLocation().reportSemanticError(SAMECONSTRAINTEXPECTED);
return;
}
}
if (objectSet instanceof Referenced_ObjectSet) {
final Identifier objectSetId = ((Referenced_ObjectSet) objectSet).getId();
collectTypesOfOpenType(timestamp, objectSet, openType, objectSetId);
} else {
// TODO: is it posssible? Perhaps log error!
return;
}
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class Start_Referenced_Component_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
Component_Type compType = null;
if (componentReference != null) {
compType = Port_Utility.checkComponentReference(timestamp, this, componentReference, false, false);
}
if (dereferredValue == null) {
return;
}
switch(dereferredValue.getValuetype()) {
case EXPRESSION_VALUE:
if (Operation_type.REFERS_OPERATION.equals(((Expression_Value) dereferredValue).getOperationType())) {
dereferredValue.getLocation().reportSemanticError("A value of a function type was expected in the argument instead of a `refers' operation," + " which does not specify any function type.");
return;
}
break;
case TTCN3_NULL_VALUE:
case FAT_NULL_VALUE:
dereferredValue.getLocation().reportSemanticError("A value of a function type was expected in the argument instead of a `null' value, which does not specify any function type.");
return;
default:
break;
}
dereferredValue.setLoweridToReference(timestamp);
IType type = dereferredValue.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type != null) {
type = type.getTypeRefdLast(timestamp);
}
if (type == null || type.getIsErroneous(timestamp)) {
return;
}
if (!Type_type.TYPE_FUNCTION.equals(type.getTypetype())) {
dereferredValue.getLocation().reportSemanticError(MessageFormat.format("A value of type function was expected in the argument of `{0}''", type.getTypename()));
return;
}
final Function_Type functionType = (Function_Type) type;
if (functionType.isRunsOnSelf()) {
dereferredValue.getLocation().reportSemanticError("The argument cannot be a function reference with 'runs on self' clause");
return;
}
if (!functionType.checkStartable(timestamp, getLocation())) {
return;
}
final IType runsOnType = functionType.getRunsOnType(timestamp);
if (compType != null && runsOnType != null && !runsOnType.isCompatible(timestamp, compType, null, null, null)) {
final String message = MessageFormat.format("Component type mismatch: the component reference os of type `{0}'', but functions of type `{1}'' run on `{2}''", compType.getTypename(), functionType.getTypename(), runsOnType.getTypename());
componentReference.getLocation().reportSemanticError(message);
}
final IType returnType = functionType.getReturnType();
if (returnType != null) {
if (functionType.returnsTemplate()) {
dereferredValue.getLocation().reportSemanticWarning(MessageFormat.format("Function of type `{0}'' return a template of type `{1}''," + " which cannot be retrieved when the test component terminates", functionType.getTypename(), returnType.getTypename()));
} else {
IType lastType = returnType;
boolean returnTypeCorrect = false;
while (!returnTypeCorrect) {
if (lastType.hasDoneAttribute()) {
returnTypeCorrect = true;
break;
}
if (lastType instanceof IReferencingType) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IType refd = ((IReferencingType) lastType).getTypeRefd(timestamp, refChain);
refChain.release();
if (lastType != refd) {
lastType = refd;
} else {
break;
}
} else {
break;
}
}
if (!returnTypeCorrect) {
dereferredValue.getLocation().reportSemanticWarning(MessageFormat.format("Return type of function type `{0}'' is `{1}'', which does not have the `done'' extension attibute." + " When the test component terminates the returnes value cannot be retrived with a `done'' operation", functionType.getTypename(), returnType.getTypename()));
}
}
}
actualParameterList2 = new ActualParameterList();
final FormalParameterList formalParameters = functionType.getFormalParameters();
if (!formalParameters.checkActualParameterList(timestamp, parameters, actualParameterList2)) {
actualParameterList2.setFullNameParent(this);
actualParameterList2.setMyScope(getMyScope());
}
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class Embedded_PDV_Type method getTypeRefdLast.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
final boolean newChain = null == referenceChain;
IReferenceChain tempReferenceChain;
if (newChain) {
tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
tempReferenceChain = referenceChain;
}
IType t = this;
while (t != null && t instanceof IReferencingType && !t.getIsErroneous(timestamp)) {
t = ((IReferencingType) t).getTypeRefd(timestamp, tempReferenceChain);
}
if (newChain) {
tempReferenceChain.release();
}
if (t != null && t.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
return t;
}
use of org.eclipse.titan.designer.AST.IReferencingType in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Type method getTypeRefdLast.
@Override
public /**
* {@inheritDoc}
*/
IType getTypeRefdLast(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
final boolean newChain = null == referenceChain;
IReferenceChain tempReferenceChain;
if (newChain) {
tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
tempReferenceChain = referenceChain;
}
IType t = this;
while (t != null && t instanceof IReferencingType && !t.getIsErroneous(timestamp)) {
t = ((IReferencingType) t).getTypeRefd(timestamp, tempReferenceChain);
}
if (newChain) {
tempReferenceChain.release();
}
if (t != null && t.getIsErroneous(timestamp)) {
setIsErroneous(true);
}
return t;
}
Aggregations