diff options
author | Mike Pall <mike> | 2012-06-09 14:41:44 +0200 |
---|---|---|
committer | Mike Pall <mike> | 2012-06-09 14:42:03 +0200 |
commit | 6c8aaef2bbb005a2176e35c08f85957a9bc428d0 (patch) | |
tree | 5a13e43b79a49b83a9bdc337b35acffa8c6e40f7 /dynasm | |
parent | e75561b70e470a19a8101349c48fe1137f0102fe (diff) | |
download | luajit2-6c8aaef2bbb005a2176e35c08f85957a9bc428d0.tar.gz |
DynASM: Compatibility with minilua.
Diffstat (limited to 'dynasm')
-rw-r--r-- | dynasm/dynasm.lua | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/dynasm/dynasm.lua b/dynasm/dynasm.lua index 2ef81647..aa6e3395 100644 --- a/dynasm/dynasm.lua +++ b/dynasm/dynasm.lua @@ -352,7 +352,7 @@ end -- Search for a file in the given path and open it for reading. local function pathopen(path, name) - local dirsep = match(package.path, "\\") and "\\" or "/" + local dirsep = package and match(package.path, "\\") and "\\" or "/" for _,p in ipairs(path) do local fullname = p == "" and name or p..dirsep..name local fin = io.open(fullname, "r") @@ -616,6 +616,17 @@ end ------------------------------------------------------------------------------ +-- Replacement for customized Lua, which lacks the package library. +local prefix = "" +if not require then + function require(name) + local fp = assert(io.open(prefix..name..".lua")) + local s = fp:read("*a") + assert(fp:close()) + return assert(loadstring(s, "@"..name..".lua"))() + end +end + -- Load architecture-specific module. local function loadarch(arch) if not match(arch, "^[%w_]+$") then return "bad arch name" end @@ -1073,8 +1084,8 @@ end -- Add the directory dynasm.lua resides in to the Lua module search path. local arg = arg if arg and arg[0] then - local prefix = match(arg[0], "^(.*[/\\])") - if prefix then package.path = prefix.."?.lua;"..package.path end + prefix = match(arg[0], "^(.*[/\\])") + if package and prefix then package.path = prefix.."?.lua;"..package.path end end -- Start DynASM. |