]> git.lizzy.rs Git - metalua.git/commitdiff
0.4-rc2
authorFabien Fleutot <fabien@macfabien.local>
Fri, 8 Feb 2008 08:26:08 +0000 (09:26 +0100)
committerFabien Fleutot <fabien@macfabien.local>
Fri, 8 Feb 2008 08:26:08 +0000 (09:26 +0100)
src/Makefile
src/compiler/bootstrap.lua
src/compiler/metalua.mlua
src/config
src/lib/extension/trycatch.mlua
src/lib/package2.lua
src/samples/h_test.mlua
src/samples/trycatch_test.mlua
src/samples/walk_id_test.mlua
src/samples/withdo_test.mlua

index e5b71be5d787af598f8fb3b4fe879c19a1a136d4..4b98639d09221bf8c43dc8756e97847379715808 100644 (file)
@@ -1,15 +1,11 @@
-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)
@@ -31,7 +27,7 @@ copy-libraries: lib/
        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 \
index e11f72e2ca137f5b9fc27548f70adeca028377db..57ad7998ba763dfa9c13614760beed27e3713cfb 100644 (file)
@@ -46,7 +46,7 @@ require 'mlp'
 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)
@@ -56,7 +56,7 @@ local function compile_file (src_filename)
    local dst_file     = io.open (dst_filename, 'wb')
    dst_file:write(dump)
    dst_file:close()
-   io.write("OK.")
+   print("...Wrote "..dst_filename)
 end
 
 
index 9b6910a04c5d4e00e30108250e9e9b5345aad862..c673f2cf87d63083b711e29f8f380fb6bffbd53f 100644 (file)
@@ -4,7 +4,25 @@
 
 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
@@ -132,14 +150,9 @@ local function main (...)
       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
index 5e34d8cc69705b7c35e436e3bb0ada11f9d37b90..b2eeb6955790bcc9ae2155b5313386bfd4b718a6 100644 (file)
@@ -4,7 +4,9 @@
 # Platforms currently supported: mingw, macosx.
 # Feel welcome to contribute additional ones! :)
 
-PLATFORM         = macosx
+PLATFORM  = none
+PLATFORMS = macosx mingw linux
+
 
 #########################################################
 # Installation paths.
index 0a7b5c4eba28252eee12fa72a77a84d963f425af..979992f5ca0c361daba5e6dc67633648547f6b73 100644 (file)
 --\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
@@ -47,7 +48,6 @@ function trycatch_builder(x)
    -- 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
@@ -169,5 +169,6 @@ mlp.stat:add{
    'end',\r
    builder = trycatch_builder }\r
 \r
+return H.alpha\r
 \r
 \r
index 738e32e21483583f774d12fcbd682a6cb4c6ed29..cf7a33a1455cbe9a7775662b7d7dd8122cd86c12 100644 (file)
@@ -46,15 +46,14 @@ end
 -- 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']]
index 87cd08a01664486e2954bd0c67f536b3d57d69b7..b8cdb53038843fb9af0e29bbe392507f3ee932f3 100644 (file)
@@ -48,7 +48,7 @@ for case in ivalues(TEST_CASES) do
    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)
index 8a8dc70d31083193bb721bb77e10343202fef55a..84123fe237ca485b0a9f350add9b7b1acd0e1e8c 100644 (file)
@@ -103,3 +103,4 @@ printf("   f returned %q", fr)
 
 ----------------------------------------------------------------------
 print "*) done."
+
index ec387d2e427ff27ff7828f7577db0df1228e4677..37dd7947c1381bde789b64e37552f985b156b96a 100644 (file)
@@ -24,28 +24,3 @@ do -- Make globals explicit:
    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
-
index 4e647b1e9dccb5cff6c19447326ccda2fd18b8c8..1de4112773a0f026f4c3738f5d932f9a64c1dabe 100644 (file)
@@ -1,3 +1,7 @@
+require 'verbose_require'
+
+-{ require 'verbose_require' and nil }
+
 -{ extension 'withdo' }
 
 local original_close = io.close