use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class EncodeExpression 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 the value to be 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 (templateInstance == 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 = templateInstance.getExpressionGovernor(timestamp, internalExpectation);
ITTCN3Template template = templateInstance.getTemplateBody();
if (type == null) {
template = template.setLoweridToReference(timestamp);
type = template.getExpressionGovernor(timestamp, internalExpectation);
}
if (type == null) {
if (!template.getIsErroneous(timestamp)) {
templateInstance.getLocation().reportSemanticError(OPERANDERROR1);
}
setIsErroneous(true);
return;
}
IsValueExpression.checkExpressionTemplateInstance(timestamp, this, templateInstance, 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(OPERANDERROR2);
setIsErroneous(true);
}
break;
default:
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template 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.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class Any2UnistrExpression 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.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class Def_ModulePar_Template method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
T3Doc.check(this.getCommentLocation(), KIND);
isUsed = false;
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_MODULEPAR, identifier, this);
NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
if (withAttributesPath != null) {
withAttributesPath.checkGlobalAttributes(timestamp, false);
withAttributesPath.checkAttributes(timestamp);
}
if (type == null) {
return;
}
type.setGenName("_T_", getGenName());
type.check(timestamp);
final IType lastType = type.getTypeRefdLast(timestamp);
switch(lastType.getTypetype()) {
case TYPE_PORT:
location.reportSemanticError(MessageFormat.format(Def_ModulePar.PORTNOTALLOWED, lastType.getFullName()));
break;
case TYPE_SIGNATURE:
location.reportSemanticError(MessageFormat.format(Def_ModulePar.SIGNATURENOTALLOWED, lastType.getFullName()));
break;
case TYPE_FUNCTION:
case TYPE_ALTSTEP:
case TYPE_TESTCASE:
if (((Function_Type) lastType).isRunsOnSelf()) {
location.reportSemanticError(MessageFormat.format(Def_ModulePar.RUNSONSELF_NOT_ALLOWED, lastType.getFullName()));
}
break;
default:
break;
}
if (defaultTemplate != null) {
realTemplate = defaultTemplate;
// Needed in case of universal charstring templates
if (defaultTemplate.getTemplatetype() == Template_type.CSTR_PATTERN && lastType.getTypetype() == Type.Type_type.TYPE_UCHARSTRING) {
realTemplate = defaultTemplate.setTemplatetype(timestamp, Template_type.USTR_PATTERN);
// FIXME implement setting the pattern type,
// once universal charstring pattern are
// supported.
}
final ITTCN3Template temporalTemplate = type.checkThisTemplateRef(timestamp, realTemplate);
temporalTemplate.checkThisTemplateGeneric(timestamp, type, false, true, true, true, false, null);
final IReferenceChain tempReferenceChain = ReferenceChain.getInstance(Def_Template.CIRCULAREMBEDDEDRECURSION, true);
tempReferenceChain.add(this);
temporalTemplate.checkRecursions(timestamp, tempReferenceChain);
tempReferenceChain.release();
// defaultTemplate.setGenNamePrefix("modulepar_");//currently does not need the prefix
defaultTemplate.setGenNameRecursive(getGenName());
defaultTemplate.setCodeSection(CodeSectionType.CS_PRE_INIT);
}
}
use of org.eclipse.titan.designer.AST.TTCN3.templates.ITTCN3Template in project titan.EclipsePlug-ins by eclipse.
the class Def_Var_Template method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp, final IReferenceChain refChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
lastTimeChecked = timestamp;
isUsed = false;
wasAssigned = false;
NamingConventionHelper.checkConvention(PreferenceConstants.REPORTNAMINGCONVENTION_LOCAL_VARTEMPLATE, identifier, this);
NamingConventionHelper.checkNameContents(identifier, getMyScope().getModuleScope().getIdentifier(), getDescription());
if (type == null) {
lastTimeChecked = timestamp;
return;
}
type.setGenName("_T_", getGenName());
type.check(timestamp);
if (initialValue == null) {
return;
}
final IType lastType = type.getTypeRefdLast(timestamp);
switch(lastType.getTypetype()) {
case TYPE_PORT:
location.reportSemanticError(MessageFormat.format(PORTNOTALLOWED, lastType.getFullName()));
break;
default:
break;
}
TTCN3Template realInitialValue = initialValue;
initialValue.setMyGovernor(type);
// Needed in case of universal charstring templates
if (initialValue.getTemplatetype() == Template_type.CSTR_PATTERN && lastType.getTypetype() == Type.Type_type.TYPE_UCHARSTRING) {
realInitialValue = initialValue.setTemplatetype(timestamp, Template_type.USTR_PATTERN);
// FIXME implement setting the pattern type, once
// universal charstring pattern are supported.
}
final ITTCN3Template temporalValue = type.checkThisTemplateRef(timestamp, realInitialValue);
temporalValue.checkThisTemplateGeneric(timestamp, type, true, true, true, true, false, this);
generateRestrictionCheck = TemplateRestriction.check(timestamp, this, realInitialValue, null);
realInitialValue.setCodeSection(CodeSectionType.CS_INLINE);
// here
if (withAttributesPath != null) {
withAttributesPath.checkGlobalAttributes(timestamp, false);
withAttributesPath.checkAttributes(timestamp);
}
if (mFormalParList != null) {
mFormalParList.reset();
mFormalParList.check(timestamp, getAssignmentType());
// template variable is always local
location.reportSemanticError(MessageFormat.format(PARAMETRIZED_LOCAL_TEMPLATE_VAR, getIdentifier()));
}
initialValue.setGenNameRecursive(getGenName());
initialValue.setCodeSection(CodeSectionType.CS_INLINE);
}
Aggregations