mirror of
https://github.com/notwa/lips
synced 2024-11-14 19:49:02 -08:00
make only the assemble function visible
This commit is contained in:
parent
c978d4914f
commit
975ff3f942
1 changed files with 5 additions and 15 deletions
20
lips.lua
20
lips.lua
|
@ -1477,12 +1477,13 @@ function Dumper:dump()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function assemble(fn_or_asm, writer, options)
|
function assembler.assemble(fn_or_asm, writer, options)
|
||||||
-- assemble MIPS R4300i assembly code.
|
-- assemble MIPS R4300i assembly code.
|
||||||
-- if fn_or_asm contains a newline; treat as assembly, otherwise load file.
|
-- if fn_or_asm contains a newline; treat as assembly, otherwise load file.
|
||||||
-- returns error message on error, or nil on success.
|
-- returns error message on error, or nil on success.
|
||||||
fn_or_asm = tostring(fn_or_asm)
|
fn_or_asm = tostring(fn_or_asm)
|
||||||
writer = writer or io.write
|
writer = writer or io.write
|
||||||
|
options = options or {}
|
||||||
|
|
||||||
function main()
|
function main()
|
||||||
local fn = nil
|
local fn = nil
|
||||||
|
@ -1503,7 +1504,7 @@ local function assemble(fn_or_asm, writer, options)
|
||||||
return parser:parse(asm)
|
return parser:parse(asm)
|
||||||
end
|
end
|
||||||
|
|
||||||
if options and options.unsafe then
|
if options.unsafe then
|
||||||
return main()
|
return main()
|
||||||
else
|
else
|
||||||
local ok, err = pcall(main)
|
local ok, err = pcall(main)
|
||||||
|
@ -1512,18 +1513,7 @@ local function assemble(fn_or_asm, writer, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
return setmetatable(assembler, {
|
return setmetatable(assembler, {
|
||||||
__call = function(_, ...)
|
__call = function(self, ...)
|
||||||
return assemble(...)
|
return self.assemble(...)
|
||||||
end,
|
end,
|
||||||
|
|
||||||
Lexer = Lexer,
|
|
||||||
Parser = Parser,
|
|
||||||
Dumper = Dumper,
|
|
||||||
|
|
||||||
registers = registers,
|
|
||||||
fpu_registers = fpu_registers,
|
|
||||||
all_registers = all_registers,
|
|
||||||
instructions = instructions,
|
|
||||||
all_instructions = all_instructions,
|
|
||||||
all_directives = all_directives,
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue