use of org.eclipse.titan.designer.AST.TTCN3.values.Testcase_Reference_Value in project titan.EclipsePlug-ins by eclipse.
the class ActivateDereferedExpression method generateCodeExpressionExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), chain);
chain.release();
if (last.getValuetype() == Value_type.ALTSTEP_REFERENCE_VALUE) {
// the referred testcase is known
final Def_Testcase testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
expression.expression.append(MessageFormat.format("{0}(", testcase.getGenNameFromScope(aData, expression.expression, myScope, "activate_")));
} else {
// the referred testcase is unknown
value.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".activate(");
}
actualParameters.generateCodeAlias(aData, expression);
expression.expression.append(')');
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Testcase_Reference_Value in project titan.EclipsePlug-ins by eclipse.
the class SubType method checkThisValue.
/**
* Checks if a given value is valid according to this sub-type.
*
* @param timestamp
* the time stamp of the actual semantic check cycle.
* @param value
* the value to be checked
*/
public void checkThisValue(final CompilationTimeStamp timestamp, final IValue value) {
if (getIsErroneous(timestamp) || (subtypeConstraint == null)) {
return;
}
if (value.getIsErroneous(timestamp)) {
return;
}
final IValue last = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
if (last.getIsErroneous(timestamp)) {
return;
}
boolean isValid = true;
switch(last.getValuetype()) {
case INTEGER_VALUE:
if (subtypeType != SubType_type.ST_INTEGER) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(new IntegerLimit(((Integer_Value) last).getValueValue()));
break;
case REAL_VALUE:
if (subtypeType == SubType_type.ST_FLOAT) {
isValid = subtypeConstraint.isElement(((Real_Value) last).getValue());
break;
} else if (subtypeType == SubType_type.ST_INTEGER) {
final Real_Value real = (Real_Value) last;
if (real.isNegativeInfinity()) {
isValid = subtypeConstraint.isElement(IntegerLimit.MINIMUM);
break;
} else if (real.isPositiveInfinity()) {
isValid = subtypeConstraint.isElement(IntegerLimit.MAXIMUM);
break;
}
}
ErrorReporter.INTERNAL_ERROR();
return;
case BOOLEAN_VALUE:
if (subtypeType != SubType_type.ST_BOOLEAN) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Boolean_Value) last).getValue());
break;
case VERDICT_VALUE:
if (subtypeType != SubType_type.ST_VERDICTTYPE) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Verdict_Value) last).getValue());
break;
case BITSTRING_VALUE:
if (subtypeType != SubType_type.ST_BITSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Bitstring_Value) last).getValue());
break;
case HEXSTRING_VALUE:
if (subtypeType != SubType_type.ST_HEXSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Hexstring_Value) last).getValue());
break;
case OCTETSTRING_VALUE:
if (subtypeType != SubType_type.ST_OCTETSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((Octetstring_Value) last).getValue());
break;
case CHARSTRING_VALUE:
switch(subtypeType) {
case ST_CHARSTRING:
isValid = subtypeConstraint.isElement(((Charstring_Value) last).getValue());
break;
case ST_UNIVERSAL_CHARSTRING:
isValid = subtypeConstraint.isElement(new UniversalCharstring(((Charstring_Value) last).getValue()));
break;
default:
ErrorReporter.INTERNAL_ERROR();
return;
}
break;
case UNIVERSALCHARSTRING_VALUE:
if (subtypeType != SubType_type.ST_UNIVERSAL_CHARSTRING) {
ErrorReporter.INTERNAL_ERROR();
return;
}
isValid = subtypeConstraint.isElement(((UniversalCharstring_Value) last).getValue());
break;
case SEQUENCEOF_VALUE:
case SETOF_VALUE:
case OBJECTID_VALUE:
case ENUMERATED_VALUE:
case CHOICE_VALUE:
case SEQUENCE_VALUE:
case SET_VALUE:
case FUNCTION_REFERENCE_VALUE:
case ALTSTEP_REFERENCE_VALUE:
case TESTCASE_REFERENCE_VALUE:
if (value.isUnfoldable(timestamp)) {
return;
}
isValid = subtypeConstraint.isElement(last);
break;
default:
return;
}
if (!isValid) {
value.getLocation().reportSemanticError(MessageFormat.format("{0} is not a valid value for type `{1}'' which has subtype {2}", last.createStringRepresentation(), myOwner.getTypename(), subtypeConstraint.toString()));
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Testcase_Reference_Value in project titan.EclipsePlug-ins by eclipse.
the class RefersExpression method evaluateValue.
@Override
public /**
* {@inheritDoc}
*/
IValue evaluateValue(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return lastValue;
}
isErroneous = false;
lastTimeChecked = timestamp;
lastValue = this;
if (referred == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp) || referredAssignment == null) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
switch(referredAssignment.getAssignmentType()) {
case A_FUNCTION:
case A_FUNCTION_RTEMP:
case A_FUNCTION_RVAL:
lastValue = new Function_Reference_Value((Def_Function) referredAssignment);
lastValue.copyGeneralProperties(this);
break;
case A_EXT_FUNCTION:
case A_EXT_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RVAL:
lastValue = new Function_Reference_Value((Def_Extfunction) referredAssignment);
lastValue.copyGeneralProperties(this);
break;
case A_ALTSTEP:
lastValue = new Altstep_Reference_Value((Def_Altstep) referredAssignment);
lastValue.copyGeneralProperties(this);
break;
case A_TESTCASE:
lastValue = new Testcase_Reference_Value((Def_Testcase) referredAssignment);
lastValue.copyGeneralProperties(this);
break;
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Testcase_Reference_Value in project titan.EclipsePlug-ins by eclipse.
the class ExecuteDereferedExpression method generateCodeExpressionExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last = value.getValueRefdLast(CompilationTimeStamp.getBaseTimestamp(), chain);
chain.release();
if (last.getValuetype() == Value_type.TESTCASE_REFERENCE_VALUE) {
// the referred testcase is known
final Def_Testcase testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
expression.expression.append(MessageFormat.format("{0}(", testcase.getGenNameFromScope(aData, expression.expression, myScope, "testcase_")));
actualParameters.generateCodeAlias(aData, expression);
} else {
// the referred testcase is unknown
value.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".execute(");
actualParameters.generateCodeAlias(aData, expression);
}
if (actualParameters.getNofParameters() > 0) {
expression.expression.append(", ");
}
if (timerValue != null) {
expression.expression.append("true, ");
timerValue.generateCodeExpression(aData, expression, true);
expression.expression.append(')');
} else {
expression.expression.append("false, new TitanFloat( new Ttcn3Float( 0.0 ) ))");
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Testcase_Reference_Value in project titan.EclipsePlug-ins by eclipse.
the class Testcase_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);
final IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp)) {
return selfReference;
}
last.setMyGovernor(this);
// 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;
}
Def_Testcase testcase = null;
switch(last.getValuetype()) {
case TESTCASE_REFERENCE_VALUE:
testcase = ((Testcase_Reference_Value) last).getReferredTestcase();
if (testcase == null) {
setIsErroneous(true);
return selfReference;
}
testcase.check(timestamp);
break;
case TTCN3_NULL_VALUE:
value.setValuetype(timestamp, Value_type.FAT_NULL_VALUE);
return selfReference;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
return selfReference;
default:
value.getLocation().reportSemanticError(TESTCASEREFERENCEVALUEEXPECTED);
value.setIsErroneous(true);
return selfReference;
}
final Component_Type temporalRunsOnType = testcase.getRunsOnType(timestamp);
if (temporalRunsOnType != null) {
if (runsOnType != null && !temporalRunsOnType.isCompatible(timestamp, runsOnType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLERUNSONTYPESERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalRunsOnType.getTypename()));
value.setIsErroneous(true);
}
}
formalParList.checkCompatibility(timestamp, testcase.getFormalParameterList(), value.getLocation());
Component_Type temporalSystemType = testcase.getSystemType(timestamp);
if (temporalSystemType == null) {
temporalSystemType = temporalRunsOnType;
}
if (systemRef == null) {
if (temporalSystemType != null && runsOnType != null && !temporalSystemType.isCompatible(timestamp, runsOnType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), runsOnType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
value.setIsErroneous(true);
}
} else {
if (temporalSystemType != null && systemType != null && !temporalSystemType.isCompatible(timestamp, systemType, null, null, null)) {
value.getLocation().reportSemanticError(MessageFormat.format(SYSTEMCLAUSEMISMATCHERROR, getTypename(), systemType.getTypename(), testcase.getAssignmentName(), temporalSystemType.getTypename()));
value.setIsErroneous(true);
}
}
if (valueCheckingOptions.sub_check) {
// there is no parent type to check
if (subType != null) {
subType.checkThisValue(timestamp, value);
}
}
value.setLastTimeChecked(timestamp);
return selfReference;
}
Aggregations