-
Notifications
You must be signed in to change notification settings - Fork 0
/
bug_20170905.txt
144 lines (120 loc) · 3.86 KB
/
bug_20170905.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
macro
stdin,StreamProxy
Dump (lvm.c)
for unity, Main_, dolua_ (lua.c)
------------------------------
<1>. (luaconf_ex.h.cs)
StreamProxy
(luaxlib.c.cs)
(liolib.c.cs)
(loadlib.c.cs)
(luac.c.cs)
Stream->StreamProxy (**Stream** Only apear in luaconf_ex.h.cs)
public class LoadF {
public class luaL_Stream {
remove : using System.IO
------------------------------
<2>. (lvm.c, compare lopcodes.h.cs)
+ //FIXME:added for debug //FIXME: not sync
internal static void Dump(int pc, Instruction i)
{
...
}
public static void luaV_execute (lua_State L) {
...
lua_assert(base_ <= L.top && L.top <= L.stack[L.stacksize-1]); //FIXME:L.top < L.stack[L.stacksize]??? L.stacksize >= L.stack.Length, overflow, so changed to <=
//Dump(L.savedpc.pc, i); //FIXME:added, only for debugging
--->(after 2009)
//Dump(L.ci.u.l.savedpc.pc, i); //FIXME:added, only for debugging
------------------------------
<3>. (lua.c)
public static int Main(string[] args) {
+ //Main_(args);
+
//FIXME: added
....
//----------------------------------------
public const bool DEBUG_ = false;
public static int docall_(Lua.lua_State L, int narg, int nres) {
int status;
int base_ = Lua.lua_gettop(L) - narg; /* function index */
status = Lua.lua_pcall(L, narg, nres, base_);
return status;
}
public static void l_message_(Lua.CharPtr pname, Lua.CharPtr msg) {
if (pname != null) Lua.luai_writestringerror("%s: ", pname);
Lua.luai_writestringerror("%s\n", msg);
}
public static Lua.lua_State L_;
public static string dolua_(string message) {
if (DEBUG_) {
Lua.fprintf(Lua.stdout, "%s\n", "==============>" + message);
}
if (L_ == null) {
L_ = Lua.luaL_newstate();
Lua.luaL_openlibs(L_);
}
if (DEBUG_) {
Lua.fprintf(Lua.stdout, "%s\n", "==============>2");
}
string errorMessage = null;
bool printResult = true;
int status = Lua.luaL_loadbuffer(L_, message, (uint)Lua.strlen(message), "=stdin");
if (status == Lua.LUA_OK) {
if (DEBUG_) {
Lua.fprintf(Lua.stdout, "%s\n", "==============>3");
}
status = docall_(L_, 0, printResult ? Lua.LUA_MULTRET : 0);
}
if ((status != Lua.LUA_OK) && !Lua.lua_isnil(L_, -1)) {
if (DEBUG_) {
Lua.fprintf(Lua.stdout, "%s\n", "==============>4");
}
Lua.CharPtr msg = Lua.lua_tostring(L_, -1);
if (msg == null) msg = "(error object is not a string)";
errorMessage = msg.ToString();
Lua.lua_pop(L_, 1);
/* force a complete garbage collection in case of errors */
Lua.lua_gc(L_, Lua.LUA_GCCOLLECT, 0);
}
if (printResult) {
//see Lua.LUA_MULTRET
if (status == Lua.LUA_OK && Lua.lua_gettop(L_) > 0) { /* any result to print? */
Lua.luaL_checkstack(L_, Lua.LUA_MINSTACK, "too many results to print");
Lua.lua_getglobal(L_, "print");
Lua.lua_insert(L_, 1);
if (Lua.lua_pcall(L_, Lua.lua_gettop(L_) - 1, 0, 0) != Lua.LUA_OK)
l_message_(progname, Lua.lua_pushfstring(L_,
"error calling " + Lua.LUA_QL("print").ToString() + " (%s)",
Lua.lua_tostring(L_, -1)));
}
}
return errorMessage;
}
public static int Main_(string[] args) {
Lua.fprintf(Lua.stdout, "%s\n", "hello");
string errorMessage;
errorMessage = dolua_("a = 100");
if (errorMessage != null) {
Lua.fprintf(Lua.stdout, "%s\n", errorMessage);
}
errorMessage = dolua_("print(a)");
if (errorMessage != null) {
Lua.fprintf(Lua.stdout, "%s\n", errorMessage);
}
return 0;
}
------------------------------
----------------------
(y,y,y) lua-5.1.4
(y,y,y) lua-5.1.5
(y,y,y) lua-5.2.0-2007
(y,y,y) lua-5.2.0-20071029
(y,y,y) lua-5.2.0-2008
(y,y,y) lua-5.2.0-2009
(y,y,y) lua-5.2.0-20090702
(y,y,y) lua-5.2.0-20100206
(y,y,y) lua-5.2.0-alpha
(y,y,y) lua-5.2.0-beta : 2017-09-06
(y,y,y) lua-5.2.0 : 2017-09-05
NOTE: luaconf_ex.h.cs should be same between two