2f4a1ece55a1 — Leonard Ritter 10 days ago
* changed CADAG init order
2 files changed, 11 insertions(+), 8 deletions(-)

M lib/tukan/CADAG.sc
M testing/test_cadag.sc
M lib/tukan/CADAG.sc +8 -7
@@ 317,7 317,7 @@ type CADAG < Struct
 
     spice dispatch-type (cls typeid ptr ...)
         let self = (getinstance cls)
-        let sw = (sc_switch_new typeid)
+        let sw = ('tag (sc_switch_new typeid) ('anchor args))
         let mutable? = ('writable? ('typeof ptr))
         for arg in ('args ...)
             let k v = ('dekey arg)

          
@@ 422,10 422,11 @@ inline alignoffsetu (offset align)
     (offset + align - 1) & -align
 
 type Handle
-    inline __dispatch (self ...)
-        let cls = (typeof self)
-        let typeid sz ptr = (unpack (storagecast self))
-        'dispatch-type cls.CADAGType typeid ptr ...
+    let __dispatch =
+        inline "#hidden" (self ...)
+            let cls = (typeof self)
+            let typeid sz ptr = (unpack (storagecast self))
+            'dispatch-type cls.CADAGType typeid ptr ...
 
     inline __unpack (self)
         unpack (storagecast self)

          
@@ 690,7 691,7 @@ type+ CADAG
                     'set aliases oldid newid
         let visit =
             va-option visit ...
-                inline (finalize handle)
+                inline (module handle finalize)
                     let newid = (finalize)
                     #report "done" md.id "->" newid (string (get-typename md.typeid))
                     newid

          
@@ 723,7 724,7 @@ type+ CADAG
                 let handle = (bitcast
                     ((storageof cls.MutableHandleType) md.typeid md.size stackptr)
                     cls.MutableHandleType)
-                let newid = (visit finalize handle)
+                let newid = (visit (view newmodule) handle finalize)
                 let oldid = (copy md.id)
                 on-alias oldid newid
                 # clear

          
M testing/test_cadag.sc +3 -1
@@ 76,11 76,13 @@ do
     let newmodule newid =
         transform (rootid)
             visit =
-                capture (finalize handle) {&module}
+                capture (module handle finalize) {}
                     dispatch handle
                     case const (self)
                         print self
                         self += 1
+                    case const2 (self)
+                        return (('const module.factory (self + 10)) as u32)
                     case vec3 (self)
                         print (self @ 0) (self @ 1) (self @ 2)
                         dispatch ('handleof module (self @ 0))