]> git.lizzy.rs Git - metalua.git/commitdiff
fixing the merge.
authorFabien Fleutot <fabien@macfabien.local>
Fri, 8 Feb 2008 21:27:31 +0000 (22:27 +0100)
committerFabien Fleutot <fabien@macfabien.local>
Fri, 8 Feb 2008 21:27:31 +0000 (22:27 +0100)
src/Makefile
src/binlibs/Makefile
src/compiler/bootstrap.lua
src/compiler/lexer.lua
src/compiler/metalua.mlua
src/compiler/mlc.mlua
src/config
src/lua/Makefile
src/lua/luaconf.h

index 4b98639d09221bf8c43dc8756e97847379715808..af2db68daa5b2bb3c744a51806c973c73601aa15 100644 (file)
@@ -7,14 +7,10 @@ else
 all: setenv.sh lua libraries install-lua bin-libraries compiler compile-libraries
 endif
 
-install-lua: lua
-       mkdir -p $(TARGET_BIN_PATH)
+install-lua: lua target-dirs
        cp $(LUA_VM_DIR)/$(RUN) $(LUA_VM_DIR)/$(COMPILE) $(TARGET_BIN_PATH)/
 
-setenv.sh: config
-       mkdir -p $(TARGET_BIN_PATH)
-       mkdir -p $(TARGET_LUA_PATH)
-       mkdir -p $(TARGET_LUA_CPATH)
+setenv.sh: config target-dirs
        echo '#!/bin/bash'                           >  $@
        echo 'export LUA_PATH="$(LUA_PATH)"'         >> $@
        echo 'export LUA_CPATH="$(LUA_CPATH)"'       >> $@
@@ -22,6 +18,9 @@ setenv.sh: config
        echo 'export PATH=$(TARGET_BIN_PATH):$$PATH' >> $@
        chmod a+x $@
 
+
+copy-libraries: lib/ target-dirs
+
 copy-libraries: lib/
        mkdir -p $(TARGET_LUA_PATH)
        cp -Rp lib/* $(TARGET_LUA_PATH)/
@@ -39,13 +38,13 @@ compile-libraries: copy-libraries bin-libraries setenv.sh compiler
        done
 
 compiler: copy-libraries bin-libraries
-       $(MAKE) -C $@ $(PLATFORM)
+       LUA_PATH="$(LUA_PATH)" LUA_CPATH="$(LUA_CPATH)" LUA_MPATH="$(LUA_MPATH)" $(MAKE) -C $@ $(PLATFORM)
 
 bin-libraries:
        $(MAKE) -C binlibs      $(PLATFORM) install
 
 lua: $@
-       $(MAKE) -C $@ $(PLATFORM)
+       $(MAKE) -C $@ $(PLATFORM) 
 
 
 clean:
@@ -53,4 +52,9 @@ clean:
        $(MAKE) -C compiler clean
        $(MAKE) -C binlibs  clean
 
+target-dirs: $(TARGET_BIN_PATH) $(TARGET_LUA_PATH) $(TARGET_LUA_CPATH)
+
+$(TARGET_BIN_PATH) $(TARGET_LUA_PATH) $(TARGET_LUA_CPATH):
+       mkdir -p $@
+
 .PHONY: all libraries lua bin-libraries copy-libraries compile-libraries compiler
index 6c34e09a200f757d09166347290346c6d4550099..8566f9f60e1728039a66128b4c72a1ac08821a95 100644 (file)
@@ -12,6 +12,8 @@ install:   libraries
        mkdir -p $(TARGET_LUA_CPATH)
        cp $(LIBS) $(TARGET_LUA_CPATH)
 
+# TODO [EVE] there is still a question, how to remove dlls,
+# cause clean knows nothing about platform
 clean:
        -rm *.o *.$(LIBEXT)
 
index 57ad7998ba763dfa9c13614760beed27e3713cfb..40cf0af6ac94f0faf734aff78d7d5192974977b0 100644 (file)
@@ -50,7 +50,7 @@ local function compile_file (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 proto        = bytecode.metalua_compile (ast)
+   local proto        = bytecode.metalua_compile (ast, src_filename)
    local dump         = bytecode.dump_string (proto)
    local dst_filename = src_filename:gsub ("%.mlua$", ".luac")
    local dst_file     = io.open (dst_filename, 'wb')
index ca71e1b5bc7cd597315c4789ecabd2c5fb647c6b..95a753eae5401bae26064e80ea78ab4e386138be 100644 (file)
@@ -317,8 +317,8 @@ function lexer:next (n)
       if a then 
          debugf ("[L:%i K:%i T:%s %q]", a.line or -1, a.char or -1, 
                  a.tag or '<none>', a[1])
-         self.lastline = a.lineinfo.last
-      end     
+      end
+      self.lastline = a.lineinfo.last
    end
    return a or eof_token
 end
index c673f2cf87d63083b711e29f8f380fb6bffbd53f..495032550093f01d9e424f234e4c9972b1a46bda 100644 (file)
@@ -155,6 +155,8 @@ local function main (...)
          st, ast = spring_pcall('mlc.ast_of_luafile', f, '@'..f)
          -- Isolate each file in a separate fenv
          ast = +{ function (...) -{ast} end (...)  }
+         ast.source  = '@'..f -- TODO [EVE]
+         code.source = '@'..f -- TODO [EVE]
          last_file = ast
       end
       if not st then os.exit (AST_COMPILE_ERROR_NUMBER) end
@@ -164,7 +166,7 @@ local function main (...)
    -- The last file returns the whole chunk's result
    if last_file then
       local c = table.shallow_copy(last_file)
-      last_file <- `Return{ origin = c.origin, c }
+      last_file <- `Return{ source = c.source, c }
    end
 
    -------------------------------------------------------------------
@@ -172,14 +174,7 @@ local function main (...)
    if cfg['print-ast'] then 
       verb_print "Resulting AST:"
       for x in values(code) do
--- [[ Get rid of fenv isolation cruft
-         match x with
-         | +{stat: return function(...) -{ast} end (...) }
-         | +{expr: function(...) -{ast} end (...) } -> x=ast
-         | _ -> 
-         end
---]]
-         printf("--- AST From %s: ---", table.tostring(x.origin, 'nohash'))
+         printf("--- AST From %s: ---", table.tostring(x.source, 'nohash'))
          --if x.origin.tag=='File' then x=x[1][2][1] end
          table.print(x, 80, 'nohash')
       end 
index 390b5aa331c60474623f64a986d61cf5477fcaa8..48a1d778546886f91bd4ee2dcadc654fde923fb9 100644 (file)
@@ -107,9 +107,10 @@ function mlc.convert (x, src_fmt, dst_fmt, name)
       return nil
    end
    
+   if x then x.source = name end -- TODO [EVE] store debug info in the special part of ast
+
    POINT 'ast', 'table' -- x is the AST
-   x = bytecode.metalua_compile(x) 
-   x.source = name
+   x = bytecode.metalua_compile(x, name or x.source) 
    POINT 'proto', 'table' 
    x = bytecode.dump_string (x)
    POINT 'luacstring', 'string' -- normally x is a bytecode dump
index b2eeb6955790bcc9ae2155b5313386bfd4b718a6..f99438c5bcdde900df4ba1b5145bca5cdce5b8b4 100644 (file)
@@ -4,7 +4,7 @@
 # Platforms currently supported: mingw, macosx.
 # Feel welcome to contribute additional ones! :)
 
-PLATFORM  = none
+PLATFORM  = linux
 PLATFORMS = macosx mingw linux
 
 
@@ -45,7 +45,9 @@ endif
 ifeq ($(PLATFORM), mingw)
   LIBEXT        = dll
   MKLIB         = gcc -shared
-  LUA_BINARIES  = $(COMPILE).exe $(RUN).exe metalua.dll
+  LUALIB        = ../lua/lua51.dll
+  LDFLAGS       = $(LUALIB) 
+  LUA_BINARIES  = $(COMPILE).exe $(RUN).exe lua51.dll
 endif
 
 ifeq ($(PLATFORM), linux)
index cd7f6ba2ab67112be72d3c7de73d0d05930c59a9..8256462bc0d77f67bbbcffbc7d22ebcba0dd89ee 100644 (file)
@@ -107,7 +107,7 @@ mingw:
        $(MAKE) "LUA_A=lua51.dll" "LUA_T=lua.exe" \
        "AR=$(CC) -shared -o" "RANLIB=strip --strip-unneeded" \
        "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" lua.exe
-       $(MAKE) "LUAC_T=luac.exe" luac.exe
+       $(MAKE) "LUA_A=lua51.dll" "LUAC_T=luac.exe" "MYCFLAGS=-DLUA_BUILD_AS_DLL" "MYLIBS=" "MYLDFLAGS=-s" luac.exe
 
 posix:
        $(MAKE) all MYCFLAGS=-DLUA_USE_POSIX
index f47ec0a805366608fd541e76b6e2bd2887379df3..60a3e19dc07d953a6c017a4bfa12194f67bbadc1 100644 (file)
 #  define LUAI_FUNC LUA_API
 #  define LUAI_DATA LUA_API
 #else /* Metalua: Original version, disabled */
-#if defined(luaall_c)
-#define LUAI_FUNC      static
-#define LUAI_DATA      /* empty */
-
-#elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
-      defined(__ELF__)
-#define LUAI_FUNC      __attribute__((visibility("hidden"))) extern
-#define LUAI_DATA      LUAI_FUNC
-
-#else
-#define LUAI_FUNC      extern
-#define LUAI_DATA      extern
-#endif
+#  if defined(luaall_c)
+#    define LUAI_FUNC  static
+#    define LUAI_DATA  /* empty */
+#  elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 302) && \
+        defined(__ELF__)
+#    define LUAI_FUNC  __attribute__((visibility("hidden"))) extern
+#    define LUAI_DATA  LUAI_FUNC
+#  else
+#    define LUAI_FUNC  extern
+#    define LUAI_DATA  extern
+#  endif
 #endif