@@ -30,7 +30,7 @@ local concat, insert = table.concat, table.insert
3030local pos_to_line , get_closest_line , trim , unpack = util .pos_to_line , util .get_closest_line , util .trim , util .unpack
3131local mtype = util .moon .type
3232local indent_char = " "
33- local Line , Lines , Block , RootBlock
33+ local Line , DelayedLine , Lines , Block , RootBlock
3434do
3535 local _parent_0 = nil
3636 local _base_0 = {
6262 end
6363 local posmap = self .posmap
6464 for i , l in ipairs (self ) do
65- local _exp_0 = type (l )
66- if " table" == _exp_0 then
67- local _
68- _ , line_no = l :flatten_posmap (line_no , out )
69- elseif " string" == _exp_0 then
65+ local _exp_0 = mtype (l )
66+ if " string" == _exp_0 or DelayedLine == _exp_0 then
7067 line_no = line_no + 1
7168 out [line_no ] = posmap [i ]
69+ elseif " table" == _exp_0 then
70+ local _
71+ _ , line_no = l :flatten_posmap (line_no , out )
7272 end
7373 end
7474 return out , line_no
8282 end
8383 for i = 1 , # self do
8484 local l = self [i ]
85- local _exp_0 = type (l )
85+ local t = mtype (l )
86+ if t == DelayedLine then
87+ l = l :render ()
88+ t = " string"
89+ end
90+ local _exp_0 = t
8691 if " string" == _exp_0 then
8792 if indent then
8893 insert (buffer , indent )
264269 end
265270 Line = _class_0
266271end
272+ do
273+ local _parent_0 = nil
274+ local _base_0 = {
275+ prepare = function () end ,
276+ render = function (self )
277+ self :prepare ()
278+ return concat (self )
279+ end
280+ }
281+ _base_0 .__index = _base_0
282+ if _parent_0 then
283+ setmetatable (_base_0 , _parent_0 .__base )
284+ end
285+ local _class_0 = setmetatable ({
286+ __init = function (self , fn )
287+ self .prepare = fn
288+ end ,
289+ __base = _base_0 ,
290+ __name = " DelayedLine" ,
291+ __parent = _parent_0
292+ }, {
293+ __index = function (cls , name )
294+ local val = rawget (_base_0 , name )
295+ if val == nil and _parent_0 then
296+ return _parent_0 [name ]
297+ else
298+ return val
299+ end
300+ end ,
301+ __call = function (cls , ...)
302+ local _self_0 = setmetatable ({}, _base_0 )
303+ cls .__init (_self_0 , ... )
304+ return _self_0
305+ end
306+ })
307+ _base_0 .__class = _class_0
308+ if _parent_0 and _parent_0 .__inherited then
309+ _parent_0 .__inherited (_parent_0 , _class_0 )
310+ end
311+ DelayedLine = _class_0
312+ end
267313do
268314 local _parent_0 = nil
269315 local _base_0 = {
0 commit comments