use of org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value in project titan.EclipsePlug-ins by eclipse.
the class IsBoundExpression method checkExpressionTemplateInstance.
/**
* Checks if the templateinstance parameter (which is a parameter of the
* expression parameter) is actually a constant or static value or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expression
* the expression to report the possible errors to.
* @param instance
* the template instance parameter of the expression to
* be checked.
* @param type
* the type against which the template instance shall be
* checked.
* @param referenceChain
* the reference chain to detect circular references.
* @param expectedValue
* the expected value of the template instance.
*/
private static void checkExpressionTemplateInstance(final CompilationTimeStamp timestamp, final Expression_Value expression, final TemplateInstance instance, final IType type, final IReferenceChain referenceChain, final Expected_Value_type expectedValue) {
Expected_Value_type internalExpectation;
if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
internalExpectation = Expected_Value_type.EXPECTED_TEMPLATE;
} else {
internalExpectation = expectedValue;
}
final ITTCN3Template body = instance.getTemplateBody();
if (Template_type.TEMPLATE_REFD.equals(body.getTemplatetype())) {
((Referenced_Template) body).getReference().setUsedInIsbound();
} else if (Template_type.SPECIFIC_VALUE.equals(body.getTemplatetype())) {
final IValue value = ((SpecificValue_Template) body).getValue();
if (value != null && Value_type.REFERENCED_VALUE.equals(value.getValuetype())) {
((Referenced_Value) value).getReference().setUsedInIsbound();
}
}
instance.check(timestamp, type);
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectation) && instance.getDerivedReference() != null) {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectation)) {
instance.getLocation().reportSemanticError(CONSTEXPECTED1);
} else {
instance.getLocation().reportSemanticError(STATICEXPECTED1);
}
expression.setIsErroneous(true);
}
ITTCN3Template template = instance.getTemplateBody();
if (template.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
return;
}
switch(template.getTemplatetype()) {
case TEMPLATE_REFD:
if (Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectation)) {
template = template.getTemplateReferencedLast(timestamp, referenceChain);
if (template.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
}
} else {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectation)) {
instance.getLocation().reportSemanticError(MessageFormat.format(CONSTEXPECTED2, ((Referenced_Template) template).getReference().getRefdAssignment(timestamp, true).getDescription()));
} else {
instance.getLocation().reportSemanticError(MessageFormat.format(STATICEXPECTED2, ((Referenced_Template) template).getReference().getRefdAssignment(timestamp, true).getDescription()));
}
expression.setIsErroneous(true);
}
break;
case SPECIFIC_VALUE:
final IValue tempValue = ((SpecificValue_Template) template).getSpecificValue();
switch(tempValue.getValuetype()) {
case REFERENCED_VALUE:
type.checkThisValueRef(timestamp, tempValue);
break;
case EXPRESSION_VALUE:
tempValue.getValueRefdLast(timestamp, referenceChain);
break;
default:
break;
}
if (tempValue.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value in project titan.EclipsePlug-ins by eclipse.
the class IsPresentExpression method checkExpressionTemplateInstance.
/**
* Checks if the templateinstance parameter (which is a parameter of the
* expression parameter) is actually a constant or static value or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expression
* the expression to report the possible errors to.
* @param instance
* the template instance parameter of the expression to
* be checked.
* @param type
* the type against which the template instance shall be
* checked.
* @param referenceChain
* the reference chain to detect circular references.
* @param expectedValue
* the expected value of the template instance.
*/
private static void checkExpressionTemplateInstance(final CompilationTimeStamp timestamp, final Expression_Value expression, final TemplateInstance instance, final IType type, final IReferenceChain referenceChain, final Expected_Value_type expectedValue) {
Expected_Value_type internalExpectation;
if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
internalExpectation = Expected_Value_type.EXPECTED_TEMPLATE;
} else {
internalExpectation = expectedValue;
}
final ITTCN3Template body = instance.getTemplateBody();
if (Template_type.TEMPLATE_REFD.equals(body.getTemplatetype())) {
// FIXME
((Referenced_Template) body).getReference().setUsedInIsbound();
} else if (Template_type.SPECIFIC_VALUE.equals(body.getTemplatetype())) {
final IValue value = ((SpecificValue_Template) body).getValue();
if (value != null && Value_type.REFERENCED_VALUE.equals(value.getValuetype())) {
// FIXME
((Referenced_Value) value).getReference().setUsedInIsbound();
}
}
instance.check(timestamp, type);
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectation) && instance.getDerivedReference() != null) {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectation)) {
instance.getLocation().reportSemanticError(CONSTEXPECTED1);
} else {
instance.getLocation().reportSemanticError(STATICEXPECTED1);
}
expression.setIsErroneous(true);
}
ITTCN3Template template = instance.getTemplateBody();
if (template.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
return;
}
switch(template.getTemplatetype()) {
case TEMPLATE_REFD:
if (Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectation)) {
template = template.getTemplateReferencedLast(timestamp, referenceChain);
if (template.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
}
} else {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectation)) {
instance.getLocation().reportSemanticError(MessageFormat.format(CONSTEXPECTED2, ((Referenced_Template) template).getReference().getRefdAssignment(timestamp, true).getDescription()));
} else {
instance.getLocation().reportSemanticError(MessageFormat.format(STATICEXPECTED2, ((Referenced_Template) template).getReference().getRefdAssignment(timestamp, true).getDescription()));
}
expression.setIsErroneous(true);
}
break;
case SPECIFIC_VALUE:
final IValue tempValue = ((SpecificValue_Template) template).getSpecificValue();
switch(tempValue.getValuetype()) {
case REFERENCED_VALUE:
type.checkThisValueRef(timestamp, tempValue);
break;
case EXPRESSION_VALUE:
tempValue.getValueRefdLast(timestamp, referenceChain);
break;
default:
break;
}
if (tempValue.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value in project titan.EclipsePlug-ins by eclipse.
the class Type method checkThisValue.
@Override
public /**
* {@inheritDoc}
*/
boolean checkThisValue(final CompilationTimeStamp timestamp, final IValue value, final Assignment lhs, final ValueCheckingOptions valueCheckingOptions) {
value.setIsErroneous(false);
final Assignment assignment = getDefiningAssignment();
if (assignment != null && assignment instanceof Definition) {
final Scope scope = value.getMyScope();
if (scope != null) {
final Module module = scope.getModuleScope();
if (module != null) {
final String referingModuleName = module.getName();
if (!((Definition) assignment).referingHere.contains(referingModuleName)) {
((Definition) assignment).referingHere.add(referingModuleName);
}
} else {
ErrorReporter.logError("The value `" + value.getFullName() + "' does not appear to be in a module");
value.setIsErroneous(true);
}
} else {
ErrorReporter.logError("The value `" + value.getFullName() + "' does not appear to be in a scope");
value.setIsErroneous(true);
}
}
check(timestamp);
final IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (last == null || last.getIsErroneous(timestamp) || getIsErroneous(timestamp)) {
return false;
}
if (Value_type.OMIT_VALUE.equals(last.getValuetype()) && !valueCheckingOptions.omit_allowed) {
value.getLocation().reportSemanticError("`omit' value is not allowed in this context");
value.setIsErroneous(true);
return false;
}
boolean selfReference = false;
switch(value.getValuetype()) {
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
selfReference = checkThisReferencedValue(timestamp, last, lhs, valueCheckingOptions.expected_value, chain, valueCheckingOptions.sub_check, valueCheckingOptions.str_elem);
chain.release();
return selfReference;
}
return false;
case REFERENCED_VALUE:
{
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
selfReference = checkThisReferencedValue(timestamp, value, lhs, valueCheckingOptions.expected_value, chain, valueCheckingOptions.sub_check, valueCheckingOptions.str_elem);
chain.release();
return selfReference;
}
case EXPRESSION_VALUE:
selfReference = value.checkExpressionSelfReference(timestamp, lhs);
if (value.isUnfoldable(timestamp, null)) {
final Type_type temporalType = value.getExpressionReturntype(timestamp, valueCheckingOptions.expected_value);
if (!Type_type.TYPE_UNDEFINED.equals(temporalType) && !isCompatible(timestamp, this.getTypetype(), temporalType, false, value.isAsn())) {
value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLEVALUE, getTypename()));
value.setIsErroneous(true);
}
}
return selfReference;
case MACRO_VALUE:
selfReference = value.checkExpressionSelfReference(timestamp, lhs);
if (value.isUnfoldable(timestamp, null)) {
final Type_type temporalType = value.getExpressionReturntype(timestamp, valueCheckingOptions.expected_value);
if (!Type_type.TYPE_UNDEFINED.equals(temporalType) && !isCompatible(timestamp, this.getTypetype(), temporalType, false, value.isAsn())) {
value.getLocation().reportSemanticError(MessageFormat.format(INCOMPATIBLEVALUE, getTypename()));
value.setIsErroneous(true);
}
return selfReference;
}
break;
default:
break;
}
return selfReference;
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value in project titan.EclipsePlug-ins by eclipse.
the class IsValueExpression method checkExpressionTemplateInstance.
/**
* Checks if the templateinstance parameter (which is a parameter of the
* expression parameter) is actually a constant or static value or not.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param expression
* the expression to report the possible errors to.
* @param instance
* the template instance parameter of the expression to
* be checked.
* @param type
* the type against which the template instance shall be
* checked.
* @param referenceChain
* the referencechain to detect circular references.
* @param expectedValue
* the expected value of the template instance.
*/
public static void checkExpressionTemplateInstance(final CompilationTimeStamp timestamp, final Expression_Value expression, final TemplateInstance instance, final IType type, final IReferenceChain referenceChain, final Expected_Value_type expectedValue) {
Expected_Value_type internalExpectation;
if (Expected_Value_type.EXPECTED_DYNAMIC_VALUE.equals(expectedValue)) {
internalExpectation = Expected_Value_type.EXPECTED_TEMPLATE;
} else {
internalExpectation = expectedValue;
}
instance.check(timestamp, type);
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectation) && instance.getDerivedReference() != null) {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectation)) {
instance.getLocation().reportSemanticError(CONSTEXPECTED1);
} else {
instance.getLocation().reportSemanticError(STATICEXPECTED1);
}
expression.setIsErroneous(true);
}
ITTCN3Template template = instance.getTemplateBody();
if (template.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
return;
}
switch(template.getTemplatetype()) {
case TEMPLATE_REFD:
if (Expected_Value_type.EXPECTED_TEMPLATE.equals(internalExpectation)) {
template = template.getTemplateReferencedLast(timestamp, referenceChain);
if (template.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
}
} else {
if (Expected_Value_type.EXPECTED_CONSTANT.equals(internalExpectation)) {
instance.getLocation().reportSemanticError(MessageFormat.format(CONSTEXPECTED2, ((Referenced_Template) template).getReference().getRefdAssignment(timestamp, true).getDescription()));
} else {
instance.getLocation().reportSemanticError(MessageFormat.format(STATICEXPECTED2, ((Referenced_Template) template).getReference().getRefdAssignment(timestamp, true).getDescription()));
}
expression.setIsErroneous(true);
}
break;
case SPECIFIC_VALUE:
final IValue tempValue = ((SpecificValue_Template) template).getSpecificValue();
switch(tempValue.getValuetype()) {
case REFERENCED_VALUE:
type.checkThisValueRef(timestamp, tempValue);
break;
case EXPRESSION_VALUE:
tempValue.getValueRefdLast(timestamp, referenceChain);
break;
default:
break;
}
if (tempValue.getIsErroneous(timestamp)) {
expression.setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.values.Expression_Value in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Integer_Type method checkThisValueLimit.
// this method accepts REAL_VALUE
public void checkThisValueLimit(final CompilationTimeStamp timestamp, final IValue value, final ValueCheckingOptions valueCheckingOptions) {
super.checkThisValue(timestamp, value, null, valueCheckingOptions);
final IValue last = value.getValueRefdLast(timestamp, valueCheckingOptions.expected_value, null);
if (null == last || last.getIsErroneous(timestamp)) {
return;
}
// already handled ones
switch(value.getValuetype()) {
case OMIT_VALUE:
case REFERENCED_VALUE:
return;
case UNDEFINED_LOWERIDENTIFIER_VALUE:
if (Value_type.REFERENCED_VALUE.equals(last.getValuetype())) {
return;
}
break;
default:
break;
}
switch(last.getValuetype()) {
case INTEGER_VALUE:
case REAL_VALUE:
break;
case NAMED_INTEGER_VALUE:
if (null != namedNumbers) {
// convert it into an integer value
final Identifier name = ((Named_Integer_Value) last).getIdentifier();
final NamedValue namedValue = namedNumbers.getNamedValueByName(name);
IValue tempValue = namedValue.getValue();
final ReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
tempValue = tempValue.getValueRefdLast(timestamp, referenceChain);
referenceChain.release();
if (!tempValue.getIsErroneous(timestamp) && Value_type.INTEGER_VALUE.equals(tempValue.getValuetype())) {
final int temp = ((Integer_Value) tempValue).intValue();
final Integer_Value converted = new Integer_Value(temp);
converted.copyGeneralProperties(value);
((Named_Integer_Value) last).setCalculatedValue(converted);
} else {
// FIXME Most probably we were not able
// to build the semantic structure for
// something, because it is not yet
// supported, like referenced values in
// sets
}
}
break;
case EXPRESSION_VALUE:
case MACRO_VALUE:
// already checked
break;
default:
value.getLocation().reportSemanticError(INTEGERVALUEEXPECTED);
value.setIsErroneous(true);
}
}
Aggregations