Commits

ZyX_I committed 5de9704

@/fwc: Moved tolstofstr function into @/fwc/constuctor

  • Participants
  • Parent commits 98b3fa8

Comments (0)

Files changed (2)

File plugin/frawor/fwc/compiler.vim

     " TODO
     return self
 endfunction
-"▶1 tolstofstr     :: CTree::[String|CTree] → [String]
-function s:F.tolstofstr(ctree)
-    let r=[]
-    let items=map(a:ctree, '[0, v:val]')
-    while !empty(items)
-        let [indent, item]=remove(items, 0)
-        if type(item)==type([])
-            call extend(items, map(item, '['.(indent+1).', v:val]'), 0)
-        else
-            call add(r, repeat('    ', indent).item)
-        endif
-        unlet item
-    endwhile
-    return r
-endfunction
 "▶1 compilestr     :: String, type → [String]
 function s:F.compilestr(vars, string, type)
     "▶2 Setup self
     else
         call t.add('return @@@')
     endif
-    return s:F.tolstofstr(t.ctree)
+    return t.tolstofstr()
 endfunction
 "▶1 makefunc       :: {f}, String, type → Fref + s:lastid, s:vars
 let s:lastid=0

File plugin/frawor/fwc/constructor.vim

         endif
     endif
 endfunction
+"▶1 tolstofstr     :: () + self → [String]
+function s:constructor.tolstofstr()
+    let r=[]
+    let items=map(deepcopy(self.ctree), '[0, v:val]')
+    while !empty(items)
+        let [indent, item]=remove(items, 0)
+        if type(item)==type([])
+            call extend(items, map(item, '['.(indent+1).', v:val]'), 0)
+        else
+            call add(r, repeat('    ', indent).item)
+        endif
+        unlet item
+    endwhile
+    return r
+endfunction
 "▶1 new
 call extend(s:constructor, {'ctree': [],
             \               'stack': [],