use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class EncvalueUnicharExpression method checkExpressionOperand1.
/**
* Checks the 1st operand
* in template (value) any_type
* @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 checkExpressionOperand1(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (templateInstance1 == null) {
setIsErroneous(true);
return;
}
final Expected_Value_type internalExpectation = Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue) ? Expected_Value_type.EXPECTED_TEMPLATE : expectedValue;
IType type = templateInstance1.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance1.getTemplateBody();
if (type == null) {
template = template.setLoweridToReference(timestamp);
type = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (type == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance1.getLocation().reportSemanticError(OPERAND1_ERROR1);
}
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance1, type, referenceChain, expectedValue);
if (getIsErroneous(timestamp)) {
return;
}
template.checkSpecificValue(timestamp, false);
type = type.getTypeRefdLast(timestamp);
switch(type.getTypetype()) {
case TYPE_UNDEFINED:
case TYPE_NULL:
case TYPE_REFERENCED:
case TYPE_VERDICT:
case TYPE_PORT:
case TYPE_COMPONENT:
case TYPE_DEFAULT:
case TYPE_SIGNATURE:
case TYPE_FUNCTION:
case TYPE_ALTSTEP:
case TYPE_TESTCASE:
if (!isErroneous) {
location.reportSemanticError(OPERAND1_ERROR2);
setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Enum2IntExpression method generateCodeExpressionExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpressionExpression(final JavaGenData aData, final ExpressionStruct expression) {
IType governor = value.getMyGovernor();
if (governor == null) {
governor = value.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
}
if (governor == null) {
governor = myLastSetGovernor;
}
if (governor == null) {
ErrorReporter.INTERNAL_ERROR("FATAL ERROR while generating code for expression `" + getFullName() + "''");
return;
}
final String name = governor.getGenNameValue(aData, expression.expression, myScope);
expression.expression.append(name);
expression.expression.append(".enum2int(");
value.generateCodeExpressionMandatory(aData, expression, false);
expression.expression.append(")");
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Enum2IntExpression 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 (value == null) {
return lastValue;
}
checkExpressionOperands(timestamp, expectedValue, referenceChain);
if (getIsErroneous(timestamp)) {
return lastValue;
}
if (isUnfoldable(timestamp, referenceChain)) {
return lastValue;
}
final IValue last = value.getValueRefdLast(timestamp, referenceChain);
if (last == null || last.getIsErroneous(timestamp)) {
setIsErroneous(true);
return lastValue;
}
IType type = last.getExpressionGovernor(timestamp, expectedValue);
type = type.getTypeRefdLast(timestamp);
switch(type.getTypetype()) {
case TYPE_ASN1_ENUMERATED:
{
final EnumItem item = ((ASN1_Enumerated_Type) type).getEnumItemWithName(((Enumerated_Value) last).getValue());
lastValue = new Integer_Value(((Integer_Value) item.getValue()).getValue());
lastValue.copyGeneralProperties(this);
break;
}
case TYPE_TTCN3_ENUMERATED:
{
final EnumItem item = ((TTCN3_Enumerated_Type) type).getEnumItemWithName(((Enumerated_Value) last).getValue());
lastValue = new Integer_Value(((Integer_Value) item.getValue()).getValue());
lastValue.copyGeneralProperties(this);
break;
}
default:
setIsErroneous(true);
break;
}
return lastValue;
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Set_Value method generateCodeExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression, final boolean forceObject) {
if (canGenerateSingleExpression()) {
expression.expression.append(generateSingleExpression(aData));
return;
}
IType governor = myGovernor;
if (governor == null) {
governor = getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
}
if (governor == null) {
governor = myLastSetGovernor;
}
final String tempId = aData.getTemporaryVariableName();
final String genName = governor.getGenNameValue(aData, expression.expression, myScope);
expression.preamble.append(MessageFormat.format("{0} {1} = new {0}();\n", genName, tempId));
setGenNamePrefix(tempId);
generateCodeInit(aData, expression.preamble, tempId);
expression.expression.append(tempId);
}
use of org.eclipse.titan.designer.AST.IType in project titan.EclipsePlug-ins by eclipse.
the class Set_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;
}
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_SET:
if (!((TTCN3_Set_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SET:
if (!((ASN1_Set_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_SET.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Set_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