Browse Source

kernel: Split MethodCompositionBrik into two.

Herbert Vojčík 7 years ago
parent
commit
309a3ba95f
2 changed files with 28 additions and 23 deletions
  1. 24 19
      support/kernel-fundamentals.js
  2. 4 4
      support/kernel-language.js

+ 24 - 19
support/kernel-fundamentals.js

@@ -202,10 +202,10 @@ define(['./compatibility' /* TODO remove */], function () {
         };
     }
 
-    MethodsBrik.deps = ["composition", "selectors", "root", "selectorConversion"];
+    MethodsBrik.deps = ["behaviorProviders", "selectors", "root", "selectorConversion"];
     function MethodsBrik (brikz, st) {
         var registerSelector = brikz.selectors.registerSelector;
-        var updateMethod = brikz.composition.updateMethod;
+        var updateMethod = brikz.behaviorProviders.updateMethod;
         var SmalltalkObject = brikz.root.Object;
         var coreFns = brikz.root.coreFns;
 
@@ -266,8 +266,8 @@ define(['./compatibility' /* TODO remove */], function () {
         };
     }
 
-    MethodCompositionBrik.deps = ["organize"];
-    function MethodCompositionBrik (brikz, st) {
+    BehaviorProvidersBrik.deps = ["organize"];
+    function BehaviorProvidersBrik (brikz, st) {
         var setupClassOrganization = brikz.organize.setupClassOrganization;
         var addOrganizationElement = brikz.organize.addOrganizationElement;
 
@@ -297,6 +297,25 @@ define(['./compatibility' /* TODO remove */], function () {
             // This is handled by #removeCompiledMethod
         }
 
+        function updateMethod (selector, traitOrBehavior) {
+            var oldMethod = traitOrBehavior.methods[selector],
+                newMethod = traitOrBehavior.localMethods[selector];
+            if (oldMethod == null && newMethod == null) {
+                console.warn("Removal of nonexistent method " + traitOrBehavior + " >> " + selector);
+                return;
+            }
+            if (newMethod === oldMethod) return;
+            if (newMethod != null) addMethod(newMethod, traitOrBehavior);
+            else removeMethod(oldMethod, traitOrBehavior);
+        }
+
+        this.updateMethod = updateMethod;
+    }
+
+    MethodCompositionBrik.deps = ["behaviorProviders"];
+    function MethodCompositionBrik (brikz, st) {
+        var updateMethod = brikz.behaviorProviders.updateMethod;
+
         function aliased (selector, method) {
             if (method.selector === selector) return method;
             var result = st.method({
@@ -369,21 +388,6 @@ define(['./compatibility' /* TODO remove */], function () {
             });
         };
 
-        // TODO move to MethodBrik once organization is fully on st side
-        function updateMethod (selector, traitOrBehavior) {
-            var oldMethod = traitOrBehavior.methods[selector],
-                newMethod = traitOrBehavior.localMethods[selector];
-            if (oldMethod == null && newMethod == null) {
-                console.warn("Removal of nonexistent method " + traitOrBehavior + " >> " + selector);
-                return;
-            }
-            if (newMethod === oldMethod) return;
-            if (newMethod != null) addMethod(newMethod, traitOrBehavior);
-            else removeMethod(oldMethod, traitOrBehavior);
-        }
-
-        this.updateMethod = updateMethod;
-
         function aliasesOfSelector (selector, traitAliases) {
             if (!traitAliases) return [selector];
             var result = Object.keys(traitAliases).filter(function (aliasSelector) {
@@ -522,6 +526,7 @@ define(['./compatibility' /* TODO remove */], function () {
         brikz.selectors = SelectorsBrik;
         brikz.packages = PackagesBrik;
         brikz.composition = MethodCompositionBrik;
+        brikz.behaviorProviders = BehaviorProvidersBrik;
         brikz.behaviors = BehaviorsBrik;
         brikz.methods = MethodsBrik;
 

+ 4 - 4
support/kernel-language.js

@@ -59,11 +59,11 @@ define(['./compatibility' /* TODO remove */], function () {
         });
     }
 
-    TraitsBrik.deps = ["behaviors", "composition", "arraySet", "root"];
+    TraitsBrik.deps = ["behaviors", "behaviorProviders", "composition", "arraySet", "root"];
     function TraitsBrik (brikz, st) {
         var coreFns = brikz.root.coreFns;
         var SmalltalkObject = brikz.root.Object;
-        var setupMethods = brikz.composition.setupMethods;
+        var setupMethods = brikz.behaviorProviders.setupMethods;
         var traitMethodChanged = brikz.composition.traitMethodChanged;
         var buildTraitOrClass = brikz.behaviors.buildTraitOrClass;
         var addElement = brikz.arraySet.addElement;
@@ -126,14 +126,14 @@ define(['./compatibility' /* TODO remove */], function () {
         };
     }
 
-    ClassesBrik.deps = ["root", "behaviors", "composition", "arraySet", "smalltalkGlobals"];
+    ClassesBrik.deps = ["root", "behaviors", "behaviorProviders", "arraySet", "smalltalkGlobals"];
     function ClassesBrik (brikz, st) {
         var SmalltalkRoot = brikz.root.Root;
         var coreFns = brikz.root.coreFns;
         var globals = brikz.smalltalkGlobals.globals;
         var SmalltalkObject = brikz.root.Object;
         var buildTraitOrClass = brikz.behaviors.buildTraitOrClass;
-        var setupMethods = brikz.composition.setupMethods;
+        var setupMethods = brikz.behaviorProviders.setupMethods;
         var removeTraitOrClass = brikz.behaviors.removeTraitOrClass;
         var addElement = brikz.arraySet.addElement;
         var removeElement = brikz.arraySet.removeElement;