use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class TestCase_Function_Visit_Handler method leave.
public void leave(IVisitableNode node) {
if (waitForTC || waitForFunction) {
if (node instanceof Definition_Statement) {
if (!waitForRecord) {
nodeVarIsRecord.add(false);
}
waitForRecord = false;
waitForValue = false;
evaluateExpression();
}
if (node instanceof Undefined_LowerIdentifier_Value) {
blockReferenceListing = false;
}
if ((node instanceof Assignment_Statement) || ((node instanceof If_Clause))) {
waitForValue = false;
// if assignment is a createExpression
if (node instanceof Assignment_Statement) {
if (((Assignment_Statement) node).getTemplate() instanceof SpecificValue_Template) {
SpecificValue_Template specValTemplate = (SpecificValue_Template) ((Assignment_Statement) node).getTemplate();
if (specValTemplate.getSpecificValue() instanceof ComponentCreateExpression) {
isCreate = true;
}
}
}
evaluateExpression();
}
if (node instanceof SequenceOf_Value) {
evaluateExpression();
}
if ((waitForFunction && (node instanceof Return_Statement)) || (waitForTC && (node instanceof ComponentCreateExpression)) || (node instanceof Send_Statement) || (node instanceof Receive_Port_Statement)) {
evaluateExpression();
}
if (waitForTcStartValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
myASTVisitor.blockIdListing = false;
}
if (waitForTcStopValues && (node instanceof Identifier) && myASTVisitor.blockIdListing) {
myASTVisitor.blockIdListing = false;
}
if (node instanceof Connect_Statement) {
waitForTcConnectValues = false;
}
if (node instanceof Disconnect_Statement) {
waitForTcDisconnectValues = false;
}
if (node instanceof Unknown_Start_Statement) {
waitForTcStartValues = false;
}
if (node instanceof Unknown_Stop_Statement) {
waitForTcStopValues = false;
}
if (node instanceof Definition_Statement) {
waitForDefStatement = false;
if (waitForValue) {
nodeVarValues.add(null);
nodeVarIsAValueReference.add(false);
waitForValue = false;
}
}
if (node instanceof Map_Statement) {
waitForMapIdentifiers = false;
}
if (node instanceof ComponentCreateExpression) {
// switch first two values
testCaseCreateValues.add(testCaseCreateCharValues.get(0));
testCaseCreateValues.add(testCaseCreateRefValues.get(0));
for (int i = 1; i < testCaseCreateCharValues.size(); i++) {
testCaseCreateValues.add(testCaseCreateCharValues.get(i));
}
testCaseCreateCharValues.clear();
testCaseCreateRefValues.clear();
waitForTcCreateValues = false;
}
if (node instanceof Assignment_Statement) {
waitForAssignmentIdentifiers = false;
waitForValue = true;
}
if (waitForTcIfCondition && (node instanceof If_Clause)) {
waitForTcIfCondition = false;
}
if (waitForTcStartParameter && (node instanceof Unknown_Start_Statement)) {
testCaseStartValueParameters.add(null);
}
if (waitForTcStopParameter && (node instanceof Unknown_Stop_Statement)) {
testCaseStopValueParameters.add(null);
}
if (isAltGuards && (node instanceof Operation_Altguard)) {
altGuardConditions.add(null);
}
if (node instanceof Operation_Altguard) {
waitForAltStatements = false;
isAltGuards = false;
isReceiveValue = false;
}
handleAltCases(node);
if (node instanceof Unknown_Start_Statement) {
waitForUnknownStartStatement = false;
}
if (node instanceof Unknown_Stop_Statement) {
waitForUnknownStopStatement = false;
}
if (node instanceof Receive_Port_Statement) {
if (waitForReceiveParameter) {
altGuardReceiveType.add("noparam");
}
// TODO checkAnyport = true;
}
}
if (node instanceof Def_Testcase) {
handleTestcase(node);
waitForTC = false;
}
if (node instanceof Def_Function) {
handleFunction(node);
waitForTC = false;
}
if (waitForAssignmentIdentifiers && (node instanceof ArraySubReference)) {
waitForAssignmentIdentifiers = false;
}
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class ConstantParser method process.
@Override
public Scope process(IVisitableNode node) {
if (node instanceof Identifier) {
name = node.toString();
}
if (node instanceof Type) {
type = Util.getTypeName((Type) node);
value = new Value(type, Writable.NULL);
return Action.skip(Type.class, this);
}
if (node instanceof org.eclipse.titan.designer.AST.Value) {
ValueHolder holder = v -> value = v;
return dispatch(this, type, holder, node);
}
return this;
}
use of org.eclipse.titan.designer.AST.Identifier in project titan.EclipsePlug-ins by eclipse.
the class AssignmentHandlerAFTRerences method visit.
@Override
public int visit(final IVisitableNode node) {
if (node instanceof ASN1Assignment) {
final ASN1Assignment assignment = (ASN1Assignment) node;
if (assignment.getAssPard() != null) {
return V_SKIP;
}
}
if (node instanceof StatementBlock) {
final ReferenceCollector referenceCollector = new ReferenceCollector();
node.accept(referenceCollector);
// TODO: broken if reference does not point anywhere
final Set<Reference> references = referenceCollector.getReferences();
addNonContagiousReferences(computeReferences(references));
if (containsErroneousReference(references)) {
setIsInfected(true);
}
return V_SKIP;
}
if (node instanceof Reference) {
final Identifier identifier = ((Reference) node).getId();
if (identifier != null) {
addContagiousReference(identifier.getDisplayName());
}
if (((Reference) node).getIsErroneous(CompilationTimeStamp.getBaseTimestamp())) {
setIsInfected(true);
setIsContagious(true);
return V_CONTINUE;
}
final Assignment assignment = ((Reference) node).getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false, null);
if (assignment == null || assignment.getIdentifier() == null || !assignment.getIdentifier().equals(identifier)) {
setIsInfected(true);
setIsContagious(true);
return V_CONTINUE;
}
}
return V_CONTINUE;
}
use of org.eclipse.titan.designer.AST.Identifier 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.Identifier in project titan.EclipsePlug-ins by eclipse.
the class Sequence_Value method evaluateIspresent.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
if (convertedValue != null && convertedValue != this) {
return convertedValue.evaluateIsbound(timestamp, reference, actualSubReference);
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_SEQUENCE:
if (!((TTCN3_Sequence_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SEQUENCE:
if (!((ASN1_Sequence_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (values.hasNamedValueWithName(fieldId)) {
// we can move on with the check
return values.getNamedValueByName(fieldId).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
if (Type_type.TYPE_TTCN3_SEQUENCE.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Sequence_Type) type).getComponentByName(fieldId);
if (compField.isOptional()) {
// create an explicit omit value
final Value result = new Omit_Value();
final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
result.setFullNameParent(bridge);
result.setMyScope(getMyScope());
return result.evaluateIspresent(timestamp, reference, actualSubReference + 1);
} else if (compField.hasDefault()) {
return compField.getDefault().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
Aggregations