From 9621add2918cc4943e6693b74ae85d51dd264fcf Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 21 Apr 2014 20:59:39 +1000 Subject: We don't need the testlua directory any more. --- .../yueliang-0.4.1/orig-5.0.3/tools/call_graph.lua | 254 --------------------- .../yueliang-0.4.1/orig-5.0.3/tools/calls.log | 152 ------------ .../orig-5.0.3/tools/sample_expr.lua | 195 ---------------- 3 files changed, 601 deletions(-) delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/call_graph.lua delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/calls.log delete mode 100644 LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/sample_expr.lua (limited to 'LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools') diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/call_graph.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/call_graph.lua deleted file mode 100644 index 5c60e17..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/call_graph.lua +++ /dev/null @@ -1,254 +0,0 @@ ---[[-------------------------------------------------------------------- - - call_graph.lua - Call graph generator. - This file is part of Yueliang. - - Copyright (c) 2005-2006 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- Notes: --- * the call tracer wraps function calls in tables to do its work --- * not very elegant as the namespace of the table/module is affected --- * tracing using the debugger is probably much more powerful... --- * use of braces {} allows editors to match braces in the output --- and do folding, if such facilities are available; for example, the --- output looks better if Lua syntax highlighting is used on SciTE -----------------------------------------------------------------------]] - ------------------------------------------------------------------------- --- options ------------------------------------------------------------------------- - -local SHOW_EXPDESC = true -- show expdesc struct data - ------------------------------------------------------------------------- --- load and initialize modules ------------------------------------------------------------------------- -require("../lzio.lua") -require("../llex.lua") -require("../lopcodes.lua") -require("../ldump.lua") -require("../lcode.lua") -require("../lparser.lua") - -function lua_assert(test) - if not test then error("assertion failed!") end -end -luaX:init() -local LuaState = {} - ------------------------------------------------------------------------- --- call graph generator --- * (1) logging functions, (2) the wrapper initializer itself ------------------------------------------------------------------------- - -llog = {} - ------------------------------------------------------------------------- --- initialize log file; the usual mode is append; can use stdout/stderr ------------------------------------------------------------------------- -function llog:init(filename) - if filename == "stdout" then self.h = io.stdout - elseif filename == "stderr" then self.h = io.stderr - else - self.h = io.open(filename, "ab") - if not self.h then - error("can't open log file "..filename.."for writing") - end - end - self.h:write("\n-- start of log --\n\n") -end - ------------------------------------------------------------------------- --- cleanly closes log file ------------------------------------------------------------------------- -function llog:exit() - self.h:write("\n-- end of log --\n\n") - if self.h ~= io.stdout and self.h ~= io.stderr then - self.h:close() - end -end - ------------------------------------------------------------------------- --- logs a message at a particular call depth ------------------------------------------------------------------------- -function llog:msg(msg, level) - if level then msg = string.rep(" ", level)..msg end - self.h:write(msg) - self.h:flush() -end - ------------------------------------------------------------------------- --- set up wrapper functions to do tracing on a per-module basis ------------------------------------------------------------------------- -function llog:calltrace(parms) - ------------------------------------------------------------------ - -- process parameters - ------------------------------------------------------------------ - local module = parms.module - local modulename = parms.modulename - if type(module) ~= "table" then - error("module table parameter required") - elseif not modulename then - error("module name parameter required") - end - ------------------------------------------------------------------ - -- use either allow or deny list - ------------------------------------------------------------------ - local allow = parms.allow or {} - local deny = parms.deny or {} - if table.getn(allow) > 0 and table.getn(deny) > 0 then - error("can't apply both allow and deny lists at the same time") - end - ------------------------------------------------------------------ - -- select functions to wrap - ------------------------------------------------------------------ - local flist = {} - for i, f in pairs(module) do - local wrapthis - if table.getn(allow) > 0 then -- allow some only - wrapthis = false - for j, v in ipairs(allow) do - if i == v then wrapthis = true; break end - end - elseif table.getn(deny) > 0 then -- deny some only - wrapthis = true - for j, v in ipairs(deny) do - if i == v then wrapthis = false; break end - end - else -- default include - wrapthis = true - end - if wrapthis then flist[i] = f end - end - ------------------------------------------------------------------ - -- wrapped function(s) in a module for tracing - ------------------------------------------------------------------ - llog.level = 0 -- nesting level - for i, f in pairs(flist) do - local ModuleName = modulename..":" - local OldName, OldFunc = i, f - if type(OldFunc) == "function" then - local NewName = "__"..OldName - while module[NewName] ~= nil do -- avoid collisions - NewName = "_"..NewName - end - module[NewName] = OldFunc - module[OldName] = - ---------------------------------------------------------- - -- wrapper function for a module's function - -- old function XYZ is renamed __XYZ - ---------------------------------------------------------- - function(self, ...) - local parms = " (" - local exps = {} - -- look for expdesc structs, identify FuncState structs too - local function checkexpdesc(v) - local typ = type(v) - if typ == "table" then - if v.code then return "func" - elseif v.L then return "ls" - elseif v.seminfo then return "token" - elseif v.k then - table.insert(exps, v) - return "exp"..table.getn(exps) - end - end - return typ - end - -- format parameters for printing - for i,v in ipairs(arg) do - if type(v) == "number" then parms = parms..v.."," - elseif type(v) == "string" then parms = parms.."'"..v.."'," - elseif type(v) == "boolean" then parms = parms..tostring(v).."," - elseif SHOW_EXPDESC then parms = parms..checkexpdesc(v).."," - else parms = parms..type(v).."," - end - end - if table.getn(arg) > 0 then -- chop last comma - parms = string.sub(parms, 1, -2) - end - -- up level - llog:msg(ModuleName..OldName..parms..") {\n", llog.level) - llog.level = llog.level + 1 - -- display contents of expdesc - if SHOW_EXPDESC and table.getn(exps) > 0 then - for i,v in ipairs(exps) do - parms = "k:'"..v.k.."'," - if v.info then parms = parms.."info:"..v.info.."," end - if v.aux then parms = parms.."aux:"..v.aux.."," end - if v.t then parms = parms.."t:"..v.t.."," end - if v.f then parms = parms.."f:"..v.f.."," end - parms = string.sub(parms, 1, -2) - llog:msg("exp"..i.."("..parms..")\n", llog.level) - end - end - -- original function called here... - local retval = {self[NewName](self, unpack(arg))} - -- format return values - local rets = " = " - for i,v in ipairs(retval) do - if type(v) == "number" then rets = rets..v.."," - elseif type(v) == "string" then rets = rets.."'"..v.."'," - elseif type(v) == "boolean" then rets = rets..tostring(v).."," - else rets = rets..type(v).."," - end - end - if table.getn(retval) > 0 then -- chop last comma - rets = string.sub(rets, 1, -2) - else - rets = "" - end - -- down level - llog.level = llog.level - 1 - llog:msg("} "..ModuleName..OldName..rets.."\n", llog.level) - return unpack(retval) - end--function - ---------------------------------------------------------- - --print("patched "..OldName) - end--if - end--for -end - ------------------------------------------------------------------------- --- testing here --- * allow/deny works a bit like a somewhat similar Apache syntax --- * e.g. to show only function 'lex' and 'save' -> allow={"lex","save",} --- to not show function 'save_and_next' -> deny={"save_and_next",} --- * you can't do both allow and deny at the same time ------------------------------------------------------------------------- - --- select the file or stream to output to ---llog:init("calls.log") -llog:init("stdout") - --- select modules to trace -llog:calltrace{module=luaX, modulename="luaX", allow={"lex"} } - -- here we trace only the main lex() function, to avoid showing - -- too many lexer calls; we want to focus on luaY and luaK -llog:calltrace{module=luaY, modulename="luaY", deny={"growvector"} } - -- growvector() is just a limit checker in Yueliang, so drop it - -- to simplify the output log -llog:calltrace{module=luaK, modulename="luaK"} ---llog:calltrace{module=luaU, modulename="luaU"} - --- select input stream -local zio = luaZ:init(luaZ:make_getS("local a = 1"), nil, "=string") ---local zio = luaZ:init(luaZ:make_getF("sample.lua"), nil, "@sample.lua") - --- compile the source -local Func = luaY:parser(LuaState, zio, nil) - --- write binary chunk -local Writer, Buff = luaU:make_setF("call_graph.out") -luaU:dump(LuaState, Func, Writer, Buff) - -llog:exit() ---end diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/calls.log b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/calls.log deleted file mode 100644 index c163f6c..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/calls.log +++ /dev/null @@ -1,152 +0,0 @@ - --- start of log -- - -luaY:parser (table,table) { - luaY:open_func (table,table) { - luaY:newproto (table) { - } luaY:newproto = table - } luaY:open_func - luaY:next (table) { - luaX:lex (table,table) { - } luaX:lex = 'TK_LOCAL' - } luaY:next - luaY:chunk (table) { - luaY:enterlevel (table) { - } luaY:enterlevel - luaY:block_follow ('TK_LOCAL') { - } luaY:block_follow = false - luaY:statement (table) { - luaY:next (table) { - luaX:lex (table,table) { - } luaX:lex = 'TK_NAME' - } luaY:next - luaY:testnext (table,'TK_FUNCTION') { - } luaY:testnext = false - luaY:localstat (table) { - luaY:str_checkname (table) { - luaY:check_condition (table,true,' expected') { - } luaY:check_condition - luaY:next (table) { - luaX:lex (table,table) { - } luaX:lex = '=' - } luaY:next - } luaY:str_checkname = 'a' - luaY:new_localvar (table,'a',0) { - luaY:registerlocalvar (table,'a') { - luaY:growvector (table,table,0,0) { - } luaY:growvector - } luaY:registerlocalvar = 0 - } luaY:new_localvar - luaY:testnext (table,',') { - } luaY:testnext = false - luaY:testnext (table,'=') { - luaY:next (table) { - luaX:lex (table,table) { - } luaX:lex = 'TK_NUMBER' - } luaY:next - } luaY:testnext = true - luaY:explist1 (table,table) { - luaY:expr (table,table) { - luaY:subexpr (table,table,-1) { - luaY:enterlevel (table) { - } luaY:enterlevel - luaY:getunopr ('TK_NUMBER') { - } luaY:getunopr = 'OPR_NOUNOPR' - luaY:simpleexp (table,table) { - luaK:numberK (table,1) { - luaK:setnvalue (table,1) { - } luaK:setnvalue - luaK:addk (table,table,table) { - luaK:ttisnumber ) { - } luaK:ttisnumber = false - luaY:growvector (table,table,0,0) { - } luaY:growvector - luaK:setnvalue (table,0) { - } luaK:setnvalue - } luaK:addk = 0 - } luaK:numberK = 0 - luaY:init_exp (table,'VK',0) { - } luaY:init_exp - luaY:next (table) { - luaX:lex (table,table) { - } luaX:lex = 'TK_EOS' - } luaY:next - } luaY:simpleexp - luaY:getbinopr ('TK_EOS') { - } luaY:getbinopr = 'OPR_NOBINOPR' - luaY:leavelevel (table) { - } luaY:leavelevel - } luaY:subexpr = 'OPR_NOBINOPR' - } luaY:expr - luaY:testnext (table,',') { - } luaY:testnext = false - } luaY:explist1 = 1 - luaY:adjust_assign (table,1,1,table) { - luaK:exp2nextreg (table,table) { - luaK:dischargevars (table,table) { - } luaK:dischargevars - luaK:freeexp (table,table) { - } luaK:freeexp - luaK:reserveregs (table,1) { - luaK:checkstack (table,1) { - } luaK:checkstack - } luaK:reserveregs - luaK:exp2reg (table,table,0) { - luaK:discharge2reg (table,table,0) { - luaK:dischargevars (table,table) { - } luaK:dischargevars - luaK:codeABx (table,'OP_LOADK',0,0) { - luaK:code (table,table,1) { - luaK:dischargejpc (table) { - luaK:patchlistaux (table,-1,0,255,0,255,0) { - } luaK:patchlistaux - } luaK:dischargejpc - luaY:growvector (table,table,0,0) { - } luaY:growvector - luaY:growvector (table,table,0,0) { - } luaY:growvector - } luaK:code = 0 - } luaK:codeABx = 0 - } luaK:discharge2reg - luaK:hasjumps (table) { - } luaK:hasjumps = false - } luaK:exp2reg - } luaK:exp2nextreg - } luaY:adjust_assign - luaY:adjustlocalvars (table,1) { - luaY:getlocvar (table,0) { - } luaY:getlocvar = table - } luaY:adjustlocalvars - } luaY:localstat - } luaY:statement = false - luaY:testnext (table,';') { - } luaY:testnext = false - luaY:block_follow ('TK_EOS') { - } luaY:block_follow = true - luaY:leavelevel (table) { - } luaY:leavelevel - } luaY:chunk - luaY:check_condition (table,true,' expected') { - } luaY:check_condition - luaY:close_func (table) { - luaY:removevars (table,0) { - luaY:getlocvar (table,0) { - } luaY:getlocvar = table - } luaY:removevars - luaK:codeABC (table,'OP_RETURN',0,1,0) { - luaK:code (table,table,1) { - luaK:dischargejpc (table) { - luaK:patchlistaux (table,-1,1,255,1,255,1) { - } luaK:patchlistaux - } luaK:dischargejpc - luaY:growvector (table,table,1,0) { - } luaY:growvector - luaY:growvector (table,table,1,0) { - } luaY:growvector - } luaK:code = 1 - } luaK:codeABC = 1 - } luaY:close_func -} luaY:parser = table - --- end of log -- - diff --git a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/sample_expr.lua b/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/sample_expr.lua deleted file mode 100644 index 519cd4c..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/tools/sample_expr.lua +++ /dev/null @@ -1,195 +0,0 @@ ---[[-------------------------------------------------------------------- - - sample_expr.lua - Stand-alone expression parsing demonstrator. - This file is part of Yueliang. - - Copyright (c) 2005 Kein-Hong Man - The COPYRIGHT file describes the conditions - under which this software may be distributed. - - See the ChangeLog for more information. - -----------------------------------------------------------------------]] - ---[[-------------------------------------------------------------------- --- Notes: --- * this is an interactive demonstrator for implementing expression --- parsing in ChunkBake, a Lua assembler --- * evaluation is immediate, and a result is immediately generated -----------------------------------------------------------------------]] - -require("../lzio.lua") -require("../llex.lua") -luaX:init() - ------------------------------------------------------------------------- --- expression parser ------------------------------------------------------------------------- - -expr = {} - -expr.unop = { - ["TK_NOT"] = true, - ["-"] = true, -} -expr.binop = { - ["^"] = 10, - ["*"] = 7, - ["/"] = 7, - ["+"] = 6, - ["-"] = 6, - ["TK_CONCAT"] = 5, - ["TK_NE"] = 3, - ["TK_EQ"] = 3, - ["<"] = 3, - ["TK_LE"] = 3, - [">"] = 3, - ["TK_GE"] = 3, - ["TK_AND"] = 2, - ["TK_OR"] = 1, -} -expr.binop_r = { - ["^"] = 9, - ["*"] = 7, - ["/"] = 7, - ["+"] = 6, - ["-"] = 6, - ["TK_CONCAT"] = 4, - ["TK_NE"] = 3, - ["TK_EQ"] = 3, - ["<"] = 3, - ["TK_LE"] = 3, - [">"] = 3, - ["TK_GE"] = 3, - ["TK_AND"] = 2, - ["TK_OR"] = 1, -} - -function expr:parse(str) - self.LS = {} - self.L = {} - self.z = luaZ:init(luaZ:make_getS(str), nil, "=string") - luaX:setinput(self.L, self.LS, self.z, self.z.name) - self:token() - local v = self:expr() - if self.tok ~= "TK_EOS" then - io.stderr:write("parse error: some tokens unparsed\n") - end - return v -end - -function expr:token() - self.tok = luaX:lex(self.LS, self.LS.t) - self.seminfo = self.LS.t.seminfo - return self.tok -end - -function expr:simpleexpr() - local tok = self.tok - if tok == "TK_NIL" then - self:token() - return nil - elseif tok == "TK_TRUE" then - self:token() - return true - elseif tok == "TK_FALSE" then - self:token() - return false - elseif tok == "TK_NUMBER" or tok == "TK_STRING" then - self:token() - return self.seminfo - elseif tok == "(" then - self:token() - local v = self:expr() - if self.tok ~= ")" then - io.stderr:write("parse error: expecting ')' to delimit\n") - else - self:token() - return v - end - end - self:token() - io.stderr:write("parse error: "..tok.." encountered, substituting nil\n") - return nil -end - -function expr:subexpr(prev_op) - local v, op - if self.unop[self.tok] then - op = self.tok - self:token() - v = self:subexpr(8) - if op == "TK_NOT" then - v = not v - else-- op == "-" then - v = -v - end - else - v = self:simpleexpr() - end - op = self.tok - if self.binop[op] then - while self.binop[op] and self.binop[op] > prev_op do - self:token() - local v2, next_op = self:subexpr(self.binop_r[op]) - if op == "^" then - v = v ^ v2 - elseif op == "*" then - v = v * v2 - elseif op == "/" then - v = v / v2 - elseif op == "+" then - v = v + v2 - elseif op == "-" then - v = v - v2 - elseif op == "TK_CONCAT" then - v = v .. v2 - elseif op == "TK_NE" then - v = v ~= v2 - elseif op == "TK_EQ" then - v = v == v2 - elseif op == "<" then - v = v < v2 - elseif op == "TK_LE" then - v = v <= v2 - elseif op == ">" then - v = v > v2 - elseif op == "TK_GE" then - v = v >= v2 - elseif op == "TK_AND" then - v = v and v2 - else-- op == "TK_OR" then - v = v or v2 - end - op = next_op - end - end - return v, op -end - -function expr:expr() - return self:subexpr(-1) -end - ------------------------------------------------------------------------- --- interactive test code ------------------------------------------------------------------------- - -io.stdout:write([[ -Lua-style expression parsing demonstrator. -Type 'exit' or 'quit' at the prompt to terminate session. -]]) -local done = false -while not done do - io.stdout:write(":>") - io.stdout:flush() - local l = io.stdin:read("*l") - if l == nil or (l == "exit" or l == "quit" and not prevline) then - done = true - else - local v = tostring(expr:parse(l)) - io.stdout:write(v, "\n") - end -end--while ---end -- cgit v1.1