SOptVisitor:: OptVisitor {
+SOptVisitor:: OptVisitor {
//
// Visitor function for C_COMPLEX_OBJECT node in OPT
//
- public enterCComplexObject (CComplexObject cObj) {
+ public enterCComplexObject (CComplexObject cObj) {
// obtain or synthesise SIM class name for cCObj.rmTypeName
- simClassName = xxx;
+ simClassName = xxx;
// create SOpt CComplexObject
- CComplexObject SCobj = new CComplexObject(simClassName);
+ CComplexObject SCobj = new CComplexObject(simClassName);
// process attributes
- for (CAttribute cAttr in cCObj.attributes) {
+ for (CAttribute cAttr in cCObj.attributes) {
// find any rule for this attribute
- if (rules.hasPathRule (cObj.rmTypeName, CAttr.rmAttributeName)) {
- attrRule = rules.pathRule (cObj.rmTypeName, CAttr.rmAttributeName);
+ if (rules.hasPathRule (cObj.rmTypeName, CAttr.rmAttributeName)) {
+ attrRule = rules.pathRule (cObj.rmTypeName, CAttr.rmAttributeName);
// deal with collapse case - go through all matching paths
- if (attrRule.collapse) {
+ if (attrRule.collapse) {
// create a new output C_ATTRIBUTE with the SIM attribute name
- CAttribute sCAttr = new CAttribute (baseName(attrRule.simPath));
+ CAttribute sCAttr = new CAttribute (baseName(attrRule.simPath));
// attach new C_OBJECT to cAttr
- for (collapseRule in rules.matchingPathRules (cCObj.rmTypeName, CAttr.rmAttributeName)
- sCAttr.appendChildren (makeCCObjects (collapseRule));
+ for (collapseRule in rules.matchingPathRules (cCObj.rmTypeName, CAttr.rmAttributeName)
+ sCAttr.appendChildren (makeCCObjects (collapseRule));
- }
+ }
else
- sCAttr.appendChildren (makeCCObjects (attrRule));
- }
- }
- }
+ sCAttr.appendChildren (makeCCObjects (attrRule));
+ }
+ }
+ }
- private List<CObject> makeCCObjects (CAttribute cAttr, SOptRule aRule) {
- List<CObject> sChildCObjList = new List<CObject>;
- CObject sChildCObj;
+ private List<CObject> makeCCObjects (CAttribute cAttr, SOptRule aRule) {
+ List<CObject> sChildCObjList = new List<CObject>;
+ CObject sChildCObj;
// if SIM target type is primitive, apply constraint conversion rule
// e.g. convert C_TERMINOLOGY_CODE to a C_STRING
- if (PrimitiveTypes.has (aRule.sim_type)) {
- for (cChildObj in cAttr.children) {
- sChildCObj = rules.execute (aRule.constraintConvRule (cChildObj));
- sChildCObjList.append (cChildObj)
- }
- }
+ if (PrimitiveTypes.has (aRule.sim_type)) {
+ for (cChildObj in cAttr.children) {
+ sChildCObj = rules.execute (aRule.constraintConvRule (cChildObj));
+ sChildCObjList.append (cChildObj)
+ }
+ }
// otherwise, execute visitor on sub-tree at path to create new C_COMPLEX_OBJECT
else
- sChildCObjList.extend (visit (aRule.rmPath));
+ sChildCObjList.extend (visit (aRule.rmPath));
- return sChildCObjList;
- }
-}
+ return sChildCObjList;
+ }
+}