ZyX_I avatar ZyX_I committed 3ad2e8f

@/fwc: A bit of refactoring: removed self.tree from @/fwc/compiler, renamed self.ctree to self.tree

Comments (0)

Files changed (2)

plugin/frawor/fwc/compiler.vim

         let args=map(args[:(curidx-1)], 'string(v:val)')+[self.argstr(1)]+
                     \args[(curidx+1):]
     endif
-    if !empty(self.pmsgs) && !empty(self.pmsgs[-1])
-        call self.call('add(@$@pmessages, ['.self.pmsgs[-1].'])')
+    if !empty(self.msgs.own) && !empty(self.msgs.own[-1])
+        call self.call('add(@$@pmessages, ['.self.msgs.own[-1].'])')
     endif
     return self.call('add(@$@messages, ['.string(a:msg).', '.join(args, ', ').
                 \                     '])')
 function s:compiler.addsavemsgs()
     let msglenstr=self.getlvarid('msglen')
     let pmsglenstr=self.getlvarid('pmsglen')
-    call add(self.restmsg, [msglenstr, pmsglenstr])
+    call add(self.msgs.savevars, [msglenstr, pmsglenstr])
     return   self.let(msglenstr,  'len(@$@messages)')
                 \.let(pmsglenstr, 'len(@$@pmessages)')
 endfunction
 "▶1 addrestmsgs    :: a:0::Bool + self → self + self
 function s:compiler.addrestmsgs(...)
-    let [msglenstr, pmsglenstr]=self.restmsg[-1]
+    let [msglenstr, pmsglenstr]=self.msgs.savevars[-1]
     if !a:0
-        call remove(self.restmsg, -1)
+        call remove(self.msgs.savevars, -1)
     endif
     return   self.if('len(@$@messages)>'.msglenstr)
                     \.call('remove(@$@messages, '.msglenstr.', -1)')
                     \.up()
     endfor
     if hascheck
-        call remove(self.restmsg, -1)
+        call remove(self.msgs.savevars, -1)
     endif
     call self.addthrow('keynmatch', a:idx, '@#@', keystr)
     call remove(self.subs, -1)
 "▶1 compilemsg     :: msgcontext, _ + self → self + self
 function s:compiler.compilemsg(msg, idx)
     if a:msg[1] is 0
-        call add(self.pmsgs, '')
+        call add(self.msgs.own, '')
         return self
     elseif a:msg[1] is 1
-        if !empty(self.pmsgs)
-            call remove(self.pmsgs, -1)
+        if !empty(self.msgs.own)
+            call remove(self.msgs.own, -1)
         endif
         return self
     endif
         endif
     endfor
     let msgstr=string(a:msg[1]).', '.join(msg, ', ')
-    call add(self.pmsgs, msgstr)
+    call add(self.msgs.own, msgstr)
     return self
 endfunction
 "▶1 compilestring  :: {string} + self → self + self
     else
         let arg=a:argcon
     endif
-    let pmsgnum=len(self.pmsgs)
+    let pmsgnum=len(self.msgs.own)
     let msg=[]
     let i=0
     for proc in arg
         call call(self['compile'.comptype], compargs, self)
         let i+=1
     endfor
-    if len(self.pmsgs)>pmsgnum
-        call remove(self.pmsgs, pmsgnum, -1)
+    if len(self.msgs.own)>pmsgnum
+        call remove(self.msgs.own, pmsgnum, -1)
     endif
     return self
 endfunction
 function s:F.compilestr(vars, string, type, doreturn)
     "▶2 Setup self
     let t=extend(s:_r.new_constructor(), {
-                \   'tree': s:_r.fwc_parser(a:string, a:type)[1:],
                 \   'type': a:type,
                 \   'subs': [0],
                 \   'vars': a:vars,
                 \   'vids': {},
                 \'argbase': '@@@',
-                \  'pmsgs': [],
                 \  'preva': [],
-                \'restmsg': [],
+                \   'msgs': {     'own': [],
+                \            'savevars': [],},
             \})
+    let tree=s:_r.fwc_parser(a:string, a:type)[1:]
     call extend(t, s:compiler, 'error')
     let t._throw=s:_f.throw
     "▲2
-    call s:F.cleanup(t.tree)
-    let t.o=remove(t.tree, 0)
-    let t.tree=t.tree[0]
+    call s:F.cleanup(tree)
+    let t.o=remove(tree, 0)
     if t.type is 'check' || t.type is 'filter'
         call        t.let('@$@messages',  '[]')
                     \.let('@$@pmessages', '[]')
                     \.try()
         if !t.o.only
             if t.type is 'check' || t.type is 'filter'
-                call t.compileadesc(t.tree)
+                call t.compileadesc(tree[0])
             else
             endif
         endif

plugin/frawor/fwc/constructor.vim

 "▶1 tolist     :: () + self → [String]
 function s:constructor.tolist()
     let r=[]
-    let items=map(deepcopy(self.ctree), '[0, v:val]')
+    let items=map(deepcopy(self.tree), '[0, v:val]')
     let toextend=[]
     while !empty(items)
         let [indent, item]=remove(items, 0)
     return r
 endfunction
 "▶1 new
-call extend(s:constructor, {'ctree': [],
-            \               'stack': [],})
+call extend(s:constructor, {'tree': [], 'stack': [],})
 function s:F.new()
     let r=deepcopy(s:constructor)
-    call add(r.stack, r.ctree)
+    call add(r.stack, r.tree)
     let r.l=r.stack[-1]
     return r
 endfunction
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.