]> git.lizzy.rs Git - metalua.git/commitdiff
compatibility with integral-variants of Lua VMs
authorFabien Fleutot <fabien@macfabien.local>
Mon, 18 Feb 2008 18:50:25 +0000 (19:50 +0100)
committerFabien Fleutot <fabien@macfabien.local>
Mon, 18 Feb 2008 18:50:25 +0000 (19:50 +0100)
src/compiler/ldump.lua
src/compiler/metalua.mlua
src/compiler/mlc.mlua
src/compiler/mlp_meta.lua
src/compiler/mlp_stat.lua

index 6299c4e8cfda6a9209d1ed47376673bab19f5577..3e07f70c21f9c5e7da1ebde39688bb777e0393ef 100644 (file)
@@ -62,11 +62,12 @@ format = { }
 format.header = string.dump(function()end):sub(1, 12)
 format.little_endian, format.int_size, 
 format.size_t_size,   format.instr_size, 
-format.number_size,   format.integral = 
-   format.header:byte(7, 12)
+format.number_size,   format.integral = format.header:byte(7, 12)
+format.little_endian = format.little_endian~=0
+format.integral      = format.integral     ~=0
 
-assert(format.number_size==8, "Number format not supported by dumper")
-assert(format.little_endian==1, "Big endian architectures not supported by dumper")
+assert(format.integral or format.number_size==8, "Number format not supported by dumper")
+assert(format.little_endian, "Big endian architectures not supported by dumper")
 
 --requires luaP
 luaU = {}
@@ -79,9 +80,9 @@ luaU.LUA_TSTRING  = 4
 luaU.LUA_TNONE   = -1
 
 -- definitions for headers of binary files
-luaU.LUA_SIGNATURE = "\27Lua"   -- binary files start with "<esc>Lua"
-luaU.VERSION = 81               -- 0x50; last format change was in 5.0
-luaU.FORMAT_VERSION = 0         -- 0 is official version. yeah I know I'm a liar.
+--luaU.LUA_SIGNATURE = "\27Lua"   -- binary files start with "<esc>Lua"
+--luaU.VERSION = 81               -- 0x50; last format change was in 5.0
+--luaU.FORMAT_VERSION = 0         -- 0 is official version. yeah I know I'm a liar.
 
 -- a multiple of PI for testing native format
 -- multiplying by 1E7 gives non-trivial integer values
@@ -98,7 +99,7 @@ luaU.FORMAT_VERSION = 0         -- 0 is official version. yeah I know I'm a liar
 ------------------------------------------------------------------------
 function luaU:ttype(o)
   local tt = type(o.value)
-  if tt == "number"      then return self.LUA_TNUMBER
+  if     tt == "number"  then return self.LUA_TNUMBER
   elseif tt == "string"  then return self.LUA_TSTRING
   elseif tt == "nil"     then return self.LUA_TNIL
   elseif tt == "boolean" then return self.LUA_TBOOLEAN
@@ -245,7 +246,11 @@ end
 -- dumps a LUA_NUMBER (hard-coded as a double)
 ------------------------------------------------------------------------
 function luaU:DumpNumber(x, D)
-  self:DumpBlock(self:from_double(x), D)
+   if format.integral then
+      self:DumpBlock(self:from_int(x, format.number_size), D)
+   else
+      self:DumpBlock(self:from_double(x), D)
+   end
 end
 
 ------------------------------------------------------------------------
index 123c5e83ef4fd3e8128abdbe9e12ed86048953a7..0f9249fe7a62495c63d8928e283afae2dd034a0d 100644 (file)
@@ -178,9 +178,9 @@ local function main (...)
    -- AST printing
    if cfg['print-ast'] then 
       verb_print "Resulting AST:"
-      for x in values(code) do
+      for x in ivalues(code) do
          printf("--- AST From %s: ---", table.tostring(x.source, 'nohash'))
-         --if x.origin.tag=='File' then x=x[1][2][1] end
+         if x.origin and x.origin.tag=='File' then x=x[1][1][2][1] end
          table.print(x, 80, 'nohash')
       end 
    end
index d2525a5acf1da063092ef4ef33256617dd486b3c..b4a3a46b798d23c3ab546c21d4af1e4f2d489ce5 100644 (file)
@@ -103,7 +103,7 @@ function mlc.convert (x, src_fmt, dst_fmt, name)
       -- x = error msg; get rid of ???
       x = x:strmatch "[^:]+:[0-9]+: (.*)" or x
       error(string.format("Parsing error in %s line %s, char %s: \n%s",
-                          filename or "?", lx.line, lx.i, x))
+                          name or "?", lx.line, lx.i, x))
       return nil
    end
    
index d88f236fad6a0f0265e9ea65bb2da07ce4900705..60a8d457704dd4f0b24ba8c824593b5d3f3937ac 100644 (file)
@@ -52,10 +52,12 @@ module ("mlp", package.seeall)
 
 function splice (ast)
    --printf(" [SPLICE] Ready to compile:\n%s", _G.table.tostring (ast, "nohash", 60))
-   local f = mlc.function_of_ast(ast)
+   local f = mlc.function_of_ast(ast, '=splice')
    --printf " [SPLICE] Splice Compiled."
-   local result = f()   
+   --local status, result = pcall(f)
    --printf " [SPLICE] Splice Evaled."
+   --if not status then print 'ERROR IN SPLICE' end
+   local result=f()
    return result
 end
 
index 7ca24330c1e434f417bf29f3ff85466e92e2d592..a77a395f26c5a3ff7086bcc8993b5b16b16f2b6f 100644 (file)
 -- for details.
 --
 ----------------------------------------------------------------------
--- History:
--- $Log: mlp_stat.lua,v $
--- Revision 1.7  2006/11/15 09:07:50  fab13n
--- debugged meta operators.
--- Added command line options handling.
---
--- Revision 1.6  2006/11/10 02:11:17  fab13n
--- compiler faithfulness to 5.1 improved
--- gg.expr extended
--- mlp.expr refactored
---
--- Revision 1.5  2006/11/09 09:39:57  fab13n
--- some cleanup
---
--- Revision 1.4  2006/11/07 21:29:02  fab13n
--- improved quasi-quoting
---
--- Revision 1.3  2006/11/07 04:38:00  fab13n
--- first bootstrapping version.
---
--- Revision 1.2  2006/11/05 15:08:34  fab13n
--- updated code generation, to be compliant with 5.1
 --
 ----------------------------------------------------------------------
 
 -- * [mlp.stat()]
 -- * [mlp.block()]
 -- * [mlp.for_header()]
--- * [mlp.add_block_terminators()]
 --
 --------------------------------------------------------------------------------
 
---require "gg"
---require "mll"
---require "mlp_misc"
---require "mlp_expr"
---require "mlp_meta"
-
 --------------------------------------------------------------------------------
 -- eta-expansions to break circular dependency
 --------------------------------------------------------------------------------