ZyX_I  committed f99bdd6

@/fwc: Made it possible to pass type to compadescr

  • Participants
  • Parent commits 5605075
  • Branches default

Comments (0)

Files changed (3)

File plugin/frawor/fwc/compiler.vim

     return self
-"▶1 compilearg      :: &self(argcontext, idx[, type])
-function s:compiler.compilearg(argcon, idx, ...)
-    let type=get(a:000, 0, self.type)
+"▶1 compilearg      :: &self(argcontext, idx, type)
+function s:compiler.compilearg(argcon, idx, type)
     if a:argcon[0] is 'arg'
         let arg=a:argcon[1:]
     let msg=[]
     let i=0
     let savedonlystrings=self.o.onlystrings
-    if type is 'complete'
+    if a:type is 'complete'
         let addedcompletion=0
         let addedcycle=0
         let argidxstr=self.getlvarid('argidx')
     for proc in arg
         let i+=1
-        let compargs=[proc, a:idx.'.'.i, type]
+        let compargs=[proc, a:idx.'.'.i, a:type]
         let comptype=proc[0]
         if comptype is 'intfunc'
-            let comptype=type
+            let comptype=a:type
             let compargs[0]=[comptype, compargs[0]]
         elseif comptype is 'defval'
-        if type is 'complete'
+        if a:type is 'complete'
             if addedcompletion && !addedcycle
                 let addedcycle=1
                 call self.let(argidxstr, 0)
     if len(self.msgs.own)>pmsgnum
         call remove(self.msgs.own, pmsgnum, -1)
-    if type is 'complete' && addedcycle
+    if a:type is 'complete' && addedcycle
         call self.without().popms()
     return self
-"▶1 compadescr      :: &self(adescr[, idx[, purgemax]])
+"▶1 compadescr      :: &self(adescr[, idx[, purgemax[, type]]])
 function s:compiler.compadescr(adescr, ...)
     let purgemax=get(a:000, 1, 0)
-    let type=self.type
+    let type=get(a:000, 2, self.type)
     "▶2 Length checks, lagsstr and nextsub variables
     if !empty(self.subs)
         let largsstr=self.getlargsstr()
             if type is 'complete' && !self.o.only
                 call self.addif(largsstr.'-1 == '.self.getlastsub())
-            call self.compilearg(arg, idx)
+            call self.compilearg(arg, idx, type)
             call self.incsub()
             if type is 'complete' && !self.o.only
                 call self.up()

File plugin/frawor/fwc/intfuncs.vim

                 \.let(condstr, 0)
     if len(a:desc[2])>1
-        call self.addif(condstr).compilearg(a:desc[2],a:idx.'(if)', a:type)
+        call self.addif(condstr).compilearg(a:desc[2], a:idx.'(if)', a:type)
         if len(a:desc[3])>1
             call self.addif()
 "▶1 `tuple'
 let s:r.tuple={'args': ['*arg']}
 "▶2 addtuple       :: tupledesc, idx, defaultArgType + self → self + self
-function s:F.addtuple(tuple, idx, default)
+function s:F.addtuple(tuple, idx, type)
     call add(self.subs, 0)
     for arg in a:tuple[1]
-        call self.compilearg(arg, a:idx.'(tuple).'.self.subs[-1], a:default)
+        call self.compilearg(arg, a:idx.'(tuple).'.self.subs[-1], a:type)
         call self.incsub()
     call remove(self.subs, -1)
 "▶1 `list'
 let s:r.list={'args': ['arg']}
 "▶2 addlist        :: listdesc, idx, defaultArgType + self → self + self
-function s:F.addlist(list, idx, default)
+function s:F.addlist(list, idx, type)
     let largstr=self.getlvarid('larg')
     let lststr=self.argstr()
     let istr=self.getlvarid('i')
     call     self.let(largstr, 'len('.lststr.')')
                 \.let(istr, 0)
-                    \.compilearg(a:list[1], a:idx.'(list)', a:default)
+                    \.compilearg(a:list[1], a:idx.'(list)', a:type)
     call remove(self.subs, -1)
 let s:r.list.pipe=s:r.list.check
 "▶1 `dict'
 let s:r.dict={'args': ['get']}
-"▶2 adddict        :: dicdesc, idx, defaultArgType + self → self + self
-function s:F.adddict(dic, idx, default)
+"▶2 adddict        :: dicdesc, idx, type + self → self + self
+function s:F.adddict(dic, idx, type)
     if len(a:dic[1])==1
         let curargstr=self.argstr()
         return self.nextthrow('!empty('.curargstr.')',
         elseif check[0] is 'expr'
             call self.addif(self.getexpr(check[1], keystr).' isnot 0')
         elseif check[0] is 'any'
-            call self.compilearg(check[1], a:idx.'.'.i.'(val)', a:default)
+            call self.compilearg(check[1], a:idx.'.'.i.'(val)', a:type)
         elseif check[0] is 'check'
                         \.compilearg(check[1], a:idx.'.'.i.'(key)', 'check')
                         \.let(foundstr, 1)
-                        \.compilearg(check[2],a:idx.'.'.i.'(val)',a:default)
+                        \.compilearg(check[2], a:idx.'.'.i.'(val)', a:type)
-        call self.compilearg(check[2], a:idx.'.'.i.'(val)',a:default).continue()
+        call self.compilearg(check[2], a:idx.'.'.i.'(val)', a:type).continue()
     if hascheck

File plugin/frawor/fwc/topconstructs.vim

     if a:type is 'complete'
         let hasnext=s:F.hasnext(a:adescr, 'next')
         if !hasnext && len(a:adescr.optional)==1
-            call self.compadescr(a:adescr.optional[0], a:idx.'.0(optional)')
+            call self.compadescr(a:adescr.optional[0], a:idx.'.0(optional)', 0,
+                        \        a:type)
             let oldsub=self.getsub(self.subs[-1])
             if oldsub isnot a:caidxstr
                 call self.let(a:caidxstr, oldsub)
                     \            a:idx.'.0(optional)',
-                    \            (a:purgemax || a:adescr.maximum==-1))
+                    \            (a:purgemax || a:adescr.maximum==-1), a:type)
     if lopt>1
             call self.if(failstr)
-                            \.compadescr(opt, a:idx.'.'.i.'(optional)')
+                            \.compadescr(opt, a:idx.'.'.i.'(optional)', 0,
+                            \            a:type)
                             \.let(failstr, 0)
         "▶3 Process prefix arguments
         if a:type is 'check' || a:type is 'pipe'
             for i in range(1, prefopts.argnum)
-                call self.compilearg(args[i-1], idx.self.string(prefix))
+                call self.compilearg(args[i-1], idx.self.string(prefix), a:type)
             if prefopts.argnum>0
                         \.let(idxdiffstr, a:largsstr.'-'.a:caidxstr)
             for i in range(1, prefopts.argnum)
                 call self.addif(idxdiffstr.'=='.i)
-                            \.compilearg(args[i-1], idx.self.string(prefix))
+                            \.compilearg(args[i-1], idx.self.string(prefix),
+                            \            a:type)
             let condition=a:largsstr.'-1 == '.self.getlastsub()
         call self.addif(condition)
-                    \.compilearg([0], a:idx.'.(next)')
+                    \.compilearg([0], a:idx.'.(next)', a:type)
         if hasnext
             call self.pushms('throwignore')
             call self.try().pushms('throw')
         call self.while(a:caidxstr.'<'.a:largsstr)
-                    \.compilearg([0], a:idx.'.(next)')
+                    \.compilearg([0], a:idx.'.(next)', a:type)
         if hasnext
         let savedsub=copy(self.subs[-1])
         if noact isnot 0 && len(noact)>1
             let self.onlyfirst+=1
-            call self.compadescr(noact[1], idx.'.nullact').out()
+            call self.compadescr(noact[1], idx.'.nullact', 0, a:type).out()
             call call(s:r.actions.optimizenullact, [a:caidxstr], self)
             let self.onlyfirst-=1
     for [actstr; actargs] in actions
         call self.addif(actionstr.' is '.self.string(actstr))
         if !empty(actargs)
-            call self.compadescr(actargs[0], idx.'.'.self.string(actstr))
+            call self.compadescr(actargs[0], idx.'.'.self.string(actstr), 0,
+                        \        a:type)
         call self.let(a:caidxstr, self.getlastsub()).up()
         let self.subs[-1]=copy(astartsub)
         call self.incsub(-1)
         if len(noact)>1
-            call self.compadescr(noact[1], idx.'.nullact')
+            call self.compadescr(noact[1], idx.'.nullact', 0, a:type)
                         \.let(a:caidxstr, self.getlastsub())
         let self.subs[-1]=copy(astartsub)