1
0
Fork 0
mirror of https://github.com/notwa/lips synced 2024-05-18 16:33:22 -07:00

lips is lips

This commit is contained in:
Connor Olding 2016-01-13 09:51:29 -08:00
parent 9fd46b571f
commit 5e12951010

View File

@ -1,6 +1,4 @@
-- split lips.lua local lips = {
local assembler = {
_DESCRIPTION = 'Assembles MIPS assembly files for the R4300i CPU.', _DESCRIPTION = 'Assembles MIPS assembly files for the R4300i CPU.',
_URL = 'https://github.com/notwa/lips/', _URL = 'https://github.com/notwa/lips/',
_LICENSE = [[ _LICENSE = [[
@ -26,7 +24,7 @@ local function readfile(fn)
return asm return asm
end end
function assembler.word_writer() function lips.word_writer()
local buff = {} local buff = {}
local max = -1 local max = -1
return function(pos, b) return function(pos, b)
@ -47,13 +45,13 @@ function assembler.word_writer()
end end
end end
function assembler.assemble(fn_or_asm, writer, options) function lips.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)
local default_writer = not writer local default_writer = not writer
writer = writer or assembler.word_writer() writer = writer or lips.word_writer()
options = options or {} options = options or {}
local function main() local function main()
@ -83,7 +81,7 @@ function assembler.assemble(fn_or_asm, writer, options)
end end
end end
return setmetatable(assembler, { return setmetatable(lips, {
__call = function(self, ...) __call = function(self, ...)
return self.assemble(...) return self.assemble(...)
end, end,