use of org.eclipse.titan.designer.AST.ASN1.Value_Assignment in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Value method getValueRefdLast.
@Override
public /**
* {@inheritDoc}
*/
IValue getValueRefdLast(final CompilationTimeStamp timestamp, final Expected_Value_type expectedValue, final IReferenceChain referenceChain) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return referencedValue;
}
final boolean newChain = null == referenceChain;
IReferenceChain tempReferenceChain;
if (newChain) {
tempReferenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
} else {
tempReferenceChain = referenceChain;
}
referencedValue = this;
isErroneous = false;
if (reference == null) {
return referencedValue;
}
reference.setIsErroneous(false);
final Assignment ass = reference.getRefdAssignment(timestamp, true);
if (ass == null) {
isErroneous = true;
return referencedValue;
}
switch(ass.getAssignmentType()) {
case A_OBJECT:
case A_OS:
{
final ISetting setting = reference.getRefdSetting(timestamp);
if (setting == null || setting.getIsErroneous(timestamp)) {
isErroneous = true;
} else if (!Setting_type.S_V.equals(setting.getSettingtype())) {
reference.getLocation().reportSemanticError(MessageFormat.format(INFORMATIONFROMOBJECTNOTVALUE, reference));
isErroneous = true;
} else {
tempReferenceChain.markState();
if (tempReferenceChain.add(this)) {
referencedValue = ((IValue) setting).getValueRefdLast(timestamp, expectedValue, referenceChain);
} else {
isErroneous = true;
}
tempReferenceChain.previousState();
}
break;
}
case A_CONST:
{
tempReferenceChain.markState();
if (tempReferenceChain.add(this)) {
if (ass instanceof Def_Const) {
referencedValue = ((Def_Const) ass).getValue();
} else if (ass instanceof Value_Assignment) {
referencedValue = ((Value_Assignment) ass).getValue();
} else {
isErroneous = true;
}
if (referencedValue != null && !isErroneous) {
referencedValue = referencedValue.getReferencedSubValue(timestamp, reference, 1, tempReferenceChain);
} else {
referencedValue = this;
tempReferenceChain.previousState();
return referencedValue;
}
if (referencedValue != null) {
referencedValue = referencedValue.getValueRefdLast(timestamp, tempReferenceChain);
} else if (reference.hasUnfoldableIndexSubReference(timestamp)) {
referencedValue = this;
tempReferenceChain.previousState();
return referencedValue;
} else if (reference.getUsedInIsbound()) {
referencedValue = this;
tempReferenceChain.previousState();
return referencedValue;
} else {
isErroneous = true;
}
} else {
isErroneous = true;
}
tempReferenceChain.previousState();
break;
}
case A_EXT_CONST:
case A_MODULEPAR:
case A_VAR:
case A_FUNCTION_RVAL:
case A_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RTEMP:
case A_EXT_FUNCTION_RVAL:
case A_PAR_VAL:
case A_PAR_VAL_IN:
case A_PAR_VAL_OUT:
case A_PAR_VAL_INOUT:
case A_MODULEPAR_TEMPLATE:
case A_PAR_TEMP_IN:
case A_PAR_TEMP_INOUT:
case A_PAR_TEMP_OUT:
referencedValue = this;
break;
case A_TEMPLATE:
case A_VAR_TEMPLATE:
// the referred definition is not a constant
// errors will be reported in Types.java
referencedValue = this;
if (!Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT2, ass.getDescription()));
}
break;
case A_FUNCTION:
case A_EXT_FUNCTION:
reference.getLocation().reportSemanticError(MessageFormat.format(VALUERETURNEXPECTED, ass.getDescription()));
isErroneous = true;
break;
default:
if (Expected_Value_type.EXPECTED_TEMPLATE.equals(expectedValue)) {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT1, ass.getDescription()));
} else {
getLocation().reportSemanticError(MessageFormat.format(UNEXPECTEDASSIGNMENT2, ass.getDescription()));
}
isErroneous = true;
break;
}
if (newChain) {
tempReferenceChain.release();
}
lastTimeChecked = timestamp;
if (referencedValue == null) {
referencedValue = this;
isErroneous = true;
}
return referencedValue;
}
use of org.eclipse.titan.designer.AST.ASN1.Value_Assignment in project titan.EclipsePlug-ins by eclipse.
the class Undefined_Assignment_O_or_V method classifyAssignment.
@Override
protected void classifyAssignment(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
final boolean newChain = null == referenceChain;
IReferenceChain temporalReferenceChain;
if (newChain) {
temporalReferenceChain = ReferenceChain.getInstance(CIRCULARASSIGNMENTCHAIN, true);
} else {
temporalReferenceChain = referenceChain;
temporalReferenceChain.markState();
}
realAssignment = null;
if (temporalReferenceChain.add(this)) {
if (null != reference && !reference.refersToSettingType(timestamp, Setting_type.S_ERROR, temporalReferenceChain)) {
reference.setMyScope(myScope);
if (null != objectReference) {
objectReference.setMyScope(rightScope);
}
if (identifier.isvalidAsnObjectReference() && reference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
final ObjectClass_refd oc = new ObjectClass_refd(reference);
oc.setLocation(reference.getLocation());
if (null != mBlock) {
final Object_Definition obj = new Object_Definition(mBlock);
// obj.setLocation(right1);
realAssignment = new Object_Assignment(identifier, assPard, oc, obj);
} else if (null != objectReference) {
final ReferencedObject obj = new ReferencedObject(objectReference);
obj.setLocation(objectReference.getLocation());
realAssignment = new Object_Assignment(identifier, assPard, oc, obj);
}
} else if (identifier.isvalidAsnValueReference() && (reference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || reference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
final Referenced_Type type = new Referenced_Type(reference);
if (null != mBlock) {
final Value value = new Undefined_Block_Value(mBlock);
value.setLocation(mBlock.getLocation());
realAssignment = new Value_Assignment(identifier, assPard, type, value);
} else if (null != objectReference) {
final Value value = new Undefined_LowerIdentifier_Value(objectReference.getId().newInstance());
value.setLocation(objectReference.getLocation());
realAssignment = new Value_Assignment(identifier, assPard, type, value);
}
}
}
}
if (null == realAssignment) {
location.reportSemanticError(UNRECOGNISABLEASSIGNMENT);
isErroneous = true;
} else {
realAssignment.setLocation(location);
realAssignment.setMyScope(myScope);
realAssignment.setRightScope(rightScope);
realAssignment.setFullNameParent(this);
}
if (newChain) {
temporalReferenceChain.release();
} else {
temporalReferenceChain.previousState();
}
}
use of org.eclipse.titan.designer.AST.ASN1.Value_Assignment 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.ASN1.Value_Assignment 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