Tue, 30 Nov 2010 13:22:35 +0000
squish.lua: AutoFetch file paths can now begin with / or . too
34 | 1 | |
2 | local cs = require "minichunkspy" | |
3 | ||
4 | local function ___adjust_chunk(chunk, newname, lineshift) | |
5 | local c = cs.disassemble(string.dump(chunk)); | |
6 | c.body.name = newname; | |
7 | ||
8 | lineshift = -c.body.line; | |
9 | local function shiftlines(c) | |
10 | c.line = c.line + lineshift; | |
11 | c.last_line = c.last_line + lineshift; | |
12 | for i, line in ipairs(c.source_lines) do | |
13 | c.source_lines[i] = line+lineshift; | |
14 | end | |
15 | for i, f in ipairs(c.prototypes) do | |
16 | shiftlines(f); | |
17 | end | |
18 | end | |
19 | shiftlines(c.body); | |
20 | ||
21 | return assert(loadstring(cs.assemble(c), newname))(); | |
22 | end |