use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const in project titan.EclipsePlug-ins by eclipse.
the class LogArgument method checkReference.
/**
* Does the semantic checking of the log argument. Once it was
* determined that it is a reference.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param reference
* the reference contained in the log argument.
*/
private void checkReference(final CompilationTimeStamp timestamp, final Reference reference) {
if (reference == null) {
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null || assignment.getIsErroneous()) {
return;
}
switch(assignment.getAssignmentType()) {
case A_FUNCTION_RVAL:
case A_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RVAL:
case A_EXT_FUNCTION_RTEMP:
{
reference.getMyScope().checkRunsOnScope(timestamp, assignment, reference, "call");
final IType assingmentType = assignment.getType(timestamp);
if (assingmentType != null) {
assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
}
break;
}
case A_CONST:
{
final IType assingmentType = assignment.getType(timestamp);
if (assingmentType != null && assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false) != null) {
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
if (assignment instanceof Def_Const) {
((Def_Const) assignment).getValue().getReferencedSubValue(timestamp, reference, 1, chain);
} else {
((Value_Assignment) assignment).getValue().getReferencedSubValue(timestamp, reference, 1, chain);
}
chain.release();
}
break;
}
case A_TEMPLATE:
{
final IType assingmentType = assignment.getType(timestamp);
if (assingmentType != null && assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false) != null) {
final IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
((Def_Template) assignment).getTemplate(timestamp).getReferencedSubTemplate(timestamp, reference, chain);
chain.release();
}
break;
}
case A_MODULEPAR_TEMPLATE:
{
final IType assingmentType = assignment.getType(timestamp);
if (assingmentType != null) {
assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
}
break;
}
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_VAR_TEMPLATE:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
{
final IType assingmentType = assignment.getType(timestamp);
if (assingmentType != null) {
assingmentType.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
}
break;
}
case A_PORT:
{
final ArrayDimensions dimensions = ((Def_Port) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, reference, assignment.getAssignmentName(), true, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (reference.getSubreferences().size() > 1) {
getLocation().reportSemanticError(MessageFormat.format("Reference to single {0} cannot have field or array sub-references", assignment.getDescription()));
isErroneous = true;
}
break;
}
case A_TIMER:
{
final ArrayDimensions dimensions = ((Def_Timer) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, reference, assignment.getAssignmentName(), true, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (reference.getSubreferences().size() > 1) {
getLocation().reportSemanticError(MessageFormat.format("Reference to single {0} cannot have field or array sub-references", assignment.getDescription()));
isErroneous = true;
}
break;
}
case A_PAR_TIMER:
case A_PAR_PORT:
if (reference.getSubreferences().size() > 1) {
getLocation().reportSemanticError(MessageFormat.format("Reference to {0} cannot have field or array sub-references", assignment.getDescription()));
isErroneous = true;
}
break;
case A_FUNCTION:
case A_EXT_FUNCTION:
getLocation().reportSemanticError(MessageFormat.format("Reference to a value, template, timer or port was ecpected instead of a call of {0}, which does not have a return type", assignment.getDescription()));
isErroneous = true;
break;
default:
getLocation().reportSemanticError(MessageFormat.format("Reference to a value, template, timer or port was expected instead of {0}", assignment.getDescription()));
isErroneous = true;
break;
}
}
use of org.eclipse.titan.designer.AST.TTCN3.definitions.Def_Const in project titan.EclipsePlug-ins by eclipse.
the class Type method checkThisTemplateRef.
@Override
public /**
* {@inheritDoc}
*/
ITTCN3Template checkThisTemplateRef(final CompilationTimeStamp timestamp, final ITTCN3Template t, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
switch(t.getTemplatetype()) {
case SUPERSET_MATCH:
case SUBSET_MATCH:
final IType it1 = getTypeRefdLast(timestamp);
final Type_type tt = it1.getTypetype();
if (Type_type.TYPE_SEQUENCE_OF.equals(tt) || Type_type.TYPE_SET_OF.equals(tt)) {
return t;
} else {
t.getLocation().reportSemanticError(MessageFormat.format("{0} cannot be used for type {1}", t.getTemplateTypeName(), getTypename()));
t.setIsErroneous(true);
return t;
}
case SPECIFIC_VALUE:
// cont below
break;
default:
return t;
}
// Case of specific value:
final ITTCN3Template template = t;
IValue value = ((SpecificValue_Template) template).getSpecificValue();
if (value == null) {
return template;
}
value = checkThisValueRef(timestamp, value);
switch(value.getValuetype()) {
case REFERENCED_VALUE:
// FIXME: referenceChain or null?
final Assignment assignment = ((Referenced_Value) value).getReference().getRefdAssignment(timestamp, false, referenceChain);
if (assignment == null) {
template.setIsErroneous(true);
} else {
switch(assignment.getAssignmentType()) {
case A_VAR_TEMPLATE:
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
template.getLocation().reportSemanticError(MessageFormat.format(REFTOVALUEEXPECTED, assignment.getDescription()));
template.setIsErroneous(true);
}
final IType type = ((Def_Var_Template) assignment).getType(timestamp);
switch(type.getTypetype()) {
case TYPE_BITSTRING:
case TYPE_BITSTRING_A:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
case TYPE_UTF8STRING:
case TYPE_NUMERICSTRING:
case TYPE_PRINTABLESTRING:
case TYPE_TELETEXSTRING:
case TYPE_VIDEOTEXSTRING:
case TYPE_IA5STRING:
case TYPE_GRAPHICSTRING:
case TYPE_VISIBLESTRING:
case TYPE_GENERALSTRING:
case TYPE_UNIVERSALSTRING:
case TYPE_BMPSTRING:
case TYPE_UTCTIME:
case TYPE_GENERALIZEDTIME:
case TYPE_OBJECTDESCRIPTOR:
{
final List<ISubReference> subReferences = ((Referenced_Value) value).getReference().getSubreferences();
final int nofSubreferences = subReferences.size();
if (nofSubreferences > 1) {
final ISubReference subreference = subReferences.get(nofSubreferences - 1);
if (subreference instanceof ArraySubReference) {
template.getLocation().reportSemanticError(MessageFormat.format("Reference to {0} can not be indexed", assignment.getDescription()));
template.setIsErroneous(true);
return template;
}
}
break;
}
default:
break;
}
return template.setTemplatetype(timestamp, Template_type.TEMPLATE_REFD);
case A_CONST:
IType type1;
if (assignment instanceof Value_Assignment) {
type1 = ((Value_Assignment) assignment).getType(timestamp);
} else {
type1 = ((Def_Const) assignment).getType(timestamp);
}
switch(type1.getTypetype()) {
case TYPE_BITSTRING:
case TYPE_BITSTRING_A:
case TYPE_HEXSTRING:
case TYPE_OCTETSTRING:
case TYPE_CHARSTRING:
case TYPE_UCHARSTRING:
case TYPE_UTF8STRING:
case TYPE_NUMERICSTRING:
case TYPE_PRINTABLESTRING:
case TYPE_TELETEXSTRING:
case TYPE_VIDEOTEXSTRING:
case TYPE_IA5STRING:
case TYPE_GRAPHICSTRING:
case TYPE_VISIBLESTRING:
case TYPE_GENERALSTRING:
case TYPE_UNIVERSALSTRING:
case TYPE_BMPSTRING:
case TYPE_UTCTIME:
case TYPE_GENERALIZEDTIME:
case TYPE_OBJECTDESCRIPTOR:
{
final List<ISubReference> subReferences = ((Referenced_Value) value).getReference().getSubreferences();
final int nofSubreferences = subReferences.size();
if (nofSubreferences > 1) {
final ISubReference subreference = subReferences.get(nofSubreferences - 1);
if (subreference instanceof ArraySubReference) {
template.getLocation().reportSemanticError(MessageFormat.format("Reference to {0} can not be indexed", assignment.getDescription()));
template.setIsErroneous(true);
return template;
}
}
break;
}
default:
break;
}
break;
case A_TEMPLATE:
case A_MODULEPAR_TEMPLATE:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_OUT:
case A_PAR_TEMP_INOUT:
case A_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RTEMP:
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
template.getLocation().reportSemanticError(MessageFormat.format(REFTOVALUEEXPECTED, assignment.getDescription()));
template.setIsErroneous(true);
}
return template.setTemplatetype(timestamp, Template_type.TEMPLATE_REFD);
default:
break;
}
}
break;
case EXPRESSION_VALUE:
{
final Expression_Value expression = (Expression_Value) value;
if (Operation_type.APPLY_OPERATION.equals(expression.getOperationType())) {
IType type = expression.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_TEMPLATE);
if (type == null) {
break;
}
type = type.getTypeRefdLast(timestamp);
if (type != null && Type_type.TYPE_FUNCTION.equals(type.getTypetype()) && ((Function_Type) type).returnsTemplate()) {
return template.setTemplatetype(timestamp, Template_type.TEMPLATE_INVOKE);
}
}
break;
}
default:
break;
}
return template;
}
Aggregations