use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class DoWhile_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
isInfiniteLoop = false;
if (statementblock != null) {
statementblock.setMyLaicStmt(null, this);
statementblock.check(timestamp);
}
if (expression != null) {
final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (!last.getIsErroneous(timestamp)) {
if (!Type_type.TYPE_BOOL.equals(temporalType)) {
last.getLocation().reportSemanticError(BOOLEANEXPECTED);
expression.setIsErroneous(true);
} else if (!expression.isUnfoldable(timestamp)) {
if (!((Boolean_Value) last).getValue()) {
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null);
expression.getLocation().reportConfigurableSemanticProblem(severity, UNNECESSARYCONTROL);
} else if (ReturnStatus_type.RS_NO.equals(hasReturn(timestamp))) {
isInfiniteLoop = true;
final String severity = Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTINFINITELOOPS, GeneralConstants.WARNING, null);
location.reportConfigurableSemanticProblem(severity, INFINITELOOP);
}
}
if (expression.getMyGovernor() == null) {
expression.setMyGovernor(new Boolean_Type());
}
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class If_Clause method check.
/**
* Does the semantic checking of this branch.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param unreachable
* boolean parameter telling if this if statement was
* already found unreachable by previous clauses or not
*
* @return true if following clauses are unreachable
*/
public boolean check(final CompilationTimeStamp timestamp, final boolean unreachable) {
if (unreachable) {
location.reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH1);
}
boolean unreachable2 = unreachable;
if (expression != null) {
final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (!last.getIsErroneous(timestamp) && !Type_type.TYPE_UNDEFINED.equals(temporalType)) {
if (!Type_type.TYPE_BOOL.equals(temporalType)) {
last.getLocation().reportSemanticError(BOOLEANEXPECTED);
expression.setIsErroneous(true);
} else if (!expression.isUnfoldable(timestamp)) {
if (((Boolean_Value) last).getValue()) {
expression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL1);
unreachable2 = true;
} else {
expression.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), UNNECESSARYCONTROL2);
statementblock.getLocation().reportConfigurableSemanticProblem(Platform.getPreferencesService().getString(ProductConstants.PRODUCT_ID_DESIGNER, PreferenceConstants.REPORTUNNECESSARYCONTROLS, GeneralConstants.WARNING, null), NEVERREACH2);
}
}
if (expression.getMyGovernor() == null) {
expression.setMyGovernor(new Boolean_Type());
}
}
}
if (statementblock != null) {
statementblock.check(timestamp);
}
return unreachable2;
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Int2Enum_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (value != null) {
value.setLoweridToReference(timestamp);
final Type_type temporalType = value.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType) {
case TYPE_INTEGER:
case TYPE_INTEGER_A:
value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
break;
case TYPE_UNDEFINED:
setIsErroneous();
break;
default:
if (!isErroneous) {
value.getLocation().reportSemanticError(OPERANDERROR1);
setIsErroneous();
}
}
}
if (reference != null) {
final IType refType = reference.checkVariableReference(timestamp).getTypeRefdLast(timestamp);
if (Type_type.TYPE_TTCN3_ENUMERATED != refType.getTypetype() && !isErroneous) {
value.getLocation().reportSemanticError(OPERANDERROR2);
setIsErroneous();
}
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Invoke_Altguard method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (expression != null) {
final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (!last.getIsErroneous(timestamp) && !Type_type.TYPE_BOOL.equals(temporalType)) {
last.getLocation().reportSemanticError(BOOLEANEXPECTED);
expression.setIsErroneous(true);
}
if (expression.getMyGovernor() == null) {
expression.setMyGovernor(new Boolean_Type());
}
}
IType type = value.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (type == null) {
lastTimeChecked = timestamp;
return;
}
type = type.getTypeRefdLast(timestamp);
if (type == null || type.getIsErroneous(timestamp)) {
lastTimeChecked = timestamp;
return;
}
if (!Type_type.TYPE_ALTSTEP.equals(type.getTypetype())) {
value.getLocation().reportSemanticError(MessageFormat.format("A value of type altstep was expected instead of `{0}''", type.getTypename()));
lastTimeChecked = timestamp;
return;
}
value.getMyScope().checkRunsOnScope(timestamp, type, this, "call");
final FormalParameterList formalParmaterList = ((Altstep_Type) type).getFormalParameters();
actualParameterList = new ActualParameterList();
formalParmaterList.checkActualParameterList(timestamp, parsedParameters, actualParameterList);
if (statementblock != null) {
statementblock.check(timestamp);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.IType.Type_type in project titan.EclipsePlug-ins by eclipse.
the class Start_Timer_Statement method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
checkTimerReference(timestamp, timerReference);
if (timerValue == null) {
final Assignment assignment = timerReference.getRefdAssignment(timestamp, true);
if (assignment != null && Assignment_type.A_TIMER.semanticallyEquals(assignment.getAssignmentType())) {
final Def_Timer defTimer = (Def_Timer) assignment;
if (!defTimer.hasDefaultDuration(timestamp, timerReference)) {
location.reportSemanticError(MessageFormat.format(MISSINGDEFAULTDURATION, assignment.getDescription()));
}
}
} else {
timerValue.setLoweridToReference(timestamp);
final Type_type temporalType = timerValue.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType) {
case TYPE_REAL:
{
final IValue last = timerValue.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (!last.isUnfoldable(timestamp)) {
final Real_Value real = (Real_Value) last;
final double val = real.getValue();
if (val < 0.0) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(NEGATIVEDURATION, real));
} else if (real.isPositiveInfinity()) {
timerValue.getLocation().reportSemanticError(MessageFormat.format(INFINITYDURATION, real.createStringRepresentation()));
}
}
return;
}
case TYPE_UNDEFINED:
return;
default:
timerValue.getLocation().reportSemanticError(FLOATEXPECTED);
return;
}
}
}
Aggregations