aboutsummaryrefslogtreecommitdiff
path: root/dynasm
diff options
context:
space:
mode:
authorMike Pall <mike>2012-06-09 14:41:44 +0200
committerMike Pall <mike>2012-06-09 14:42:03 +0200
commit6c8aaef2bbb005a2176e35c08f85957a9bc428d0 (patch)
tree5a13e43b79a49b83a9bdc337b35acffa8c6e40f7 /dynasm
parente75561b70e470a19a8101349c48fe1137f0102fe (diff)
downloadluajit-6c8aaef2bbb005a2176e35c08f85957a9bc428d0.tar.gz
luajit-6c8aaef2bbb005a2176e35c08f85957a9bc428d0.tar.bz2
luajit-6c8aaef2bbb005a2176e35c08f85957a9bc428d0.zip
DynASM: Compatibility with minilua.
Diffstat (limited to 'dynasm')
-rw-r--r--dynasm/dynasm.lua17
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
352 352
353-- Search for a file in the given path and open it for reading. 353-- Search for a file in the given path and open it for reading.
354local function pathopen(path, name) 354local function pathopen(path, name)
355 local dirsep = match(package.path, "\\") and "\\" or "/" 355 local dirsep = package and match(package.path, "\\") and "\\" or "/"
356 for _,p in ipairs(path) do 356 for _,p in ipairs(path) do
357 local fullname = p == "" and name or p..dirsep..name 357 local fullname = p == "" and name or p..dirsep..name
358 local fin = io.open(fullname, "r") 358 local fin = io.open(fullname, "r")
@@ -616,6 +616,17 @@ end
616 616
617------------------------------------------------------------------------------ 617------------------------------------------------------------------------------
618 618
619-- Replacement for customized Lua, which lacks the package library.
620local prefix = ""
621if not require then
622 function require(name)
623 local fp = assert(io.open(prefix..name..".lua"))
624 local s = fp:read("*a")
625 assert(fp:close())
626 return assert(loadstring(s, "@"..name..".lua"))()
627 end
628end
629
619-- Load architecture-specific module. 630-- Load architecture-specific module.
620local function loadarch(arch) 631local function loadarch(arch)
621 if not match(arch, "^[%w_]+$") then return "bad arch name" end 632 if not match(arch, "^[%w_]+$") then return "bad arch name" end
@@ -1073,8 +1084,8 @@ end
1073-- Add the directory dynasm.lua resides in to the Lua module search path. 1084-- Add the directory dynasm.lua resides in to the Lua module search path.
1074local arg = arg 1085local arg = arg
1075if arg and arg[0] then 1086if arg and arg[0] then
1076 local prefix = match(arg[0], "^(.*[/\\])") 1087 prefix = match(arg[0], "^(.*[/\\])")
1077 if prefix then package.path = prefix.."?.lua;"..package.path end 1088 if package and prefix then package.path = prefix.."?.lua;"..package.path end
1078end 1089end
1079 1090
1080-- Start DynASM. 1091-- Start DynASM.