ZyX_I avatar ZyX_I committed aa0034b

@/fwc: More constructor improvements: added toblock()

Comments (0)

Files changed (2)

plugin/frawor/fwc/compiler.vim

     endif
     return self.call('add(@$@messages, ['.string(a:msg).', '.join(args, ', ').
                 \                     '])')
-                \.throw(s:cfstr).up()
+                \.throw(s:cfstr)
 endfunction
 "▶1 nextthrow      :: condition::expr, throwargs + self → self + self
 function s:compiler.nextthrow(cond, ...)
                     \.let(dirnamestr, '@%@.os.path.dirname('.dirnamestr.')')
                 \.up()
                 \.nextthrow('!'.foundstr, 'nowrite', a:idx, '@#@', curargstr)
-            \.up()
+            \.up().up()
     return self
 endfunction
 "▶1 addtypecond    :: types, idx + self → self + self
 "▶1 compilecheck   :: checkcontext, idx + self → self + self
 function s:compiler.compilecheck(check, idx)
     let curargstr=self.argstr()
-    let idx=a:idx
-    for check in a:check[1:]
-        "▶2 `func' check
-        if check[0] is 'func'
-            call self.nextthrow(self.getfunc(check, 0, curargstr).' is 0',
-                        \       'funcfail', idx, '@#@')
-        "▶2 `expr' check
-        elseif check[0] is 'expr'
-            call self.nextthrow(self.getexpr(check, curargstr).' is 0',
-                        \       'exprfail', idx, '@#@')
-        "▶2 `intfunc' check
-        else
-            let desc=check[1:]
-            "▶3 `func'
-            if desc[0] is 'func'
-                call self.nextthrow(self.getfunc(desc[1], 0, curargstr).' is 0',
-                            \       'funcfail', idx, '@#@')
-            "▶3 `eval'
-            elseif desc[0] is 'eval'
-                call self.nextthrow(self.getexpr(desc[1], curargstr).' is 0',
-                            \       'exprfail', idx, '@#@')
-            "▶3 `not'
-            elseif desc[0] is 'not'
-                let msglenstr=self.getlvarid('msglen')
-                let pmsglenstr=self.getlvarid('pmsglen')
-                call self.addsavemsgs()
-                        \.try()
-                            \.compilearg(desc[1], idx.'(not)')
-                            \.throw('"NOTFAILED"')
-                        \.catch(s:cfreg)
-                            \.addrestmsgs()
-                        \.up().catch('^NOTFAILED$')
-                            \.addthrow('notfail', idx, '@#@')
-            "▶3 `either'
-            elseif desc[0] is 'either'
-                let sucstr=self.getlvarid('succeeded')
-                let msglenstr=self.getlvarid('msglen')
-                let pmsglenstr=self.getlvarid('pmsglen')
-                call self.let(sucstr, 1).addsavemsgs()
-                if !empty(desc[1])
-                    call self.try()
-                                \.compilearg(desc[1][0], idx.'(either).0',
-                                \            'check')
+    let check=a:check[1]
+    "▶2 `func' check
+    if check[0] is 'func'
+        call self.nextthrow(self.getfunc(check, 0, curargstr).' is 0',
+                    \       'funcfail', a:idx, '@#@')
+    "▶2 `expr' check
+    elseif check[0] is 'expr'
+        call self.nextthrow(self.getexpr(check, curargstr).' is 0',
+                    \       'exprfail', a:idx, '@#@')
+    "▶2 `intfunc' check
+    else
+        let desc=check[1:]
+        "▶3 `func'
+        if desc[0] is 'func'
+            call self.nextthrow(self.getfunc(desc[1], 0, curargstr).' is 0',
+                        \       'funcfail', a:idx, '@#@')
+        "▶3 `eval'
+        elseif desc[0] is 'eval'
+            call self.nextthrow(self.getexpr(desc[1], curargstr).' is 0',
+                        \       'exprfail', a:idx, '@#@')
+        "▶3 `not'
+        elseif desc[0] is 'not'
+            let msglenstr=self.getlvarid('msglen')
+            let pmsglenstr=self.getlvarid('pmsglen')
+            call self.addsavemsgs()
+                    \.try()
+                        \.compilearg(desc[1], a:idx.'(not)')
+                        \.throw('"NOTFAILED"')
+                    \.catch(s:cfreg)
+                        \.addrestmsgs()
+                    \.up().catch('^NOTFAILED$')
+                        \.addthrow('notfail', a:idx, '@#@')
+        "▶3 `either'
+        elseif desc[0] is 'either'
+            let sucstr=self.getlvarid('succeeded')
+            let msglenstr=self.getlvarid('msglen')
+            let pmsglenstr=self.getlvarid('pmsglen')
+            call self.let(sucstr, 1).addsavemsgs()
+            if !empty(desc[1])
+                call self.try()
+                            \.compilearg(desc[1][0], a:idx.'(either).0',
+                            \            'check')
+                        \.up().catch(s:cfreg)
+                            \.let(sucstr, 0).up()
+            endif
+            let i=1
+            for arg in desc[1][1:]
+                call self.addif('!'.sucstr)
+                            \.let(sucstr, 1)
+                            \.try()
+                                \.compilearg(arg, a:idx.'(either).'.i,'check')
                             \.up().catch(s:cfreg)
-                                \.let(sucstr, 0).up()
+                                \.let(sucstr, 0)
+                            \.up()
+                        \.up()
+                let i+=1
+            endfor
+            call self.addif(sucstr).addrestmsgs().up()
+                        \.addif().addthrow('eitherfail',a:idx,'@#@').up().up()
+        "▶3 `tuple'
+        elseif desc[0] is 'tuple'
+            call self.addtypecond([type([])], a:idx)
+                        \.nextthrow('len('.curargstr.')!='.len(desc[1]),
+                        \           'invlstlen', a:idx, '@#@', len(desc[1]),
+                        \                        'len('.curargstr.')')
+                        \.addtuple(desc, a:idx, 'check')
+        "▶3 `list'
+        elseif desc[0] is 'list'
+            call self.addtypecond([type([])], a:idx).addlist(desc,a:idx,'check')
+        "▶3 `dict'
+        elseif desc[0] is 'dict'
+            call self.addtypecond([type({})], a:idx).adddict(desc,a:idx,'check')
+        "▶3 `in'
+        elseif desc[0] is 'in'
+            call self.nextthrow('index('.self.getvar(desc[1]).', '.
+                        \                curargstr.')==-1',
+                        \       'ninlist', a:idx, '@#@')
+        "▶3 `key'
+        elseif desc[0] is 'key'
+            call self.addtypecond([type('')], a:idx)
+                        \.nextthrow('!has_key('.self.getvar(desc[1]).', '.
+                        \                       curargstr.')',
+                        \           'nindict', a:idx, '@#@', curargstr)
+        "▶3 `haskey'
+        elseif desc[0] is 'haskey'
+            call self.addtypecond([type({})], a:idx)
+            if len(desc[1])>1
+                let keys='['.join(map(copy(desc[1]),
+                            \         'type(v:val)==type("")?'.
+                            \               's:F.string(v:val):'.
+                            \               'self.getvar(v:val)'),
+                            \', ').']'
+                let absentkeys='filter('.keys.', '.
+                            \          string('!has_key('.curargstr.', '.
+                            \                           'v:val)').')'
+                call self.nextthrow('!empty('.absentkeys.')',
+                            \       'keysmis', a:idx, '@#@',
+                            \                  'join('.absentkeys.', ", ")')
+            elseif !empty(desc[1])
+                let keystr=((type(desc[1][0])==type(''))?
+                            \       (s:F.string(desc[1][0])):
+                            \       (self.getvar(desc[1][0])))
+                call self.nextthrow('!has_key('.curargstr.', '.keystr.')',
+                            \       'keymis', a:idx, '@#@', keystr)
+            endif
+        "▶3 `range'
+        elseif desc[0] is 'range'
+            "▶4 Determine whether we accept floating-point values
+            let acceptfloat=has('float') &&
+                        \(desc[1][0] is 'float' || desc[1][1] is 'float')
+            if acceptfloat
+                call self.addtypecond([type(0), type(0.0)], a:idx)
+            else
+                call self.addtypecond([type(0)], a:idx)
+            endif
+            "▶4 Obtain range borders
+            let range=map(desc[1:],
+                        \'((v:val[0] is "inf" || v:val[0] is "nan")?'.
+                        \   '(""):'.
+                        \   '((v:val[0] is "number"||v:val[0] is "float")?'.
+                        \       '(v:val[1]):'.
+                        \       '(self.getvar(v:val))))')
+            if type(range[0])!=type('') && type(range[1])!=type('')
+                        \&& range[0]>range[1]
+                call reverse(range)
+            endif
+            "▶4 Construct condition
+            let cond=''
+            call map(range, '((type(v:val)=='.type('').')?'.
+                        \               '(v:val):'.
+                        \               '(string(v:val)))')
+            if range[0] isnot ''
+                let cond.=range[0].'>'.curargstr
+            endif
+            if range[1] isnot ''
+                if !empty(cond)
+                    let cond.=' || '
                 endif
-                let i=1
-                for arg in desc[1][1:]
-                    call self.addif('!'.sucstr)
-                                \.let(sucstr, 1)
-                                \.try()
-                                    \.compilearg(arg, idx.'(either).'.i,'check')
-                                \.up().catch(s:cfreg)
-                                    \.let(sucstr, 0)
-                                \.up()
-                            \.up()
-                    let i+=1
-                endfor
-                call self.addif(sucstr).addrestmsgs().up()
-                            \.addif().addthrow('eitherfail',idx,'@#@').up().up()
-            "▶3 `tuple'
-            elseif desc[0] is 'tuple'
-                call self.addtypecond([type([])], idx)
-                            \.nextthrow('len('.curargstr.')!='.len(desc[1]),
-                            \           'invlstlen', idx, '@#@', len(desc[1]),
-                            \                        'len('.curargstr.')')
-                            \.addtuple(desc, idx, 'check')
-            "▶3 `list'
-            elseif desc[0] is 'list'
-                call self.addtypecond([type([])], idx).addlist(desc,idx,'check')
-            "▶3 `dict'
-            elseif desc[0] is 'dict'
-                call self.addtypecond([type({})], idx).adddict(desc,idx,'check')
-            "▶3 `in'
-            elseif desc[0] is 'in'
-                call self.nextthrow('index('.self.getvar(desc[1]).', '.
-                            \                curargstr.')==-1',
-                            \       'ninlist', idx, '@#@')
-            "▶3 `key'
-            elseif desc[0] is 'key'
-                call self.addtypecond([type('')], idx)
-                            \.nextthrow('!has_key('.self.getvar(desc[1]).', '.
-                            \                       curargstr.')',
-                            \           'nindict', idx, '@#@', curargstr)
-            "▶3 `haskey'
-            elseif desc[0] is 'haskey'
-                call self.addtypecond([type({})], idx)
-                if len(desc[1])>1
-                    let keys='['.join(map(copy(desc[1]),
-                                \         'type(v:val)==type("")?'.
-                                \               's:F.string(v:val):'.
-                                \               'self.getvar(v:val)'),
-                                \', ').']'
-                    let absentkeys='filter('.keys.', '.
-                                \          string('!has_key('.curargstr.', '.
-                                \                           'v:val)').')'
-                    call self.nextthrow('!empty('.absentkeys.')',
-                                \       'keysmis', idx, '@#@',
-                                \                  'join('.absentkeys.', ", ")')
-                elseif !empty(desc[1])
-                    let keystr=((type(desc[1][0])==type(''))?
-                                \       (s:F.string(desc[1][0])):
-                                \       (self.getvar(desc[1][0])))
-                    call self.nextthrow('!has_key('.curargstr.', '.keystr.')',
-                                \       'keymis', idx, '@#@', keystr)
+                let cond.=curargstr.'>'.range[1]
+            endif
+            "▶4 Add condition to result
+            if !empty(cond)
+                call self.nextthrow(cond, 'nrange', a:idx, '@#@',
+                            \                       'string('.curargstr.')',
+                            \                       'string('.range[0].')',
+                            \                       'string('.range[1].')')
+            endif
+        "▶3 `match'
+        elseif desc[0] is 'match'
+            let regex=((type(desc[1][1])==type(''))?
+                        \(s:F.string(desc[1][1])):
+                        \(self.getvar(desc[1][1])))
+            call self.addtypecond([type('')], a:idx)
+                        \.nextthrow(curargstr.'!~#'.regex,
+                        \           'nregmatch',a:idx,'@#@', curargstr, regex)
+        "▶3 `path'
+        elseif desc[0] is 'path'
+            call self.addtypecond([type('')], a:idx)
+            let spec=desc[1]
+            if spec[0] is 'd'
+                let spec=spec[1:]
+                if spec[0] is 'w'
+                    call self.nextthrow('filewritable('.curargstr.')!=2',
+                                \       'nwrite', a:idx, '@#@', curargstr)
+                    let spec=spec[1:]
+                elseif spec[0] is 'W'
+                    call self.nextthrow('filewritable('.curargstr.')!=2 &&'.
+                                \      '(@%@.os.path.exists('.curargstr.')'.
+                                \       '|| filewritable('.
+                                \               '@%@.os.path.dirname('.
+                                \                        curargstr.'))!=2)',
+                                \      'nowrite', a:idx, '@#@', curargstr)
+                    let spec=spec[1:]
+                elseif spec[0] is 'p'
+                    call self.addpathp(a:idx)
+                                \.nextthrow('!@%@.os.path.isdir('.
+                                \                             curargstr.')',
+                                \           'isdir', a:idx, '@#@', curargstr)
+                    let spec=spec[1:]
+                else
+                    call self.nextthrow('!@%@.os.path.isdir('.curargstr.')',
+                                \       'isdir', a:idx, '@#@', curargstr)
                 endif
-            "▶3 `range'
-            elseif desc[0] is 'range'
-                "▶4 Determine whether we accept floating-point values
-                let acceptfloat=has('float') &&
-                            \(desc[1][0] is 'float' || desc[1][1] is 'float')
-                if acceptfloat
-                    call self.addtypecond([type(0), type(0.0)], idx)
-                else
-                    call self.addtypecond([type(0)], idx)
+            else
+                let fileonly=0
+                if spec[0] is 'f'
+                    let spec=spec[1:]
+                    let fileonly=1
                 endif
-                "▶4 Obtain range borders
-                let range=map(desc[1:],
-                            \'((v:val[0] is "inf" || v:val[0] is "nan")?'.
-                            \   '(""):'.
-                            \   '((v:val[0] is "number"||v:val[0] is "float")?'.
-                            \       '(v:val[1]):'.
-                            \       '(self.getvar(v:val))))')
-                if type(range[0])!=type('') && type(range[1])!=type('')
-                            \&& range[0]>range[1]
-                    call reverse(range)
-                endif
-                "▶4 Construct condition
-                let cond=''
-                call map(range, '((type(v:val)=='.type('').')?'.
-                            \               '(v:val):'.
-                            \               '(string(v:val)))')
-                if range[0] isnot ''
-                    let cond.=range[0].'>'.curargstr
-                endif
-                if range[1] isnot ''
-                    if !empty(cond)
-                        let cond.=' || '
-                    endif
-                    let cond.=curargstr.'>'.range[1]
-                endif
-                "▶4 Add condition to result
-                if !empty(cond)
-                    call self.nextthrow(cond, 'nrange', idx, '@#@',
-                                \                       'string('.curargstr.')',
-                                \                       'string('.range[0].')',
-                                \                       'string('.range[1].')')
-                endif
-            "▶3 `match'
-            elseif desc[0] is 'match'
-                let regex=((type(desc[1][1])==type(''))?
-                            \(s:F.string(desc[1][1])):
-                            \(self.getvar(desc[1][1])))
-                call self.addtypecond([type('')], idx)
-                            \.nextthrow(curargstr.'!~#'.regex,
-                            \           'nregmatch',idx,'@#@', curargstr, regex)
-            "▶3 `path'
-            elseif desc[0] is 'path'
-                call self.addtypecond([type('')], idx)
-                let spec=desc[1]
-                if spec[0] is 'd'
-                    let spec=spec[1:]
-                    if spec[0] is 'w'
-                        call self.nextthrow('filewritable('.curargstr.')!=2',
-                                    \       'nwrite', idx, '@#@', curargstr)
+                if fileonly
+                    if spec[0] is 'r'
+                        call self.nextthrow('!filereadable('.curargstr.')',
+                                    \       'nread', a:idx, '@#@', curargstr)
                         let spec=spec[1:]
-                    elseif spec[0] is 'W'
-                        call self.nextthrow('filewritable('.curargstr.')!=2 &&'.
-                                    \      '(@%@.os.path.exists('.curargstr.')'.
-                                    \       '|| filewritable('.
-                                    \               '@%@.os.path.dirname('.
-                                    \                        curargstr.'))!=2)',
-                                    \      'nowrite', idx, '@#@', curargstr)
-                        let spec=spec[1:]
-                    elseif spec[0] is 'p'
-                        call self.addpathp(idx)
-                                    \.nextthrow('!@%@.os.path.isdir('.
-                                    \                             curargstr.')',
-                                    \           'isdir', idx, '@#@', curargstr)
-                        let spec=spec[1:]
-                    else
-                        call self.nextthrow('!@%@.os.path.isdir('.curargstr.')',
-                                    \       'isdir', idx, '@#@', curargstr)
-                    endif
-                else
-                    let fileonly=0
-                    if spec[0] is 'f'
-                        let spec=spec[1:]
-                        let fileonly=1
-                    endif
-                    if fileonly
-                        if spec[0] is 'r'
-                            call self.nextthrow('!filereadable('.curargstr.')',
-                                        \       'nread', idx, '@#@', curargstr)
-                            let spec=spec[1:]
-                        elseif spec[-1:] isnot 'x'
-                            call self.nextthrow('@%@.os.path.isdir('.
-                                        \                         curargstr.')',
-                                        \       'isfile', idx, '@#@', curargstr)
-                        endif
-                    endif
-                    if spec[0] is 'w'
-                        call self.nextthrow('!filewritable('.curargstr.')',
-                                    \       'nwrite', idx, '@#@', curargstr)
-                        let spec=spec[1:]
-                    elseif spec[0] is 'W'
-                        call self.nextthrow('!filewritable('.curargstr.') &&'.
-                                    \      '(@%@.os.path.exists('.curargstr.')'.
-                                    \       '|| filewritable('.
-                                    \               '@%@.os.path.dirname('.
-                                    \                        curargstr.'))!=2)',
-                                    \      'nowrite', idx, '@#@', curargstr)
-                        let spec=spec[1:]
-                    elseif spec[0] is 'p'
-                        call self.addpathp(idx).up()
-                        let spec=spec[1:]
-                    endif
-                    if spec is 'x'
-                        call self.nextthrow('!executable('.curargstr.')',
-                                    \       'nexecable', idx, '@#@', curargstr)
+                    elseif spec[-1:] isnot 'x'
+                        call self.nextthrow('@%@.os.path.isdir('.
+                                    \                         curargstr.')',
+                                    \       'isfile', a:idx, '@#@', curargstr)
                     endif
                 endif
-            "▶3 `type'
-            elseif desc[0] is 'type'
-                call self.addtypecond(desc[1], idx)
-            "▶3 `isfunc'
-            elseif desc[0] is 'isfunc'
-                let frefpref='string('.curargstr.')[10:11]'
-                if desc[1]
-                    call self.addtypecond([2], idx)
-                    call self.nextthrow('!exists('.string('*'.curargstr).') ||'.
-                                \                       frefpref.' is "s:"',
-                                \       'nfunc', idx, '@#@',
-                                \                'string('.curargstr.')[10:-3]')
-                else
-                    call self.nextthrow('!((type('.curargstr.')==2 && '.
-                                \         'exists('.string('*'.curargstr).')&&'.
-                                \          frefpref.' isnot "s:") '.
-                                \        '|| (type('.curargstr.')=='.type('').
-                                \            '&& '.curargstr.'=~#'.
-                                \             '''\v^%(%([sla]@!\w:)?%(\w|\.)+|'.
-                                \                    '%(s@!\w:)?\w+|'.
-                                \                    '%(<SNR>\w+))$'''.
-                                \            '&& exists("*".'.curargstr.')))',
-                                \       'nsfunc', idx, '@#@',
-                                \                 'string('.curargstr.')')
+                if spec[0] is 'w'
+                    call self.nextthrow('!filewritable('.curargstr.')',
+                                \       'nwrite', a:idx, '@#@', curargstr)
+                    let spec=spec[1:]
+                elseif spec[0] is 'W'
+                    call self.nextthrow('!filewritable('.curargstr.') &&'.
+                                \      '(@%@.os.path.exists('.curargstr.')'.
+                                \       '|| filewritable('.
+                                \               '@%@.os.path.dirname('.
+                                \                        curargstr.'))!=2)',
+                                \      'nowrite', a:idx, '@#@', curargstr)
+                    let spec=spec[1:]
+                elseif spec[0] is 'p'
+                    call self.addpathp(a:idx)
+                    let spec=spec[1:]
                 endif
-            "▶3 `isreg'
-            elseif desc[0] is 'isreg'
-                call self.addtypecond([type('')], idx)
-                            \.try().call('matchstr("", '.curargstr.')').up()
-                            \.catch().addthrow('nreg', idx, '@#@', curargstr,
-                            \                  'v:exception')
-            "▶3 `bool'
-            elseif desc[0] is 'bool'
-                call self.nextthrow('index([0, 1], '.curargstr.')==-1',
-                            \       'nbool', idx,'@#@', 'string('.curargstr.')')
-            "▶3 `is'
-            elseif desc[0] is 'is'
-                let var=self.getvar(desc[1])
-                call self.nextthrow(curargstr.' isnot '.var,
-                            \       'isnot', idx, '@#@', var,
-                            \                'string('.curargstr.')')
-            "▶3 `value'
-            elseif desc[0] is 'value'
-                call self.witharg(self.getvar(desc[1], 1))
-                            \.compilearg(desc[2], idx.'(value)', 'check')
-                            \.without()
-            "▶3 `_', `any'
-            elseif desc[0] is '_' || desc[0] is 'any'
-                " Just do nothing here
+                if spec is 'x'
+                    call self.nextthrow('!executable('.curargstr.')',
+                                \       'nexecable', a:idx, '@#@', curargstr)
+                endif
             endif
-            "▲3
+        "▶3 `type'
+        elseif desc[0] is 'type'
+            call self.addtypecond(desc[1], a:idx)
+        "▶3 `isfunc'
+        elseif desc[0] is 'isfunc'
+            let frefpref='string('.curargstr.')[10:11]'
+            if desc[1]
+                call self.addtypecond([2], a:idx)
+                call self.nextthrow('!exists('.string('*'.curargstr).') ||'.
+                            \                       frefpref.' is "s:"',
+                            \       'nfunc', a:idx, '@#@',
+                            \                'string('.curargstr.')[10:-3]')
+            else
+                call self.nextthrow('!((type('.curargstr.')==2 && '.
+                            \         'exists('.string('*'.curargstr).')&&'.
+                            \          frefpref.' isnot "s:") '.
+                            \        '|| (type('.curargstr.')=='.type('').
+                            \            '&& '.curargstr.'=~#'.
+                            \             '''\v^%(%([sla]@!\w:)?%(\w|\.)+|'.
+                            \                    '%(s@!\w:)?\w+|'.
+                            \                    '%(<SNR>\w+))$'''.
+                            \            '&& exists("*".'.curargstr.')))',
+                            \       'nsfunc', a:idx, '@#@',
+                            \                 'string('.curargstr.')')
+            endif
+        "▶3 `isreg'
+        elseif desc[0] is 'isreg'
+            call self.addtypecond([type('')], a:idx)
+                        \.try().call('matchstr("", '.curargstr.')').up()
+                        \.catch().addthrow('nreg', a:idx, '@#@', curargstr,
+                        \                  'v:exception')
+        "▶3 `bool'
+        elseif desc[0] is 'bool'
+            call self.nextthrow('index([0, 1], '.curargstr.')==-1',
+                        \       'nbool', a:idx,'@#@', 'string('.curargstr.')')
+        "▶3 `is'
+        elseif desc[0] is 'is'
+            let var=self.getvar(desc[1])
+            call self.nextthrow(curargstr.' isnot '.var,
+                        \       'isnot', a:idx, '@#@', var,
+                        \                'string('.curargstr.')')
+        "▶3 `value'
+        elseif desc[0] is 'value'
+            call self.witharg(self.getvar(desc[1], 1))
+                        \.compilearg(desc[2], a:idx.'(value)', 'check')
+                        \.without()
+        "▶3 `_', `any'
+        elseif desc[0] is '_' || desc[0] is 'any'
+            " Just do nothing here
         endif
-        "▲2
-        let idx=s:F.incidx(idx)
-    endfor
+        "▲3
+    endif
+    "▲2
     return self
 endfunction
 "▶1 compilearg     :: argcontext, idx[, defcomptype] + self → self + self
         let arg=a:argcon
     endif
     let pmsgnum=len(self.pmsgs)
-    let check=['check']
     let msg=[]
     let i=0
-    let squashedlen=0
     for proc in arg
-        if proc[0] is 'check'
-            let squashedlen+=1
-            call add(check, proc[1])
-            let i+=1
-            continue
-        elseif proc[0] is 'pipe' && proc[1][0] is 'intfunc'
+        if proc[0] is 'pipe' && proc[1][0] is 'intfunc'
                     \&& has_key(s:pipechecks, proc[1][1])
-            call add(check, s:pipechecks[proc[1][1]])
+            call self.compilecheck(['check', s:pipechecks[proc[1][1]]],
+                        \          a:idx.'(pipe)')
         elseif self.type is 'filter' && proc[0] is 'intfunc'
                     \&& has_key(s:pipechecks, proc[1])
-            call add(check, s:pipechecks[proc[1]])
-        endif
-        if len(check)>1
-            call self.compilecheck(check, a:idx.'.'.(i+((squashedlen)?
-                        \                                   (1-squashedlen):
-                        \                                   (0))))
-            let squashedlen=0
-            call remove(check, 1, -1)
+            call self.compilecheck(['check', s:pipechecks[proc[1]]],
+                        \          a:idx.'(pipe)')
         endif
         let compargs=[proc, a:idx.'.'.i]
         let comptype=proc[0]
         call call(self['compile'.comptype], compargs, self)
         let i+=1
     endfor
-    if len(check)>1
-        call self.compilecheck(check, a:idx.'.'.(i+1-len(check)))
-        call remove(check, 1, -1)
-    endif
     if len(self.pmsgs)>pmsgnum
         call remove(self.pmsgs, pmsgnum, -1)
     endif

plugin/frawor/fwc/constructor.vim

     endif
     return self
 endfunction
+"▶1 toblock
+function s:constructor.toblock(block)
+    while get(self.l, 0) isnot a:block
+        call self.up()
+    endwhile
+    return self
+endfunction
 "▶1 if         :: &self(condition)
 function s:constructor.if(condition)
     return self.out().deeper('if', a:condition).deeper()
 endfunction
 "▶1 else       :: &self
 function s:constructor.else()
-    return self.add('else').deeper()
+    return self.toblock('if').add('else').deeper()
 endfunction
 "▶1 elseif     :: &self(condition)
 function s:constructor.elseif(condition)
-    return self.add('elseif', a:condition).deeper()
+    return self.toblock('if').add('elseif', a:condition).deeper()
 endfunction
 "▶1 endif      :: &self
 function s:constructor.endif()
     if get(self.l, 0) is 'if'
-        return self.add('endif').up()
+        return self.toblock('if').add('endif').up()
     endif
     return self
 endfunction
 endfunction
 "▶1 catch      :: &self(regex?)
 function s:constructor.catch(...)
-    return self.add('catch', '/'.escape(get(a:000, 0, '.*'), '/').'/').deeper()
+    return self.toblock('try')
+                \.add('catch', '/'.escape(get(a:000,0,'.*'), '/').'/').deeper()
 endfunction
 "▶1 finally    :: &self
 function s:constructor.finally()
-    return self.add('finally').deeper()
+    return self.toblock('try').add('finally').deeper()
 endfunction
 "▶1 while      :: &self(condition)
 function s:constructor.while(condition)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.