Skip to content

Commit

Permalink
wut
Browse files Browse the repository at this point in the history
  • Loading branch information
efrederickson committed Dec 15, 2012
1 parent a483ecd commit 6e6c31c
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 26 deletions.
18 changes: 18 additions & 0 deletions SharpLua.sln
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpLua.AlmostADebugger",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpLua.NewCompilerTests", "SharpLua.NewCompilerTests\SharpLua.NewCompilerTests.csproj", "{273F06C9-9BF0-455D-BDB6-318B5D8B9DF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "sl-test", "C:\Users\elijah.FFHS2\Documents\SharpDevelop Projects\sl-test\sl-test.csproj", "{44224AA6-FBE9-4371-A191-A8F9AA49507E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -445,6 +447,22 @@ Global
{71ACA15C-FDDE-460D-B9D6-40FB6DF675D6}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{71ACA15C-FDDE-460D-B9D6-40FB6DF675D6}.Release|Win32.ActiveCfg = Release|Any CPU
{71ACA15C-FDDE-460D-B9D6-40FB6DF675D6}.Release|x86.ActiveCfg = Release|Any CPU
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|Any CPU.Build.0 = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|Any CPU.ActiveCfg = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|Win32.Build.0 = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|Win32.ActiveCfg = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|x86.Build.0 = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Debug|x86.ActiveCfg = Debug|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|Any CPU.Build.0 = Release|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|Any CPU.ActiveCfg = Release|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|Mixed Platforms.Build.0 = Release|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|Mixed Platforms.ActiveCfg = Release|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|Win32.Build.0 = Release|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|Win32.ActiveCfg = Release|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|x86.Build.0 = Release|x86
{44224AA6-FBE9-4371-A191-A8F9AA49507E}.Release|x86.ActiveCfg = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
13 changes: 6 additions & 7 deletions SharpLua/Interfacing/Lua.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public LuaInterface()
LuaDLL.lua_replace(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
translator = new ObjectTranslator(this, luaState);
LuaDLL.lua_replace(luaState, (int)LuaIndexes.LUA_GLOBALSINDEX);
LuaDLL.luaL_dostring(luaState, ScriptStrings.InitLuaNet); // steffenj: lua_dostring renamed to luaL_dostring

tracebackFunction = new SharpLua.Lua.lua_CFunction(traceback);

Expand All @@ -67,8 +66,9 @@ public LuaInterface()
//LuaDLL.lua_atpanic(luaState, tracebackFunction);
LuaDLL.lua_atpanic(luaState, panicCallback);

LuaDLL.luaL_dostring(luaState, ScriptStrings.InitClrLib);
LuaDLL.luaL_dostring(luaState, ScriptStrings.InitExtLib);
DoString(ScriptStrings.InitLuaNet, "LuaNet");
DoString(ScriptStrings.InitClrLib, "ClrLib");
DoString(ScriptStrings.InitExtLib, "ExtLib");
luaState.initializing = false;
luaState.SetInterface(this);
}
Expand Down Expand Up @@ -105,10 +105,9 @@ public LuaInterface(SharpLua.Lua.LuaState lState)
LuaDLL.lua_replace(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
translator = new ObjectTranslator(this, this.luaState);
LuaDLL.lua_replace(lState, (int)LuaIndexes.LUA_GLOBALSINDEX);
LuaDLL.luaL_dostring(lState, ScriptStrings.InitLuaNet); // steffenj: lua_dostring renamed to luaL_dostring

LuaDLL.luaL_dostring(luaState, ScriptStrings.InitClrLib);
LuaDLL.luaL_dostring(luaState, ScriptStrings.InitExtLib);
DoString(ScriptStrings.InitLuaNet, "LuaNet");
DoString(ScriptStrings.InitClrLib, "ClrLib");
DoString(ScriptStrings.InitExtLib, "ExtLib");
}
_StatePassed = true;
lState.initializing = false;
Expand Down
6 changes: 5 additions & 1 deletion SharpLua/LuaCore/VM/ldo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ public static int luaD_rawrunprotected(LuaState L, Pfunc f, object ud)
catch (LuaException ex)
{
Debug.WriteLine("Caught exception: " + ex.ToString());

Debug.WriteLine("Status: " + ex.c.status);

if (lj.status == 0)
lj.status = -1;
}
Expand Down Expand Up @@ -490,7 +491,10 @@ private static void luaD_call(LuaState L, StkId func, int nResults)
if (++L.nCcalls >= LUAI_MAXCCALLS)
{
if (L.nCcalls == LUAI_MAXCCALLS)
{
Debug.WriteLine("C stack overflow");
luaG_runerror(L, "C stack overflow");
}
else if (L.nCcalls >= (LUAI_MAXCCALLS + (LUAI_MAXCCALLS >> 3)))
luaD_throw(L, LUA_ERRERR); /* error while handing stack error */
}
Expand Down
11 changes: 1 addition & 10 deletions SharpLua/LuaCore/VM/lvm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,6 @@ public static void luaV_gettable(LuaState L, TValue t, TValue key, StkId val)
setobj2s(L, val, res);
return;
}

/*
if (!ttisnil(res) || // result is not nil?
(tm = fasttm(L, h.metatable, TMS.TM_INDEX)) == null)
{ // or no TM?
setobj2s(L, val, res);
return;
}
*/
/* else will try the tag method */
}
else if (ttisnil(tm = luaT_gettmbyobj(L, t, TMS.TM_INDEX)))
Expand All @@ -168,7 +159,7 @@ public static void luaV_gettable(LuaState L, TValue t, TValue key, StkId val)
callTMres(L, val, tm, t, key);
return;
}
t = tm; /* else repeat with `tm' */
t = tm; /* else repeat with 'tm' */
}
luaG_runerror(L, "loop in gettable");
}
Expand Down
4 changes: 2 additions & 2 deletions SharpLua/LuaCore/lua.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ public partial class Lua
{

//public const string LUA_VERSION = "Lua 5.1";
public const string LUA_VERSION = "SharpLua 2.0";
public const string LUA_VERSION = "SharpLua 2.0 Emulating Lua 5.1";
//public const string LUA_RELEASE = "Lua 5.1.5";
public const string LUA_RELEASE = "SharpLua 2.0.0";
public const int LUA_VERSION_NUM = 501;
//public const string LUA_COPYRIGHT = "Copyright (C) 1994-2012 Lua.org, PUC-Rio";
//public const string LUA_AUTHORS = "R. Ierusalimschy, L. H. de Figueiredo & W. Celes";
public const string LUA_COPYRIGHT = "Copyright (C) 2012 LoDC";
public const string LUA_AUTHORS = "Elijah Frederickson";
public const string LUA_AUTHORS = "Elijah Frederickson and others";


/* mark for precompiled code (`<esc>Lua') */
Expand Down
5 changes: 4 additions & 1 deletion SharpLua/LuaCore/luaconf.cs
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,10 @@ @@ LUAI_THROW/LUAI_TRY define how Lua does exception handling.
*/
//#if defined(__cplusplus)
///* C++ exceptions */
public static void LUAI_THROW(LuaState L, lua_longjmp c) { throw new LuaException(L, c); }
public static void LUAI_THROW(LuaState L, lua_longjmp c)
{
throw new LuaException(L, c);
}
//#define LUAI_TRY(L,c,a) try { a } catch(...) \
// { if ((c).status == 0) (c).status = -1; }
public static void LUAI_TRY(LuaState L, lua_longjmp c, object a)
Expand Down
6 changes: 4 additions & 2 deletions SharpLua/Resources/extlib.slua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ function table.tolookup(t)
end

-- override base type
--[[
rawtype = type
function type(o)
local a, b = pcall(function()
Expand All @@ -35,6 +36,7 @@ function type(o)
end)
return a and b or rawtype(o)
end
]]

-- table.invert
function table.invert(t)
Expand Down Expand Up @@ -132,8 +134,8 @@ strMt.__index = function(t, k)
end
debug.setmetatable('', strMt)

function dostring(s)
return loadstring(s)()
function dostring(s, ...)
return loadstring(s)(...)
end

function table.copy(new, old)
Expand Down
Binary file modified SharpLua/Resources/extlib.sluac
Binary file not shown.
2 changes: 1 addition & 1 deletion SharpLuaAddIn/Src/CodeCompletion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ bool IsInsideStringOrComment(ITextEditor textArea, IDocumentLine curLine, int cu
// ++i; // skip escaped character
//}
}
else if (c == '/' && i + 1 < cursorOffset && textArea.Document.GetCharAt(i + 1) == '/')
else if (c == '-' && i + 1 < cursorOffset && textArea.Document.GetCharAt(i + 1) == '-')
{
return true;
}
Expand Down
4 changes: 2 additions & 2 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ X set "..." to command line args in _G
X set - set (table, key, value)
X table.removeitem - removes an item from a table

- Implicit 'self' arg
? Implicit 'self' arg
- ++, --

- Change LASM library to be a wrapper for the LuaAssemblyTools library

Parser/Lexer
X option to continue parsing after a parse error (add to error list)
- allow embedded LASM (?)
- allow embedded LASM (would require the new compiler)
- Link tokens together? (Next/Previous)

Modify Parser to handle [,] differently, so it can be ExactReconstructed
Expand Down

0 comments on commit 6e6c31c

Please sign in to comment.