use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class Set_Value method evaluateIspresent.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIspresent(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_SET:
if (!((TTCN3_Set_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SET:
if (!((ASN1_Set_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (values.hasNamedValueWithName(fieldId)) {
// we can move on with the check
return values.getNamedValueByName(fieldId).getValue().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
if (Type_type.TYPE_TTCN3_SET.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Set_Type) type).getComponentByName(fieldId);
if (compField.isOptional()) {
// create an explicit omit value
final Value result = new Omit_Value();
final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
result.setFullNameParent(bridge);
result.setMyScope(getMyScope());
return result.evaluateIspresent(timestamp, reference, actualSubReference + 1);
} else if (compField.hasDefault()) {
return compField.getDefault().evaluateIspresent(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class Set_Value method evaluateIsbound.
@Override
public /**
* {@inheritDoc}
*/
boolean evaluateIsbound(final CompilationTimeStamp timestamp, final Reference reference, final int actualSubReference) {
final List<ISubReference> subreferences = reference.getSubreferences();
if (getIsErroneous(timestamp) || subreferences.size() <= actualSubReference) {
return true;
}
final IType type = myGovernor.getTypeRefdLast(timestamp);
if (type.getIsErroneous(timestamp)) {
return false;
}
final ISubReference subreference = subreferences.get(actualSubReference);
switch(subreference.getReferenceType()) {
case arraySubReference:
return false;
case fieldSubReference:
final Identifier fieldId = ((FieldSubReference) subreference).getId();
switch(type.getTypetype()) {
case TYPE_TTCN3_SET:
if (!((TTCN3_Set_Type) type).hasComponentWithName(fieldId.getName())) {
return false;
}
break;
case TYPE_ASN1_SET:
if (!((ASN1_Set_Type) type).hasComponentWithName(fieldId)) {
return false;
}
break;
default:
return false;
}
if (values.hasNamedValueWithName(fieldId)) {
// we can move on with the check
return values.getNamedValueByName(fieldId).getValue().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
if (Type_type.TYPE_TTCN3_SET.equals(type.getTypetype())) {
return false;
}
final CompField compField = ((ASN1_Set_Type) type).getComponentByName(fieldId);
if (compField.isOptional()) {
// create an explicit omit value
final Value result = new Omit_Value();
final BridgingNamedNode bridge = new BridgingNamedNode(this, "." + fieldId.getDisplayName());
result.setFullNameParent(bridge);
result.setMyScope(getMyScope());
return result.evaluateIsbound(timestamp, reference, actualSubReference + 1);
} else if (compField.hasDefault()) {
return compField.getDefault().evaluateIsbound(timestamp, reference, actualSubReference + 1);
}
return false;
case parameterisedSubReference:
return false;
default:
return false;
}
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class For_Loop_Definitions method check.
@Override
public /**
* {@inheritDoc}
*/
void check(final CompilationTimeStamp timestamp) {
if (lastCompilationTimeStamp != null && !lastCompilationTimeStamp.isLess(timestamp)) {
return;
}
lastCompilationTimeStamp = timestamp;
lastUniquenessCheckTimeStamp = timestamp;
if (definitionMap == null) {
definitionMap = new HashMap<String, Definition>(definitions.size());
}
definitionMap.clear();
String definitionName;
Definition definition;
Identifier identifier;
for (int i = 0, size = definitions.size(); i < size; i++) {
definition = definitions.get(i);
identifier = definition.getIdentifier();
definitionName = identifier.getName();
if (definitionMap.containsKey(definitionName)) {
final Location otherLocation = definitionMap.get(definitionName).getIdentifier().getLocation();
otherLocation.reportSingularSemanticError(MessageFormat.format(DUPLICATEDEFINITIONFIRST, identifier.getDisplayName()));
identifier.getLocation().reportSemanticError(MessageFormat.format(DUPLICATEDEFINITIONREPEATED, identifier.getDisplayName()));
} else {
definitionMap.put(definitionName, definition);
if (parentScope != null && definition.getLocation() != null) {
if (parentScope.hasAssignmentWithId(timestamp, identifier)) {
definition.getLocation().reportSemanticError(MessageFormat.format(StatementBlock.HIDINGSCOPEELEMENT, identifier.getDisplayName()));
final List<ISubReference> subReferences = new ArrayList<ISubReference>();
subReferences.add(new FieldSubReference(identifier));
final Reference reference = new Reference(null, subReferences);
final Assignment assignment = parentScope.getAssBySRef(timestamp, reference);
if (assignment != null && assignment.getLocation() != null) {
assignment.getLocation().reportSingularSemanticError(MessageFormat.format(StatementBlock.HIDDENSCOPEELEMENT, identifier.getDisplayName()));
}
} else if (parentScope.isValidModuleId(identifier)) {
definition.getLocation().reportSemanticWarning(MessageFormat.format(StatementBlock.HIDINGMODULEIDENTIFIER, identifier.getDisplayName()));
}
}
}
definition.check(timestamp);
}
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class FormalParameterList method check.
public final void check(final CompilationTimeStamp timestamp, final Assignment_type definitionType) {
if (lastTimeChecked != null && !lastTimeChecked.isLess(timestamp)) {
return;
}
minimumNofParameters = 0;
isStartable = true;
for (int i = 0, size = parameters.size(); i < size; i++) {
FormalParameter parameter = parameters.get(i);
final Identifier identifier = parameter.getIdentifier();
if (parentScope != null) {
if (parentScope.hasAssignmentWithId(timestamp, identifier)) {
parameter.getLocation().reportSemanticError(MessageFormat.format(HIDINGSCOPEELEMENT, identifier.getDisplayName()));
parentScope.hasAssignmentWithId(timestamp, identifier);
final List<ISubReference> subReferences = new ArrayList<ISubReference>();
subReferences.add(new FieldSubReference(identifier));
final Reference reference = new Reference(null, subReferences);
final Assignment assignment = parentScope.getAssBySRef(timestamp, reference);
if (assignment != null && assignment.getLocation() != null) {
assignment.getLocation().reportSingularSemanticWarning(MessageFormat.format(HIDDENSCOPEELEMENT, identifier.getDisplayName()));
}
} else if (parentScope.isValidModuleId(identifier)) {
parameter.getLocation().reportSemanticWarning(MessageFormat.format(HIDINGMODULEIDENTIFIER, identifier.getDisplayName()));
}
}
parameter.check(timestamp);
if (parameter.getAssignmentType() != parameter.getRealAssignmentType()) {
parameter = parameter.setParameterType(parameter.getRealAssignmentType());
parameters.set(i, parameter);
}
if (Assignment_type.A_TEMPLATE.semanticallyEquals(definitionType)) {
if (!Assignment_type.A_PAR_VAL_IN.semanticallyEquals(parameter.getAssignmentType()) && !Assignment_type.A_PAR_TEMP_IN.semanticallyEquals(parameter.getAssignmentType())) {
parameter.getLocation().reportSemanticError("A template cannot have " + parameter.getAssignmentName());
}
} else if (Assignment_type.A_TESTCASE.semanticallyEquals(definitionType)) {
if (Assignment_type.A_PAR_TIMER.semanticallyEquals(parameter.getAssignmentType()) && Assignment_type.A_PAR_PORT.semanticallyEquals(parameter.getAssignmentType())) {
parameter.getLocation().reportSemanticError("A testcase cannot have " + parameter.getAssignmentName());
}
} else {
// everything is allowed for functions and altsteps
}
// startability check
switch(parameter.getAssignmentType()) {
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 tempType = parameter.getType(timestamp);
if (isStartable && tempType != null && tempType.isComponentInternal(timestamp)) {
isStartable = false;
}
break;
}
default:
isStartable = false;
}
if (!parameter.hasDefaultValue()) {
minimumNofParameters = i + 1;
}
}
if (parameters.size() > reportTooManyParametersSize) {
getLocation().reportConfigurableSemanticProblem(reportTooManyParameters, MessageFormat.format(TOOMANYPARAMETERS, reportTooManyParametersSize));
}
checkUniqueness(timestamp);
lastTimeChecked = timestamp;
}
use of org.eclipse.titan.designer.AST.FieldSubReference in project titan.EclipsePlug-ins by eclipse.
the class Qualifier method findReferences.
@Override
public /**
* {@inheritDoc}
*/
void findReferences(final ReferenceFinder referenceFinder, final List<Hit> foundIdentifiers) {
if (definition != null && subReferences != null) {
// qualifiers were not semantically analyzed
for (ISubReference sr : subReferences) {
sr.findReferences(referenceFinder, foundIdentifiers);
}
if (referenceFinder.fieldId != null) {
// we are searching for a field of a type
final IType t = definition.getType(CompilationTimeStamp.getBaseTimestamp());
if (t == null) {
return;
}
final List<IType> typeArray = new ArrayList<IType>();
final Reference reference = new Reference(null);
reference.addSubReference(new FieldSubReference(definition.getIdentifier()));
for (ISubReference sr : subReferences) {
reference.addSubReference(sr);
}
reference.setLocation(location);
reference.setMyScope(definition.getMyScope());
final boolean success = t.getFieldTypesAsArray(reference, 1, typeArray);
if (!success) {
// TODO: maybe a partially erroneous reference could be searched too
return;
}
if (subReferences.size() != typeArray.size()) {
ErrorReporter.INTERNAL_ERROR();
return;
}
for (int i = 0; i < subReferences.size(); i++) {
if (typeArray.get(i) == referenceFinder.type && !(subReferences.get(i) instanceof ArraySubReference) && subReferences.get(i).getId().equals(referenceFinder.fieldId)) {
foundIdentifiers.add(new Hit(subReferences.get(i).getId()));
}
}
}
}
}
Aggregations