use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class Template_ActualParameter method generateCodeDefaultValue.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeDefaultValue(final JavaGenData aData, final StringBuilder source) {
if (template == null) {
return;
}
final TTCN3Template temp = template.getTemplateBody();
final Reference baseReference = template.getDerivedReference();
if (baseReference != null) {
final ExpressionStruct expression = new ExpressionStruct();
expression.expression.append(MessageFormat.format("{0}.assign(", temp.get_lhs_name()));
baseReference.generateCode(aData, expression);
expression.expression.append(')');
}
// FIXME handle the needs conversion case
// temp.generateCodeInit(aData, source, temp.get_lhs_name());
// FIXME generate restriction check code if needed
}
use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class Call_Statement method checkCallBody.
/**
* Checks the response and exception handling part of a call operation.
*
* @param timestamp
* the timestamp of the actual build cycle.
* @param portType
* the port type of the actual call statement.
* @param signature
* the signature type of the actual call statement.
*/
private void checkCallBody(final CompilationTimeStamp timestamp, final Port_Type portType, final IType signature) {
boolean hasCatchTimeout = false;
for (int i = 0; i < altGuards.getNofAltguards(); i++) {
final AltGuard altGuard = altGuards.getAltguardByIndex(i);
if (!altguard_type.AG_OP.equals(altGuard.getType())) {
continue;
}
final Statement statement = ((Operation_Altguard) altGuard).getGuardStatement();
if (Statement_type.S_CATCH.equals(statement.getType())) {
((Catch_Statement) statement).setCallSettings(true, timerValue != null);
hasCatchTimeout |= ((Catch_Statement) statement).hasTimeout();
}
}
altGuards.setMyLaicStmt(altGuards, null);
altGuards.setMyAltguards(altGuards);
altGuards.check(timestamp);
if (portType != null) {
// operation.
for (int i = 0; i < altGuards.getNofAltguards(); i++) {
final AltGuard altguard = altGuards.getAltguardByIndex(i);
if (!altguard_type.AG_OP.equals(altguard.getType())) {
continue;
}
final Statement statement = ((Operation_Altguard) altguard).getGuardStatement();
if (statement.getIsErroneous()) {
continue;
}
switch(statement.getType()) {
case S_GETREPLY:
{
final Reference tempPortReference = ((Getreply_Statement) statement).getPortReference();
if (tempPortReference == null) {
final String message = MessageFormat.format("The `{0}'' operation must refer to the same port as the previous `call'' statement: `{1}'' was expected instead of `any port''", statement.getStatementName(), portReference.getId().getDisplayName());
statement.getLocation().reportSemanticError(message);
} else if (!portReference.getId().equals(tempPortReference.getId())) {
final String message = MessageFormat.format("The `{0}'' operation refers to a different port than the previous `call'' statement: `{1}'' was expected instead of `{2}''", statement.getStatementName(), portReference.getId().getDisplayName(), tempPortReference.getId().getDisplayName());
tempPortReference.getLocation().reportSemanticError(message);
}
final TemplateInstance instance = ((Getreply_Statement) statement).getReceiveParameter();
if (instance != null) {
final IType tempSignature = instance.getExpressionGovernor(timestamp, Expected_Value_type.EXPECTED_DYNAMIC_VALUE);
if (tempSignature != null && signature != null && !signature.isCompatible(timestamp, tempSignature, null, null, null)) {
final String message = MessageFormat.format(GETRPELYTOWRONGSIGNATURE, signature.getTypename(), tempSignature.getTypename());
instance.getLocation().reportSemanticError(message);
}
}
break;
}
case S_CATCH:
final Reference tempPortReference = ((Catch_Statement) statement).getPortReference();
if (tempPortReference == null) {
final String message = MessageFormat.format("The `{0}'' operation must refer to the same port as the previous `call'' statement: `{1}'' was expected instead of `any port''", statement.getStatementName(), portReference.getId().getDisplayName());
statement.getLocation().reportSemanticError(message);
} else if (!portReference.getId().equals(tempPortReference.getId())) {
final String message = MessageFormat.format("The `{0}'' operation refers to a different port than the previous `call'' statement: `{1}'' was expected instead of `{2}''", statement.getStatementName(), portReference.getId().getDisplayName(), tempPortReference.getId().getDisplayName());
tempPortReference.getLocation().reportSemanticError(message);
}
final Signature_Type tempSignature = ((Catch_Statement) statement).getSignatureType();
if (tempSignature != null && signature != null && !signature.isCompatible(timestamp, tempSignature, null, null, null)) {
final String message = MessageFormat.format("The `catch'' operation refers to a different signature than the previous `call'' statement: `{0}'' was expected instead of `{1}''", signature.getTypename(), tempSignature.getTypename());
statement.getLocation().reportSemanticError(message);
}
break;
default:
break;
}
}
}
if (timerValue != null && !hasCatchTimeout) {
location.reportSemanticWarning("The call operation has a timer, but the timeout expection is not cought");
}
}
use of org.eclipse.titan.designer.AST.Reference 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()));
}
}
}
}
}
use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class ASN1_Enumerated_Type method checkThisValueRef.
@Override
public final /**
* {@inheritDoc}
*/
IValue checkThisValueRef(final CompilationTimeStamp timestamp, final IValue value) {
IValue temp = value;
if (Value_type.REFERENCED_VALUE.equals(value.getValuetype())) {
// we are not able to parse lower identifier values as default values
// so the parsed reference needs to be converted.
final Reference reference = ((Referenced_Value) value).getReference();
if (reference.getModuleIdentifier() == null && reference.getSubreferences().size() == 1) {
final Identifier identifier = reference.getId();
temp = new Enumerated_Value(identifier);
temp.setMyGovernor(this);
temp.setFullNameParent(this);
temp.setMyScope(value.getMyScope());
return temp;
}
}
if (Value_type.UNDEFINED_LOWERIDENTIFIER_VALUE.equals(temp.getValuetype())) {
if (nameMap != null && nameMap.containsKey(((Undefined_LowerIdentifier_Value) temp).getIdentifier().getName())) {
temp = temp.setValuetype(timestamp, Value_type.ENUMERATED_VALUE);
temp.setMyGovernor(this);
temp.setFullNameParent(this);
temp.setMyScope(value.getMyScope());
return temp;
}
}
return super.checkThisValueRef(timestamp, value);
}
use of org.eclipse.titan.designer.AST.Reference in project titan.EclipsePlug-ins by eclipse.
the class TableConstraint method getOpenTypeAlternativeName.
// Original titan.core version: t_type->get_otaltname(is_strange);
private Identifier getOpenTypeAlternativeName(final CompilationTimeStamp timestamp, final Type type, final AtomicBoolean isStrange) {
StringBuffer sb = new StringBuffer();
// TODO: if (is_tagged() || is_constrained() || hasRawAttrs()) {
if (!type.getIsErroneous(timestamp) && type.isConstrained()) {
sb.append(type.getGenNameOwn());
isStrange.set(true);
} else if (!type.getIsErroneous(timestamp) && type instanceof Referenced_Type) {
Reference t_ref = ((Referenced_Type) type).getReference();
if (t_ref != null) {
final Identifier id = t_ref.getId();
final String dn = id.getDisplayName();
int i = dn.indexOf('.');
if (i >= 0 && i < dn.length()) {
// id is not regular because t_ref is a parameterized reference
sb.append(id.getName());
isStrange.set(true);
} else {
Assignment as = t_ref.getRefdAssignment(timestamp, true);
if (as == null) {
return null;
}
Scope assScope = as.getMyScope();
if (assScope.getParentScope() == assScope.getModuleScope()) {
sb.append(id.getName());
isStrange.set(false);
} else {
// t_ref is a dummy reference in a parameterized assignment
// (i.e. it points to a parameter assignment of an instantiation)
// perform the same examination recursively on the referenced type
// (which is the actual parameter)
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
chain.release();
return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
}
}
} else {
// the type comes from an information object [class]
// examine the referenced type recursively
IReferenceChain chain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
IType referencedType = ((Referenced_Type) type).getTypeRefd(timestamp, chain);
chain.release();
return getOpenTypeAlternativeName(timestamp, (Type) referencedType, isStrange);
}
} else {
Identifier tmpId1 = new Identifier(Identifier_type.ID_NAME, type.getFullName());
String s = tmpId1.getDisplayName();
// module name will be cut off:
if (s.startsWith("@") && s.indexOf('.') > 0) {
s = s.substring(s.indexOf('.') + 1);
}
Identifier tmpId2 = new Identifier(Identifier_type.ID_ASN, s);
sb.append(tmpId2.getTtcnName());
}
// conversion to lower case initial:
sb.replace(0, 1, sb.substring(0, 1).toLowerCase());
// trick:
Identifier tmpId = new Identifier(Identifier_type.ID_NAME, sb.toString());
return new Identifier(Identifier_type.ID_ASN, tmpId.getAsnName());
}
Aggregations