-PLATFORMS = macosx mingw linux
-
include config
-none:
- @echo Please select one of supported platforms:
- @echo $(PLATFORMS)
-
+ifeq ($(PLATFORM), none)
+all:
+ @echo "You haven't edited 'config' yet. Set your settings there, then run 'make' again"
+else
all: setenv.sh lua libraries install-lua bin-libraries compiler compile-libraries
-
-$(PLATFORMS):
- PLATFORM=$@ $(MAKE) all
+endif
install-lua: lua
mkdir -p $(TARGET_BIN_PATH)
cp -Rp lib/* $(TARGET_LUA_PATH)/
compile-libraries: copy-libraries bin-libraries setenv.sh compiler
- echo "Compiling libraries:"
+ @echo "Compiling libraries:"
for src in $$(find $(TARGET_LUA_PATH) -name '*.mlua') ; do \
bc="$$(dirname $$src)/$$(basename $$src .mlua).luac"; \
if [ $$src -nt $$bc ]; then \
require 'package2'
local function compile_file (src_filename)
- io.write("Compiling "..src_filename.."... ")
+ print("Compiling "..src_filename.."... ")
local src_file = io.open (src_filename, 'r')
local src = src_file:read '*a'; src_file:close()
local ast = mlc.ast_of_luastring (src)
local dst_file = io.open (dst_filename, 'wb')
dst_file:write(dump)
dst_file:close()
- io.write("OK.")
+ print("...Wrote "..dst_filename)
end
require 'metalua.compiler'
require 'clopts'
-require 'springs'
+
+do
+ local mfast = os.getenv 'LUA_NOSPRINGS'
+ if mfast=='yes' or mfast=='true' then
+ function spring_pcall(f, ...)
+ if type(f)=='string' then f = loadstring("return "..f)() end
+ return pcall(f, ...)
+ end
+ else
+ require 'springs'
+ function spring_pcall(...)
+ local ring = springs.new()
+ ring:dostring (INIT_COMPILATION_RING)
+ st, ast = ring:pcall(...)
+ ring:close()
+ return st, ast
+ end
+ end
+end
AST_COMPILE_ERROR_NUMBER = -1
RUNTIME_ERROR_NUMBER = -3
local st, ast
match x with
| `Library{ l } -> st, ast = true, `Call{ `Id 'require', `String{ l } }
- | `Literal{ e } ->
- local ring = springs.new()
- ring:dostring (INIT_COMPILATION_RING)
- st, ast = ring:pcall('mlc.ast_of_luastring', e, 'literal')
+ | `Literal{ e } -> st, ast = spring_pcall('mlc.ast_of_luastring', e, 'literal')
| `File{ f } ->
- local ring = springs.new()
- ring:dostring (INIT_COMPILATION_RING)
- st, ast = ring:pcall('mlc.ast_of_luafile', f, '@'..f) -- FIXME: handle '-'
+ st, ast = spring_pcall('mlc.ast_of_luafile', f, '@'..f)
-- Isolate each file in a separate fenv
ast = +{ function (...) -{ast} end (...) }
last_file = ast
# Platforms currently supported: mingw, macosx.
# Feel welcome to contribute additional ones! :)
-PLATFORM = macosx
+PLATFORM = none
+PLATFORMS = macosx mingw linux
+
#########################################################
# Installation paths.
--\r
--------------------------------------------------------------------------------\r
\r
--- Get match parsers and builder, for catch cases handling:\r
-require 'extension.match' \r
-\r
-{ extension 'H' }\r
-{ extension 'log' }\r
\r
+-- Get match parsers and builder, for catch cases handling:\r
+local match_alpha = require 'extension.match' \r
+local H = H:new{side='inside', alpha = match_alpha }\r
+\r
-- We'll need to track rogue return statements:\r
require 'walk'\r
\r
-- to outside macro code.\r
local caught_return = !mlp.gensym 'caught_return'\r
\r
- local H = H:new{side='inside'}\r
!try_code; !(catch_code or { }); !(finally_code or { })\r
\r
--$log(try_code, catch_cases, finally_code)\r
'end',\r
builder = trycatch_builder }\r
\r
+return H.alpha\r
\r
\r
-- Execute a metalua module sources compilation in a separate ring.
----------------------------------------------------------------------
local function spring_load(filename)
- local env_fast = os.getenv 'LUA_MFAST'
+ local env_fast = os.getenv 'LUA_NOSPRINGS'
if env_fast=='yes' or env_fast=='true' then
- -- degraded mode without spring:
- -- print "Warning: loading metalua source file in the same compilation ring;"
- -- print "metalevels 0 might interfere, condider unsetting environment variable LUA_MFAST"
+ --print "LUA_NOSPRINGS mode"
return mlc.function_of_luafile(filename)
else
-- run compilation in a separate spring universe:
+ --print "Springs mode"
require 'springs'
local r = springs.new()
r:dostring [[require 'metalua.compiler']]
local comment, ast, cfg = unpack(case)
print ('\n'..'-':rep(70))
print (comment)
- if cfg then H:set(cfg) end
+ local H = H:new(cfg)
print ("\nBEFORE PARSING:")
$log (ast, H, 50)
H(ast)
----------------------------------------------------------------------
print "*) done."
+
disp('Globals made explicit', ast)
end
-
-do -- Alpha rename local vars:
- local ast = table.deep_copy(ast)
- local cfg = { id = { } }
- local translations = autotable()
- function cfg.id.bound (id, binder)
- local tmp = translations[id[1]]
- if not tmp then
- printf("new tmp for name %s", id[1])
- tmp = { }
- translations[id[i]] = tmp
- end
- local new_name = tmp[binder]
- if not new_name then
- printf("new name for name %s binder %s", id[1], tostring(binder))
- new_name = mlp.gensym('_local_'..id[1])
-
- tmp[binder] = new_name
- end
- id[1] = new_name
- end
- walk_id.block(cfg, ast)
- disp('Local alpha-renamed', ast)
-end
-
+require 'verbose_require'
+
+-{ require 'verbose_require' and nil }
+
-{ extension 'withdo' }
local original_close = io.close