comparison src/luan/init.luan @ 118:735708619119

add Debug.debug() git-svn-id: https://luan-java.googlecode.com/svn/trunk@119 21e917c8-12df-6dd8-5cb6-c86387c605b9
author fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9>
date Sun, 01 Jun 2014 07:07:31 +0000
parents 1ff1c32417eb
children
comparison
equal deleted inserted replaced
117:e935581cf9fb 118:735708619119
1 --Io.stdout.write "this is init.luan\n" 1 --Io.stdout.write "this is init.luan\n"
2 2
3 function _G.print(...) 3 local function print(...)
4 local list = {} 4 local list = {}
5 for v in Basic.values(...) do 5 for v in Basic.values(...) do
6 list[#list+1] = to_string(v) 6 list[#list+1] = to_string(v)
7 list[#list+1] = '\t' 7 list[#list+1] = '\t'
8 end 8 end
11 else 11 else
12 list[#list] = '\n' 12 list[#list] = '\n'
13 Io.stdout.write( Table.unpack(list) ) 13 Io.stdout.write( Table.unpack(list) )
14 end 14 end
15 end 15 end
16
17 _G.print = print
18
19
20 local Debug = {}
21 Package.loaded.Debug = Debug
22 _G.Debug = Debug
23
24 function Debug.debug(prompt)
25 prompt = prompt or "luan_debug> "
26 local function console()
27 return Io.read_console_line(prompt)
28 end
29 for line in console do
30 local fn = load(line,"stdin",true)
31 local result = Table.pack( fn() )
32 if result.n > 0 then
33 print( Table.unpack(result,1,result.n) )
34 end
35 end
36 end