Skip to content

Commit

Permalink
解决 local变量超过200个的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
junlong.lin committed Apr 16, 2021
1 parent 70e479a commit 399c474
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions LuaProfiler/Tools/InjectLua/InjectLua/Parse/LLex.cs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ public string code
if (operateDict.TryGetValue(Str.Length, out op))
{
sbCache.Append(op.value);
if (op.sibling != null)
{
op = op.sibling;
sbCache.Append(op.value);
}
}

string result = sbCache.ToString();
Expand Down
4 changes: 3 additions & 1 deletion LuaProfiler/Tools/InjectLua/InjectLua/Parse/Parse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ public static class Parse
{
public static readonly string LOCAL_PROFILER =
"local BeginMikuSample = MikuLuaProfiler.LuaProfiler.BeginSample "
+ "local EndMikuSample = MikuLuaProfiler.LuaProfiler.EndSample " + "local miku_unpack_return_value = miku_unpack_return_value ";
+ "local EndMikuSample = MikuLuaProfiler.LuaProfiler.EndSample " + "local miku_unpack_return_value = miku_unpack_return_value local MikuMainChunkFun = function(...) ";
#region parse
public static string InsertSample(string value, string name)
{
LLex l = new LLex(new StringLoadInfo(value), name);
string sampleStr = string.Format("{0}BeginMikuSample(\"[lua]:require {1},{1}&line:1\")", LOCAL_PROFILER, name);
l.InsertString(0, sampleStr);

int lastPos = 0;
int nextPos = l.pos;
l.Next();
Expand All @@ -58,6 +59,7 @@ public static string InsertSample(string value, string name)
nextPos = l.pos;

InsertSample(l, ref lastPos, ref nextPos, tokenType, false);
l.InsertString(l.Length, "\n end return MikuMainChunkFun(...)");

return l.code;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,11 @@ public string code
if (operateDict.TryGetValue(Str.Length, out op))
{
sbCache.Append(op.value);
if (op.sibling != null)
{
op = op.sibling;
sbCache.Append(op.value);
}
}

string result = sbCache.ToString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,14 @@ public static class Parse
{
public static readonly string LOCAL_PROFILER =
"local BeginMikuSample = MikuLuaProfiler.LuaProfiler.BeginSample "
+ "local EndMikuSample = MikuLuaProfiler.LuaProfiler.EndSample " + "local miku_unpack_return_value = miku_unpack_return_value ";
+ "local EndMikuSample = MikuLuaProfiler.LuaProfiler.EndSample " + "local miku_unpack_return_value = miku_unpack_return_value local MikuMainChunkFun = function(...) ";
#region parse
public static string InsertSample(string value, string name)
{
LLex l = new LLex(new StringLoadInfo(value), name);
string sampleStr = string.Format("{0}BeginMikuSample(\"[lua]:require {1},{1}&line:1\")", LOCAL_PROFILER, name);
l.InsertString(0, sampleStr);

int lastPos = 0;
int nextPos = l.pos;
l.Next();
Expand All @@ -58,6 +59,7 @@ public static string InsertSample(string value, string name)
nextPos = l.pos;

InsertSample(l, ref lastPos, ref nextPos, tokenType, false);
l.InsertString(l.Length, "\n end return MikuMainChunkFun(...)");

return l.code;
}
Expand Down

0 comments on commit 399c474

Please sign in to comment.