use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkConnectionEndpoint.
/**
* Checks a reference to see if it really references a valid component
* type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param source
* the statement to report an error to, in case it is in
* a control part.
* @param componentReference
* the reference of the component to be checked.
* @param portReference
* the reference to a port of the component to be
* checked.
* @param allowSystem
* tells if the system component should be allowed or not
* as an endpoint.
*
* @return the referenced component type, or null if there were
* problems.
*/
public static IType checkConnectionEndpoint(final CompilationTimeStamp timestamp, final Statement source, final Value componentReference, final PortReference portReference, final boolean allowSystem) {
final IType componentType = checkComponentReference(timestamp, source, componentReference, true, allowSystem);
if (portReference == null) {
return componentType;
}
if (componentType == null) {
// the component type can not be determined
final List<ISubReference> subreferences = portReference.getSubreferences();
if (subreferences.size() > 1) {
// check array indices
for (int i = 0; i < subreferences.size(); i++) {
final ISubReference subreference = subreferences.get(i);
if (subreference instanceof ArraySubReference) {
final Value value = ((ArraySubReference) subreference).getValue();
value.setLoweridToReference(timestamp);
final Type_type temporalType1 = value.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
switch(temporalType1) {
case TYPE_INTEGER:
{
final IReferenceChain referenceChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
final IValue last1 = value.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, referenceChain);
referenceChain.release();
if (!last1.isUnfoldable(timestamp) && Value.Value_type.INTEGER_VALUE.equals(last1.getValuetype())) {
if (((Integer_Value) last1).signum() < 0) {
value.getLocation().reportSemanticError(ArraySubReference.NATIVEINTEGEREXPECTED);
value.setIsErroneous(true);
}
}
break;
}
case TYPE_UNDEFINED:
value.setIsErroneous(true);
break;
default:
if (!value.getIsErroneous(timestamp)) {
value.getLocation().reportSemanticError(ArraySubReference.INTEGERINDEXEXPECTED);
value.setIsErroneous(true);
}
break;
}
}
}
}
return null;
}
final ComponentTypeBody componentBody = ((Component_Type) componentType).getComponentBody();
portReference.setBaseScope(componentBody);
portReference.setComponent((Component_Type) componentType);
// for compatibility
portReference.getRefdAssignment(timestamp, false);
final Identifier portIdentifier = portReference.getId();
if (!componentBody.hasLocalAssignmentWithId(portIdentifier)) {
portReference.getLocation().reportSemanticError(MessageFormat.format(NOPORTWITHNAME, componentType.getTypename(), portIdentifier.getDisplayName()));
return null;
}
final Assignment assignment = componentBody.getLocalAssignmentById(portIdentifier);
if (assignment == null) {
return null;
}
if (!Assignment_type.A_PORT.semanticallyEquals(assignment.getAssignmentType())) {
portReference.getLocation().reportSemanticError(MessageFormat.format(DEFINITIONNOTPORT, portIdentifier.getDisplayName(), componentType.getTypename(), assignment.getAssignmentName()));
return null;
}
final ArrayDimensions dimensions = ((Def_Port) assignment).getDimensions();
if (dimensions != null) {
dimensions.checkIndices(timestamp, portReference, "port", false, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
} else if (portReference.getSubreferences().size() > 1) {
portReference.getLocation().reportSemanticError(MessageFormat.format("Port `{0}'' is not an array. The reference cannot have field or array sub-references", portIdentifier.getDisplayName()));
}
Port_Type portType = ((Def_Port) assignment).getType(timestamp);
if (portType != null) {
final PortTypeBody portBody = portType.getPortBody();
if (PortType_type.PT_USER.equals(portBody.getPortType())) {
final IType providerType = portBody.getProviderType();
if (providerType instanceof Port_Type) {
portType = (Port_Type) providerType;
}
}
}
return portType;
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Port_Utility method checkSignatureReference.
/**
* Checks a reference to see if it really references a valid signature
* type.
*
* @param timestamp
* the timestamp of the actual semantic check cycle.
* @param reference
* the reference to check.
*
* @return the referenced signature type, or null if there were
* problems.
*/
public static Signature_Type checkSignatureReference(final CompilationTimeStamp timestamp, final Reference reference) {
if (reference == null) {
return null;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment == null) {
return null;
}
if (!Assignment_type.A_TYPE.semanticallyEquals(assignment.getAssignmentType())) {
reference.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXPECTED1, assignment.getAssignmentName()));
return null;
}
IType result = ((Def_Type) assignment).getType(timestamp);
if (result == null) {
return null;
}
result = result.getFieldType(timestamp, reference, 1, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false);
if (result == null) {
return null;
}
result = result.getTypeRefdLast(timestamp);
switch(result.getTypetype()) {
case TYPE_SIGNATURE:
return (Signature_Type) result;
case TYPE_PORT:
reference.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXPECTED2, result.getTypename()));
return null;
default:
reference.getLocation().reportSemanticError(MessageFormat.format(SIGNATUREEXPECTED3, result.getTypename()));
return null;
}
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Reference_InternalLogArgument method checkRecursions.
@Override
public /**
* {@inheritDoc}
*/
void checkRecursions(final CompilationTimeStamp timestamp, final IReferenceChain referenceChain) {
if (reference == null) {
return;
}
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment != null) {
referenceChain.markState();
referenceChain.add(assignment);
referenceChain.previousState();
}
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Referenced_Altguard method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
if (expression != null) {
final IValue last = expression.getValueRefdLast(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE, null);
final Type_type temporalType = last.getExpressionReturntype(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (!last.getIsErroneous(timestamp) && !Type_type.TYPE_BOOL.equals(temporalType)) {
last.getLocation().reportSemanticError(BOOLEANEXPECTED);
expression.setIsErroneous(true);
}
if (expression.getMyGovernor() == null) {
expression.setMyGovernor(new Boolean_Type());
}
}
if (reference != null) {
final Assignment assignment = reference.getRefdAssignment(timestamp, true);
if (assignment != null) {
if (Assignment_type.A_ALTSTEP.semanticallyEquals(assignment.getAssignmentType())) {
reference.getMyScope().checkRunsOnScope(timestamp, assignment, reference, "call");
} else {
reference.getLocation().reportSemanticError(MessageFormat.format(ALTSTEPREFERENCEEXPECTED, assignment.getAssignmentName()));
}
}
}
if (statementblock != null) {
statementblock.check(timestamp);
}
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.Assignment in project titan.EclipsePlug-ins by eclipse.
the class Start_Component_Statement method generateCode.
@Override
public /**
* {@inheritDoc}
*/
void generateCode(final JavaGenData aData, final StringBuilder source) {
final ExpressionStruct expression = new ExpressionStruct();
final Assignment func = functionInstanceReference.getRefdAssignment(CompilationTimeStamp.getBaseTimestamp(), false);
final Def_Function function = (Def_Function) func;
expression.expression.append(MessageFormat.format("{0}(", func.getGenNameFromScope(aData, source, myScope, "start_")));
componentReference.generateCodeExpression(aData, expression, false);
FormalParameterList formalParameterList = function.getFormalParameterList();
if (formalParameterList.getNofParameters() > 0) {
expression.expression.append(',');
ISubReference subReference = functionInstanceReference.getSubreferences().get(0);
((ParameterisedSubReference) subReference).getActualParameters().generateCodeNoAlias(aData, expression);
}
expression.expression.append(')');
expression.mergeExpression(source);
}
Aggregations