Commits

ZyX_I committed 06d8a73

@frawor: Improved deplen generation, added it to require feature

Comments (0)

Files changed (1)

plugin/frawor.vim

         endif
     endfor
 endfunction
-"▶1 updatedeplen    :: plugdict + s:deplen → + s:deplen
-function s:F.updatedeplen(plugdict)
-    " XXX max([])=0
-    let s:deplen[a:plugdict.id]=max(map(keys(a:plugdict.dependencies),
-                \                       '((v:val is# a:plugdict.id)?'.
-                \                           '(0):'.
-                \                           '(get(s:deplen, v:val, 0)))'))+1
+"▶1 updatedeplen    :: plid, newval, dict + s:deplen → + s:deplen
+function s:F.updatedeplen(plid, newval, updated)
+    let s:deplen[a:plid]=a:newval
+    let a:updated[a:plid]=1
+    if has_key(s:dependents, a:plid)
+        let nv=a:newval+1
+        call map(keys(s:dependents[a:plid]),
+                    \'((!has_key(a:updated, v:val) && '.
+                    \  's:deplen[v:val]<'.nv.')?'.
+                    \   's:F.updatedeplen(v:val, '.nv.', a:updated):'.
+                    \   '0)')
+    endif
 endfunction
 "▶1 newplugin       :: version, sid, file, dependencies, oneload, g → +s:pls,
 function s:F.newplugin(version, sid, file, dependencies, oneload, g)
     "▲2
     let s:pls[plid]=plugdict
     let s:shadow[plid]=shadowdict
-    call s:F.updatedeplen(plugdict)
+    let s:deplen[plid]=max(map(keys(plugdict.dependencies),
+                \              '((v:val is# '.string(plid).')?'.
+                \                  '(0):'.
+                \                  '(get(s:deplen, v:val, 0)))'))+1
     call s:F.initfeatures(plugdict)
     let plugdict.g._pluginloaded=0
     if a:oneload
         let plugdict.g._loading=1
         let d={}
         try
+            let olddeplen=s:deplen[plid]
             "▶2 Loading dependencies
             for [dplid, d.Version] in items(plugdict.dependencies)
                 if has_key(s:loading, dplid)
                     endif
                     continue
                 endif
-                if s:F.loadplugin(dplid)
-                    let dversion=s:pls[dplid].version
-                    "▶3 Checking dependency version
-                    if d.Version[0]!=dversion[0]
-                        call s:_f.throw('majmismatch', dplid, plid,
-                                    \                  d.Version[0],
-                                    \                  dversion[0])
-                    elseif s:F.compareversions(d.Version, dversion)>0
-                        call s:_f.throw('oldversion', dplid, plid,
-                                    \                 join(d.Version, '.'),
-                                    \                 join(dversion,  '.'))
+                if !has_key(s:pls, dplid) || s:pls[dplid].status!=2
+                    if !s:F.loadplugin(dplid)
+                        call s:_f.throw('reqfailed', dplid, plid)
                     endif
-                    "▲3
-                else
-                    call s:_f.throw('reqfailed', dplid, plid)
                 endif
+                let dversion=s:pls[dplid].version
+                "▶3 Checking dependency version
+                if d.Version[0]!=dversion[0]
+                    call s:_f.throw('majmismatch', dplid, plid,
+                                \                  d.Version[0],
+                                \                  dversion[0])
+                elseif s:F.compareversions(d.Version, dversion)>0
+                    call s:_f.throw('oldversion', dplid, plid,
+                                \                 join(d.Version, '.'),
+                                \                 join(dversion,  '.'))
+                endif
+                "▲3
             endfor
-            call s:F.updatedeplen(plugdict)
             "▶2 Running features
             for feature in s:F.getfeatures(plugdict, 'all')
                 call s:F.addfeature(plugdict, feature, 1)
             if !plugdict.oneload
                 execute 'source '.fnameescape(plugdict.file)
             endif
+            if s:deplen[plid]>olddeplen
+                call s:F.updatedeplen(plid, s:deplen[plid], {})
+            endif
             "▶2 Modifying plugdict status
             let plugdict.g._pluginloaded=1
             let plugdict.status=2
                 return 0
             endif
         endif
+    elseif s:deplen[dplid]+1>s:deplen[plid]
+        call s:F.updatedeplen(plid, s:deplen[dplid]+1, {})
     endif
     "▲2
     let dfeatures=get(s:plfeatures, dplid, {})