diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:23:22 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2018-11-08 15:24:15 -0800 |
| commit | 652c29bdef1f0991cc13bef59d6dc78b657ae9a4 (patch) | |
| tree | 8e335399e77b1893657b9fa985db0738034daac3 /files.lua | |
| parent | 1f3660f393c1a17988a15b89f18686b28e51a9e7 (diff) | |
Major overhaul, splitting nomsu_compiler into nomsu_environment,
nomsu_compiler, and nomsu_decompiler. Also added comprehensions.
Diffstat (limited to 'files.lua')
| -rw-r--r-- | files.lua | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -25,9 +25,14 @@ local _FILE_CACHE = setmetatable({ }, { __index = _SPOOFED_FILES }) local _BROWSE_CACHE = { } +local _anon_number = 0 Files.spoof = function(filename, contents) + if not contents then + filename, contents = "<anonymous file #" .. tostring(_anon_number) .. ">", filename + _anon_number = _anon_number + 1 + end _SPOOFED_FILES[filename] = contents - return contents + return filename end Files.read = function(filename) do @@ -37,7 +42,9 @@ Files.read = function(filename) end end if filename == 'stdin' then - return Files.spoof('stdin', io.read('*a')) + local contents = io.read('*a') + Files.spoof('stdin', contents) + return contents end local file = io.open(filename) if not (file) then |
