use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class TimerRunningExpression 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 (reference == null) {
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
setIsErroneous(true);
return;
}
switch(assignment.getAssignmentType()) {
case A_TIMER:
{
final ArrayDimensions dimensions = ((Def_Timer) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, reference, "timer", false, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR, assignment.getIdentifier().getDisplayName()));
}
break;
}
case A_PAR_TIMER:
if (reference.getSubreferences().size() > 1) {
reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR, assignment.getIdentifier().getDisplayName()));
}
break;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(OPERANDERROR2, assignment.getDescription()));
setIsErroneous(true);
break;
}
checkExpressionDynamicPart(expectedValue, OPERATIONNAME, true, true, false);
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class UndefRunningExpression 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) {
setIsErroneous(false);
if (reference == null) {
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
setIsErroneous(true);
return;
}
switch(assignment.getAssignmentType()) {
case A_TIMER:
case A_PAR_TIMER:
{
realExpression = new TimerRunningExpression(reference);
realExpression.setMyScope(getMyScope());
realExpression.setFullNameParent(this);
realExpression.setLocation(getLocation());
realExpression.evaluateValue(timestamp, expectedValue, referenceChain);
break;
}
case A_CONST:
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_FUNCTION_RVAL:
case A_EXT_FUNCTION_RVAL:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
{
final Referenced_Value value = new Referenced_Value(reference);
value.setMyScope(getMyScope());
value.setFullNameParent(this);
value.getValueRefdLast(timestamp, referenceChain);
realExpression = new ComponentRunnningExpression(value);
realExpression.setMyScope(getMyScope());
realExpression.setFullNameParent(this);
realExpression.setLocation(getLocation());
realExpression.evaluateValue(timestamp, expectedValue, referenceChain);
break;
}
default:
reference.getLocation().reportSemanticError(MessageFormat.format("First operand of operation `<timer or component> running'' should be timer or component reference instead of {0}", assignment.getDescription()));
setIsErroneous(true);
break;
}
}
use of org.eclipse.titan.designer.AST.Assignment 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.Assignment in project titan.EclipsePlug-ins by eclipse.
the class BrokenPartsViaReferences method collectBrokenModulesViaInvertedImports.
protected List<Module> collectBrokenModulesViaInvertedImports(final List<Module> startModules, final Map<Module, List<Module>> invertedImports) {
final List<Module> startModulesCopy = new ArrayList<Module>(startModules);
final List<Module> result = new ArrayList<Module>();
final MessageConsoleStream stream = TITANDebugConsole.getConsole().newMessageStream();
if (writeDebugInfo) {
for (Module startModule : startModules) {
TITANDebugConsole.println(" ** Module " + startModule.getName() + " can not be skipped as it was not yet analyzed.", stream);
}
}
for (int s = 0; s < startModulesCopy.size(); ++s) {
final Module startModule = startModulesCopy.get(s);
if (!result.contains(startModule)) {
result.add(startModule);
}
final List<Module> whereStartModuleUsed = invertedImports.get(startModule);
for (int d = 0; d < whereStartModuleUsed.size(); ++d) {
final Module dependentModule = whereStartModuleUsed.get(d);
if (!startModulesCopy.contains(dependentModule)) {
startModulesCopy.add(dependentModule);
if (writeDebugInfo) {
TITANDebugConsole.println(" ** Module " + dependentModule.getName() + " can not be skipped as it depends on " + startModule.getName() + " which needs to be checked.", stream);
}
}
}
startModule.notCheckRoot();
final Assignments assignments = startModule.getAssignments();
for (int d = 0; d < assignments.getNofAssignments(); ++d) {
final Assignment assignment = assignments.getAssignmentByIndex(d);
assignment.notCheckRoot();
}
}
return result;
}
use of org.eclipse.titan.designer.AST.Assignment 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;
}
}
Aggregations