@@ -19162,6 +19162,32 @@ public Expression evaluate(ModelSpecification sigma,
1916219162
1916319163 Expression lft = left.evaluate(sigma, beta);
1916419164 Expression rgt = right.evaluate(sigma, beta);
19165+
19166+ if ("->apply".equals(operator) &&
19167+ lft instanceof UnaryExpression &&
19168+ ((UnaryExpression) lft).getOperator().equals("lambda"))
19169+ { UnaryExpression lam = (UnaryExpression) lft;
19170+ // create a new local state binding lam.accumulator to rgt
19171+ // Evaluate lft in that state.
19172+
19173+ Expression arg = lam.getArgument();
19174+ Attribute acc = lam.getAccumulator();
19175+
19176+ if (acc != null)
19177+ { String nme = acc.getName();
19178+ beta.addNewEnvironment();
19179+ beta.addVariable(nme, rgt);
19180+
19181+ // JOptionPane.showInputDialog("Evaluating " + arg + " in environment " + beta);
19182+
19183+ Expression res = arg.evaluate(sigma, beta);
19184+ beta.removeLastEnvironment();
19185+ return res.simplify();
19186+ }
19187+
19188+ return new BasicExpression("null");
19189+ }
19190+
1916519191 return simplify(operator, lft, rgt, false);
1916619192 }
1916719193
@@ -21645,7 +21671,7 @@ public Expression simplifyOCL()
2164521671 synLeft > synRight)
2164621672 { BinaryExpression res =
2164721673 new BinaryExpression(operator, rexpr, lexpr);
21648- System.out .println(">> OCL efficiency smell (OES): Inefficient logical combination: " + this);
21674+ System.err .println("! Possible OCL efficiency smell (OES): Inefficient logical combination: " + this);
2164921675 return res;
2165021676 }
2165121677
@@ -21663,7 +21689,7 @@ public Expression simplifyOCL()
2166321689
2166421690 if (leftargop.equals("->select"))
2166521691 { // s->select(P)->size() = 0
21666- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21692+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2166721693
2166821694 UnaryExpression notpred =
2166921695 new UnaryExpression("not", leftargpred);
@@ -21674,7 +21700,7 @@ public Expression simplifyOCL()
2167421700 }
2167521701 else if (leftargop.equals("->reject"))
2167621702 { // s->reject(P)->size() = 0
21677- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21703+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2167821704
2167921705 BinaryExpression res =
2168021706 new BinaryExpression("->forAll", leftargleft,
@@ -21683,7 +21709,7 @@ else if (leftargop.equals("->reject"))
2168321709 }
2168421710 else if (leftargop.equals("|"))
2168521711 { // s->select(x | P)->size() = 0
21686- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21712+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2168721713
2168821714 UnaryExpression notpred =
2168921715 new UnaryExpression("not", leftargpred);
@@ -21694,7 +21720,7 @@ else if (leftargop.equals("|"))
2169421720 }
2169521721 else if (leftargop.equals("|R"))
2169621722 { // s->reject(x | P)->size() = 0
21697- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21723+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2169821724
2169921725 BinaryExpression res =
2170021726 new BinaryExpression("!", leftargleft,
@@ -21704,7 +21730,7 @@ else if (leftargop.equals("|R"))
2170421730 }
2170521731 else if ("->size".equals(leftop))
2170621732 { // col->size() = 0 is col->isEmpty()
21707- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21733+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2170821734
2170921735 Expression col = arg.getArgument();
2171021736 UnaryExpression res =
@@ -21720,7 +21746,7 @@ else if ("->size".equals(leftop))
2172021746 if (leftop.equals("->count"))
2172121747 { // s->count(x) = 0
2172221748
21723- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21749+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2172421750
2172521751 BinaryExpression res =
2172621752 new BinaryExpression("->excludes", be.getLeft(),
@@ -21743,7 +21769,7 @@ else if ("->size".equals(leftop))
2174321769
2174421770 if (leftargop.equals("->select"))
2174521771 { // s->select(P)->size() = 1
21746- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21772+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2174721773
2174821774 BinaryExpression res =
2174921775 new BinaryExpression("->exists1", leftargleft,
@@ -21752,7 +21778,7 @@ else if ("->size".equals(leftop))
2175221778 }
2175321779 else if (leftargop.equals("->reject"))
2175421780 { // s->reject(P)->size() = 1
21755- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21781+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2175621782
2175721783 UnaryExpression notpred =
2175821784 new UnaryExpression("not", leftargpred);
@@ -21763,7 +21789,7 @@ else if (leftargop.equals("->reject"))
2176321789 }
2176421790 else if (leftargop.equals("|"))
2176521791 { // s->select(x | P)->size() = 1
21766- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21792+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2176721793
2176821794 BinaryExpression res =
2176921795 new BinaryExpression("#1", leftargleft,
@@ -21772,7 +21798,7 @@ else if (leftargop.equals("|"))
2177221798 }
2177321799 else if (leftargop.equals("|R"))
2177421800 { // s->reject(x | P)->size() = 1
21775- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21801+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2177621802
2177721803 UnaryExpression notpred =
2177821804 new UnaryExpression("not", leftargpred);
@@ -21799,7 +21825,7 @@ else if (leftargop.equals("|R"))
2179921825
2180021826 if (leftargop.equals("->select"))
2180121827 { // s->select(P)->size() > 0
21802- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21828+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2180321829
2180421830 BinaryExpression res =
2180521831 new BinaryExpression("->exists", leftargleft,
@@ -21808,7 +21834,7 @@ else if (leftargop.equals("|R"))
2180821834 }
2180921835 else if (leftargop.equals("->reject"))
2181021836 { // s->reject(P)->size() > 0
21811- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21837+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2181221838
2181321839 UnaryExpression notpred =
2181421840 new UnaryExpression("not", leftargpred);
@@ -21820,7 +21846,7 @@ else if (leftargop.equals("->reject"))
2182021846 else if (leftargop.equals("|"))
2182121847 { // s->select(x | P)->size() > 0
2182221848
21823- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21849+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2182421850
2182521851 BinaryExpression res =
2182621852 new BinaryExpression("#", leftargleft,
@@ -21830,7 +21856,7 @@ else if (leftargop.equals("|"))
2183021856 else if (leftargop.equals("|R"))
2183121857 { // s->reject(x | P)->size() > 0
2183221858
21833- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21859+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2183421860
2183521861 UnaryExpression notpred =
2183621862 new UnaryExpression("not", leftargpred);
@@ -21843,7 +21869,7 @@ else if (leftargop.equals("|R"))
2184321869 else if ("->size".equals(leftop))
2184421870 { // col->size() > 0
2184521871
21846- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21872+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2184721873 Expression col = arg.getArgument();
2184821874 UnaryExpression res =
2184921875 new UnaryExpression("->notEmpty", col);
@@ -21857,7 +21883,7 @@ else if ("->size".equals(leftop))
2185721883 String leftop = be.getOperator();
2185821884 if (leftop.equals("->count"))
2185921885 { // s->count(x) > 0
21860- System.out .println(">> OCL efficiency smell (OES): Inefficient comparison: " + this);
21886+ System.err .println("!! OCL efficiency smell (OES): Inefficient comparison: " + this);
2186121887
2186221888 BinaryExpression res =
2186321889 new BinaryExpression("->includes", be.getLeft(),
@@ -21873,7 +21899,7 @@ else if ("->size".equals(leftop))
2187321899 { BinaryExpression lbe = (BinaryExpression) domain;
2187421900
2187521901 if (lbe.operator.equals("->select"))
21876- { System.out .println(">> OCL efficiency smell (OES): Inefficient nested select: " + this);
21902+ { System.err .println("!! OCL efficiency smell (OES): Inefficient nested select: " + this);
2187721903 Expression newleft = lbe.getLeft();
2187821904 Expression newright = lbe.getRight();
2187921905 BasicExpression ref =
@@ -21887,7 +21913,7 @@ else if ("->size".equals(leftop))
2188721913 return new BinaryExpression("|", newdomain, newpred);
2188821914 }
2188921915 else if (lbe.operator.equals("->reject"))
21890- { System.out .println(">> OCL efficiency smell (OES): Inefficient nested select: " + this);
21916+ { System.err .println("!! OCL efficiency smell (OES): Inefficient nested select: " + this);
2189121917 Expression newleft = lbe.getLeft();
2189221918 Expression newright = lbe.getRight();
2189321919 BasicExpression ref =
@@ -21911,7 +21937,7 @@ else if (operator.equals("|R"))
2191121937 { BinaryExpression lbe = (BinaryExpression) domain;
2191221938
2191321939 if (lbe.operator.equals("->select"))
21914- { System.out .println(">> OCL efficiency smell (OES): Inefficient nested select/reject: " + this);
21940+ { System.err .println("!! OCL efficiency smell (OES): Inefficient nested select/reject: " + this);
2191521941 Expression newleft = lbe.getLeft();
2191621942 Expression newright = lbe.getRight();
2191721943 BasicExpression ref =
@@ -21926,7 +21952,7 @@ else if (operator.equals("|R"))
2192621952 return new BinaryExpression("|", newdomain, newpred);
2192721953 }
2192821954 else if (lbe.operator.equals("->reject"))
21929- { System.out .println(">> OCL efficiency smell (OES): Inefficient nested reject: " + this);
21955+ { System.err .println("!! OCL efficiency smell (OES): Inefficient nested reject: " + this);
2193021956 Expression newleft = lbe.getLeft();
2193121957 Expression newright = lbe.getRight();
2193221958 BasicExpression ref =
@@ -21948,19 +21974,19 @@ else if (operator.equals("->select"))
2194821974 if (left instanceof BinaryExpression)
2194921975 { BinaryExpression lbe = (BinaryExpression) left;
2195021976 if (lbe.operator.equals("->select"))
21951- { System.out .println(">> OCL efficiency smell (OES): Inefficient nested select: " + this);
21977+ { System.err .println("!! OCL efficiency smell (OES): Inefficient nested select: " + this);
2195221978 Expression predicate1 = lbe.getRight();
2195321979 Expression combinedPred =
2195421980 new BinaryExpression("&", predicate1, right);
2195521981 BinaryExpression res = (BinaryExpression) clone();
2195621982 res.left = lbe.getLeft();
2195721983 res.operator = "->select";
2195821984 res.right = combinedPred;
21959- System.out.println(">> Replacing with: " + res);
21985+ System.out.println("!! Replacing with: " + res);
2196021986 return res;
2196121987 }
2196221988 else if (lbe.operator.equals("->reject"))
21963- { System.out .println(">> OCL efficiency smell (OES): Inefficient nested select: " + this);
21989+ { System.err .println("!! OCL efficiency smell (OES): Inefficient nested select: " + this);
2196421990 Expression predicate1 = lbe.getRight();
2196521991 Expression pred2 =
2196621992 Expression.negate(predicate1);
@@ -21970,7 +21996,7 @@ else if (lbe.operator.equals("->reject"))
2197021996 res.left = lbe.getLeft();
2197121997 res.operator = "->select";
2197221998 res.right = combinedPred;
21973- System.out.println(">> Replacing with: " + res);
21999+ System.out.println("!! Replacing with: " + res);
2197422000 return res;
2197522001 }
2197622002 }
@@ -21980,7 +22006,7 @@ else if (operator.equals("->reject"))
2198022006 if (left instanceof BinaryExpression)
2198122007 { BinaryExpression lbe = (BinaryExpression) left;
2198222008 if (lbe.operator.equals("->select"))
21983- { System.out .println(">> OCL efficiency smell (OES): Inefficient nested select: " + this);
22009+ { System.err .println("!! OCL efficiency smell (OES): Inefficient nested select: " + this);
2198422010 Expression predicate1 = lbe.getRight();
2198522011 Expression combinedPred =
2198622012 new BinaryExpression("&",
@@ -21989,7 +22015,7 @@ else if (operator.equals("->reject"))
2198922015 res.left = lbe.getLeft();
2199022016 res.operator = "->select";
2199122017 res.right = combinedPred;
21992- System.out.println(">> Replacing with: " + res);
22018+ System.out.println("!! Replacing with: " + res);
2199322019 return res;
2199422020 }
2199522021 else if (lbe.operator.equals("->reject"))
0 commit comments