aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2018-11-06 07:19:03 +0000
committers-ol <s-ol@users.noreply.github.com>2018-11-06 07:19:03 +0000
commita6fb6af3d2adacc6fecb7684f9b04909da6b08e5 (patch)
tree38f65359d83f803ebd6c3ab12c19040f01279d85
parentfix client behaviour (diff)
downloadmmm-a6fb6af3d2adacc6fecb7684f9b04909da6b08e5.tar.gz
mmm-a6fb6af3d2adacc6fecb7684f9b04909da6b08e5.zip
add metadata for compilation
-rw-r--r--dump_tree.moon16
-rw-r--r--mmm/mmmfs/fileder.moon1
2 files changed, 15 insertions, 2 deletions
diff --git a/dump_tree.moon b/dump_tree.moon
index 72259cd..a35a223 100644
--- a/dump_tree.moon
+++ b/dump_tree.moon
@@ -18,6 +18,12 @@ root\mount path
dump_fileder = do
escape = (str) -> string.format '%q', tostring str
+ compile = (old, new, val) -> escape "
+-- this property has been transpiled from '#{old}'
+-- to '#{new}' for execution in the browser.
+-- refer to the original property as the source.
+#{to_lua val}"
+
_dump = (fileder) ->
code = "Fileder {"
@@ -28,7 +34,7 @@ dump_fileder = do
if key.type\match '^text/moonscript %->'
newkey = Key key.name, key.type\gsub '^text/moonscript %-> (.*)', 'text/lua -> %1'
code ..= "
- [#{escape newkey}] = #{escape to_lua val},"
+ [fromcache(#{escape newkey}, #{escape key})] = #{compile key, newkey, val},"
for child in *fileder.children
code ..= "
@@ -40,7 +46,13 @@ dump_fileder = do
(fileder) -> "
- local Fileder = (require 'mmm.mmmfs').Fileder
+ local mmmfs = require 'mmm.mmmfs'
+ local Key, Fileder = mmmfs.Key, mmmfs.Fileder
+ local function fromcache(str, orig)
+ local key = Key(str)
+ key.original = Key(orig)
+ return key
+ end
return #{_dump fileder}
"
diff --git a/mmm/mmmfs/fileder.moon b/mmm/mmmfs/fileder.moon
index 1a6d012..310d8c5 100644
--- a/mmm/mmmfs/fileder.moon
+++ b/mmm/mmmfs/fileder.moon
@@ -19,6 +19,7 @@ class Key
elseif 'table' == type opts
@name = opts.name
@type = opts.type
+ @original = opts.original
else
error "wrong argument type: #{type opts}, #{type second}"