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 = {}
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
------------------------------------------------------------------------
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
-- 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
------------------------------------------------------------------------
-- 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
-- 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
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
-- 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
--------------------------------------------------------------------------------