Entity: CExpression 469 389 null * abstract needsBracket boolean 3 false false false kind String 3 false false false cexpId String 3 false true false isStatic boolean 3 false false false Operation: toString CExpression String query abstract true true Operation: newCBasicExpression CExpression CExpression id String name String t CType query static true CBasicExpression->exists( b | b.cexpId = id & b.data = name & b.kind = "variable" & b.type = t & b.elementType = t & result = b ) Operation: defineCOpRef CExpression CExpression op COperation query static true CBasicExpression->exists( be | be.cexpId = op.name + "_ref" & be.data = op.name & be.type = op.returnType & result = be ) Operation: defineCOpReference CExpression CExpression op String typ String query static true CBasicExpression->exists( be | be.cexpId = op + "_ref" & be.data = op & CPrimitiveType->exists( t | t.name = typ & t.ctypeId = op + "_" + typ & be.type = t & be.elementType = t & result = be ) ) Entity: CBinaryExpression 255 543 CExpression * operator String 3 false false false Operation: toString CBinaryExpression String query true (needsBracket = true => result = "(" + left + " " + operator + " " + right + ")") & (true => result = left + " " + operator + " " + right) Entity: CUnaryExpression 854 462 CExpression * operator String 3 false false false Operation: toString CUnaryExpression String query true result = operator + argument Entity: CType 53 437 null * abstract ctypeId String 3 false true false name String 3 false false false Operation: newCType CType CType id String name String static query true CPrimitiveType->exists( t | t.ctypeId = id & t.name = name & result = t) Entity: CBasicExpression 485 655 CExpression * data String 3 false false false Operation: parameterString CBasicExpression String p Sequence(CExpression) query true ( p.size = 0 => result = "" ) & ( p.size = 1 => result = "" + p[1] ) & ( p.size > 1 => result = p[1] + ", " + parameterString(p.tail) ) Operation: parString CBasicExpression String query true ( parameters.size = 0 & kind = "operation" => result = "()" ) & ( parameters.size = 0 & kind /= "operation" => result = "") & ( parameters.size > 0 => result = "(" + parameterString(parameters) + ")" ) Operation: toString CBasicExpression String query true ( arrayIndex.size = 0 & reference.size = 0 => result = data + parString() ) & ( arrayIndex.size > 0 & reference.size = 0 => result = data + "[" + arrayIndex.any + " -1]" ) & ( arrayIndex.size = 0 & reference.size > 0 => result = reference.any + "->" + data ) & ( arrayIndex.size > 0 & reference.size > 0 => result = reference.any + "->" + data + "[" + arrayIndex.any + " -1]" ) Association: CExpression CType 0 467 393 279 433 1 type null Association: CExpression CType 0 467 426 314 453 1 elementType null Association: CBinaryExpression CExpression 0 325 541 467 461 1 left null 325 478 Association: CBinaryExpression CExpression 0 407 543 491 477 1 right null 421 531 Association: CBasicExpression CExpression 0 589 657 696 478 0 parameters null ordered Association: CUnaryExpression CExpression -1 857 465 724 396 1 argument null Association: CArrayType CType 0 740 820 901 851 1 componentType null 741 847 Association: CPointerType CType 0 1251 802 1164 858 1 pointsTo null 1181 857 Association: CMember CType 0 1140 672 1055 845 1 type null Association: CBasicExpression CExpression -1 487 684 529 712 -1 arrayIndex null 427 683 427 746 507 747 Association: CBasicExpression CBasicExpression -1 637 679 625 711 -1 reference null 752 703 751 752 643 753 Generalisation: CExpression CUnaryExpression 855 489 726 440 Generalisation: CExpression CBasicExpression 557 657 558 478 Generalisation: CExpression CBinaryExpression 257 568 487 386 223 569 224 368 488 366 Entity: CPrimitiveType 710 701 CType * name String 3 false false false Operation: toString CPrimitiveType String query true result = name Entity: CArrayType 616 764 CType * duplicates boolean 3 false false false Operation: toString CArrayType String query true result = componentType + "*" Entity: CPointerType 1151 764 CType * Operation: toString CPointerType String query true result = pointsTo + "*" Generalisation: CType CStruct 962 663 962 847 Generalisation: CType CPrimitiveType 865 753 939 845 Generalisation: CType CPointerType 1160 801 1153 846 Generalisation: CType CArrayType 840 802 903 845 Entity: CStruct 829 809 CType * name String 3 false true false Operation: toString CStruct String query true result = "struct " + name Entity: CMember 1138 619 null * name String 3 false false false isKey boolean 3 false false false Operation: inheritedCMembers CMember Set(CMember) query type : CPointerType & type.pointsTo : CStruct anc = type.pointsTo & result = anc.allCMembers() Operation: allCMembers CStruct Set(CMember) query true sups = members->select(name = "super") & (sups.size = 0 => result = members) & (sups.size > 0 => result = (members - sups)->union(sups.any.inheritedCMembers())) Operation: createOp CStruct String ent String query true einst = ent.toLowerCase + "_instances" & result = "struct " + ent + "* create" + ent + "(void)\n" + "{ struct " + ent + "* result = (struct " + ent + "*) malloc(sizeof(struct " + ent + "));\n" + members->collect( m | m.initialiser() )->sum() + " " + einst + " = append" + ent + "(" + einst + ", result);\n" + " " + ent.toLowerCase + "_size++;\n" + " return result;\n" + "}\n" Operation: createPKOp CStruct String ent String key String query true einst = ent.toLowerCase + "_instances" & result = "struct " + ent + "* create" + ent + "(char* _value)\n" + "{ struct " + ent + "* result = NULL;\n" + " result = get" + ent + "ByPK(_value);\n" + " if (result != NULL) { return result; }\n" + " result = (struct " + ent + "*) malloc(sizeof(struct " + ent + "));\n" + members->collect( m | m.initialiser() )->sum() + " set" + ent + "_" + key + "(result, _value);\n" + " " + einst + " = append" + ent + "(" + einst + ", result);\n" + " " + ent.toLowerCase + "_size++;\n" + " return result;\n" + "}\n" Operation: getterOp CMember String ent String query true result = type + " get" + ent + "_" + name + "(struct " + ent + "* self) { return self->" + name + "; }\n" Operation: inheritedGetterOp CMember String ent String sup String query true (name /= "super" => result = type + " get" + ent + "_" + name + "(struct " + ent + "* self) { return get" + sup + "_" + name + "(self->super); }\n") & (name = "super" => result = self.ancestorGetterOps(ent,sup) ) Operation: ancestorGetterOps CMember String ent String sup String query type : CPointerType & type.pointsTo : CStruct anc = type.pointsTo & result = anc.members->collect( m | m.inheritedGetterOp(ent, sup) )->sum() Operation: inheritedGetterOps CMember String ent String query type : CPointerType & type.pointsTo : CStruct sup = type.pointsTo & result = sup.members->collect( m | m.inheritedGetterOp(ent, sup.name) )->sum() Operation: setterOp CMember String ent String query true result = "void set" + ent + "_" + name + "(struct " + ent + "* self, " + type + " _value) { self->" + name + " = _value; }\n" Operation: inheritedSetterOp CMember String ent String sup String query true (name /= "super" => result = "void set" + ent + "_" + name + "(struct " + ent + "* self, " + type + " _value) { set" + sup + "_" + name + "(self->super, _value); }\n") & (name = "super" => result = self.ancestorSetterOps(ent,sup) ) Operation: ancestorSetterOps CMember String ent String sup String query type : CPointerType & type.pointsTo : CStruct anc = type.pointsTo & result = anc.members->collect( m | m.inheritedSetterOp(ent, sup) )->sum() Operation: inheritedSetterOps CMember String ent String query type : CPointerType & type.pointsTo : CStruct sup = type.pointsTo & result = sup.members->collect( m | m.inheritedSetterOp(ent, sup.name) )->sum() Operation: getAllOp CMember String ent String query true result = type + "* getAll" + ent + "_" + name + "(struct " + ent + "* _col[])\n" + "{ int n = length((void**) _col);\n" + " " + type + "* result = (" + type + "*) calloc(n, sizeof(" + type + "));\n" + " int i = 0;\n" + " for ( ; i < n; i++)\n" + " { result[i] = get" + ent + "_" + name + "(_col[i]); }\n" + " return result;\n" + "}\n" Operation: getAllOp1 CMember String ent String query true result = type + "* getAll" + ent + "_" + name + "(struct " + ent + "* _col[])\n" + "{ int n = length((void**) _col);\n" + " " + type + "* result = (" + type + "*) calloc(n+1, sizeof(" + type + "));\n" + " int i = 0;\n" + " for ( ; i < n; i++)\n" + " { result[i] = get" + ent + "_" + name + "(_col[i]); }\n" + " result[n] = NULL;\n" + " return result;\n" + "}\n" Operation: inheritedAllOp CMember String ent String sup String query true (name /= "super" & type : CPrimitiveType => result = getAllOp(ent)) & (name /= "super" & type : CPointerType => result = getAllOp1(ent)) & (name = "super" => result = self.ancestorAllOps(ent,sup) ) Operation: ancestorAllOps CMember String ent String sup String query type : CPointerType anc = type.pointsTo & result = anc.members->collect( m | m.inheritedAllOp(ent, sup) )->sum() Operation: inheritedAllOps CMember String ent String query type : CPointerType sup = type.pointsTo & result = sup.members->collect( m | m.inheritedAllOp(ent, sup.name) )->sum() Operation: getPKOp CMember String ent String query true e = ent.toLowerCase & result = "struct " + ent + "* get" + ent + "ByPK(char* _ex)\n" + "{ int n = length((void**) " + e + "_instances);\n" + " int i = 0;\n" + " for ( ; i < n; i++)\n" + " { char* _v = get" + ent + "_" + name + "(" + e + "_instances[i]);\n" + " if (_v != NULL && strcmp(_v,_ex) == 0)\n" + " { return " + e + "_instances[i]; }\n" + " }\n" + " return NULL;\n" + "}\n" Operation: getPKsOp CMember String ent String query true e = ent.toLowerCase & result = "struct " + ent + "** get" + ent + "ByPKs(char* _col[])\n" + "{ int n = length((void**) _col);\n" + " struct " + ent + "** result = (struct " + ent + "**) calloc(n+1, sizeof(struct " + ent + "*));\n" + " int i = 0; int j = 0;\n" + " for ( ; i < n; i++)\n" + " { char* _v = _col[i];\n" + " struct " + ent + "* _ex = get" + ent + "ByPK(_v);\n" + " if (_ex != NULL)\n" + " { result[j] = _ex; j++; }\n" + " }\n" + " result[j] = NULL;\n" + " return result; }\n" Operation: initialiser CMember String query true (isKey = true => result = "") & (name = "super" => result = " result->super = create" + type.pointsTo.name + "();\n") & (type : CPointerType or type : CArrayType => result = " result->" + name + " = NULL;\n") & (type : CPrimitiveType => result = " result->" + name + " = 0;\n") Operation: concatenateOp CStruct String query true result = "struct " + name + "** concatenate" + name + "(struct " + name + "* _col1[], struct " + name + "* _col2[])\n" + "{ int _n = length((void**) _col1);\n" + " int _m = length((void**) _col2);\n" + " struct " + name + "** result = (struct " + name + "**) calloc(_n + _m + 1, sizeof(struct " + name + "*));\n" + " int i = 0;\n" + " int j = 0;\n" + " for ( ; i < _n; i++)\n" + " { result[j] = _col1[i];\n" + " j++;\n" + " }\n" + " i = 0;\n" + " for ( ; i < _m; i++)\n" + " { result[j] = _col2[i];\n" + " j++;\n" + " }\n" + " result[j] = NULL;\n" + " return result;\n" + "}\n" Operation: intersectionOp CStruct String query true result = "struct " + name + "** intersection" + name + "(struct " + name + "* _col1[], struct " + name + "* _col2[])\n" + "{ int n = length((void**) _col1);\n" + " int m = length((void**) _col2);\n" + " struct " + name + "** result = (struct " + name + "**) calloc(n + 1, sizeof(struct " + name + "*));\n" + " int i = 0;\n" + " int j = 0;\n" + " for ( ; i < n; i++)\n" + " { struct " + name + "* _ex = _col1[i];\n" + " if (isIn((void*) _ex, (void**) _col2))\n" + " { result[j] = _ex; j++; }\n" + " }\n" + " result[j] = NULL;\n" + " return result;\n" + "}\n" Operation: insertAtOp CStruct String query true result = "struct " + name + "** insertAt" + name + "(struct " + name + "* _col1[], int ind, struct " + name + "* _col2[])\n" + "{ if (ind <= 0) { return _col1; }\n" + " int n = length((void**) _col1);\n" + " int m = length((void**) _col2);\n" + " if (m == 0) { return _col1; }\n" + " struct " + name + "** result = (struct " + name + "**) calloc(n + m + 1, sizeof(struct " + name + "*));\n" + " int i = 0; int j = 0;\n" + " for ( ; i < ind - 1 && i < n; i++)\n" + " { result[i] = _col1[i]; }\n" + " if (i == ind - 1)\n" + " { for ( ; j < m; j++, i++)\n" + " { result[i] = _col2[j]; }\n" + " for ( ; i < n + m; i++)\n" + " { result[i] = _col1[i - m]; }\n" + " }\n" + " else \n" + " { for ( ; j < m; j++, i++)\n" + " { result[i] = _col2[j]; }\n" + " }\n" + " result[n+m] = NULL;\n" + " return result;\n" + "}\n" Operation: exists1Op CStruct String query true result = "unsigned char exists1" + name + "(struct " + name + "* _col[], unsigned char (*test)(struct " + name + "*))\n" + "{ int n = length((void**) _col);\n" + " unsigned char result = FALSE; \n" + " unsigned char found = FALSE;\n" + " int i = 0; \n" + " for ( ; i < n; i++)\n" + " { struct " + name + "* ex = _col[i];\n" + " if (ex == NULL) { return result; }\n" + " if ((*test)(ex))\n" + " { if (found) { return FALSE; }\n" + " else { found = TRUE; }\n" + " }\n" + " }\n" + " if (found) { return TRUE; }\n" + " return result;\n" + "}\n" Operation: isUniqueOp CStruct String query true result = "unsigned char isUnique" + name + "(struct " + name + "* _col[], void* (*fe)(struct " + name + "*))\n" + "{ unsigned char result = TRUE; \n" + " void** _values = collect" + name + "(_col, fe);\n" + " int n = length((void**) _values);\n" + " int i = 0; \n" + " for ( ; i < n; i++)\n" + " { void* ex = _values[i];\n" + " if (i < n - 1 && isIn(ex, _values + (i + 1)))\n" + " { return FALSE; }\n" + " }\n" + " return result;\n" + "}\n" Operation: frontOp CStruct String query true result = "struct " + name + "** front" + name + "(struct " + name + "* _col[])\n" + "{ int n = length((void**) _col);\n" + " return subrange" + name + "(_col, 1, n-1); }\n" Operation: tailOp CStruct String query true result = "struct " + name + "** tail" + name + "(struct " + name + "* _col[])\n" + "{ int n = length((void**) _col);\n" + " return subrange" + name + "(_col, 2, n); }\n" Operation: collectPrimOp CStruct String t String query true result = " " + t + "* collect" + name + "_" + t + "(struct " + name + "* _col[], " + t + " (*fe)(struct " + name + "*))\n" + " { int n = length((void**) _col);\n" + " " + t + "* result = (" + t + "*) calloc(n, sizeof(" + t + "));\n" + " int i = 0;\n" + " for ( ; i < n; i++)\n" + " { struct " + name + "* self = _col[i];\n" + " result[i] = (*fe)(self);\n" + " }\n" + " return result;\n" + " }\n" Operation: removeAllOp CStruct String query true result = "struct " + name + "** removeAll" + name + "(struct " + name + "* _col1[], struct " + name + "* _col2[])\n" + "{ int n = length((void**) _col1);\n" + " struct " + name + "** result = (struct " + name + "**) calloc(n+1, sizeof(struct " + name + "*));\n" + " int i = 0; int j = 0;\n" + " for ( ; i < n; i++)\n" + " { struct " + name + "* ex = _col1[i];\n" + " if (isIn((void*) ex, (void**) _col2)) {}\n" + " else \n" + " { result[j] = ex; j++; }\n" + " }\n" + " result[j] = NULL;\n" + " return result;\n" + "}\n" Operation: asSetOp CStruct String query true result = "struct " + name + "** asSet" + name + "(struct " + name + "* _col[])\n" + "{ int n = length((void**) _col);\n" + " if (n == 0) { return _col; }\n" + " struct " + name + "** result = (struct " + name + "**) calloc(n + 1, sizeof(struct " + name + "*));\n" + " int i = 0; int j = 0;\n" + " result[j] = NULL;\n" + " for ( ; i < n; i++)\n" + " { struct " + name + "* ex = _col[i];\n" + " if (isIn((void*) ex, (void**) result)) {}\n" + " else \n" + " { result[j] = _col[i]; j++;\n" + " result[j] = NULL; }\n" + " } \n" + " result[j] = NULL;\n" + " return result;\n" + "}\n" Entity: CVariable 1117 991 null * name String 3 false false false kind String 3 false false false initialisation String 3 false false false Entity: CProgram 1058 1049 null * Operation: defineCOp CProgram COperation b CExpression par String pt CType query true COperation->exists( op | op.name = "op_" + operations@pre.size & op.scope = "auxiliary" & op.isStatic = false & b.needsBracket = true & op.returnType = b.type & op.isQuery = true & CReturnStatement->exists( rt | rt.cstatId = "return_" + b.cexpId & b : rt.returnValue & op.code = rt ) & CVariable->exists( v | v.name = par & v.type = pt & v : op.parameters ) & op : operations & result = op ) Operation: printOperations CProgram void true operations->forAll( op | op->display() ) Operation: printProgramHeader CProgram void true "#include "->display() & "#include "->display() & "#include "->display() & "#include "->display() & "#include "->display() & "#include "->display() & "#include \"ocl.h\"\n"->display() & "#include \"app.h\"\n"->display() Entity: COperation 1256 917 null * name String 3 false false false opId String 3 false true false isStatic boolean 3 false false false scope String 3 false false false isQuery boolean 3 false false false Operation: parameterDeclaration COperation String s Sequence(CVariable) query true ( s.size = 0 => result = "void" ) & ( s.size = 1 => result = s[1].type + " " + s[1].name ) & ( s.size > 1 => result = s[1].type + " " + s[1].name + ", " + parameterDeclaration(s.tail) ) Operation: toString COperation String query true result = returnType + " " + name + "(" + parameterDeclaration(parameters) + ")\n" + "{ " + code + "\n}\n" Operation: getDeclaration COperation String query true result = returnType + " " + name + "(" + parameterDeclaration(parameters) + ");\n" Association: CProgram COperation 1 1143 1051 1253 1005 0 operations null Association: CProgram CVariable 1 1139 1098 1199 1057 0 variables null Association: CProgram CStruct -1 1160 1058 831 835 0 structs null 1120 955 1121 837 Association: COperation CVariable -1 1316 914 1120 1008 0 parameters null ordered Association: CVariable CType 0 1047 993 937 900 1 type null Association: COperation CType 0 1326 917 901 899 1 returnType null Entity: CStatement 1216 668 null * abstract cstatId String 3 false true false Operation: toString CStatement String query true result = "" Entity: CReturnStatement 1132 731 CStatement * Operation: toString CReturnStatement String query true (returnValue.size >= 1 => result = "return " + returnValue.any + "; ") & (returnValue.size = 0 => result = "return; ") Operation: toString CExpression String query true result = " " Entity: CBreakStatement 913 893 CStatement * Operation: toString CBreakStatement String query true result = " break; " Entity: OpCallStatement 1098 916 CStatement * assignsTo String 3 false false false Operation: toString OpCallStatement String query true result = callExp + "; " Entity: CLoopStatement 1359 854 CStatement * abstract Entity: ForLoop 1325 975 CLoopStatement * Operation: toString ForLoop String query true ind = "ind_" + cstatId & result = "int " + ind + " = 0;\n" + "for ( ; " + ind + " < length((void**) " + loopRange + "); " + ind + "++)\n" + " { " + loopRange.elementType + " " + loopVar + " = (" + loopRange + ")[" + ind + "];\n" + " " + body + " } " Entity: WhileLoop 1393 904 CLoopStatement * Operation: toString WhileLoop String query true result = "while (" + test + ")\n" + " { " + body + "}" Entity: CAssignment 878 572 CStatement * Operation: toString CAssignment String query true (type.size = 0 => result = left + " = " + right + "; ") & (type.size > 0 => result = type.any + " " + left + " = " + right + "; ") Association: CAssignment CType 0 870 576 27 255 -1 type null Entity: CSequenceStatement 1542 655 CStatement * kind int 3 false false false Operation: toString CSequenceStatement String query true (statements.size > 1 => result = statements.front->collect( s | s.toString() + "\n " )->sum() + statements.last.toString()) & (statements.size = 1 => result = statements.last.toString()) & (true => result = "") Entity: IfStatement 985 613 CStatement * Operation: toString IfStatement String query true (elsePart.size = 0 => result = "if (" + test + ")\n" + " { " + ifPart + " } ") & (elsePart.size > 0 => result = "if (" + test + ")\n" + " { " + ifPart + " }\n" + " else \n" + " { " + elsePart.any + " } ") Entity: DeclarationStatement 1133 781 CStatement * createsInstanceOf String 3 false false false assignsTo String 3 false false false Operation: toString DeclarationStatement String query true (createsInstanceOf = "String" => result = type + " " + assignsTo + " = \"\"; ") & (type : CPrimitiveType => result = type + " " + assignsTo + " = 0; ") & (true => result = type + " " + assignsTo + " = NULL; ") Association: DeclarationStatement CType 0 1141 783 1280 1666 1 type null Association: DeclarationStatement CType 0 1141 783 1280 1666 1 elementType null Association: COperation CStatement -1 1411 583 1280 666 1 code null Association: CReturnStatement CExpression -1 1125 728 1050 735 -1 returnValue null Association: OpCallStatement CExpression -1 1104 918 978 780 1 callExp null 1051 859 Association: CLoopStatement CExpression -1 1360 865 1076 778 1 test null 1117 859 Association: CAssignment CExpression -1 885 617 956 748 1 left null Association: CAssignment CExpression -1 939 615 974 730 1 right null Association: IfStatement CExpression -1 1016 658 1029 727 1 test null Association: IfStatement CStatement -1 1124 653 1217 672 1 ifPart null 1153 670 Association: IfStatement CStatement -1 1068 656 1217 689 -1 elsePart null 1067 689 Association: CSequenceStatement CStatement -1 1537 709 1363 688 0 statements null ordered Association: CLoopStatement CStatement -1 1477 855 1349 713 1 body null 1475 725 Association: ForLoop CSequenceStatement -1 1469 982 1614 711 1 increment null 1629 965 Generalisation: CStatement CReturnStatement 1233 729 1234 707 Generalisation: CStatement CBreakStatement 1061 897 1278 713 Generalisation: CStatement OpCallStatement 1289 915 1296 708 Generalisation: CStatement CLoopStatement 1414 856 1332 710 Generalisation: CLoopStatement ForLoop 1371 978 1369 878 Generalisation: CLoopStatement WhileLoop 1485 906 1484 877 Generalisation: CStatement CSequenceStatement 1536 678 1360 675 Generalisation: CStatement IfStatement 1127 620 1237 668 1233 617 Generalisation: CStatement CAssignment 1021 578 1258 670 1253 597 Generalisation: CStatement DeclarationStatement 1318 778 1319 710 Association: ForLoop CExpression 0 1327 984 958 768 1 loopVar null 850 981 Association: ForLoop CExpression 0 1328 1010 960 752 1 loopRange null 740 1005 Association: CStruct CMember 1 975 646 1137 632 0 members null ordered Association: CStruct CMember 0 985 656 1147 642 0 allMembers null