use of org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type in project titan.EclipsePlug-ins by eclipse.
the class Def_Type_Visit_Handler method visitDefTypeChildrenNodes.
public void visitDefTypeChildrenNodes(IVisitableNode node) {
if (node instanceof Def_Port) {
Def_Port port = (Def_Port) node;
componentPortNames.add(port.getIdentifier().toString());
}
if (node instanceof Def_Var) {
Def_Var var = (Def_Var) node;
componentVarNames.add(var.getIdentifier().toString());
if (var.getType(compilationCounter) instanceof Integer_Type) {
componentVarTypes.add("INTEGER");
}
}
if (waitForCompReference && (node instanceof Reference)) {
componentPortTypes.add(((Reference) node).getId().toString());
}
if (waitForSetOfFieldType) {
if (node instanceof Reference) {
setOfFieldType = node.toString();
myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
waitForSetOfFieldType = false;
} else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SetOf_Type)) {
Type type = (Type) node;
setOfFieldType = TypeMapper.map(type.getTypename());
myASTVisitor.nodeNameSetOfTypesHashMap.put(parentName, setOfFieldType);
waitForSetOfFieldType = false;
}
}
if (waitForRecordOfFieldType) {
if (node instanceof Reference) {
recordOfFieldType = node.toString();
myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
waitForRecordOfFieldType = false;
} else if (node instanceof Type && !(node instanceof Referenced_Type) && !(node instanceof SequenceOf_Type)) {
Type type = (Type) node;
recordOfFieldType = TypeMapper.map(type.getTypename());
myASTVisitor.nodeNameRecordOfTypesHashMap.put(parentName, recordOfFieldType);
waitForRecordOfFieldType = false;
}
}
if (node instanceof CompField) {
// component
CompField compFieldNode = (CompField) node;
if (compFieldNode.getType() instanceof Referenced_Type) {
compFieldTypes.add(((Referenced_Type) compFieldNode.getType()).getReference().getId().toString());
} else {
compFieldTypes.add(myASTVisitor.cutModuleNameFromBeginning(compFieldNode.getType().getTypename()));
}
compFieldNames.add(compFieldNode.getIdentifier().toString());
}
if (node instanceof Charstring_Value) {
// charstring
Charstring_Value singleValuedNode = (Charstring_Value) node;
charstringValue = singleValuedNode.getValue();
}
if (node instanceof Integer_Value) {
String value = ((Integer_Value) node).toString();
if (myASTVisitor.isNextIntegerNegative) {
value = "-" + value;
}
expressionValue.add("new INTEGER(\"" + value + "\")");
}
if (node instanceof Real_Value) {
String value = ((Real_Value) node).toString();
if (myASTVisitor.isNextIntegerNegative) {
value = "-" + value;
}
if (value.equals("-Infinity") || value.equals("Infinity")) {
value = "null";
}
expressionValue.add(value);
}
if (node instanceof Undefined_LowerIdentifier_Value) {
String value = ((Undefined_LowerIdentifier_Value) node).getIdentifier().toString();
if (myASTVisitor.isNextIntegerNegative) {
value = "-" + value;
}
expressionValue.add(value);
}
if (node instanceof EnumerationItems) {
for (int i = 0; i < ((EnumerationItems) node).getItems().size(); i++) {
enumItems.add(((EnumerationItems) node).getItems().get(i).getId().toString());
if (((EnumerationItems) node).getItems().get(i).getValue() != null) {
enumItemValues.add(((EnumerationItems) node).getItems().get(i).getValue().toString());
} else {
enumItemValues.add(null);
}
}
}
if (waitingForPortAttriburtes && (node instanceof Referenced_Type)) {
isPortTypeAReferencedType = true;
}
if (waitingForPortAttriburtes && (node instanceof PortTypeBody)) {
PortTypeBody body = (PortTypeBody) node;
int inCount = body.getInMessages().getNofTypes();
int outCount = body.getOutMessage().getNofTypes();
for (int i = 0; i < inCount; i++) {
inMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getInMessages().getTypeByIndex(i).getTypename()));
}
for (int i = 0; i < outCount; i++) {
outMessageName.add(myASTVisitor.cutModuleNameFromBeginning(body.getOutMessage().getTypeByIndex(i).getTypename()));
}
int shorterListSize = inMessageName.size() <= outMessageName.size() ? inMessageName.size() : outMessageName.size();
// if inout delete from both lists and add to inout
for (int i = 0; i < inMessageName.size(); i++) {
for (int j = 0; j < outMessageName.size(); j++) {
if (inMessageName.get(i).equals(outMessageName.get(j))) {
inOutMessageName.add(inMessageName.get(i));
inMessageName.remove(i);
if (j == (outMessageName.size() - 1)) {
i--;
}
outMessageName.remove(j);
j--;
}
}
}
myASTVisitor.portNamePortTypeHashMap.put(currentPortName, body.getTestportType().toString());
portTypeList.add(body.getTestportType().toString());
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type in project titan.EclipsePlug-ins by eclipse.
the class Done_Statement method generateCodeExpression.
@Override
public /**
* {@inheritDoc}
*/
void generateCodeExpression(final JavaGenData aData, final ExpressionStruct expression) {
aData.addCommonLibraryImport("TTCN_Runtime");
aData.addBuiltinTypeImport("TitanComponent");
if (componentreference != null) {
if (doneMatch != null) {
// value returning done
// figure out what type the done() function belongs to
IType t = doneMatch.getExpressionGovernor(CompilationTimeStamp.getBaseTimestamp(), Expected_Value_type.EXPECTED_TEMPLATE);
if (t == null) {
ErrorReporter.INTERNAL_ERROR("Encountered a done with unknown governor `" + getFullName() + "''");
return;
}
while (t instanceof Referenced_Type && !t.hasDoneAttribute()) {
final IReferenceChain refChain = ReferenceChain.getInstance(IReferenceChain.CIRCULARREFERENCE, true);
t = ((IReferencingType) t).getTypeRefd(CompilationTimeStamp.getBaseTimestamp(), refChain);
refChain.release();
}
if (!t.hasDoneAttribute()) {
ErrorReporter.INTERNAL_ERROR("Encountered a done return type without done attribute `" + getFullName() + "''");
return;
}
// determine whether the done() function is in the same module
final Module t_module = t.getMyScope().getModuleScope();
if (t_module != myStatementBlock.getModuleScope()) {
expression.expression.append(MessageFormat.format("{0}.", t_module.getIdentifier().getName()));
}
expression.expression.append("done(");
componentreference.generateCodeExpression(aData, expression, true);
expression.expression.append(", ");
// FIXME handle decoded match
doneMatch.generateCode(aData, expression, Restriction_type.TR_NONE);
// expression.expression.append(", ");
// FIXME handle value redirection
} else {
// simple done
componentreference.generateCodeExpressionMandatory(aData, expression, true);
expression.expression.append(".done(");
}
// FIXME handle index redirection
expression.expression.append(')');
} else if (isAny) {
// any component.done
expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ANY_COMPREF)");
} else {
// all component.done
expression.expression.append("TTCN_Runtime.component_done(TitanComponent.ALL_COMPREF)");
}
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type 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());
}
use of org.eclipse.titan.designer.AST.TTCN3.types.Referenced_Type in project titan.EclipsePlug-ins by eclipse.
the class Undefined_Assignment_OS_or_VS 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.setMyScope(getMyScope());
if (!reference.refersToSettingType(timestamp, Setting_type.S_ERROR, temporalReferenceChain)) {
if (identifier.isvalidAsnObjectSetReference() && reference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
final ObjectClass_refd oc = new ObjectClass_refd(reference);
oc.setLocation(reference.getLocation());
realAssignment = new ObjectSet_Assignment(identifier, assPard, oc, newObjectSetDefinitionInstance());
// assPard = null;
// left = null;
// right = null;
// asstype = A_OS;
} else if (identifier.isvalidAsnValueSetReference() && (reference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || reference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
final Referenced_Type type = new Referenced_Type(reference);
type.setLocation(reference.getLocation());
realAssignment = newValueSetAssignmentInstance(type);
// left = null;
// right = null;
// asstype = A_VS;
}
}
}
}
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.TTCN3.types.Referenced_Type in project titan.EclipsePlug-ins by eclipse.
the class Undefined_Assignment_T_or_OC 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)) {
reference.setMyScope(rightScope);
if (identifier.isvalidAsnObjectClassReference() && reference.refersToSettingType(timestamp, Setting_type.S_OC, temporalReferenceChain)) {
final ObjectClass_refd oc = new ObjectClass_refd(reference);
oc.setLocation(reference.getLocation());
realAssignment = new ObjectClass_Assignment(identifier, assPard, oc);
// assPard = null;
// asstype = Assignment.A_OC;
} else if (identifier.isvalidAsnTyperef() && (reference.refersToSettingType(timestamp, Setting_type.S_T, temporalReferenceChain) || reference.refersToSettingType(timestamp, Setting_type.S_VS, temporalReferenceChain))) {
final Referenced_Type type = new Referenced_Type(reference);
type.setLocation(reference.getLocation());
realAssignment = new Type_Assignment(identifier, assPard, type);
// assPard = null;
// asstype = A_TYPE;
}
}
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();
}
}
Aggregations