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.moon | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'files.moon') diff --git a/files.moon b/files.moon index 738c5f8..ca50290 100644 --- a/files.moon +++ b/files.moon @@ -16,16 +16,22 @@ _FILE_CACHE = setmetatable {}, __index:_SPOOFED_FILES _BROWSE_CACHE = {} -- Create a fake file and put it in the cache +_anon_number = 0 Files.spoof = (filename, contents)-> + if not contents + filename, contents = "", filename + _anon_number += 1 _SPOOFED_FILES[filename] = contents - return contents + return filename -- Read a file's contents (searching first locally, then in the nomsupath) Files.read = (filename)-> if file_contents = _FILE_CACHE[filename] return file_contents if filename == 'stdin' - return Files.spoof('stdin', io.read('*a')) + contents = io.read('*a') + Files.spoof('stdin', contents) + return contents file = io.open(filename) return nil unless file contents = file\read("*a") -- cgit v1.2.3