Commits

ZyX_I committed 361103b

@/fwc/constructor: Renamed self.l to self._l

Comments (0)

Files changed (5)

          their names
     1.1: Made block compiling functions be located in self._comp now
     2.0: Renamed self.tree and self.stack to self._tree and self._stack
+    3.0: Renamed self.l to self._l
 @/os:
     0.1: Added |frawor-r-os.path.relpath|
          Made |frawor-r-os.path.normpath| also simplify its argument

plugin/frawor/fwc/compiler.vim

 "▶1 Header
 scriptencoding utf-8
 execute frawor#Setup('0.0', {'@/fwc/parser'       : '0.0',
-            \                '@/fwc/constructor'  : '2.0',
+            \                '@/fwc/constructor'  : '3.0',
             \                '@/fwc/intfuncs'     : '0.0',
             \                '@/fwc/topconstructs': '0.0',
             \                '@/resources'        : '0.0'}, 1)
     else
         let vstr=self.vstrs[-1]
         call add(self.vstinf[vstr], ['let', a:ldstr])
-        call filter(self.l, '!(v:val[0] is# "let" && v:val[1] is# vstr)')
+        call filter(self._l, '!(v:val[0] is# "let" && v:val[1] is# vstr)')
         if a:filter
             return self.let(vstr, self.getmatcher(self.matcher, a:ldstr,
                         \                         self.comparg, 1))
 " }
 " For other syntax trees it will return 0.
 function s:compiler.optgetconds()
-    if len(self.l)==2
-                \&& len(self.l[0])>2
-                \&& self.l[0][0] is# 'if'
-                \&& ((self.l[0][-1] is# 'endif'
-                \  && self.l[0][-3] isnot# 'else')
-                \ || (self.l[0][-2] isnot# 'else'))
+    if len(self._l)==2
+                \&& len(self._l[0])>2
+                \&& self._l[0][0] is# 'if'
+                \&& ((self._l[0][-1] is# 'endif'
+                \  && self._l[0][-3] isnot# 'else')
+                \ || (self._l[0][-2] isnot# 'else'))
         let conditions=[]
-        let iftree=copy(self.l[0])
+        let iftree=copy(self._l[0])
         while !empty(iftree)
             let type=remove(iftree, 0)
             if type is# 'if' || type is# 'elseif'
 "▶1 optimizecompf   :: &self(varname)
 " XXX low-level hacks here
 function s:compiler.optimizecompf(vstr)
-    call self._down(self.l[2][-1][1])
+    call self._down(self._l[2][-1][1])
     let conditions=self.optgetconds()
     call self._up()
     if type(conditions)==type([])
-        call self._down(self.l[2])
-        let argidxstr=self.l[-1][1][-1][1]
-        let removestr=self.l[-1][-1][0][1]
+        call self._down(self._l[2])
+        let argidxstr=self._l[-1][1][-1][1]
+        let removestr=self._l[-1][-1][0][1]
         let condition=join(conditions, ' || ')
         let chargstr=a:vstr.'['.argidxstr.']'
         if condition=~#'\v^%([^@]|\V'.chargstr.'\v)+$'
             call self._up()
             call self._up()
-            call remove(self.l, -2, -1)
+            call remove(self._l, -2, -1)
             let condition=substitute(condition, '\V'.chargstr, 'v:val', 'g')
             call self.call('filter('.a:vstr.', '.string('!('.condition.')').')')
         else
-            call remove(self.l, -1)
+            call remove(self._l, -1)
             call self.if(condition)
             call         self.call(removestr)
             call     self._up()

plugin/frawor/fwc/constructor.vim

 "▶1 Header
 scriptencoding utf-8
-execute frawor#Setup('2.0', {'@/resources': '0.0'}, 1)
+execute frawor#Setup('3.0', {'@/resources': '0.0'}, 1)
 let s:constructor={}
 let s:comp={}
 let s:constructor._comp=s:comp
 endfunction
 "▶1 _add       :: item, ... + self → self + self
 function s:constructor._add(...)
-    let self.l+=a:000
+    let self._l+=a:000
     return self
 endfunction
 "▶1 _up        :: &self
 function s:constructor._up()
     call remove(self._stack, -1)
-    let self.l=self._stack[-1]
+    let self._l=self._stack[-1]
     return self
 endfunction
 "▶1 _down      :: &self(list)
 function s:constructor._down(list)
     call add(self._stack, a:list)
-    let self.l=a:list
+    let self._l=a:list
     return self
 endfunction
 "▶1 _deeper    :: ()[, conelement1[, ...]] + self → self + self
 endfunction
 "▶1 _out       :: &self
 function s:constructor._out()
-    if type(get(self.l, 0))==type('')
+    if type(get(self._l, 0))==type('')
         return self._up()
     endif
     return self
 endfunction
 "▶1 _toblock
 function s:constructor._toblock(block)
-    while get(self.l, 0) isnot a:block
+    while get(self._l, 0) isnot a:block
         call self._up()
     endwhile
     return self
 "▶2 addif      :: &self(expr?)
 function s:constructor.addif(...)
     if a:0
-        if get(self.l, 0) is# 'if' && get(self.l, -2) isnot# 'else' &&
-                    \                 get(self.l, -1) isnot# 'endif'
+        if get(self._l, 0) is# 'if' && get(self._l, -2) isnot# 'else' &&
+                    \                  get(self._l, -1) isnot# 'endif'
             return call(self.elseif, a:000, self)
         else
             return call(self.if, a:000, self)
         endif
     else
-        if get(self.l, 0) is# 'if'
+        if get(self._l, 0) is# 'if'
             return self.else()
         else
             return self
     call extend(a:toextend, map(remove(a:item, 0), '['.(a:indent+1).', v:val]'))
     call add(a:toextend, [a:indent, 'endfor'])
 endfunction
-"▶2 for        :: &self(vars, expr)
-function s:constructor.for(vars, expr)
-    return self._out()._deeper('for', a:vars, a:expr)._deeper()
+"▶2 for        :: &self(var, expr)
+function s:constructor.for(var, expr)
+    return self._out()._deeper('for', a:var, a:expr)._deeper()
 endfunction
 "▶1 execute: call, throw, return
 "▶2 comp.execute
 function s:F.new()
     let r=deepcopy(s:constructor)
     call add(r._stack, r._tree)
-    let r.l=r._stack[-1]
+    let r._l=r._stack[-1]
     return r
 endfunction
 call s:_f.postresource('new_constructor', s:F.new)

plugin/frawor/fwc/intfuncs.vim

 "▶2 optimize
 " XXX low-level hacks here
 function s:r.not.optimize(idx, type)
-    call self._down(self.l[1])
+    call self._down(self._l[1])
     let conditions=self.optgetconds()
     call self._up()
     if type(conditions)==type([])
-        call remove(self.l, 0, -1)
+        call remove(self._l, 0, -1)
         call self._add('if', 0, [])
         call self.nextthrow('!('.join(conditions, ' || ').')', 'notfail', a:idx)
-        call remove(self.l, 1, 3)
+        call remove(self._l, 1, 3)
     endif
     return self
 endfunction

plugin/frawor/fwc/topconstructs.vim

 "▶2 optimizenullact :: &self(caidxstr)
 " XXX low-level hacks here
 function s:r.actions.optimizenullact(caidxstr)
-    if len(self.l)==2 && self.l[1][0] is# 'if'
-                \&& (len(self.l[1])==3 ||
-                \    (len(self.l[1])==4 && self.l[-1] is# 'endif'))
+    if len(self._l)==2 && self._l[1][0] is# 'if'
+                \&& (len(self._l[1])==3 ||
+                \    (len(self._l[1])==4 && self._l[-1] is# 'endif'))
                 \&& len(self._stack[-2])==3
                 \&& self._stack[-2][0] is# 'if'
-                \&& self.l[1][1] is# self._stack[-2][1]
-        call extend(self.l, self.l[1][2])
-        call remove(self.l, 1)
-    elseif len(self.l)==3 && self.l[1][0] is# 'let'
-                \&& self.l[1][2] is# a:caidxstr
-                \&& self.l[2][0] is# 'if'
-                \&& (len(self.l[2])==3 ||
-                \    (len(self.l[2])==4 && self.l[-1] is# 'endif'))
+                \&& self._l[1][1] is# self._stack[-2][1]
+        call extend(self._l, self._l[1][2])
+        call remove(self._l, 1)
+    elseif len(self._l)==3 && self._l[1][0] is# 'let'
+                \&& self._l[1][2] is# a:caidxstr
+                \&& self._l[2][0] is# 'if'
+                \&& (len(self._l[2])==3 ||
+                \    (len(self._l[2])==4 && self._l[-1] is# 'endif'))
                 \&& len(self._stack[-2])==3
                 \&& self._stack[-2][0] is# 'if'
-                \&& self.l[2][1][:(-1-len(self.l[1][1]))] is
+                \&& self._l[2][1][:(-1-len(self._l[1][1]))] is
                 \   self._stack[-2][1][:(-1-len(a:caidxstr))]
-        call extend(self.l, self.l[2][2])
-        call remove(self.l, 1, 2)
+        call extend(self._l, self._l[2][2])
+        call remove(self._l, 1, 2)
     endif
     return self
 endfunction