From 652c29bdef1f0991cc13bef59d6dc78b657ae9a4 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Thu, 8 Nov 2018 15:23:22 -0800 Subject: Major overhaul, splitting nomsu_compiler into nomsu_environment, nomsu_compiler, and nomsu_decompiler. Also added comprehensions. --- files.lua | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'files.lua') diff --git a/files.lua b/files.lua index 13679e3..d08d7df 100644 --- a/files.lua +++ b/files.lua @@ -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 = "", 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 -- cgit v1.2.3