├── .gitignore ├── Example Projects ├── CSharpExampleProject │ ├── CSharpExampleProject.csproj │ ├── Program.cs │ └── Properties │ │ └── AssemblyInfo.cs └── TestModule │ ├── Class1.cs │ ├── Properties │ └── AssemblyInfo.cs │ └── TestModule.csproj ├── GenerateDocumentation ├── GenerateDocumentation.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── LICENSE.txt ├── Libraries └── lbci │ ├── LBCI.cs │ ├── Properties │ └── AssemblyInfo.cs │ ├── lbci.c │ ├── lbci.csproj │ ├── lbci_print.lua │ └── lbci_test.lua ├── NuGetPackage ├── CreateNuGetPackage.bat └── Package │ └── SharpLua.nuspec ├── OLD.SharpLua ├── CHANGELOG.txt ├── CryptoLib │ ├── CryptoLib.csproj │ ├── MyClass.cs │ └── Properties │ │ └── AssemblyInfo.cs ├── Example Projects │ ├── CSharpExampleProject.ConvertedToVBNet │ │ ├── Program.vb │ │ ├── Properties │ │ │ └── AssemblyInfo.vb │ │ ├── VBNetExampleProject.vbproj │ │ └── app.config │ └── CSharpExampleProject │ │ ├── CSharpExampleProject.csproj │ │ ├── Program.cs │ │ ├── Properties │ │ └── AssemblyInfo.cs │ │ └── app.config ├── NuGetPackage │ ├── CreateNuGetPackage.bat │ └── Package │ │ ├── SharpLua.Web.nuspec │ │ └── SharpLua.nuspec ├── SharpLua.Compiler │ ├── Compiler.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SharpLua.Compiler.csproj │ └── app.config ├── SharpLua.Interactive │ ├── MyClass.cs │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SharpLua.Interactive.csproj │ └── app.config ├── SharpLua.Launcher │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SharpLua.Launcher.csproj │ └── app.config ├── SharpLua.Scripts │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SharpLua.Scripts.csproj │ ├── for.slua │ └── functions.slua ├── SharpLua.Serializer │ ├── Program.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── SharpLua.Serializer.csproj │ └── app.config ├── SharpLua.Web.TestPages │ ├── AssemblyInfo.cs │ ├── Global.asax │ ├── Global.asax.cs │ ├── SharpLua.Web.TestPages.csproj │ ├── SharpLua.Web.TestPages.css │ ├── Web.config │ ├── default.htm │ ├── docbook.css │ ├── dump.slua │ ├── factorial.slua │ ├── hello.slua │ ├── rss.slua │ └── webform.slua ├── SharpLua.Web │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── README.txt │ ├── SharpLua.Web.csproj │ └── SharpLuaHttpHandler.cs ├── SharpLua.sln ├── SharpLua │ ├── #Lua.ico │ ├── AssemblyCache.cs │ ├── Chunk │ │ ├── Assignment.cs │ │ ├── BreakStmt.cs │ │ ├── Chunk.cs │ │ ├── DoStmt.cs │ │ ├── ExprStmt.cs │ │ ├── ForInStmt.cs │ │ ├── ForStmt.cs │ │ ├── Function.cs │ │ ├── IfStmt.cs │ │ ├── LocalFunc.cs │ │ ├── LocalVar.cs │ │ ├── RepeatStmt.cs │ │ ├── ReturnStmt.cs │ │ ├── Statement.cs │ │ └── WhileStmt.cs │ ├── Expr │ │ ├── Access.cs │ │ ├── BaseExpr.cs │ │ ├── BoolLiteral.cs │ │ ├── Expr.cs │ │ ├── FunctionBody.cs │ │ ├── FunctionCall.cs │ │ ├── FunctionValue.cs │ │ ├── GroupExpr.cs │ │ ├── KeyAccess.cs │ │ ├── MethodCall.cs │ │ ├── NameAccess.cs │ │ ├── NilLiteral.cs │ │ ├── NumberLiteral.cs │ │ ├── OperTable.cs │ │ ├── Operation.cs │ │ ├── OperatorExpr.cs │ │ ├── PrimaryExpr.cs │ │ ├── StringLiteral.cs │ │ ├── TableConstructor.cs │ │ ├── Term.cs │ │ ├── VarName.cs │ │ └── VariableArg.cs │ ├── ExternalLibraryLoader.cs │ ├── Inspector.cs │ ├── Library │ │ ├── BaseLib.cs │ │ ├── ClassLib.cs │ │ ├── ConsoleLib.cs │ │ ├── CoroutineLib.cs │ │ ├── FileLib.cs │ │ ├── FileSystemLib.cs │ │ ├── ILuaLibrary.cs │ │ ├── IOLib.cs │ │ ├── MathLib.cs │ │ ├── OSLib.cs │ │ ├── PackageLib.cs │ │ ├── ScriptLib.cs │ │ ├── StringLib.cs │ │ ├── TableLib.cs │ │ └── WinFormLib.cs │ ├── Lua.Grammar.txt │ ├── LuaRuntime.cs │ ├── LuaTypes │ │ ├── LuaBoolean.cs │ │ ├── LuaClass.cs │ │ ├── LuaCoroutine.cs │ │ ├── LuaError.cs │ │ ├── LuaFunction.cs │ │ ├── LuaMultiValue.cs │ │ ├── LuaNil.cs │ │ ├── LuaNumber.cs │ │ ├── LuaString.cs │ │ ├── LuaTable.cs │ │ ├── LuaUserdata.cs │ │ └── LuaValue.cs │ ├── ObjectToLua.cs │ ├── Parser │ │ ├── Parser.cs │ │ ├── ParserException.cs │ │ ├── ParserInput.cs │ │ ├── Syntax │ │ │ ├── Access.cs │ │ │ ├── Args.cs │ │ │ ├── Assignment.cs │ │ │ ├── BaseExpr.cs │ │ │ ├── BoolLiteral.cs │ │ │ ├── BreakStmt.cs │ │ │ ├── Chunk.cs │ │ │ ├── DoStmt.cs │ │ │ ├── ElseifBlock.cs │ │ │ ├── Expr.cs │ │ │ ├── ExprStmt.cs │ │ │ ├── Field.cs │ │ │ ├── ForInStmt.cs │ │ │ ├── ForStmt.cs │ │ │ ├── Function.cs │ │ │ ├── FunctionBody.cs │ │ │ ├── FunctionCall.cs │ │ │ ├── FunctionName.cs │ │ │ ├── FunctionValue.cs │ │ │ ├── GroupExpr.cs │ │ │ ├── IfStmt.cs │ │ │ ├── ItemValue.cs │ │ │ ├── KeyAccess.cs │ │ │ ├── KeyValue.cs │ │ │ ├── LocalFunc.cs │ │ │ ├── LocalVar.cs │ │ │ ├── MethodCall.cs │ │ │ ├── NameAccess.cs │ │ │ ├── NameValue.cs │ │ │ ├── NilLiteral.cs │ │ │ ├── NumberLiteral.cs │ │ │ ├── OperatorExpr.cs │ │ │ ├── ParamList.cs │ │ │ ├── PrimaryExpr.cs │ │ │ ├── RepeatStmt.cs │ │ │ ├── ReturnStmt.cs │ │ │ ├── Statement.cs │ │ │ ├── StringLiteral.cs │ │ │ ├── TableConstructor.cs │ │ │ ├── Term.cs │ │ │ ├── Var.cs │ │ │ ├── VarName.cs │ │ │ ├── VariableArg.cs │ │ │ └── WhileStmt.cs │ │ ├── TextInput.cs │ │ └── TextParserCommon.cs │ ├── Properties │ │ └── AssemblyInfo.cs │ ├── Serializer.cs │ ├── SharpLua.csproj │ ├── SharpLua.sln │ ├── Test │ │ ├── BasicTest.slua │ │ ├── Battle.slua │ │ ├── ClassesExample.slua │ │ ├── HelloWorld.slua │ │ ├── LedgerExample.slua │ │ ├── LuaPad.slua │ │ ├── WinFormExample.slua │ │ ├── icon │ │ │ ├── add.png │ │ │ ├── open.png │ │ │ └── save.png │ │ ├── newTables.slua │ │ ├── serialization.slua │ │ └── tablefunctions.slua │ ├── init.slua │ └── string.patterns.txt ├── SharpLuaAddIn │ ├── Configuration │ │ └── AssemblyInfo.cs │ ├── LuaAddin.addin │ ├── Resources │ │ ├── Lua-Mode.xshd │ │ └── Pad.xfrm │ ├── SharpLuaAddIn.csproj │ ├── Src │ │ ├── MyUserControl.cs │ │ └── TestPad.cs │ └── Templates │ │ ├── Lua.xft │ │ ├── SharpLua.xft │ │ └── SharpLuaClass.xft └── TODO.txt ├── README.txt ├── Scripts ├── Documentation.slua ├── GenerateDocumentationAndBuildAddIn.bat ├── XFuscator.lua ├── generateIntellisense.bat └── generateIntellisense.slua ├── SharpLua.AlmostADebugger ├── Core.lua ├── Form1.Designer.cs ├── Form1.cs ├── Form1.resx ├── Program.cs ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings └── SharpLua.AlmostADebugger.csproj ├── SharpLua.Compiler ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── SharpLua.Compiler.csproj ├── SharpLua.Interactive ├── Main.cs ├── Properties │ └── AssemblyInfo.cs ├── SharpLua.Interactive.csproj └── lua.cs ├── SharpLua.InterfacingTests ├── Entity.cs ├── Properties │ └── AssemblyInfo.cs ├── SharpLua.InterfacingTests.csproj ├── TestLua.cs └── test.lua ├── SharpLua.LASMTests ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── SharpLua.LASMTests.csproj ├── SharpLua.NewCompilerTests ├── Program.cs ├── Properties │ └── AssemblyInfo.cs └── SharpLua.NewCompilerTests.csproj ├── SharpLua.sln ├── SharpLua ├── Decompiler │ ├── Decompiler.cs │ └── disassembler example.lua ├── Defines.txt ├── Interfacing │ ├── CheckType.cs │ ├── GenerateEventAssembly.cs │ ├── Lua.cs │ ├── LuaBase.cs │ ├── LuaDLL.cs │ ├── LuaException.cs │ ├── LuaFunction.cs │ ├── LuaFunctionAttribute.cs │ ├── LuaGlobalAttribute.cs │ ├── LuaHideAttribute.cs │ ├── LuaModuleAttribute.cs │ ├── LuaRegistrationHelper.cs │ ├── LuaScriptException.cs │ ├── LuaTable.cs │ ├── LuaUserData.cs │ ├── Metatables.cs │ ├── MethodWrapper.cs │ ├── ObjectTranslator.cs │ ├── ProxyType.cs │ └── ScriptStrings.cs ├── LASM │ ├── Chunk.cs │ ├── Disassembler.cs │ ├── Dumper.cs_ │ ├── Enums.cs │ ├── Instruction.cs │ ├── LASM.txt │ ├── LASMDecompiler.cs │ ├── LasmParser.cs │ ├── LuaFile.cs │ ├── PlatformConfig.cs │ ├── Readme.txt │ ├── Verifier.cs │ └── bit.cs ├── LuaCore │ ├── Libraries │ │ ├── lbaselib.cs │ │ ├── lbitlib.cs │ │ ├── ldblib.cs │ │ ├── liolib.cs │ │ ├── lmathlib.cs │ │ ├── loadlib.cs │ │ ├── loslib.cs │ │ ├── lstrlib.cs │ │ ├── ltablib.cs │ │ └── lualib.cs │ ├── Parser │ │ ├── llex.cs │ │ └── lparser.cs │ ├── VM │ │ ├── lapi.cs │ │ ├── lauxlib.cs │ │ ├── lcode.cs │ │ ├── ldebug.cs │ │ ├── ldo.cs │ │ ├── ldump.cs │ │ ├── lfunc.cs │ │ ├── lgc.cs │ │ ├── lmem.cs │ │ ├── lopcodes.cs │ │ ├── lundump.cs │ │ └── lvm.cs │ ├── linit.cs │ ├── llimits.cs │ ├── lobject.cs │ ├── lstate.cs │ ├── lstring.cs │ ├── ltable.cs │ ├── ltm.cs │ ├── lua.cs │ ├── luaconf.cs │ ├── lzio.cs │ ├── print.cs │ └── printf.cs ├── LuaRuntime.cs ├── NewParser │ ├── Ast │ │ ├── BinaryOperator.cs │ │ ├── Chunk.cs │ │ ├── Expression │ │ │ ├── AnonymousFunctionExpr.cs │ │ │ ├── BinOpExpr.cs │ │ │ ├── BoolExpr.cs │ │ │ ├── CallExpr.cs │ │ │ ├── Expression.cs │ │ │ ├── IndexExpr.cs │ │ │ ├── InlineFunctionStatement.cs │ │ │ ├── MemberExpr.cs │ │ │ ├── NilExpr.cs │ │ │ ├── NumberExpr.cs │ │ │ ├── StringCallExpr.cs │ │ │ ├── StringExpr.cs │ │ │ ├── TableCallExpr.cs │ │ │ ├── TableConstructorExpr.cs │ │ │ ├── TableConstructorKeyExpr.cs │ │ │ ├── TableConstructorNamedFunctionExpr.cs │ │ │ ├── TableConstructorStringKeyExpr.cs │ │ │ ├── TableConstructorValueExpr.cs │ │ │ ├── UnOpExpr.cs │ │ │ ├── VarargExpr.cs │ │ │ └── VariableExpression.cs │ │ ├── Scope.cs │ │ ├── Statement │ │ │ ├── AssignmentStatement.cs │ │ │ ├── AugmentedAssignmentStatement.cs │ │ │ ├── BreakStatement.cs │ │ │ ├── CallStatement.cs │ │ │ ├── ContinueStatement.cs │ │ │ ├── DoStatement.cs │ │ │ ├── ForStatement.cs │ │ │ ├── FunctionStatement.cs │ │ │ ├── GotoStatement.cs │ │ │ ├── IfStmt.cs │ │ │ ├── LabelStatement.cs │ │ │ ├── RepeatStatement.cs │ │ │ ├── ReturnStatement.cs │ │ │ ├── Statement.cs │ │ │ ├── UsingStatement.cs │ │ │ └── WhileStatement.cs │ │ └── Variable.cs │ ├── Compiler │ │ ├── AstToCodeMap.txt │ │ ├── Block.cs │ │ ├── Compiler.cs │ │ ├── Compiler2.cs │ │ ├── Compiler3.cs │ │ ├── K2Reg.cs │ │ ├── Unescaper.cs │ │ └── Var2Reg.cs │ ├── Lexer.cs │ ├── Location.cs │ ├── LuaSourceException.cs │ ├── Parser.cs │ ├── Refactoring │ │ ├── AddDependency.cs │ │ ├── FindImplementation.cs │ │ ├── FindMisspelledVariables.cs │ │ ├── FindReferences.cs │ │ ├── FindReferencesBeforeDefinition.cs │ │ ├── FindUnusedVariables.cs │ │ └── InlineFunction.cs │ ├── StringExt.cs │ ├── Todo.txt │ ├── Token.cs │ ├── TokenReader.cs │ ├── Visitors │ │ ├── BasicBeautifier.cs │ │ ├── Beautifier.cs │ │ ├── ExactReconstruction.cs │ │ ├── FormattingOptions.cs │ │ ├── LuaCompatibleOutput.cs │ │ ├── Minifier.cs │ │ └── NonModifiedAstBeautifier.cs │ └── XmlDocumentation │ │ ├── Documentation.cs │ │ ├── DocumentationComment.cs │ │ ├── ExtractDocumentationComments.cs │ │ └── Format.txt ├── Properties │ └── AssemblyInfo.cs ├── Resources │ ├── BuildResources.bat │ ├── clrlib.slua │ ├── clrlib.sluac │ ├── extlib.slua │ ├── extlib.sluac │ ├── luanet.slua │ └── luanet.sluac ├── SharpLua.csproj ├── lua.cs └── luac.cs ├── SharpLuaAddIn ├── Configuration │ └── AssemblyInfo.cs ├── Documentation.xml ├── LuaAddin.addin ├── Resources │ ├── Field.png │ └── SharpLua.xshd ├── SharpLuaAddIn.csproj ├── Src │ ├── AstExtractor.cs │ ├── BracketSearcher.cs │ ├── CodeCompletion.cs │ ├── Common.cs │ ├── CompletionDatas.cs │ ├── CompletionList.cs │ ├── DocumentationManager.cs │ ├── LuaLanguageBinding.cs │ ├── LuaPad.cs │ ├── SharpLuaFormattingStrategy.cs │ └── TestPad.cs ├── Templates │ ├── Lua.xft │ ├── SharpLua.xft │ └── SharpLuaClass.xft └── slua.ico ├── TODO.txt └── experimental-newparser ├── Program.cs ├── Properties └── AssemblyInfo.cs └── experimental-newparser.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | #ignore thumbnails created by windows 2 | Thumbs.db 3 | #Ignore files built by Visual Studio 4 | *.obj 5 | *.exe 6 | *.pdb 7 | *.user 8 | *.aps 9 | *.pch 10 | *.vspscc 11 | *_i.c 12 | *_p.c 13 | *.ncb 14 | *.suo 15 | *.tlb 16 | *.tlh 17 | *.bak 18 | *.cache 19 | *.ilk 20 | *.log 21 | [Bb]in/ 22 | [Dd]ebug*/ 23 | *.lib 24 | *.sbr 25 | obj/ 26 | [Rr]elease*/ 27 | _ReSharper*/ 28 | [Tt]est[Rr]esult* 29 | SharpLua2/ 30 | SharpLua2Tester/ 31 | experimental/ 32 | Scripts/generatedIntellisense.txt 33 | Scripts/Documentation.xml -------------------------------------------------------------------------------- /Example Projects/CSharpExampleProject/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("CSharpExampleProject")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("CSharpExampleProject")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4ae8d85a-dcdb-4771-8d6f-0aa254f0b7e5")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Example Projects/TestModule/Class1.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua; 6 | 7 | namespace TestModule 8 | { 9 | [LuaModule("testmodule")] 10 | public class TestModule 11 | { 12 | [LuaFunction] 13 | public static void What() 14 | { 15 | Console.WriteLine("ha"); 16 | } 17 | 18 | [LuaFunction] 19 | // Doesn't show up - not static 20 | public int X() 21 | { 22 | return 9; 23 | } 24 | 25 | [LuaFunction] 26 | public static string GetVersion() 27 | { 28 | return "1.0 Beta"; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /Example Projects/TestModule/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("TestModule")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("TestModule")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("538e2700-fdc2-4d4b-95a8-33b0c6fabe9a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /GenerateDocumentation/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using SharpLua; 7 | using SharpLua.Ast; 8 | using SharpLua.XmlDocumentation; 9 | 10 | namespace GenerateDocumentation 11 | { 12 | class Program 13 | { 14 | static void Main(string[] args) 15 | { 16 | try 17 | { 18 | Lexer l = new Lexer(); 19 | Parser p = new Parser(l.Lex(File.ReadAllText(args[0]))); 20 | Chunk c = p.Parse(); 21 | var doc = ExtractDocumentationComments.Extract(c); 22 | File.WriteAllText(Path.ChangeExtension(args[0], ".xml"), 23 | Documentation.Write(doc)); 24 | } 25 | catch (Exception ex) 26 | { 27 | Console.WriteLine(ex.ToString()); 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /GenerateDocumentation/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("GenerateDocumentation")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("GenerateDocumentation")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("342c38d8-f41d-46af-a2a3-866eec5e686b")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | Copyright (c) 2011-2012 LoDC 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 4 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 5 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 6 | persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 9 | 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 11 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 12 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 13 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 14 | -------------------------------------------------------------------------------- /Libraries/lbci/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("lbci")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("lbci")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("9b14d15b-d83d-4574-af88-27bb740c6acc")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Libraries/lbci/lbci_print.lua: -------------------------------------------------------------------------------- 1 | require"lbci" 2 | 3 | local write=io.write 4 | 5 | local function S(t,k,x,c) 6 | local n=t[k] 7 | if n==1 then k=string.sub(k,1,-2) end 8 | write(n,x or ""," ",k,c or ", ") 9 | end 10 | 11 | local function constant(f,i) 12 | if i~=nil and i<0 then 13 | write(inspector.getconstant(f,-i)," ") 14 | end 15 | end 16 | 17 | local function inspect(f,all) 18 | local F=inspector.getheader(f) 19 | local k 20 | 21 | if F.line==0 then k="main" else k="function" end 22 | write("\n",k," <",F.source,":",F.line,",",F.lastline,"> (") 23 | S(F,"instructions",nil,")\n") 24 | if F.isvararg then k="+" else k="" end 25 | S(F,"params",k) 26 | S(F,"slots") 27 | S(F,"upvalues") 28 | S(F,"locals") 29 | S(F,"constants") 30 | S(F,"functions",nil,"\n") 31 | 32 | for i=1,F.instructions do 33 | local a,b,c,d,e=inspector.getinstruction(f,i) 34 | b=string.sub(b.." ",1,9) 35 | write("\t",i,"\t[",a,"]\t",b,"\t",c," ",d," ",e or "","\t; ") 36 | constant(f,c) 37 | constant(f,d) 38 | constant(f,e) 39 | write("\n") 40 | end 41 | 42 | if all then 43 | for i=1,F.functions do 44 | inspect(inspector.getfunction(f,i),all) 45 | end 46 | end 47 | 48 | end 49 | 50 | local f=assert(loadfile"print.lua") 51 | inspect(f) 52 | inspect(function () end) 53 | -------------------------------------------------------------------------------- /Libraries/lbci/lbci_test.lua: -------------------------------------------------------------------------------- 1 | require"lbci" 2 | 3 | local function inspect(f,all) 4 | local F=inspector.getheader(f) 5 | print("header",f) 6 | for k,v in next,F do 7 | print("",k,v) 8 | end 9 | 10 | print("constants",F.constants) 11 | for i=1,F.constants do 12 | local a=inspector.getconstant(f,i) 13 | print("",i,a) 14 | end 15 | 16 | print("locals",F.locals) 17 | for i=1,F.locals do 18 | local a,b,c=inspector.getlocal(f,i) 19 | print("",i,a,b,c) 20 | end 21 | 22 | print("upvalues",F.upvalues) 23 | for i=1,F.upvalues do 24 | local a=inspector.getupvalue(f,i) 25 | print("",i,a) 26 | end 27 | 28 | print("functions",F.functions) 29 | for i=1,F.functions do 30 | local a=inspector.getfunction(f,i) 31 | print("",i,a) 32 | end 33 | 34 | print("instructions",F.instructions) 35 | for i=1,F.instructions do 36 | local a,b,c,d,e=inspector.getinstruction(f,i) 37 | print("",i,a,b,c,d,e) 38 | if b=="GETGLOBAL" then print(">>> ",inspector.getconstant(f,-d)) end 39 | if b=="SETGLOBAL" then print(">>>*",inspector.getconstant(f,-d)) end 40 | end 41 | 42 | print() 43 | if all then 44 | for i=1,F.functions do 45 | inspect(inspector.getfunction(f,i),all) 46 | end 47 | end 48 | 49 | end 50 | 51 | f=function (x,y) 52 | print(x,"=",y,23) 53 | local z=x+2*y 54 | local last 55 | X=245 56 | return inspect 57 | end 58 | 59 | inspect(debug.getinfo(1).func,true) 60 | do return end 61 | 62 | inspect(f) 63 | inspect(inspect) 64 | f(1,2) 65 | inspector.setconstant(f,3,98) 66 | f(1,2) 67 | inspector.setconstant(f,3,123,987) 68 | f(1,2) 69 | inspector.setconstant(f,3) 70 | f(1,2) 71 | f(1,2) 72 | 73 | -------------------------------------------------------------------------------- /NuGetPackage/CreateNuGetPackage.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd Package 3 | 4 | :: create folder 5 | mkdir lib 6 | cd lib 7 | mkdir net40 8 | cd net40 9 | 10 | :: copy binaries 11 | copy /Y ..\..\..\..\bin\SharpLua.dll . 12 | 13 | :: create NuGet package 14 | cd ..\.. 15 | nuget pack SharpLua.nuspec 16 | 17 | move *.nupkg .. 18 | cd .. 19 | del Package\lib\net40\SharpLua.dll 20 | 21 | for %%f in (*.nupkg) do nuget push "%%f" 22 | del *.nupkg -------------------------------------------------------------------------------- /NuGetPackage/Package/SharpLua.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SharpLua 5 | 2.1.1.1 6 | mlnlover11 7 | mlnlover11 8 | https://github.com/mlnlover11/SharpLua 9 | false 10 | Lua implementation in C# 11 | 12 | Copyright 2012 LoDC 13 | Lua 14 | 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/CHANGELOG.txt: -------------------------------------------------------------------------------- 1 | Version 1.0.* 2 | + Inital Creation 3 | + Added basic .NET interop 4 | + extended base libraries 5 | Version 1.1.* 6 | + Added Built-in classes 7 | + More advanced .NET interop 8 | + coroutine library 9 | + combined class Lua and class LuaRuntime 10 | + added a SharpDevelop addin 11 | + Added a "compiler" which serializes the AST into a roughly 6x larger file 12 | + added a full object serializer/deserializer 13 | + moved stuff around 14 | + added a compiler to create standalone Exe files 15 | + added C# and VB.NET example projects 16 | + String Regex pattern matching 17 | + return internal assembly version for in the Banner 18 | + directly enumerate .NET arrays (For in <.NET array> do print() end 19 | -------------------------------------------------------------------------------- /OLD.SharpLua/CryptoLib/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("CryptoLib")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("mlnlover11 Productions")] 16 | [assembly: AssemblyProduct("CryptoLib")] 17 | [assembly: AssemblyCopyright("Copyright (C) 2011-2012 mlnlover11 Productions")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/Example Projects/CSharpExampleProject.ConvertedToVBNet/Properties/AssemblyInfo.vb: -------------------------------------------------------------------------------- 1 | #Region "Using directives" 2 | 3 | Imports System.Reflection 4 | Imports System.Runtime.InteropServices 5 | 6 | #End Region 7 | 8 | ' General Information about an assembly is controlled through the following 9 | ' set of attributes. Change these attribute values to modify the information 10 | ' associated with an assembly. 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ' This sets the default COM visibility of types in the assembly to invisible. 21 | ' If you need to expose a type to COM, use [ComVisible(true)] on that type. 22 | 23 | 24 | ' The assembly version has following format : 25 | ' 26 | ' Major.Minor.Build.Revision 27 | ' 28 | ' You can specify all the values or you can use the default the Revision and 29 | ' Build Numbers by using the '*' as shown below: 30 | 31 | -------------------------------------------------------------------------------- /OLD.SharpLua/Example Projects/CSharpExampleProject.ConvertedToVBNet/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OLD.SharpLua/Example Projects/CSharpExampleProject/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("CSharpExampleProject")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("CSharpExampleProject")] 17 | [assembly: AssemblyCopyright("Copyright 2012")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/Example Projects/CSharpExampleProject/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OLD.SharpLua/NuGetPackage/CreateNuGetPackage.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | cd Package 3 | 4 | :: create folder 5 | mkdir lib 6 | cd lib 7 | mkdir net40 8 | cd net40 9 | 10 | :: copy binaries 11 | copy /Y ..\..\..\..\bin\debug\SharpLua.dll . 12 | 13 | :: create NuGet package 14 | cd ..\.. 15 | nuget pack SharpLua.nuspec 16 | 17 | move *.nupkg .. 18 | cd .. 19 | del Package\lib\net40\SharpLua.dll 20 | 21 | cd Package\lib\net40 22 | 23 | :: copy binaries 24 | copy /Y ..\..\..\..\bin\debug\SharpLua.Web.dll . 25 | 26 | :: create NuGet package 27 | cd ..\.. 28 | nuget pack SharpLua.Web.nuspec 29 | 30 | move *.nupkg .. 31 | cd .. 32 | del Package\lib\net40\SharpLua.Web.dll 33 | 34 | 35 | for %%f in (*.nupkg) do nuget push "%%f" 36 | del *.nupkg -------------------------------------------------------------------------------- /OLD.SharpLua/NuGetPackage/Package/SharpLua.Web.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SharpLua.Web 5 | 1.0.1 6 | mlnlover11 7 | mlnlover11 8 | https://github.com/mlnlover11/SharpLua 9 | false 10 | Web handler for SharpLua 11 | Fixed dependency 12 | Copyright 2012 mlnlover11 Productions 13 | Lua 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/NuGetPackage/Package/SharpLua.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SharpLua 5 | 1.0.4 6 | mlnlover11 7 | mlnlover11 8 | https://github.com/mlnlover11/SharpLua 9 | false 10 | Lua implementation in C# 11 | Minor updates 12 | Copyright 2012 mlnlover11 Productions 13 | Lua 14 | 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Compiler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.Compiler")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("mlnlover11 Productions")] 16 | [assembly: AssemblyProduct("SharpLua.Compiler")] 17 | [assembly: AssemblyCopyright("Copyright (C) 2011-2012 mlnlover11 Productions")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Compiler/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Interactive/MyClass.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: elijah 4 | * Date: 1/1/2012 5 | * Time: 2:27 PM 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | using System.Collections.Generic; 11 | 12 | namespace SharpLua.Interactive 13 | { 14 | /// 15 | /// The interaction. 16 | /// 17 | public class MyClass 18 | { 19 | SharpLua.LuaRuntime.Main(args 20 | } 21 | } -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Interactive/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: elijah 4 | * Date: 1/1/2012 5 | * Time: 2:29 PM 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | 11 | namespace SharpLua.Interactive 12 | { 13 | class Program 14 | { 15 | public static void Main(string[] args) 16 | { 17 | SharpLua.LuaRuntime.REPL(args); 18 | } 19 | } 20 | } -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Interactive/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.Interactive")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("SharpLua.Interactive")] 17 | [assembly: AssemblyCopyright("Copyright 2012")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Interactive/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Launcher/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: elijah 4 | * Date: 1/14/2012 5 | * Time: 8:55 AM 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | 11 | namespace SharpLua.Launcher 12 | { 13 | /// 14 | /// Class with program entry point. 15 | /// 16 | internal sealed class Program 17 | { 18 | /// 19 | /// Program entry point. 20 | /// 21 | [STAThread] 22 | private static void Main(string[] args) 23 | { 24 | SharpLua.LuaRuntime.REPL(args); 25 | } 26 | 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Launcher/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.Launcher")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("SharpLua.Launcher")] 17 | [assembly: AssemblyCopyright("Copyright 2012")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Launcher/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Scripts/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.Scripts")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("mlnlover11 Productions")] 16 | [assembly: AssemblyProduct("SharpLua.Scripts")] 17 | [assembly: AssemblyCopyright("Copyright (C) 2012 mlnlover11 Productions")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Scripts/for.slua: -------------------------------------------------------------------------------- 1 | -- for L00PZ 2 | 3 | -- basic for loop 4 | for i = 1, 100, 1 do 5 | print("Pass " .. i) 6 | end 7 | 8 | -- create and fill table 9 | t = { } 10 | print"Creating sample table" 11 | for i = 1, 50 do 12 | t[i] = "Round " .. i .. "::" .. math.random(0, 999999999) 13 | end 14 | 15 | -- print table contents 16 | print"Created sample table, printing it" 17 | for k, v in pairs(t) do 18 | print(t, k, v) 19 | end -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Scripts/functions.slua: -------------------------------------------------------------------------------- 1 | -- function samples 2 | 3 | f = function(arg1, ...) 4 | print(arg1, arg) 5 | end 6 | 7 | f("a", "b", "c") 8 | 9 | t = { } 10 | function t:die(...) 11 | t.dead = true 12 | end 13 | 14 | t:die() 15 | print(t.dead) 16 | t.c = class() 17 | t.c.__index = t 18 | --print(t.c.t.c.t.c.t.c.Name) -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Serializer/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: elijah 4 | * Date: 12/26/2011 5 | * Time: 12:25 PM 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | using System.IO; 11 | using SharpLua.AST; 12 | 13 | namespace SharpLua.Luac 14 | { 15 | class Program 16 | { 17 | public static int Main(string[] args) 18 | { 19 | if (args.Length == 0) 20 | { 21 | Console.WriteLine("Usage: luac [outfile]"); 22 | Console.WriteLine(" is the input file name"); 23 | Console.WriteLine(" [outfile] is an optional output file name"); 24 | return 1; 25 | } 26 | Parser.Parser p = new SharpLua.Parser.Parser(); 27 | bool success; 28 | Chunk c = p.ParseChunk(new Parser.TextInput(File.ReadAllText(args[0])), out success); 29 | if (success) 30 | { 31 | string _out = ""; 32 | if (args.Length > 1) 33 | _out = args[1]; 34 | else 35 | _out = Path.GetDirectoryName(args[0]) + "\\" + Path.GetFileNameWithoutExtension(args[0]) + ".sluac"; 36 | SharpLua.Serializer.Serialize(c, _out); 37 | return 0; 38 | } 39 | else 40 | { 41 | Console.WriteLine("Parsing error(s)!"); 42 | foreach (Tuple t in p.Errors) 43 | Console.WriteLine("Line " + t.Item1 + ": " + t.Item2); 44 | } 45 | return 1; 46 | } 47 | } 48 | } -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Serializer/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.Serializer")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("mlnlover11 Productions")] 16 | [assembly: AssemblyProduct("SharpLua.Serializer")] 17 | [assembly: AssemblyCopyright("Copyright (C) 2011-2012 mlnlover11 Productions")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Serializer/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.Web.TestPages")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("SharpLua.Web.TestPages")] 17 | [assembly: AssemblyCopyright("Copyright 2012")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/Global.asax: -------------------------------------------------------------------------------- 1 | <%@ Application Codebehind="Global.cs" 2 | Inherits="SharpLua.Web.TestPages.Global" 3 | %> 4 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/SharpLua.Web.TestPages.css: -------------------------------------------------------------------------------- 1 | /*----------------------------------------------*/ 2 | BODY 3 | { font-family: Verdana, Arial; 4 | font-weight: normal; 5 | font-size: 11px; 6 | color: Black; 7 | background-color: #F0F0F0; 8 | } 9 | /*----------------------------------------------*/ 10 | TABLE 11 | { font-size: 11px; 12 | background-color: #000000; 13 | border-width: 1px; 14 | border-color: #000000; 15 | border-collapse: collapse; 16 | margin: 0; 17 | } 18 | /*----------------------------------------------*/ 19 | TD 20 | { background-color: #FFFFFF; 21 | border-color: #FF0000; 22 | border-width: 0px; 23 | padding: 4; 24 | margin: 0; 25 | } 26 | /*----------------------------------------------*/ 27 | DIV 28 | { width:120px; 29 | height:120px; 30 | border:solid 1px black; 31 | padding:8px; 32 | background-color:#F0F0FF; 33 | } 34 | /*----------------------------------------------*/ 35 | SELECT 36 | { font-family: Verdana; 37 | font-weight: normal; 38 | font-size: 11px; 39 | color: #000000; 40 | background-color: #FFFFFF; 41 | } 42 | /*----------------------------------------------*/ 43 | INPUT 44 | { font-family: Verdana; 45 | font-weight: normal; 46 | font-size: 11px; 47 | color: #000000; 48 | } 49 | /*----------------------------------------------*/ 50 | TEXTAREA 51 | { font-family: Verdana; 52 | font-weight: normal; 53 | font-size: 11px; 54 | color: #000000; 55 | background-color: #FFFFFF; 56 | } 57 | /*----------------------------------------------*/ 58 | A 59 | { FONT-WEIGHT: normal; 60 | COLOR: #004080; 61 | font-style: normal; 62 | text-decoration: none; 63 | } 64 | 65 | A:hover 66 | { FONT-WEIGHT: bold; 67 | COLOR: #FF5357; 68 | } 69 | /*----------------------------------------------*/ 70 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/default.htm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | SharpLua Web Tests/Examples 5 | 6 | 7 | 8 |

SharpLua Web Tests

9 |

Examples

10 |

hello.slua A simple hello world page.

11 |

factorial.slua Compute factorials.

12 |

webform.slua An example web form.

13 |

rss.slua Display data from an RSS feed.

14 | 15 | 16 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/dump.slua: -------------------------------------------------------------------------------- 1 | -- page that gets data dumped from form.slua 2 | 3 | web.response.Write("Your data:

") 4 | 5 | for q in web.response.QueryString do 6 | web.response.Write(q) 7 | web.response.Write(":") 8 | web.response.Write(web.request.QueryString.Item(q)) 9 | web.response.Write("
") 10 | end 11 | 12 | web.response.Write("Values posted:
") 13 | 14 | for q in web.response.Form do 15 | web.response.Write(q) 16 | web.response.Write(":") 17 | web.response.Write(web.request.Form.Item(q)) 18 | web.response.Write("
") 19 | end -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/factorial.slua: -------------------------------------------------------------------------------- 1 | -- A web page which allows the user to enter a number 2 | -- then computes and displays its factorial. 3 | 4 | function factorial(n) 5 | if n == 1 then return 1 end 6 | return n * factorial(n - 1) 7 | end 8 | web.response.Write([[ 9 |

Factorial in #Lua

10 |
11 |

Please enter a number 12 | 13 |

]]) 14 | 15 | n = web.request.QueryString("number") 16 | web.response.Write(tostring(factorial(n))) 17 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/hello.slua: -------------------------------------------------------------------------------- 1 | -- hello world in #Lua.Web 2 | 3 | web.response.Write("

HAI WORLD!!!!1!

") -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/rss.slua: -------------------------------------------------------------------------------- 1 | -- load an RSS feed 2 | 3 | -- load the xml dll 4 | script.reference("System.Xml") 5 | 6 | -- my website feed ;) 7 | feed= "http://elijah.awesome99.org/index.php/tools/blocks/page_list/blog_rss?bID=30&cID=71&arHandle=Main" 8 | 9 | -- create an XmlDocument & load feed 10 | news = script.create"System.Xml.XmlDocument" 11 | new.Load(feed) 12 | web.response.Write("

RSS Feed:


") 13 | 14 | -- print contents to screen 15 | for node in new.SelectNodes("/rss/channel/item/title") do 16 | web.response.Write("

") 17 | web.response.Write(node.InnerText) 18 | web.response.Write("

") 19 | end 20 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web.TestPages/webform.slua: -------------------------------------------------------------------------------- 1 | -- example to use forms in #Lua 2 | 3 | web.response.Write("

Example Web HTTP FORM Posting


Enter your data

") 4 | 5 | web.response.Write([[ 6 |

Please Type your name

7 |

When you press submit you'll be sent to example1. 8 |

9 |

Whats your name? 10 |

Telephone? 11 | 12 |

13 | ]]) -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.Web")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("SharpLua.Web")] 17 | [assembly: AssemblyCopyright("Copyright 2012")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua.Web/README.txt: -------------------------------------------------------------------------------- 1 | Create a new ASP.NET web application project. 2 | Change the web.config to include the following within : 3 | 4 | 5 | 6 | 7 | 8 | 9 | Copy SharpLua.dll and SharpLua.Web.dll into the bin directory of the web application 10 | Then write your SharpLua Page as a text file with a *.slua or *.lua extension 11 | 12 | Web context stuff is in the table called 'web' 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/#Lua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/OLD.SharpLua/SharpLua/#Lua.ico -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/BreakStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | /// 10 | /// A statement that breaks the current loop 11 | /// 12 | [Serializable()] 13 | public partial class BreakStmt : Statement 14 | { 15 | /// 16 | /// Does nothing 17 | /// 18 | /// 19 | /// 20 | /// 21 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 22 | { 23 | throw new NotImplementedException(); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/DoStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | /// 10 | /// A do statement 11 | /// 12 | [Serializable()] 13 | public partial class DoStmt : Statement 14 | { 15 | /// 16 | /// Executes the chunk 17 | /// 18 | /// Runs in the given environment 19 | /// whether to break execution 20 | /// 21 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 22 | { 23 | return this.Body.Execute(enviroment, out isBreak); 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/ExprStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | /// 10 | /// An Expression 11 | /// 12 | [Serializable()] 13 | public partial class ExprStmt : Statement 14 | { 15 | /// 16 | /// Executes the chunk 17 | /// 18 | /// Runs in the given environment 19 | /// whether to break execution 20 | /// 21 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 22 | { 23 | this.Expr.Evaluate(enviroment); 24 | isBreak = false; 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/ForStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | /// 10 | /// A for loop 11 | /// 12 | [Serializable()] 13 | public partial class ForStmt : Statement 14 | { 15 | /// 16 | /// Executes the chunk 17 | /// 18 | /// Runs in the given environment 19 | /// whether to break execution 20 | /// 21 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 22 | { 23 | LuaNumber start = this.Start.Evaluate(enviroment) as LuaNumber; 24 | LuaNumber end = this.End.Evaluate(enviroment) as LuaNumber; 25 | 26 | double step = 1; 27 | if (this.Step != null) 28 | { 29 | step = (this.Step.Evaluate(enviroment) as LuaNumber).Number; 30 | } 31 | 32 | var table = new LuaTable(enviroment); 33 | table.SetNameValue(this.VarName, start); 34 | this.Body.Enviroment = table; 35 | 36 | while (step > 0 && start.Number <= end.Number || 37 | step <= 0 && start.Number >= end.Number) 38 | { 39 | var returnValue = this.Body.Execute(out isBreak); 40 | if (returnValue != null || isBreak == true) 41 | { 42 | isBreak = false; 43 | return returnValue; 44 | } 45 | start.Number += step; 46 | } 47 | 48 | isBreak = false; 49 | return null; 50 | } 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/IfStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | /// 10 | /// An if/then statement 11 | /// 12 | [Serializable()] 13 | public partial class IfStmt : Statement 14 | { 15 | /// 16 | /// Executes the chunk 17 | /// 18 | /// The environment to run in 19 | /// whether to break execution 20 | /// 21 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 22 | { 23 | LuaValue condition = this.Condition.Evaluate(enviroment); 24 | 25 | if (condition.GetBooleanValue() == true) 26 | { 27 | return this.ThenBlock.Execute(enviroment, out isBreak); 28 | } 29 | else 30 | { 31 | foreach (ElseifBlock elseifBlock in this.ElseifBlocks) 32 | { 33 | condition = elseifBlock.Condition.Evaluate(enviroment); 34 | 35 | if (condition.GetBooleanValue() == true) 36 | { 37 | return elseifBlock.ThenBlock.Execute(enviroment, out isBreak); 38 | } 39 | } 40 | 41 | if (this.ElseBlock != null) 42 | { 43 | return this.ElseBlock.Execute(enviroment, out isBreak); 44 | } 45 | } 46 | 47 | isBreak = false; 48 | return null; 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/LocalFunc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | /// 10 | /// A local function 11 | /// 12 | [Serializable()] 13 | public partial class LocalFunc : Statement 14 | { 15 | /// 16 | /// Executes the chunk 17 | /// 18 | /// The environment to run in 19 | /// whether to break execution 20 | /// 21 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 22 | { 23 | enviroment.SetNameValue(this.Name, this.Body.Evaluate(enviroment)); 24 | isBreak = false; 25 | return null; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/LocalVar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | /// 10 | /// A local variable 11 | /// 12 | [Serializable()] 13 | public partial class LocalVar : Statement 14 | { 15 | /// 16 | /// Executes the chunk 17 | /// 18 | /// The environment to run in 19 | /// whether to break execution 20 | /// 21 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 22 | { 23 | LuaValue[] values = this.ExprList.ConvertAll(expr => expr.Evaluate(enviroment)).ToArray(); 24 | LuaValue[] neatValues = LuaMultiValue.UnWrapLuaValues(values); 25 | 26 | for (int i = 0; i < Math.Min(this.NameList.Count, neatValues.Length); i++) 27 | { 28 | enviroment.RawSetValue(this.NameList[i], neatValues[i]); 29 | } 30 | 31 | if (neatValues.Length < this.NameList.Count) 32 | { 33 | for (int i = neatValues.Length; i < this.NameList.Count - neatValues.Length; i++) 34 | { 35 | enviroment.RawSetValue(this.NameList[i], LuaNil.Nil); 36 | } 37 | } 38 | 39 | isBreak = false; 40 | return null; 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/RepeatStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class RepeatStmt : Statement 11 | { 12 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 13 | { 14 | while (true) 15 | { 16 | var returnValue = this.Body.Execute(enviroment, out isBreak); 17 | if (returnValue != null || isBreak == true) 18 | { 19 | isBreak = false; 20 | return returnValue; 21 | } 22 | 23 | LuaValue condition = this.Condition.Evaluate(enviroment); 24 | 25 | if (condition.GetBooleanValue() == true) 26 | { 27 | break; 28 | } 29 | } 30 | 31 | return null; 32 | } 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/ReturnStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class ReturnStmt : Statement 11 | { 12 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 13 | { 14 | throw new NotImplementedException(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/Statement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | using SharpLua.LuaTypes; 7 | 8 | namespace SharpLua.AST 9 | { 10 | [Serializable()] 11 | public abstract partial class Statement 12 | { 13 | public abstract LuaValue Execute(LuaTable enviroment, out bool isBreak); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Chunk/WhileStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class WhileStmt : Statement 11 | { 12 | public override LuaValue Execute(LuaTable enviroment, out bool isBreak) 13 | { 14 | while (true) 15 | { 16 | LuaValue condition = this.Condition.Evaluate(enviroment); 17 | 18 | if (condition.GetBooleanValue() == false) 19 | { 20 | break; 21 | } 22 | 23 | var returnValue = this.Body.Execute(enviroment, out isBreak); 24 | if (returnValue != null || isBreak == true) 25 | { 26 | isBreak = false; 27 | return returnValue; 28 | } 29 | } 30 | 31 | isBreak = false; 32 | return null; 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/Access.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public abstract partial class Access 11 | { 12 | public abstract LuaValue Evaluate(LuaValue baseValue, LuaTable enviroment); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/BaseExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public abstract partial class BaseExpr : Term 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/BoolLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class BoolLiteral : Term 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return LuaBoolean.From(bool.Parse(this.Text)); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/Expr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public abstract partial class Expr 11 | { 12 | public abstract LuaValue Evaluate(LuaTable enviroment); 13 | 14 | public abstract Term Simplify(); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/FunctionBody.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class FunctionBody 11 | { 12 | public LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return new LuaFunction( 15 | new LuaFunc(delegate(LuaValue[] args) 16 | { 17 | var table = new LuaTable(enviroment); 18 | 19 | List names = this.ParamList.NameList; 20 | 21 | if (names.Count > 0) 22 | { 23 | int argCount = Math.Min(names.Count, args.Length); 24 | 25 | for (int i = 0; i < argCount; i++) 26 | { 27 | table.SetNameValue(names[i], args[i]); 28 | } 29 | 30 | if (this.ParamList.HasVarArg) 31 | { 32 | if (argCount < args.Length) 33 | { 34 | LuaValue[] remainedArgs = new LuaValue[args.Length - argCount]; 35 | for (int i = 0; i < remainedArgs.Length; i++) 36 | { 37 | remainedArgs[i] = args[argCount + i]; 38 | } 39 | table.SetNameValue("...", new LuaMultiValue(remainedArgs)); 40 | table.SetNameValue("arg", new LuaMultiValue(remainedArgs)); 41 | } 42 | } 43 | } 44 | else if (this.ParamList.IsVarArg != null) 45 | { 46 | table.SetNameValue("...", new LuaMultiValue(args)); 47 | } 48 | 49 | this.Chunk.Enviroment = table; 50 | 51 | return this.Chunk.Execute(); 52 | }) 53 | ); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/FunctionValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class FunctionValue : Term 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return this.Body.Evaluate(enviroment); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/GroupExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class GroupExpr : BaseExpr 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return this.Expr.Evaluate(enviroment); 15 | } 16 | 17 | public override Term Simplify() 18 | { 19 | return this.Expr.Simplify(); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/KeyAccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class KeyAccess : Access 11 | { 12 | public override LuaValue Evaluate(LuaValue baseValue, LuaTable enviroment) 13 | { 14 | LuaValue key = this.Key.Evaluate(enviroment); 15 | return LuaValue.GetKeyValue(baseValue, key); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/NameAccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class NameAccess : Access 11 | { 12 | public override LuaValue Evaluate(LuaValue baseValue, LuaTable enviroment) 13 | { 14 | LuaValue key = new LuaString(this.Name); 15 | return LuaValue.GetKeyValue(baseValue, key); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/NilLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class NilLiteral : Term 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return LuaNil.Nil; 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/NumberLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Globalization; 4 | using System.Text; 5 | 6 | using SharpLua.LuaTypes; 7 | 8 | namespace SharpLua.AST 9 | { 10 | [Serializable()] 11 | public partial class NumberLiteral : Term 12 | { 13 | public override LuaValue Evaluate(LuaTable enviroment) 14 | { 15 | double number; 16 | 17 | if (string.IsNullOrEmpty(this.HexicalText)) 18 | { 19 | number = double.Parse(this.Text, NumberStyles.AllowDecimalPoint | NumberStyles.AllowExponent); 20 | } 21 | else 22 | { 23 | number = int.Parse(this.HexicalText, NumberStyles.HexNumber); 24 | } 25 | 26 | return new LuaNumber (number); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/PrimaryExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class PrimaryExpr : Term 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | LuaValue baseValue = this.Base.Evaluate(enviroment); 15 | 16 | foreach (Access access in this.Accesses) 17 | { 18 | baseValue = access.Evaluate(baseValue, enviroment); 19 | } 20 | 21 | return baseValue; 22 | } 23 | 24 | public override Term Simplify() 25 | { 26 | if (this.Accesses.Count == 0) 27 | { 28 | return this.Base.Simplify(); 29 | } 30 | else 31 | { 32 | return this; 33 | } 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/StringLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class StringLiteral : Term 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return new LuaString(this.Text); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/TableConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class TableConstructor : Term 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | LuaTable table = new LuaTable(); 15 | 16 | foreach (Field field in this.FieldList) 17 | { 18 | NameValue nameValue = field as NameValue; 19 | if (nameValue != null) 20 | { 21 | table.SetNameValue(nameValue.Name, nameValue.Value.Evaluate(enviroment)); 22 | continue; 23 | } 24 | 25 | KeyValue keyValue = field as KeyValue; 26 | if (keyValue != null) 27 | { 28 | table.SetKeyValue( 29 | keyValue.Key.Evaluate(enviroment), 30 | keyValue.Value.Evaluate(enviroment)); 31 | continue; 32 | } 33 | 34 | ItemValue itemValue = field as ItemValue; 35 | if (itemValue != null) 36 | { 37 | table.AddValue(itemValue.Value.Evaluate(enviroment)); 38 | continue; 39 | } 40 | } 41 | 42 | return table; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/Term.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class Term : Expr 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | throw new NotImplementedException(); 15 | } 16 | 17 | public override Term Simplify() 18 | { 19 | return this; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/VarName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class VarName : BaseExpr 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return enviroment.GetValue(this.Name); 15 | } 16 | 17 | public override Term Simplify() 18 | { 19 | return this; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Expr/VariableArg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | using SharpLua.LuaTypes; 6 | 7 | namespace SharpLua.AST 8 | { 9 | [Serializable()] 10 | public partial class VariableArg : Term 11 | { 12 | public override LuaValue Evaluate(LuaTable enviroment) 13 | { 14 | return enviroment.GetValue(this.Name); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Library/ILuaLibrary.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: elijah 4 | * Date: 12/21/2011 5 | * Time: 10:53 AM 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | using SharpLua.LuaTypes; 11 | 12 | namespace SharpLua.Library 13 | { 14 | /// 15 | /// A Lua Library extension. ALL FUNCTIONS **MUST** BE STATIC. 16 | /// 17 | public interface ILuaLibrary 18 | { 19 | void RegisterModule(LuaTable environment); 20 | 21 | string ModuleName 22 | {get;} 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/LuaTypes/LuaBoolean.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LuaTypes 7 | { 8 | [Serializable()] 9 | public class LuaBoolean : LuaValue 10 | { 11 | public static readonly LuaBoolean False = new LuaBoolean { BoolValue = false }; 12 | 13 | public static readonly LuaBoolean True = new LuaBoolean { BoolValue = true }; 14 | 15 | public bool BoolValue { get; set; } 16 | 17 | public override object Value 18 | { 19 | get { return this.BoolValue; } 20 | } 21 | 22 | public override string GetTypeCode() 23 | { 24 | return "boolean"; 25 | } 26 | 27 | public override bool GetBooleanValue() 28 | { 29 | return this.BoolValue; 30 | } 31 | 32 | public override string ToString() 33 | { 34 | if (this.MetaTable != null) 35 | { 36 | LuaFunction function = this.MetaTable.GetValue("__tostring") as LuaFunction; 37 | if (function != null) 38 | { 39 | return function.Invoke(new LuaValue[] { this }).ToString(); 40 | } 41 | } 42 | 43 | return this.BoolValue.ToString().ToLower(); 44 | } 45 | 46 | private LuaBoolean() { MetaTable = new LuaTable(); } 47 | 48 | public static LuaBoolean From(bool value) 49 | { 50 | if (value == true) 51 | { 52 | return True; 53 | } 54 | else 55 | { 56 | return False; 57 | } 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/LuaTypes/LuaError.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LuaTypes 7 | { 8 | [Serializable()] 9 | public class LuaError : Exception 10 | { 11 | public LuaError(string message) 12 | : base(message) 13 | { 14 | } 15 | 16 | public LuaError(string message, Exception innerException) 17 | : base(message, innerException) 18 | { 19 | } 20 | 21 | public LuaError(string messageformat, params object[] args) 22 | : base(string.Format(messageformat, args)) 23 | { 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/LuaTypes/LuaFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LuaTypes 7 | { 8 | [Serializable()] 9 | public delegate LuaValue LuaFunc(LuaValue[] args); 10 | 11 | [Serializable()] 12 | public class LuaFunction : LuaValue 13 | { 14 | public LuaFunction(LuaFunc function) 15 | { 16 | this.Function = function; 17 | } 18 | 19 | public LuaFunc Function { get; set; } 20 | 21 | public override object Value 22 | { 23 | get { return this.Function; } 24 | } 25 | 26 | public override string GetTypeCode() 27 | { 28 | return "function"; 29 | } 30 | 31 | public LuaValue Invoke(LuaValue[] args) 32 | { 33 | return this.Function.Invoke(args); 34 | } 35 | 36 | public override string ToString() 37 | { 38 | if (this.MetaTable != null) 39 | { 40 | LuaFunction function = this.MetaTable.GetValue("__tostring") as LuaFunction; 41 | if (function != null) 42 | { 43 | return function.Invoke(new LuaValue[] { this }).ToString(); 44 | } 45 | } 46 | 47 | return "Function " + GetHashCode(); 48 | } 49 | 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/LuaTypes/LuaNil.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LuaTypes 7 | { 8 | [Serializable()] 9 | public class LuaNil : LuaValue 10 | { 11 | public static readonly LuaNil Nil = new LuaNil(); 12 | 13 | private LuaNil() { MetaTable = new LuaTable(); } 14 | 15 | public override object Value 16 | { 17 | get { return null; } 18 | } 19 | 20 | public override string GetTypeCode() 21 | { 22 | return "nil"; 23 | } 24 | 25 | public override bool GetBooleanValue() 26 | { 27 | return false; 28 | } 29 | 30 | public override string ToString() 31 | { 32 | if (this.MetaTable != null) 33 | { 34 | LuaFunction function = this.MetaTable.GetValue("__tostring") as LuaFunction; 35 | if (function != null) 36 | { 37 | return function.Invoke(new LuaValue[] { this }).ToString(); 38 | } 39 | } 40 | 41 | return "nil"; 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/LuaTypes/LuaNumber.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LuaTypes 7 | { 8 | [Serializable()] 9 | public class LuaNumber : LuaValue 10 | { 11 | public LuaNumber(double number) 12 | { 13 | MetaTable = new LuaTable(); 14 | this.Number = number; 15 | } 16 | 17 | public double Number { get; set; } 18 | 19 | public override object Value 20 | { 21 | get { return this.Number; } 22 | } 23 | 24 | public override string GetTypeCode() 25 | { 26 | return "number"; 27 | } 28 | 29 | public override string ToString() 30 | { 31 | if (this.MetaTable != null) 32 | { 33 | LuaFunction function = this.MetaTable.GetValue("__tostring") as LuaFunction; 34 | if (function != null) 35 | { 36 | return function.Invoke(new LuaValue[] { this }).ToString(); 37 | } 38 | } 39 | 40 | return this.Number.ToString(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/LuaTypes/LuaString.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LuaTypes 7 | { 8 | [Serializable()] 9 | public class LuaString : LuaValue 10 | { 11 | public LuaString(string text) 12 | { 13 | MetaTable = new LuaTable(); 14 | this.Text = text; 15 | } 16 | 17 | public static readonly LuaString Empty = new LuaString(string.Empty); 18 | 19 | public string Text { get; set; } 20 | 21 | public override object Value 22 | { 23 | get { return this.Text; } 24 | } 25 | 26 | public override string GetTypeCode() 27 | { 28 | return "string"; 29 | } 30 | 31 | public override string ToString() 32 | { 33 | if (this.MetaTable != null) 34 | { 35 | LuaFunction function = this.MetaTable.GetValue("__tostring") as LuaFunction; 36 | if (function != null) 37 | { 38 | return function.Invoke(new LuaValue[] { this }).ToString(); 39 | } 40 | } 41 | 42 | return this.Text; 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/LuaTypes/LuaUserdata.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LuaTypes 7 | { 8 | [Serializable()] 9 | public class LuaUserdata : LuaValue 10 | { 11 | private object Object; 12 | 13 | public LuaUserdata(object obj) 14 | { 15 | MetaTable = new LuaTable(); 16 | this.Object = obj; 17 | } 18 | 19 | public LuaUserdata(object obj, LuaTable metatable) 20 | { 21 | this.Object = obj; 22 | this.MetaTable = metatable; 23 | } 24 | /// 25 | /// Added by Arjen...initialize .NET object as LuaUserData using reflection 26 | /// 27 | /// .NET object 28 | /// True if object should reflect in LUA else empty metatable 29 | public LuaUserdata(object obj, bool init) 30 | { 31 | if (init) 32 | { 33 | MetaTable = SharpLua.ObjectToLua.GetControlMetaTable(); 34 | this.Object = obj; 35 | } 36 | else 37 | { 38 | MetaTable = new LuaTable(); 39 | this.Object = obj; 40 | } 41 | } 42 | 43 | 44 | public override object Value 45 | { 46 | get { return this.Object; } 47 | } 48 | 49 | public override string GetTypeCode() 50 | { 51 | return "userdata"; 52 | } 53 | 54 | public override string ToString() 55 | { 56 | if (this.MetaTable != null) 57 | { 58 | LuaFunction function = this.MetaTable.GetValue("__tostring") as LuaFunction; 59 | if (function != null) 60 | { 61 | return function.Invoke(new LuaValue[] { this }).ToString(); 62 | } 63 | } 64 | 65 | return "userdata"; 66 | } 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/ParserException.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * User: elijah 3 | * Date: 3/26/2012 4 | * Time: 4:26 PM 5 | */ 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | namespace SharpLua.Parser 10 | { 11 | /// 12 | /// Just a parser exception 13 | /// 14 | public class ParserException : Exception 15 | { 16 | public List> Errors; 17 | 18 | public ParserException(List> errors, string msg) 19 | : base(msg) 20 | { 21 | this.Errors = errors; 22 | } 23 | 24 | public int FirstErrorIndex 25 | { 26 | get 27 | { 28 | return Errors[0].Item1; 29 | } 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/ParserInput.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.Parser 6 | { 7 | public interface ParserInput 8 | { 9 | int Length { get; } 10 | 11 | bool HasInput(int pos); 12 | 13 | T GetInputSymbol(int pos); 14 | 15 | T[] GetSubSection(int position, int length); 16 | 17 | string FormErrorMessage(int position, string message); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Access.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class Access 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Args.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class Args 9 | { 10 | public List ArgList = new List(); 11 | 12 | public StringLiteral String; 13 | 14 | public TableConstructor Table; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Assignment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class Assignment : Statement 8 | { 9 | public List VarList = new List(); 10 | 11 | public List ExprList = new List(); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/BaseExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class BaseExpr 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/BoolLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class BoolLiteral : Term 8 | { 9 | public string Text; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/BreakStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class BreakStmt : Statement 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Chunk.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class Chunk 8 | { 9 | public List Statements = new List(); 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/DoStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class DoStmt : Statement 8 | { 9 | public Chunk Body; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/ElseifBlock.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class ElseifBlock 9 | { 10 | public Expr Condition; 11 | 12 | public Chunk ThenBlock; 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Expr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class Expr 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/ExprStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class ExprStmt : Statement 8 | { 9 | public Expr Expr; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Field.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class Field 9 | { 10 | public Expr Value; 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/ForInStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class ForInStmt : Statement 8 | { 9 | public List NameList = new List(); 10 | 11 | public List ExprList = new List(); 12 | 13 | public Chunk Body; 14 | 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/ForStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class ForStmt : Statement 8 | { 9 | public string VarName; 10 | 11 | public Expr Start; 12 | 13 | public Expr End; 14 | 15 | public Expr Step; 16 | 17 | public Chunk Body; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Function.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class Function : Statement 8 | { 9 | public FunctionName Name; 10 | 11 | public FunctionBody Body; 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/FunctionBody.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class FunctionBody 8 | { 9 | public ParamList ParamList; 10 | 11 | public Chunk Chunk; 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/FunctionCall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class FunctionCall : Access 8 | { 9 | public Args Args; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/FunctionName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class FunctionName 9 | { 10 | public List FullName = new List(); 11 | 12 | public string MethodName; 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/FunctionValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class FunctionValue : Term 8 | { 9 | public FunctionBody Body; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/GroupExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class GroupExpr : BaseExpr 8 | { 9 | public Expr Expr; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/IfStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class IfStmt : Statement 8 | { 9 | public Expr Condition; 10 | 11 | public Chunk ThenBlock; 12 | 13 | public List ElseifBlocks = new List(); 14 | 15 | public Chunk ElseBlock; 16 | 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/ItemValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class ItemValue : Field 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/KeyAccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class KeyAccess : Access 8 | { 9 | public Expr Key; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/KeyValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class KeyValue : Field 9 | { 10 | public Expr Key; 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/LocalFunc.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class LocalFunc : Statement 8 | { 9 | public string Name; 10 | 11 | public FunctionBody Body; 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/LocalVar.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class LocalVar : Statement 8 | { 9 | public List NameList = new List(); 10 | 11 | public List ExprList = new List(); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/MethodCall.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class MethodCall : Access 8 | { 9 | public string Method; 10 | 11 | public Args Args; 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/NameAccess.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class NameAccess : Access 8 | { 9 | public string Name; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/NameValue.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class NameValue : Field 9 | { 10 | public string Name; 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/NilLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class NilLiteral : Term 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/NumberLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class NumberLiteral : Term 8 | { 9 | public string HexicalText; 10 | 11 | public string Text; 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/OperatorExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class OperatorExpr : Expr 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/ParamList.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class ParamList 9 | { 10 | public List NameList = new List(); 11 | 12 | public bool HasVarArg; 13 | 14 | public string IsVarArg; 15 | 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/PrimaryExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class PrimaryExpr : Term 8 | { 9 | public BaseExpr Base; 10 | 11 | public List Accesses = new List(); 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/RepeatStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class RepeatStmt : Statement 8 | { 9 | public Chunk Body; 10 | 11 | public Expr Condition; 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/ReturnStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class ReturnStmt : Statement 8 | { 9 | public List ExprList = new List(); 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Statement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class Statement 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/StringLiteral.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class StringLiteral : Term 8 | { 9 | public string Text; 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/TableConstructor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class TableConstructor : Term 8 | { 9 | public List FieldList = new List(); 10 | 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Term.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class Term : Expr 8 | { 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/Var.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | [Serializable()] 8 | public partial class Var 9 | { 10 | public BaseExpr Base; 11 | 12 | public List Accesses = new List(); 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/VarName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class VarName : BaseExpr 8 | { 9 | /// 10 | /// The name of the variable 11 | /// 12 | public string Name; 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/VariableArg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class VariableArg : Term 8 | { 9 | /// 10 | /// An argument 11 | /// 12 | public string Name; 13 | 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Parser/Syntax/WhileStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua.AST 6 | { 7 | public partial class WhileStmt : Statement 8 | { 9 | /// 10 | /// The while Condition that is evaluated. 11 | /// 12 | public Expr Condition; 13 | 14 | /// 15 | /// The body of the code that is executed. 16 | /// 17 | public Chunk Body; 18 | 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | using System.Windows.Forms; 5 | 6 | // General Information about an assembly is controlled through the following 7 | // set of attributes. Change these attribute values to modify the information 8 | // associated with an assembly. 9 | [assembly: AssemblyTitle("SharpLua")] 10 | [assembly: AssemblyDescription("A Lua for .NET Framework")] 11 | [assembly: AssemblyConfiguration("")] 12 | [assembly: AssemblyCompany("mlnlover11 Productions")] 13 | [assembly: AssemblyProduct("SharpLua")] 14 | [assembly: AssemblyCopyright("Copyright © 2011-2012 mlnlover11 Productions")] 15 | [assembly: AssemblyTrademark("")] 16 | [assembly: AssemblyCulture("")] 17 | 18 | // Setting ComVisible to false makes the types in this assembly not visible 19 | // to COM components. If you need to access a type in this assembly from 20 | // COM, set the ComVisible attribute to true on that type. 21 | [assembly: ComVisible(false)] 22 | 23 | // The following GUID is for the ID of the typelib if this project is exposed to COM 24 | [assembly: Guid("a7223b58-663c-4229-b532-b52bd18e2bec")] 25 | 26 | // Version information for an assembly consists of the following four values: 27 | // 28 | // Major Version 29 | // Minor Version 30 | // Build Number 31 | // Revision 32 | // 33 | // You can specify all the values or you can default the Build and Revision Numbers 34 | // by using the '*' as shown below: 35 | // [assembly: AssemblyVersion("1.0.*")] 36 | [assembly: AssemblyVersion("1.1.*")] 37 | namespace SharpLua 38 | { 39 | internal class AssemblyVersion 40 | { 41 | public static string Version 42 | { 43 | get 44 | { 45 | return Assembly.GetExecutingAssembly().GetName().Version.ToString(); 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Serializer.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: elijah 4 | * Date: 12/26/2011 5 | * Time: 12:19 PM 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | using System.IO; 11 | using System.Runtime.Serialization; 12 | using System.Runtime.Serialization.Formatters; 13 | using System.Runtime.Serialization.Formatters.Binary; 14 | using SharpLua.AST; 15 | 16 | namespace SharpLua 17 | { 18 | /// 19 | /// Serializes an object. The object must have the Serializable() attribute. 20 | /// 21 | public class Serializer 22 | { 23 | public static void Serialize(object obj, string filename) 24 | { 25 | IFormatter formatter = new BinaryFormatter(); 26 | Stream stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None); 27 | formatter.Serialize(stream, obj); 28 | stream.Close(); 29 | } 30 | 31 | public static object Deserialize(string filename) 32 | { 33 | IFormatter formatter = new BinaryFormatter(); 34 | Stream stream = new FileStream(filename, FileMode.Open); 35 | object o = formatter.Deserialize(stream); 36 | stream.Close(); 37 | return o; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/SharpLua.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 11.00 3 | # Visual Studio 2010 4 | # SharpDevelop 4.2.0.8342-alpha 5 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpLua", "SharpLua.csproj", "{9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}" 6 | EndProject 7 | Global 8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 9 | Debug|Any CPU = Debug|Any CPU 10 | Debug|x86 = Debug|x86 11 | Release|Any CPU = Release|Any CPU 12 | Release|x86 = Release|x86 13 | Debug|Any CPU = Debug|Any CPU 14 | Debug|x86 = Debug|x86 15 | Release|Any CPU = Release|Any CPU 16 | Release|x86 = Release|x86 17 | EndGlobalSection 18 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 19 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Debug|Any CPU.Build.0 = Debug|Any CPU 20 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Debug|x86.Build.0 = Debug|x86 22 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Debug|x86.ActiveCfg = Debug|x86 23 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Release|Any CPU.Build.0 = Release|Any CPU 24 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Release|Any CPU.ActiveCfg = Release|Any CPU 25 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Release|x86.Build.0 = Release|x86 26 | {9B6F4AAC-1B76-4CB6-B7CE-EFBBB0C7F5C0}.Release|x86.ActiveCfg = Release|x86 27 | EndGlobalSection 28 | EndGlobal 29 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/Battle.slua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Battle - An advanced class test simulating a battle 3 | ]] 4 | math.randomseed(os.time()) 5 | 6 | player = class:CreateClass() 7 | enemy = class:CreateClass() 8 | 9 | -- create the "player" 10 | player.Health = 100 11 | player.MaxHealth = 100 12 | player.Damage = math.random(1, 100) 13 | player.Dead = false 14 | -- get their name 15 | player.Name = "Bob" 16 | function player:Attack() 17 | dmg = player.Damage 18 | player.Damage = math.random(1, 100) 19 | return dmg 20 | end 21 | 22 | function player:TakeDamage(dmg) 23 | player.Health = player.Health - dmg 24 | if player.Health <= 0 then 25 | player.Dead = true 26 | end 27 | end 28 | 29 | enemy.Health = 100 30 | enemy.MaxHealth = 100 31 | enemy.Damage = math.random(1, 100) 32 | enemy.Dead = false 33 | enemy.Name = "Larry" 34 | function enemy:Attack() 35 | dmg = enemy.Damage 36 | enemy.Damage = math.random(1, 100) 37 | return dmg 38 | end 39 | 40 | function enemy:TakeDamage(dmg) 41 | enemy.Health = enemy.Health - dmg 42 | if enemy.Health <= 0 then 43 | enemy.Dead = true 44 | end 45 | end 46 | print"Created fighters" 47 | -- END INITIALIZE PLAYER AND ENEMY 48 | 49 | while true do 50 | print(player.Name .. " is attacking: " .. player.Damage .. " damage") 51 | enemy:TakeDamage(player.Attack()) 52 | if enemy.Dead then 53 | print("Enemy is dead!") 54 | break 55 | end 56 | print("Enemy health: " .. enemy.Health) 57 | print(enemy.Name .. " is attacking: " .. enemy.Damage .. " damage") 58 | player:TakeDamage(enemy.Attack()) 59 | if player.Dead then 60 | print("Player is dead!") 61 | break 62 | end 63 | print("Player health: " .. player.Health) 64 | end 65 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/ClassesExample.slua: -------------------------------------------------------------------------------- 1 | --[[ 2 | Class testing. 3 | Tests for using parent objects directly, 4 | how to set metamethods in classes, 5 | and multiple inheritance 6 | ]] 7 | 8 | -- you can create a class with calling the class table (class()) 9 | -- or calling the CreateClass method (class:CreateClass()) 10 | c=class() 11 | 12 | -- #lua classes are a built-in type, but setting objects on them is easy. 13 | -- you use a class like you would use a table: 14 | c.Test = true 15 | c.print = function(a) print("C is printing " .. a) end 16 | 17 | -- create another class, 18 | -- which will be a subclass of c 19 | d = c:CreateSubclass() 20 | -- because it inherited "c", it call all "c"'s methods 21 | d.print("hello from d") 22 | -- random function 23 | d.printd = function() print"class d" end 24 | 25 | -- the class library also supports multiple inheritance 26 | e = class(d, c) 27 | 28 | -- see? it imports both classes. 29 | e.print("hai") 30 | e.printd() 31 | 32 | -- you cannot set class metamethods, so just set them as functions. 33 | -- the real class metatable takes care of them. 34 | -- do not bother returning values, as they are discarded. 35 | e.__newindex = function(t, k, v) print(t, k, v) end 36 | e.__index = function(table, index) print("getting index: " .. index) end 37 | e.__call = function() print"calling table e" end 38 | -- #Lua also has 2 different automatic functions: 39 | e.constructor = function() print"Created an instance of e" end 40 | e.destructor = function(self) print"e is dying! :O" end 41 | 42 | -- lets try these functions... 43 | e.s="n00bz" 44 | print(e.s) 45 | e() 46 | f = e:new() 47 | 48 | destroy(f) -- uses class "e"'s destructor -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/HelloWorld.slua: -------------------------------------------------------------------------------- 1 | -- There are a couple ways to print hello world in #Lua. 2 | -- If you know Lua, you should know the first two: 3 | print("Hello World!") 4 | io.write("Hello World!\n") 5 | -- If you dont know Lua, those two functions will both write 'Hello World!' to the console. 6 | -- io.write does not write an EndOfLine character, so you need to specify that with '\n'. 7 | -- A new way in #Lua is to use the console module 8 | console.write"Hello World!\n" 9 | console.writeline"Hello World!" 10 | -- And in color: 11 | console.writecolor("red", "Hello World, I am Red Text!") 12 | -- With the writecolor function you can use any value of the System.ConsoleColor enum. 13 | -- The only formats of text allowed for color are 'Red' or 'red', not something like 'RED' or 'rEd'. 14 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/WinFormExample.slua: -------------------------------------------------------------------------------- 1 | form = WinForms.Form{ 2 | Text="Main Form", Height=200, StartPosition="CenterScreen", 3 | WinForms.Label{ Text="Hello!", Name="lable", Width=80, Height=17, Top=9, Left=12 }, 4 | WinForms.Button{ Text="Click", Width=80, Height=23, Top=30, Left=12, 5 | Click=function(sender,e) WinForms.ShowMessage(lable.Text,"Clicked") end }, 6 | } 7 | WinForms.Run(form) -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/icon/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/OLD.SharpLua/SharpLua/Test/icon/add.png -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/icon/open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/OLD.SharpLua/SharpLua/Test/icon/open.png -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/icon/save.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/OLD.SharpLua/SharpLua/Test/icon/save.png -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/newTables.slua: -------------------------------------------------------------------------------- 1 | -- a test for the new LuaTable table system 2 | t = { } 3 | for i=1,100 do t[i] = "" .. i end 4 | for k, v in pairs(t) do print(k, v) end 5 | for k, v in ipairs(t) do print(k, v) end 6 | -- if k == v then it passed. -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/serialization.slua: -------------------------------------------------------------------------------- 1 | -- this script shows how you can load and save the _G (global environment) through sessions 2 | -- this doesn't work when using require, dofile, openfile, etc. 3 | -- this is because the environment is passed through a variable, not LuaRuntime.GlobalEnvironment. 4 | -- so to see this script actually work, copy/paste or type it into SharpLua. 5 | 6 | -- the saving function is ssave(filename, object) 7 | ssave("environment.bin", _G) 8 | 9 | -- to prove it works, lets set a variable 10 | hello = function() end 11 | print(hello) 12 | -- and you can save any object 13 | ssave("hello", hello) 14 | 15 | -- load environment from file 16 | _G = sload("environment.bin") 17 | 18 | -- look! the "hello" function is gone! 19 | print(hello) 20 | -- now load and run it from the file 21 | hello = sload("hello") 22 | hello() -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/Test/tablefunctions.slua: -------------------------------------------------------------------------------- 1 | -- cannot use [table]:function, as that doesn't work internally 2 | 3 | function a() 4 | t = { } 5 | t.b = function() 6 | print("hi") 7 | end 8 | return t 9 | end 10 | 11 | tbl = a() 12 | tbl.b() 13 | 14 | -- you can copy tables: 15 | tbl2 = { ["hi"] = "hi" } 16 | table.copy(tbl, tbl2) 17 | -- and then you can access it, because its in the new table 18 | print(tbl.hi) 19 | tbl2.hi = math.pi 20 | print(tbl.hi) 21 | print(tbl2.hi) 22 | 23 | -- you can print tables also 24 | -- using table.dump, table.print, and table.printcontents 25 | table.dump(tbl) 26 | -- but if you have some varaible pointing to its parent, such as _G, 27 | -- because you can access it like _G._G._G._G._G._G, it may cause weird printing 28 | table.dump(_G) 29 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLua/init.slua: -------------------------------------------------------------------------------- 1 | --#Lua loads from the LUA_PATH variable also. 2 | package.path = package.path .. ";C:\\users\\elijah.ffhs2\\appdata\\lua.5.1.4\\lua\\?.lua" 3 | package.path = package.path .. ";C:\\users\\elijah.ffhs2\\appdata\\lua.5.1.4\\?.lua" 4 | package.path = package.path .. ";C:\\users\\elijah.ffhs2\\appdata\\lua.5.1.4\\?.wlua" 5 | 6 | script.import"system.windows.forms" 7 | script.import"sharplua" 8 | script.import"system.drawing" 9 | script.import"system.io" 10 | 11 | require"cryptolib" 12 | 13 | -- test 14 | script.reference"CSharpexampleproject" 15 | c=script.create"csharpexampleproject.test2" 16 | --for k, v in iarray(c.Values) do print(k, v) end 17 | --for k, v in iarray(c.Dict) do print(k, v) end 18 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/Configuration/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows.Forms; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | 8 | // Information about this assembly is defined by the following 9 | // attributes. 10 | // 11 | // change them to the information which is associated with the assembly 12 | // you compile. 13 | 14 | [assembly: AssemblyTitle("SharpLua.SharpDevelop.AddIn")] 15 | [assembly: AssemblyDescription("A #Lua Addin for Sharp Develop")] 16 | [assembly: AssemblyConfiguration("")] 17 | [assembly: AssemblyCompany("mlnlover11 Productions")] 18 | [assembly: AssemblyProduct("SharpLua.SharpDevelop.AddIn")] 19 | [assembly: AssemblyCopyright("Copyright (C) 2011 mlnlover11 Productions")] 20 | [assembly: AssemblyTrademark("")] 21 | 22 | [assembly: AssemblyCulture("")] 23 | // This sets the default COM visibility of types in the assembly to invisible. 24 | // If you need to expose a type to COM, use on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | // The assembly version has following format : 28 | // 29 | // Major.Minor.Build.Revision 30 | // 31 | // You can specify all values by your own or you can build default build and revision 32 | // numbers with the '*' character (the default): 33 | 34 | [assembly: AssemblyVersion("1.0.*")] 35 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/LuaAddin.addin: -------------------------------------------------------------------------------- 1 |  8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 34 | 35 | 36 | 37 | 41 | 42 | 43 | 44 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/Resources/Pad.xfrm: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/Src/MyUserControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows.Forms; 4 | // 5 | // Created by SharpDevelop. 6 | // User: elijah 7 | // Date: 05/20/2011 8 | // Time: 8:45 PM 9 | // 10 | // To change this template use Tools | Options | Coding | Edit Standard Headers. 11 | // 12 | using ICSharpCode.SharpDevelop.Gui.XmlForms; 13 | using System.IO; 14 | using System.Reflection; 15 | namespace SharpLua.SharpDevelop.AddIn 16 | { 17 | 18 | public class LuaPad : BaseSharpDevelopUserControl 19 | { 20 | 21 | public LuaPad() 22 | { 23 | System.IO.Stream StreamX = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SharpLua.SharpDevelop.AddIn.Pad.xfrm"); 24 | SetupFromXmlStream(StreamX); 25 | //AddHandler (Me.Get(Of Button)("test")).Click, AddressOf ButtonClick 26 | SetupWebPage(); 27 | } 28 | 29 | public void SetupWebPage() 30 | { 31 | WebBrowser WebBrowser = new WebBrowser(); 32 | WebBrowser.ScrollBarsEnabled = true; 33 | WebBrowser.ScriptErrorsSuppressed = true; 34 | WebBrowser.Parent = this; 35 | WebBrowser.Location = new System.Drawing.Point(19, 100); 36 | WebBrowser.Size = new System.Drawing.Size(this.Size.Width, this.Size.Height * 3); 37 | WebBrowser.Dock = DockStyle.Fill; 38 | WebBrowser.Navigate("http://www.lua.org/about.html"); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/Src/TestPad.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows.Forms; 4 | // 5 | // Created by SharpDevelop. 6 | // User: elijah 7 | // Date: 05/20/2011 8 | // Time: 8:45 PM 9 | // 10 | // To change this template use Tools | Options | Coding | Edit Standard Headers. 11 | // 12 | using ICSharpCode.Core; 13 | using ICSharpCode.SharpDevelop.Gui; 14 | namespace SharpLua.SharpDevelop.AddIn 15 | { 16 | 17 | /// 18 | /// Description of the pad content 19 | /// 20 | public class TestPad : AbstractPadContent 21 | { 22 | 23 | private LuaPad ctl = new LuaPad(); 24 | 25 | /// 26 | /// Creates a new TestPad object 27 | /// 28 | public TestPad() 29 | { 30 | //ctl = new LuaPad() 31 | } 32 | 33 | /// 34 | /// The representing the pad 35 | /// 36 | public override object Control { 37 | get { return ctl; } 38 | } 39 | 40 | /// 41 | /// Refreshes the pad 42 | /// 43 | public void RedrawContent() 44 | { 45 | // TODO: Refresh the whole pad control here, renew all resource strings, whatever 46 | // Note that you do not need to recreate the control. 47 | } 48 | 49 | /// 50 | /// Cleans up all used resources 51 | /// 52 | public override void Dispose() 53 | { 54 | ctl.Dispose(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/Templates/Lua.xft: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/Templates/SharpLua.xft: -------------------------------------------------------------------------------- 1 |  2 | -------------------------------------------------------------------------------- /OLD.SharpLua/SharpLuaAddIn/Templates/SharpLuaClass.xft: -------------------------------------------------------------------------------- 1 |  2 | 23 | 24 | -------------------------------------------------------------------------------- /OLD.SharpLua/TODO.txt: -------------------------------------------------------------------------------- 1 | TODO 2 | - Documentation 3 | - compression library (separate project), using IExtendFramework 4 | - error: error level also 5 | - set "..." to command line args in _G 6 | - Lists 7 | - new icon 8 | - automatically save and load environments 9 | - serialize functions, userdata, etc. May need to create a new serializer. 10 | - Fix script.call 11 | - test SharpLua.Web.TestPages (yes, they are untested. i dont have access to c:\inetpub for some reason...) -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | SharpLua 2.0 is a combination of a port of Lua 5.1.5, various interfaces, but will be eventually replaced by new, better, code. 2 | Why did I start with a Lua 5.1.5 C port? because... You Can't Get More Accurate Than The Original (TM), and the C api allows easier porting of C libs. 3 | 4 | 5 | SharpLua is an implementation of Lua for .NET 6 | It can run lua files including bytecode (compatible with native Lua), create .NET objects and call methods on them (including static methods), and 7 | supports all standard lua functions. It does not support C Libraries. 8 | 9 | To use in your projects, just add a reference to the SharpLua.dll file and use the 10 | SharpLua.LuaInterface class or the SharpLua.LuaRuntime, SharpLua.Lua is the raw Lua API. 11 | 12 | NOTE: If you simplify the AST, you CAN NOT use a reconstructor that operates on the tokens unless you patch the tokens, as the Simplification process does not do that 13 | 14 | Features Lua 5.1.5 doesn't have: 15 | - table.unpack (similar to _G.unpack) 16 | - a large extension library 17 | - clr library (allows .NET object access) 18 | - Syntax extensions 19 | - ! (not) 20 | - >> (right shift) 21 | - << (left shift) 22 | - & (bitwise and) 23 | - | (bitwise or) 24 | - ^^ (Xor) 25 | - ~(bitwise not) 26 | - using/do statements 27 | - named functions in tables (e.g. { function x() end }) 28 | 29 | Current projects: 30 | SharpLua The SharpLua core, along with a LASM library 31 | SharpLua.Interactive SharpLua REPL 32 | SharpLua.InterfacingTests SharpLua interfacing tests. As apposed to using the raw Lua API. 33 | SharpLua.Compiler SharpLua bytecode compiler 34 | 35 | Future projects: 36 | SharpLua.Decompiler SharpLua bytecode decompiler 37 | SharpLua.Web Web handler for #Lua 38 | SharpLua SharpDevelop AddIn Support SharpLua/Lua files and projects, GUI 39 | designer, and msbuild project builder 40 | SharpLua Wpf support -------------------------------------------------------------------------------- /Scripts/GenerateDocumentationAndBuildAddIn.bat: -------------------------------------------------------------------------------- 1 | ..\GenerateDocumentation\bin\Debug\GenerateDocumentation.exe Documentation.slua 2 | copy Documentation.xml ..\SharpLuaAddIn 3 | cd ..\SharpLuaAddIn 4 | msbuild /m 5 | :: msbuild /m /t:rebuild -------------------------------------------------------------------------------- /Scripts/generateIntellisense.bat: -------------------------------------------------------------------------------- 1 | ..\sharplua.interactive\bin\debug\sharplua.interactive generateIntellisense.slua -NOI >generatedIntellisense.txt -------------------------------------------------------------------------------- /Scripts/generateIntellisense.slua: -------------------------------------------------------------------------------- 1 | scanned = { 2 | -- Put things that shouldn't be in intellisense here. 3 | packageName = true, 4 | decompile = true, 5 | arg = true, 6 | [-1] = true, 7 | [0] = true, 8 | n = true, 9 | [3] = true, 10 | ["..."] = true, 11 | TestModule = true, 12 | PrintHi = true, 13 | TestModule2 = true, 14 | test = true, 15 | DEBUG = true, 16 | set_global_mt = true, 17 | scanned = true, 18 | } 19 | 20 | for k, v in pairs(_G) do 21 | if not scanned[k] then 22 | scanned[k] = true 23 | print("new CompletionItem(\"" .. k .. "\"), ") 24 | if type(v) == "table" then 25 | for k2, v2 in pairs(v) do 26 | if not scanned[k2] then 27 | print("new CompletionItem(\"" .. k2 .. "\"), ") 28 | scanned[k2] = true 29 | end 30 | end 31 | print"" 32 | end 33 | end 34 | end 35 | -------------------------------------------------------------------------------- /SharpLua.AlmostADebugger/Core.lua: -------------------------------------------------------------------------------- 1 | clr.load"SharpLua.LASM" 2 | lasm = luanet.namespace"SharpLua.LASM" 3 | dis = lasm.Disassembler 4 | assert(dis, "Could not load LASM Disassembler!") 5 | 6 | local func = nil 7 | function Load(s) 8 | local a = loadstring(s) 9 | func = a 10 | if a then 11 | return a, dis.Disassemble(string.dump(a)) 12 | else 13 | return a 14 | end 15 | end -------------------------------------------------------------------------------- /SharpLua.AlmostADebugger/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Windows.Forms; 5 | 6 | namespace SharpLua.AlmostADebugger 7 | { 8 | static class Program 9 | { 10 | /// 11 | /// The main entry point for the application. 12 | /// 13 | [STAThread] 14 | static void Main() 15 | { 16 | Application.EnableVisualStyles(); 17 | Application.SetCompatibleTextRenderingDefault(false); 18 | Console.WriteLine("Initializing GUI..."); 19 | LuaRuntime.Run(System.IO.File.ReadAllText("Core.lua")); 20 | Application.Run(new Form1()); 21 | Console.WriteLine("Exiting..."); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SharpLua.AlmostADebugger/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SharpLua.AlmostADebugger")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("SharpLua.AlmostADebugger")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1ef25505-0ca3-4558-ba67-0cd75ec882d3")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SharpLua.AlmostADebugger/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.17929 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace SharpLua.AlmostADebugger.Properties 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SharpLua.AlmostADebugger/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SharpLua.Compiler/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SharpLua.Compiler")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("SharpLua.Compiler")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("00a124af-9a2c-4b90-af06-6ed6fc215a5a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SharpLua.Interactive/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SharpLua.Interactive")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("SharpLua.Interactive")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("3ab383a1-a27c-4975-b0df-5febb95cd706")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SharpLua.InterfacingTests/Entity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace LuaInterface.Tests 6 | { 7 | public class Entity 8 | { 9 | public event EventHandler Clicked; 10 | 11 | protected virtual void OnEntityClicked(EventArgs e) 12 | { 13 | EventHandler handler = Clicked; 14 | 15 | if (handler != null) 16 | { 17 | // Use the () operator to raise the event. 18 | handler(this, e); 19 | } 20 | } 21 | 22 | public Entity() 23 | { 24 | 25 | } 26 | 27 | public void Click() 28 | { 29 | OnEntityClicked(new EventArgs()); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SharpLua.InterfacingTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SharpLua.InterfacingTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("SharpLua.InterfacingTests")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("4e7445cb-0545-408f-8f29-516411f05ce8")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SharpLua.InterfacingTests/test.lua: -------------------------------------------------------------------------------- 1 | width=100 2 | height=200 3 | message="Hello World!" 4 | color={r=100,g=20,b=50} 5 | tree={branch1={leaf1=10,leaf2="leaf2"},leaf3="leaf3"} 6 | 7 | function func(x,y) 8 | return x,x+y 9 | end 10 | 11 | -------------------------------------------------------------------------------- /SharpLua.LASMTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SharpLua.LASMTests")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("KPBSD")] 12 | [assembly: AssemblyProduct("SharpLua.LASMTests")] 13 | [assembly: AssemblyCopyright("Copyright © KPBSD 2012")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("7848530d-fb9b-4ad7-9069-32d9c3283b73")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /SharpLua.NewCompilerTests/Program.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * Created by SharpDevelop. 3 | * User: enoch 4 | * Date: 11/3/2012 5 | * Time: 5:41 PM 6 | * 7 | * To change this template use Tools | Options | Coding | Edit Standard Headers. 8 | */ 9 | using System; 10 | using System.IO; 11 | using System.Text; 12 | using SharpLua.Ast; 13 | using SharpLua.LASM; 14 | 15 | namespace SharpLua.NewCompilerTests 16 | { 17 | class Program 18 | { 19 | public static void Main(string[] args) 20 | { 21 | while (true) 22 | { 23 | try 24 | { 25 | string s = Console.ReadLine(); 26 | Lexer l = new Lexer(); 27 | Parser p = new Parser(l.Lex(s)); 28 | Ast.Chunk c = p.Parse(); 29 | Compiler.Compiler cplr = new SharpLua.Compiler.Compiler(); 30 | LuaFile proto = cplr.Compile(c, ""); 31 | Console.WriteLine("compiled!"); 32 | FileStream fs = File.Open("out.sluac", FileMode.Create); 33 | foreach (char ch in proto.Compile()) 34 | { 35 | //Console.WriteLine(ch + " " + (int)ch); 36 | fs.WriteByte((byte)ch); 37 | } 38 | fs.Close(); 39 | Console.WriteLine("written to out.sluac!"); 40 | } 41 | catch (Exception ex) 42 | { 43 | Console.WriteLine(ex.ToString()); 44 | } 45 | } 46 | Console.Write("Press any key to continue . . . "); 47 | Console.ReadKey(true); 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /SharpLua.NewCompilerTests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region Using directives 2 | 3 | using System; 4 | using System.Reflection; 5 | using System.Runtime.InteropServices; 6 | 7 | #endregion 8 | 9 | // General Information about an assembly is controlled through the following 10 | // set of attributes. Change these attribute values to modify the information 11 | // associated with an assembly. 12 | [assembly: AssemblyTitle("SharpLua.NewCompilerTests")] 13 | [assembly: AssemblyDescription("")] 14 | [assembly: AssemblyConfiguration("")] 15 | [assembly: AssemblyCompany("")] 16 | [assembly: AssemblyProduct("SharpLua.NewCompilerTests")] 17 | [assembly: AssemblyCopyright("Copyright 2012")] 18 | [assembly: AssemblyTrademark("")] 19 | [assembly: AssemblyCulture("")] 20 | 21 | // This sets the default COM visibility of types in the assembly to invisible. 22 | // If you need to expose a type to COM, use [ComVisible(true)] on that type. 23 | [assembly: ComVisible(false)] 24 | 25 | // The assembly version has following format : 26 | // 27 | // Major.Minor.Build.Revision 28 | // 29 | // You can specify all the values or you can use the default the Revision and 30 | // Build Numbers by using the '*' as shown below: 31 | [assembly: AssemblyVersion("1.0.*")] 32 | -------------------------------------------------------------------------------- /SharpLua/Defines.txt: -------------------------------------------------------------------------------- 1 | This file describes some the DEFINEs that you can edit. 2 | 3 | OVERRIDE_LOAD 4 | This is unnecessary, as it is ignored. 5 | It should define whether #Lua overrides the default parser to allow its syntax 6 | extensions to be used. 7 | 8 | IMPLICIT_VARARG 9 | This defines whether all functions are implicitly vararg or not. 10 | This is somewhat javascript-style, as js has implicit varargs. 11 | It is enabled by default. If LUA_COMPAT_VARARG is also enabled, it defines the 'arg' variable 12 | 13 | LUA_COMPAT_VARARG 14 | Whether vararg functions have an implicit 'arg' variable 15 | 16 | VANILLA_LUA 17 | Whether the parser in the NewParser folder should have the extended #Lua syntax or 18 | just plain Lua syntax. It should not be defined, but if you wish to re-use a lua parser 19 | somewhere else, it can be defined. -------------------------------------------------------------------------------- /SharpLua/Interfacing/LuaBase.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace SharpLua 6 | { 7 | /// 8 | /// Base class to provide consistent disposal flow across lua objects. Uses code provided by Yves Duhoux and suggestions by Hans Schmeidenbacher and Qingrui Li 9 | /// 10 | public abstract class LuaBase : IDisposable 11 | { 12 | private bool _Disposed; 13 | protected int _Reference; 14 | protected LuaInterface _Interpreter; 15 | 16 | ~LuaBase() 17 | { 18 | Dispose(false); 19 | } 20 | 21 | public void Dispose() 22 | { 23 | Dispose(true); 24 | GC.SuppressFinalize(this); 25 | } 26 | 27 | public virtual void Dispose(bool disposeManagedResources) 28 | { 29 | if (!_Disposed) 30 | { 31 | if (disposeManagedResources) 32 | { 33 | if (_Reference != 0) 34 | _Interpreter.dispose(_Reference); 35 | } 36 | _Interpreter = null; 37 | _Disposed = true; 38 | } 39 | } 40 | 41 | public override bool Equals(object o) 42 | { 43 | if (o is LuaBase) 44 | { 45 | LuaBase l = (LuaBase)o; 46 | return _Interpreter.compareRef(l._Reference, _Reference); 47 | } 48 | else return false; 49 | } 50 | 51 | public override int GetHashCode() 52 | { 53 | return _Reference; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SharpLua/Interfacing/LuaException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace SharpLua 5 | { 6 | /// 7 | /// Exceptions thrown by the Lua runtime 8 | /// 9 | [Serializable] 10 | public class LuaException : Exception 11 | { 12 | public LuaException() 13 | { } 14 | 15 | public LuaException(string message) 16 | : base(message) 17 | { } 18 | 19 | public LuaException(string message, Exception innerException) 20 | : base(message, innerException) 21 | { } 22 | 23 | protected LuaException(SerializationInfo info, StreamingContext context) 24 | : base(info, context) 25 | { } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SharpLua/Interfacing/LuaFunctionAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua 7 | { 8 | /// 9 | /// Defines a function for use in a SharpLua module that has the 10 | /// ModuleAttribute applied to the class. If the name is not specified, 11 | /// it defaults to the method name 12 | /// 13 | [AttributeUsage(AttributeTargets.Method)] 14 | public class LuaFunctionAttribute : Attribute 15 | { 16 | public string FunctionName { get; internal set; } 17 | 18 | public LuaFunctionAttribute(string name) 19 | { 20 | FunctionName = name; 21 | } 22 | 23 | public LuaFunctionAttribute() 24 | { 25 | FunctionName = ""; 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /SharpLua/Interfacing/LuaGlobalAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SharpLua 4 | { 5 | /// 6 | /// Marks a method for global usage in Lua scripts 7 | /// 8 | /// 9 | /// 10 | [AttributeUsage(AttributeTargets.Method)] 11 | // sealed 12 | public class LuaGlobalAttribute : Attribute 13 | { 14 | private string name, descript; 15 | /// 16 | /// An alternative name to use for calling the function in Lua - leave empty for CLR name 17 | /// 18 | public string Name { get { return name; } set { name = value; } } 19 | 20 | /// 21 | /// A description of the function 22 | /// 23 | public string Description { get { return descript; } set { descript = value; } } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SharpLua/Interfacing/LuaHideAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SharpLua 4 | { 5 | /// 6 | /// Marks a method, field or property to be hidden from Lua auto-completion 7 | /// 8 | [AttributeUsage(AttributeTargets.Method | AttributeTargets.Field | AttributeTargets.Property)] 9 | public sealed class LuaHideAttribute : Attribute 10 | { } 11 | } 12 | -------------------------------------------------------------------------------- /SharpLua/Interfacing/LuaModuleAttribute.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua 7 | { 8 | /// 9 | /// Defines a module for use in SharpLua. If the module name is not specified, 10 | /// it defaults to the class name 11 | /// 12 | [AttributeUsage(AttributeTargets.Class)] 13 | public class LuaModuleAttribute : Attribute 14 | { 15 | public string ModuleName { get; internal set; } 16 | 17 | public LuaModuleAttribute(string name) 18 | { 19 | ModuleName = name; 20 | } 21 | 22 | public LuaModuleAttribute() 23 | { 24 | ModuleName = ""; 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SharpLua/Interfacing/LuaScriptException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SharpLua 4 | { 5 | /// 6 | /// Exceptions thrown by the Lua runtime because of errors in the script 7 | /// 8 | public class LuaScriptException : LuaException 9 | { 10 | private bool isNet; 11 | /// 12 | /// Returns true if the exception has occured as the result of a .NET exception in user code 13 | /// 14 | public bool IsNetException 15 | { 16 | get { return isNet; } 17 | set { isNet = value; } 18 | } 19 | 20 | private readonly string source; 21 | 22 | /// 23 | /// The position in the script where the exception was triggered. 24 | /// 25 | public override string Source { get { return source; } } 26 | 27 | /// 28 | /// Creates a new Lua-only exception. 29 | /// 30 | /// The message that describes the error. 31 | /// The position in the script where the exception was triggered. 32 | public LuaScriptException(string message, string source) 33 | : base(message) 34 | { 35 | this.source = source; 36 | } 37 | 38 | /// 39 | /// Creates a new .NET wrapping exception. 40 | /// 41 | /// The .NET exception triggered by user-code. 42 | /// The position in the script where the exception was triggered. 43 | public LuaScriptException(Exception innerException, string source) 44 | : base(innerException.Message, innerException) 45 | { 46 | this.source = source; 47 | this.IsNetException = true; 48 | } 49 | 50 | public override string ToString() 51 | { 52 | // Prepend the error source 53 | return GetType().FullName + ": " + source + Message; 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SharpLua/LASM/Enums.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.LASM 7 | { 8 | public enum Vararg 9 | { 10 | VARARG_NOVARARG = 0, 11 | VARARG_HASARG = 1, 12 | VARARG_ISVARARG = 2, 13 | VARARG_NEEDSARG = 4, 14 | } 15 | 16 | public enum Format 17 | { 18 | Official, 19 | Unofficial, 20 | } 21 | 22 | public enum ConstantType 23 | { 24 | Nil = 0, 25 | Bool = 1, 26 | Number = 3, 27 | String = 4, 28 | } 29 | 30 | public enum OpcodeType 31 | { 32 | ABC, //ABC 33 | ABx, //ABx 34 | AsBx //AsBx 35 | }; 36 | } -------------------------------------------------------------------------------- /SharpLua/LASM/LASM.txt: -------------------------------------------------------------------------------- 1 | LASM (Lua Assembly) is used to write Lua bytecode. 2 | I hope to write more information about it later. 3 | 4 | Controls: 5 | [] - Optional 6 | 7 | .const Value 8 | Value = "String", true/false/nil, Number 9 | .local Name 10 | StartPC, EndPC = 0, 0 11 | .upval Name 12 | .upvalue Name 13 | .stacksize Value 14 | .maxstacksize value 15 | .vararg 16 | .name Name 17 | .options 18 | 19 | .func [name] 20 | .function [name] 21 | .end 22 | 23 | Opcodes: 24 | 25 | -------------------------------------------------------------------------------- /SharpLua/LASM/LuaFile.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace SharpLua.LASM 3 | { 4 | public class LuaFile 5 | { 6 | public string Identifier = (char)27 + "Lua"; 7 | public int Version = 0x51; 8 | public Format Format = Format.Official; 9 | public int FormatNumber = 0; 10 | public bool BigEndian = false; 11 | public int IntegerSize = 4; 12 | public int SizeT = 4; 13 | public int InstructionSize = 4; 14 | public int NumberSize = 8; 15 | public bool IsFloatingPointNumbers = true; 16 | public Chunk Main = new Chunk(); 17 | 18 | public LuaFile() { } 19 | 20 | public LuaFile(Lua.Proto p) 21 | { 22 | Main = new Chunk(p); 23 | } 24 | 25 | public string Compile() 26 | { 27 | string c = ""; 28 | c += Identifier; 29 | c += (char)Version; // Should be 0x51 30 | c += (char)(Format == Format.Official ? 0 : FormatNumber); 31 | c += (char)(BigEndian ? 0 : 1); 32 | c += (char)IntegerSize; 33 | c += (char)SizeT; 34 | c += (char)InstructionSize; 35 | c += (char)NumberSize; 36 | c += (char)(IsFloatingPointNumbers ? 0 : 1); 37 | // Main function 38 | c += Main.Compile(this); 39 | return c; 40 | } 41 | 42 | public void StripDebugInfo() 43 | { 44 | if (Main != null) 45 | Main.StripDebugInfo(); 46 | } 47 | 48 | public void Verify() 49 | { 50 | if (Main != null) 51 | Main.Verify(); 52 | } 53 | 54 | } 55 | } -------------------------------------------------------------------------------- /SharpLua/LuaCore/Libraries/lualib.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: lualib.h,v 1.36.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Lua standard libraries 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | 11 | namespace SharpLua 12 | { 13 | public partial class Lua 14 | { 15 | /* Key to file-handle type */ 16 | public const string LUA_FILEHANDLE = "FILE*"; 17 | 18 | public const string LUA_COLIBNAME = "coroutine"; 19 | public const string LUA_TABLIBNAME = "table"; 20 | public const string LUA_IOLIBNAME = "io"; 21 | public const string LUA_OSLIBNAME = "os"; 22 | public const string LUA_STRLIBNAME = "string"; 23 | public const string LUA_MATHLIBNAME = "math"; 24 | public const string LUA_DBLIBNAME = "debug"; 25 | public const string LUA_LOADLIBNAME = "package"; 26 | public const string LUA_BITLIBNAME = "bit"; 27 | public const string LUA_BITLIB32NAME = "bit32"; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /SharpLua/LuaCore/linit.cs: -------------------------------------------------------------------------------- 1 | /* 2 | ** $Id: linit.c,v 1.14.1.1 2007/12/27 13:02:25 roberto Exp $ 3 | ** Initialization of libraries for lua.c 4 | ** See Copyright Notice in lua.h 5 | */ 6 | 7 | using System; 8 | using System.Collections.Generic; 9 | using System.Text; 10 | 11 | namespace SharpLua 12 | { 13 | public partial class Lua 14 | { 15 | private readonly static luaL_Reg[] lualibs = { 16 | new luaL_Reg("", luaopen_base), 17 | new luaL_Reg(LUA_LOADLIBNAME, luaopen_package), 18 | new luaL_Reg(LUA_TABLIBNAME, luaopen_table), 19 | new luaL_Reg(LUA_IOLIBNAME, luaopen_io), 20 | new luaL_Reg(LUA_OSLIBNAME, luaopen_os), 21 | new luaL_Reg(LUA_STRLIBNAME, luaopen_string), 22 | new luaL_Reg(LUA_MATHLIBNAME, luaopen_math), 23 | new luaL_Reg(LUA_DBLIBNAME, luaopen_debug), 24 | new luaL_Reg(LUA_BITLIBNAME, luaopen_bit32), 25 | new luaL_Reg(LUA_BITLIB32NAME, luaopen_bit32), 26 | new luaL_Reg(null, null) 27 | }; 28 | 29 | 30 | public static void luaL_openlibs(LuaState L) 31 | { 32 | for (int i = 0; i < lualibs.Length - 1; i++) 33 | { 34 | luaL_Reg lib = lualibs[i]; 35 | lua_pushcfunction(L, lib.func); 36 | lua_pushstring(L, lib.name); 37 | lua_call(L, 1, 0); 38 | } 39 | } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/BinaryOperator.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast 7 | { 8 | public enum BinaryOperator 9 | { 10 | Add, // + 11 | Subtract, // - 12 | Multiply, // * 13 | Divide, // / 14 | Power, // ^ 15 | Modulus, // % 16 | Concat, // .. 17 | 18 | And, // and 19 | Or, // or 20 | LessThan, // < 21 | LessThanOrEqualTo, // <= 22 | GreaterThan, // > 23 | GreaterThanOrEqualTo, // >= 24 | NotEqual, // ~= 25 | Equals, // == 26 | 27 | ShiftRight, // >> 28 | ShiftLeft, // << 29 | Xor, // ** 30 | BitAnd, // & 31 | BitOr, // | 32 | BitNot, // ~ 33 | 34 | NONE = -1, 35 | } 36 | 37 | public enum UnaryOperator 38 | { 39 | Not, // !, not 40 | Length, // # 41 | BitNot, // ~ 42 | Negate, // - 43 | UnNegate, // + 44 | 45 | NONE = -1, 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Chunk.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast 7 | { 8 | public class Chunk : Statement.Statement 9 | { 10 | public List Body = new List(); 11 | 12 | public Chunk() 13 | { 14 | 15 | } 16 | 17 | public Chunk(Scope s) 18 | { 19 | Scope = s; 20 | } 21 | 22 | public override Statement.Statement Simplify() 23 | { 24 | for (int i = 0; i < Body.Count; i++) 25 | Body[i] = Body[i].Simplify(); 26 | 27 | return this; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/AnonymousFunctionExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class AnonymousFunctionExpr : Expression 9 | { 10 | public List Body = null; 11 | public bool IsVararg = false; 12 | public List Arguments = new List(); 13 | 14 | public override Expression Simplify() 15 | { 16 | for (int i = 0; i < Body.Count; i++) 17 | Body[i] = Body[i].Simplify(); 18 | 19 | if (Refactoring.CanInline(this)) 20 | return Refactoring.InlineFunction(this).Simplify(); // Simplify call here may be redundant 21 | 22 | return this; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/BoolExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class BoolExpr : Expression 9 | { 10 | public bool Value = false; 11 | 12 | public BoolExpr() { } 13 | public BoolExpr(bool value) { Value = value; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/CallExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class CallExpr : Expression 9 | { 10 | public Expression Base = null; 11 | public List Arguments = new List(); 12 | 13 | public override Expression Simplify() 14 | { 15 | Base = Base.Simplify(); 16 | for (int i = 0; i < Arguments.Count; i++) 17 | Arguments[i] = Arguments[i].Simplify(); 18 | return this; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/Expression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public abstract class Expression 9 | { 10 | public int ParenCount = 0; 11 | public Scope Scope = null; 12 | 13 | public virtual Expression Simplify() 14 | { 15 | return this; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/IndexExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class IndexExpr : Expression 9 | { 10 | public Expression Base = null; 11 | public Expression Index = null; 12 | 13 | public override Expression Simplify() 14 | { 15 | Base = base.Simplify(); 16 | Index = Index.Simplify(); 17 | 18 | return this; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/InlineFunctionStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class InlineFunctionExpression : Expression 9 | { 10 | public List Expressions = new List(); 11 | public bool IsVararg = false; 12 | public List Arguments = new List(); 13 | 14 | public override Expression Simplify() 15 | { 16 | for (int i = 0; i < Expressions.Count; i++) 17 | Expressions[i] = Expressions[i].Simplify(); 18 | 19 | return this; 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/MemberExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class MemberExpr : Expression 9 | { 10 | public Expression Base = null; 11 | public string Indexer = ""; // either '.' or ':' 12 | public string Ident = ""; 13 | 14 | public override Expression Simplify() 15 | { 16 | Base = Base.Simplify(); 17 | return this; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/NilExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class NilExpr : Expression 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/NumberExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class NumberExpr : Expression 9 | { 10 | public string Value; 11 | 12 | public NumberExpr() { } 13 | public NumberExpr(string value) { Value = value; } 14 | public NumberExpr(double value) { Value = value.ToString(); } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/StringCallExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class StringCallExpr : CallExpr 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/StringExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class StringExpr : Expression 9 | { 10 | public string Value; 11 | public TokenType StringType; 12 | 13 | 14 | public StringExpr() 15 | { 16 | Value = ""; 17 | } 18 | 19 | public StringExpr(string v) 20 | { 21 | Value = v; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/TableCallExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class TableCallExpr : CallExpr 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/TableConstructorExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class TableConstructorExpr : Expression 9 | { 10 | public List EntryList = new List(); 11 | 12 | public override Expression Simplify() 13 | { 14 | for (int i = 0; i < EntryList.Count; i++) 15 | EntryList[i] = EntryList[i].Simplify(); 16 | 17 | return this; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/TableConstructorKeyExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class TableConstructorKeyExpr : Expression 9 | { 10 | public Expression Key = null; 11 | public Expression Value = null; 12 | 13 | public override Expression Simplify() 14 | { 15 | Key = Key.Simplify(); 16 | Value = Value.Simplify(); 17 | return this; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/TableConstructorNamedFunctionExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua.Ast.Statement; 6 | 7 | namespace SharpLua.Ast.Expression 8 | { 9 | public class TableConstructorNamedFunctionExpr : Expression 10 | { 11 | public FunctionStatement Value; 12 | 13 | public override Expression Simplify() 14 | { 15 | Value.Simplify(); // FunctionStatements do not simplify into something else 16 | return this; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/TableConstructorStringKeyExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class TableConstructorStringKeyExpr : Expression 9 | { 10 | public string Key = ""; 11 | public Expression Value = null; 12 | 13 | public override Expression Simplify() 14 | { 15 | Value = Value.Simplify(); 16 | return this; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/TableConstructorValueExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class TableConstructorValueExpr : Expression 9 | { 10 | public Expression Value = null; 11 | 12 | public override Expression Simplify() 13 | { 14 | Value = Value.Simplify(); 15 | return this; 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/UnOpExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class UnOpExpr : Expression 9 | { 10 | public Expression Rhs = null; 11 | public string Op = ""; 12 | 13 | public UnaryOperator GetOperator() 14 | { 15 | if (Op == "!" || Op == "not") 16 | return UnaryOperator.Not; 17 | else if (Op == "#") 18 | return UnaryOperator.Length; 19 | else if (Op == "~") 20 | return UnaryOperator.BitNot; 21 | else if (Op == "-") 22 | return UnaryOperator.Negate; 23 | else if (Op == "+") 24 | return UnaryOperator.UnNegate; 25 | else 26 | return UnaryOperator.NONE; 27 | } 28 | 29 | public override Expression Simplify() 30 | { 31 | Rhs = Rhs.Simplify(); 32 | UnaryOperator unop = GetOperator(); 33 | if (Rhs is NumberExpr) 34 | { 35 | if (unop == UnaryOperator.Negate) 36 | return new NumberExpr("-" + ((NumberExpr)Rhs).Value); 37 | else if (unop == UnaryOperator.UnNegate) 38 | { 39 | double res; 40 | if (Lua.luaO_str2d(((NumberExpr)Rhs).Value, out res) == 1) 41 | { 42 | return new NumberExpr(Math.Abs(res)); 43 | } 44 | } 45 | } 46 | else if (Rhs is BoolExpr) 47 | if (unop == UnaryOperator.Not) 48 | return new BoolExpr(!((BoolExpr)Rhs).Value); 49 | 50 | return this; 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/VarargExpr.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class VarargExpr : Expression 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Expression/VariableExpression.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Expression 7 | { 8 | public class VariableExpression : Expression 9 | { 10 | public Variable Var; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/AssignmentStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class AssignmentStatement : Statement 9 | { 10 | public List Lhs = new List(); 11 | public List Rhs = new List(); 12 | public bool IsLocal = false; 13 | 14 | public override Statement Simplify() 15 | { 16 | for (int i = 0; i < Lhs.Count; i++) 17 | Lhs[i] = Lhs[i].Simplify(); 18 | for (int i = 0; i < Rhs.Count; i++) 19 | Rhs[i] = Rhs[i].Simplify(); 20 | return base.Simplify(); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/AugmentedAssignmentStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | /// 9 | /// This way we know that the first BinOpExpr's Op is used in the assignment. 10 | /// 11 | public class AugmentedAssignmentStatement : AssignmentStatement 12 | { 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/BreakStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class BreakStatement : Statement 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/CallStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class CallStatement : Statement 9 | { 10 | // Is a CallExpr 11 | public Expression.Expression Expression = null; 12 | 13 | public override Statement Simplify() 14 | { 15 | Expression = Expression.Simplify(); 16 | return base.Simplify(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/ContinueStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class ContinueStatement : Statement 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/DoStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class DoStatement : Chunk 9 | { 10 | public DoStatement(Scope s) 11 | : base(new Scope(s)) 12 | { 13 | 14 | } 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/ForStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class NumericForStatement : Chunk 9 | { 10 | public Variable Variable = null; 11 | public Expression.Expression Start = null; 12 | public Expression.Expression End = null; 13 | public Expression.Expression Step = null; 14 | 15 | public NumericForStatement(Scope s) 16 | : base(new Scope(s)) 17 | { 18 | 19 | } 20 | 21 | public override Statement Simplify() 22 | { 23 | Start = Start.Simplify(); 24 | End = End.Simplify(); 25 | Step = Step.Simplify(); 26 | return base.Simplify(); 27 | } 28 | } 29 | 30 | public class GenericForStatement : Chunk 31 | { 32 | public List VariableList = null; 33 | public List Generators = null; 34 | 35 | public GenericForStatement(Scope s) 36 | : base(new Scope(s)) 37 | { 38 | 39 | } 40 | 41 | public override Statement Simplify() 42 | { 43 | for (int i = 0; i < Generators.Count; i++) 44 | Generators[i] = Generators[i].Simplify(); 45 | return base.Simplify(); 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/FunctionStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class FunctionStatement : Chunk 9 | { 10 | public bool IsLocal = false; 11 | public bool IsVararg = false; 12 | public List Arguments = new List(); 13 | public Expression.Expression Name = null; 14 | 15 | public FunctionStatement(Scope s) 16 | : base(s) 17 | { 18 | 19 | } 20 | 21 | public override Statement Simplify() 22 | { 23 | Name = Name.Simplify(); 24 | return base.Simplify(); 25 | } 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/GotoStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class GotoStatement : Statement 9 | { 10 | public string Label = ""; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/IfStmt.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class IfStmt : Chunk 9 | { 10 | public List Clauses = new List(); 11 | 12 | public override Statement Simplify() 13 | { 14 | for (int i = 0; i < Clauses.Count; i++) 15 | Clauses[i].Simplify(); 16 | return base.Simplify(); 17 | } 18 | } 19 | 20 | public abstract class SubIfStmt : Chunk 21 | { 22 | public SubIfStmt(Scope s) 23 | : base(s) 24 | { 25 | 26 | } 27 | } 28 | 29 | public class ElseIfStmt : SubIfStmt 30 | { 31 | public Expression.Expression Condition = null; 32 | 33 | public ElseIfStmt(Scope s) 34 | : base(new Scope(s)) 35 | { 36 | 37 | } 38 | 39 | public override Statement Simplify() 40 | { 41 | Condition = Condition.Simplify(); 42 | return base.Simplify(); 43 | } 44 | } 45 | 46 | public class ElseStmt : SubIfStmt 47 | { 48 | public ElseStmt(Scope s) 49 | : base(new Scope(s)) 50 | { 51 | 52 | } 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/LabelStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class LabelStatement : Statement 9 | { 10 | public string Label = ""; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/RepeatStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class RepeatStatement : Chunk 9 | { 10 | public Expression.Expression Condition = null; 11 | 12 | public RepeatStatement(Scope s) 13 | : base(new Scope(s)) 14 | { 15 | 16 | } 17 | 18 | public override Statement Simplify() 19 | { 20 | Condition = Condition.Simplify(); 21 | return base.Simplify(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/ReturnStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class ReturnStatement : Statement 9 | { 10 | public List Arguments = null; 11 | 12 | public override Statement Simplify() 13 | { 14 | for (int i = 0; i < Arguments.Count; i++) 15 | Arguments[i] = Arguments[i].Simplify(); 16 | return base.Simplify(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/Statement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public abstract class Statement 9 | { 10 | public Scope Scope = null; 11 | public bool HasSemicolon = false; 12 | public int LineNumber = 0; 13 | 14 | public List ScannedTokens = new List(); 15 | public Token SemicolonToken; 16 | 17 | public virtual Statement Simplify() 18 | { 19 | return this; 20 | } 21 | } 22 | 23 | } 24 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/UsingStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class UsingStatement : Chunk 9 | { 10 | public AssignmentStatement Vars = null; 11 | 12 | public UsingStatement(Scope s) 13 | : base(new Scope(s)) 14 | { 15 | 16 | } 17 | 18 | public override Statement Simplify() 19 | { 20 | Vars.Simplify(); 21 | return base.Simplify(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Statement/WhileStatement.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast.Statement 7 | { 8 | public class WhileStatement : Chunk 9 | { 10 | public Expression.Expression Condition = null; 11 | 12 | public WhileStatement(Scope s) 13 | : base(new Scope(s)) 14 | { 15 | 16 | } 17 | 18 | public override Statement Simplify() 19 | { 20 | Condition = Condition.Simplify(); 21 | return base.Simplify(); 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Ast/Variable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Ast 7 | { 8 | public class Variable 9 | { 10 | public string Name; 11 | public bool IsGlobal = false; 12 | public int References = 0; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Compiler/AstToCodeMap.txt: -------------------------------------------------------------------------------- 1 |  2 | AnonymousFunctionExpr 3 | 4 | BinOpExpr 5 | Lhs 6 | Rhs 7 | 8 | 9 | BoolExpr 10 | Constant 11 | 12 | CallExpr 13 | 14 | 15 | CALL 16 | 17 | StringCallExpr 18 | 19 | 20 | CALL 2 21 | 22 | TableCallExpr 23 | 24 | 25 | CALL 2 26 | 27 | IndexExpr 28 | 29 | InlineFunctionExpr 30 | DoExpr(AnonymousFunctionExpr) 31 | -> function (, ) return end 32 | 33 | TableConstructorKeyExpr 34 | 35 | MemberExpr 36 | 37 | NilExpr 38 | 39 | NumberExpr 40 | Constant 41 | 42 | StringExpr 43 | Constant 44 | 45 | TableConstructorStringKeyExpr 46 | 47 | TableConstructorExpr 48 | 49 | UnOpExpr 50 | Rhs 51 | 52 | 53 | TableConstructorValueExpr 54 | 55 | VarargExpr 56 | 57 | VariableExpression 58 | 59 | AssignmentStatement 60 | Local 61 | 62 | Global 63 | 64 | AugmentedAssignmentStatement 65 | 66 | BreakStatement 67 | 68 | CallStatement 69 | 70 | DoStatement 71 | 72 | GenericForStatement 73 | 74 | NumericForStatement 75 | 76 | FunctionStatement 77 | 78 | GotoStatement 79 | 80 | IfStmt 81 | 82 | LabelStatement 83 | 84 | RepeatStatement 85 | 86 | ReturnStatement 87 | 88 | UsingStatement 89 | 90 | WhileStatement 91 | 92 | ElseIfStmt 93 | 94 | ElseStmt 95 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Compiler/Block.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua.LASM; 6 | 7 | namespace SharpLua.Compiler 8 | { 9 | class Block 10 | { 11 | public bool IsLoop = false; 12 | public Block PreviousBlock = null; // 13 | 14 | public Chunk Chunk = null; 15 | 16 | public K2Reg K = null; 17 | public Var2Reg V = new Var2Reg(); 18 | 19 | public Block() 20 | { 21 | Chunk = new Chunk(); 22 | K = new K2Reg(this); 23 | } 24 | 25 | public Block(Block parent) 26 | { 27 | K = new K2Reg(this); 28 | //parent.PreviousBlock = this; 29 | this.PreviousBlock = parent; 30 | V = new Var2Reg(parent.V); 31 | Chunk = parent.Chunk; 32 | } 33 | 34 | public int regnum = 0; 35 | public int getreg() 36 | { 37 | //Console.WriteLine(regnum); 38 | return 39 | /*++*/ 40 | regnum 41 | ++ 42 | ; 43 | } 44 | 45 | public void CheckLocalName(string varname) 46 | { 47 | //if (V.has(varname)) 48 | //{ 49 | Local l = new Local(varname, 0, 0); 50 | if (Chunk.Locals.Any((L) => l.Name == varname)) 51 | return; 52 | Chunk.Locals.Add(l); 53 | //} 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Compiler/K2Reg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua.LASM; 6 | 7 | namespace SharpLua.Compiler 8 | { 9 | class K2Reg 10 | { 11 | public Dictionary dic = new Dictionary(); 12 | Block b = null; 13 | 14 | public int this[object o] 15 | { 16 | get 17 | { 18 | if (dic.ContainsKey(o)) 19 | return dic[o]; 20 | else 21 | { 22 | dic.Add(o, dic.Count); 23 | 24 | Constant con = new Constant((ConstantType)(-1), null); 25 | con.Value = o; 26 | con.Number = dic.Count - 1; 27 | 28 | if (o is string) 29 | { 30 | con.Type = ConstantType.String; 31 | } 32 | else if (o is double) 33 | con.Type = ConstantType.Number; 34 | else if (o is bool) 35 | con.Type = ConstantType.Bool; 36 | else if (o == null) 37 | { 38 | con.Type = ConstantType.Nil; 39 | } 40 | else 41 | throw new Exception("Invalid constant type '" + o.GetType().ToString() + "'!"); 42 | 43 | b.Chunk.Constants.Add(con); 44 | 45 | return dic[o]; 46 | } 47 | }/* 48 | set 49 | { 50 | dic[o] = value; 51 | }*/ 52 | } 53 | 54 | public K2Reg(Block b) 55 | { 56 | this.b = b; 57 | } 58 | 59 | public void Check(object o) 60 | { 61 | object tmp = this[o]; 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Compiler/Var2Reg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.Compiler 7 | { 8 | class Var2Reg 9 | { 10 | public Dictionary dic = new Dictionary(); 11 | 12 | public Var2Reg Parent = null; 13 | 14 | public int this[object o] 15 | { 16 | get 17 | { 18 | if (dic.ContainsKey(o)) 19 | return dic[o]; 20 | else if (Parent != null && Parent.has(o)) 21 | return Parent[o]; 22 | else 23 | { 24 | dic.Add(o, dic.Count); 25 | return dic[o]; 26 | } 27 | }/* 28 | set 29 | { 30 | dic[o] = value; 31 | }*/ 32 | } 33 | 34 | public bool has(object o) 35 | { 36 | return dic.ContainsKey(o) || (Parent != null && Parent.has(o)); 37 | } 38 | 39 | public Var2Reg() { } 40 | public Var2Reg(Var2Reg par) { Parent = par; } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Location.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua 7 | { 8 | public class Location 9 | { 10 | public int Line = 0; 11 | public int Column = 0; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /SharpLua/NewParser/LuaSourceException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace SharpLua 4 | { 5 | /// 6 | /// Lua script parsing error 7 | /// 8 | public class LuaSourceException : Exception 9 | { 10 | public int Line, Column; 11 | 12 | public LuaSourceException(int line, int col, string msg) 13 | : base(msg) 14 | { 15 | Line = line; 16 | Column = col; 17 | //Message = msg; 18 | } 19 | 20 | public string GenerateMessage(string filename) 21 | { 22 | return filename + ":" + Line + ":" + Column + ": " + Message; 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Refactoring/FindReferences.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua.Ast; 6 | using SharpLua.Ast.Expression; 7 | using SharpLua.Ast.Statement; 8 | 9 | namespace SharpLua 10 | { 11 | public partial class Refactoring 12 | { 13 | public static List FindReferences(Chunk c, Variable v) 14 | { 15 | throw new NotImplementedException(); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Refactoring/FindReferencesBeforeDefinition.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua.Ast; 6 | using SharpLua.Ast.Expression; 7 | using SharpLua.Ast.Statement; 8 | 9 | namespace SharpLua 10 | { 11 | //public partial class Refactoring 12 | //{ 13 | // public static void FindReferencesBeforeDefinition(Chunk c) 14 | // { 15 | // 16 | // } 17 | //} 18 | } 19 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Refactoring/FindUnusedVariables.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua.Ast; 6 | 7 | namespace SharpLua 8 | { 9 | public partial class Refactoring 10 | { 11 | public static List FindUnusedVariables(Chunk c) 12 | { 13 | List unused = new List(); 14 | foreach (Variable v in c.Scope.GetAllVariables()) 15 | { 16 | if (v.References == 0 // wait.. wut? 17 | || v.References == 1) 18 | unused.Add(v); 19 | } 20 | return unused; 21 | } 22 | 23 | public static List FindUnusedLocalVariables(Chunk c) 24 | { 25 | List unused = new List(); 26 | foreach (Variable v in c.Scope.GetAllVariables()) 27 | { 28 | if (v.References == 0 29 | || v.References == 1) 30 | if (v.IsGlobal == false) 31 | unused.Add(v); 32 | } 33 | return unused; 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Refactoring/InlineFunction.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using SharpLua.Ast; 6 | using SharpLua.Ast.Expression; 7 | using SharpLua.Ast.Statement; 8 | 9 | namespace SharpLua 10 | { 11 | public partial class Refactoring 12 | { 13 | public static bool CanInline(AnonymousFunctionExpr e) 14 | { 15 | if (e.Body.Count > 0 && e.Body[0] is ReturnStatement) 16 | return true; 17 | return false; 18 | } 19 | 20 | public static InlineFunctionExpression InlineFunction(AnonymousFunctionExpr e) 21 | { 22 | if (!CanInline(e)) 23 | throw new Exception("Cannot inline function!"); 24 | 25 | ReturnStatement rs = e.Body[0] as ReturnStatement; 26 | 27 | InlineFunctionExpression ife = new InlineFunctionExpression(); 28 | foreach (Variable v in e.Arguments) 29 | ife.Arguments.Add(v); 30 | ife.IsVararg = e.IsVararg; 31 | 32 | foreach (Expression expr in rs.Arguments) 33 | ife.Expressions.Add(expr); 34 | 35 | ife.Scope = e.Scope; 36 | rs.Scope = e.Scope; 37 | return ife; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /SharpLua/NewParser/StringExt.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * User: edfrederickson 3 | * Date: 10/8/2012 4 | * Time: 6:37 PM 5 | * Copyright 2012 LoDC 6 | */ 7 | using System; 8 | 9 | namespace SharpLua 10 | { 11 | /// 12 | /// string extensions 13 | /// 14 | public static class StringExt 15 | { 16 | public static string Repeat(this string s, int n) 17 | { 18 | string s2 = ""; 19 | for (int i = 0; i < n; i++) 20 | s2 += s; 21 | return s2; 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Todo.txt: -------------------------------------------------------------------------------- 1 | TODO: 2 | - Test it more 3 | - EmptyStatement (empty semicolon statement) 4 | - Ast2code 5 | - Write comments in LuaCompliantOutput 6 | - Add a LuaCompliantMiniOutput 7 | - Compiler -------------------------------------------------------------------------------- /SharpLua/NewParser/Token.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua 7 | { 8 | public class Token 9 | { 10 | public TokenType Type; 11 | /// 12 | /// Leading whitespace and comments 13 | /// 14 | public List Leading = new List(); 15 | /// 16 | /// Only value will be the EndOfStream token. 17 | /// 18 | public Token FollowingEoSToken = null; 19 | public string Data; 20 | public int Line, Column; 21 | 22 | public Location Location 23 | { 24 | get 25 | { 26 | return new Location() { Line = Line, Column = Column }; 27 | } 28 | } 29 | 30 | public Token() 31 | { 32 | Line = 0; 33 | Column = 0; 34 | Data = ""; 35 | Type = TokenType.UNKNOWN; 36 | } 37 | 38 | public string Print() 39 | { 40 | return "<" + Type.ToString() + ", Data='" + Data + "', LeadingCount = " + Leading.Count + ", Line/Col=" + Line + "/" + Column + ">"; 41 | } 42 | } 43 | 44 | public enum TokenType 45 | { 46 | UNKNOWN = -1, 47 | 48 | Keyword, 49 | Ident, 50 | 51 | Number, 52 | SingleQuoteString, 53 | DoubleQuoteString, 54 | LongString, 55 | 56 | Symbol, 57 | 58 | WhitespaceSpace, // ' ' 59 | WhitespaceTab, // \t 60 | WhitespaceN, // \n 61 | WhitespaceR, // \r 62 | ShortComment, 63 | DocumentationComment, 64 | LongComment, 65 | Shebang, 66 | 67 | EndOfStream, 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /SharpLua/NewParser/Visitors/FormattingOptions.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * User: elijah 3 | * Date: 10/19/2012 4 | * Time: 9:27 AM 5 | * Copyright 2012 LoDC 6 | */ 7 | using System; 8 | 9 | namespace SharpLua.Visitors 10 | { 11 | /// 12 | /// Options for when coverting an Ast back to Code 13 | /// 14 | public class FormattingOptions 15 | { 16 | public FormattingOptions() 17 | { 18 | EOL = "\r\n"; 19 | Tab = " "; 20 | TabsToSpaces = false; 21 | ConvertNewLines = false; 22 | } 23 | 24 | /// 25 | /// The End-Of-Line character(s) 26 | /// 27 | public string EOL { get; set; } 28 | /// 29 | /// The Tab character(s). Four spaces by default 30 | /// 31 | public string Tab { get; set; } 32 | /// 33 | /// Whether to convert Tabs to spaces or not (ExactReconstructor) 34 | /// 35 | public bool TabsToSpaces { get; set; } 36 | /// 37 | /// Whether to convert new lines to the FormattingOptions.EOL (ExactReconstructor) 38 | /// 39 | public bool ConvertNewLines { get; set; } 40 | 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /SharpLua/NewParser/XmlDocumentation/Documentation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Xml; 6 | 7 | namespace SharpLua.XmlDocumentation 8 | { 9 | public static class Documentation 10 | { 11 | public static List Read(string s) 12 | { 13 | XmlDocument doc = new XmlDocument(); 14 | doc.LoadXml(s); 15 | XmlNode n = doc.SelectSingleNode("/Documentation"); 16 | List ret = new List(); 17 | foreach (XmlNode n2 in n.ChildNodes) 18 | { 19 | DocumentationComment dc = new DocumentationComment(); 20 | dc.Ident = n2.Name; 21 | string s2 = n2.InnerText; 22 | string[] lines = s2.Split('\n'); 23 | foreach (string line in lines) 24 | dc.Lines.Add(line.Replace("\r", "").Replace("\n", "")); 25 | ret.Add(dc); 26 | } 27 | return ret; 28 | } 29 | 30 | public static string Write(List comments) 31 | { 32 | StringBuilder sb = new StringBuilder(); 33 | XmlWriter w = XmlWriter.Create(sb, new XmlWriterSettings() { Indent = true, IndentChars = " ", }); 34 | w.WriteStartElement("Documentation"); 35 | foreach (DocumentationComment cmt in comments) 36 | { 37 | w.WriteStartElement(cmt.Ident); 38 | w.WriteString(cmt.Text); 39 | w.WriteEndElement(); 40 | } 41 | w.WriteEndElement(); 42 | w.Flush(); 43 | w.Close(); 44 | return sb.ToString(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SharpLua/NewParser/XmlDocumentation/DocumentationComment.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace SharpLua.XmlDocumentation 7 | { 8 | public class DocumentationComment 9 | { 10 | public List Lines = new List(); 11 | public string Ident = null; 12 | public string EOL = "\r\n"; 13 | 14 | public string Text 15 | { 16 | get 17 | { 18 | StringBuilder sb = new StringBuilder(); 19 | foreach (string l in Lines) 20 | { 21 | string line = l.TrimStart(); 22 | if (line.Length > 3 && line.Substring(0, 3) == "---") 23 | line = line.Substring(3); 24 | sb.Append(line); 25 | sb.Append(EOL); 26 | } 27 | return sb.ToString(); 28 | } 29 | } 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /SharpLua/NewParser/XmlDocumentation/Format.txt: -------------------------------------------------------------------------------- 1 | Saved format: 2 | 3 | 4 | data 5 | 6 | -------------------------------------------------------------------------------- /SharpLua/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("SharpLua")] 9 | [assembly: AssemblyDescription("Lua implementation for .NET")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("LoDC")] 12 | [assembly: AssemblyProduct("SharpLua")] 13 | [assembly: AssemblyCopyright("Copyright © 2012 LoDC")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("1a9cd761-692f-40db-8566-c0217e5d3e0a")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("2.0.*")] 36 | [assembly: AssemblyFileVersion("2.0.0.0")] 37 | -------------------------------------------------------------------------------- /SharpLua/Resources/BuildResources.bat: -------------------------------------------------------------------------------- 1 | :: Build's the EmbeddedResource precompiled core scripts 2 | :: Run this whenever the core scripts are edited 3 | :: DebugInfo is stripped because: 4 | :: A - it results in a smaller file 5 | :: B - these scripts don't (...) have errors, so it doesn't matter 6 | @echo off 7 | 8 | :: Having a weird issue with this: 9 | :: ..\..\bin\sluac -s -o clrlib.sluac clrlib.slua 10 | 11 | ..\..\bin\sluac -o clrlib.sluac clrlib.slua 12 | ..\..\bin\sluac -s -o extlib.sluac extlib.slua 13 | ..\..\bin\sluac -s -o luanet.sluac luanet.slua 14 | 15 | if ERRORLEVEL 1 ( PAUSE ) -------------------------------------------------------------------------------- /SharpLua/Resources/clrlib.sluac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/SharpLua/Resources/clrlib.sluac -------------------------------------------------------------------------------- /SharpLua/Resources/extlib.sluac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/SharpLua/Resources/extlib.sluac -------------------------------------------------------------------------------- /SharpLua/Resources/luanet.slua: -------------------------------------------------------------------------------- 1 | local metatable = {} 2 | local rawget = rawget 3 | local import_type = luanet.import_type 4 | local load_assembly = luanet.load_assembly 5 | luanet.error, luanet.type = error, type 6 | -- Lookup a .NET identifier component. 7 | function metatable:__index(key) -- key is e.g. 'Form' 8 | -- Get the fully-qualified name, e.g. 'System.Windows.Forms.Form' 9 | local fqn = rawget(self,'.fqn') 10 | fqn = ((fqn and fqn .. '.') or '') .. key 11 | 12 | -- Try to find either a luanet function or a CLR type 13 | local obj = rawget(luanet,key) or import_type(fqn) 14 | 15 | -- If key is neither a luanet function or a CLR type, then it is simply 16 | -- an identifier component. 17 | if obj == nil then 18 | -- It might be an assembly, so we load it too. 19 | pcall(load_assembly,fqn) 20 | obj = { ['.fqn'] = fqn } 21 | setmetatable(obj, metatable) 22 | end 23 | 24 | -- Cache this lookup 25 | rawset(self, key, obj) 26 | return obj 27 | end 28 | 29 | -- A non-type has been called; e.g. foo = System.Foo() 30 | function metatable:__call(...) 31 | error('No such type: ' .. rawget(self,'.fqn'), 2) 32 | end 33 | 34 | -- This is the root of the .NET namespace 35 | luanet['.fqn'] = false 36 | setmetatable(luanet, metatable) 37 | 38 | -- Preload the mscorlib assembly 39 | luanet.load_assembly('mscorlib') 40 | -------------------------------------------------------------------------------- /SharpLua/Resources/luanet.sluac: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/SharpLua/Resources/luanet.sluac -------------------------------------------------------------------------------- /SharpLuaAddIn/Configuration/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows.Forms; 4 | using System.Reflection; 5 | using System.Runtime.CompilerServices; 6 | using System.Runtime.InteropServices; 7 | 8 | // Information about this assembly is defined by the following 9 | // attributes. 10 | // 11 | // change them to the information which is associated with the assembly 12 | // you compile. 13 | 14 | [assembly: AssemblyTitle("SharpLua.SharpDevelop.AddIn")] 15 | [assembly: AssemblyDescription("A #Lua Addin for Sharp Develop")] 16 | [assembly: AssemblyConfiguration("")] 17 | [assembly: AssemblyCompany("mlnlover11 Productions")] 18 | [assembly: AssemblyProduct("SharpLua.SharpDevelop.AddIn")] 19 | [assembly: AssemblyCopyright("Copyright (C) 2011 mlnlover11 Productions")] 20 | [assembly: AssemblyTrademark("")] 21 | 22 | [assembly: AssemblyCulture("")] 23 | // This sets the default COM visibility of types in the assembly to invisible. 24 | // If you need to expose a type to COM, use on that type. 25 | 26 | [assembly: ComVisible(false)] 27 | // The assembly version has following format : 28 | // 29 | // Major.Minor.Build.Revision 30 | // 31 | // You can specify all values by your own or you can build default build and revision 32 | // numbers with the '*' character (the default): 33 | 34 | [assembly: AssemblyVersion("1.0.*")] 35 | -------------------------------------------------------------------------------- /SharpLuaAddIn/Resources/Field.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/efrederickson/SharpLua/f515f9dc47deb81c7ded3107f7007be9299b1efd/SharpLuaAddIn/Resources/Field.png -------------------------------------------------------------------------------- /SharpLuaAddIn/Src/LuaLanguageBinding.cs: -------------------------------------------------------------------------------- 1 | /* 2 | * User: elijah 3 | * Date: 10/24/2012 4 | * Time: 3:14 PM 5 | * Copyright 2012 LoDC 6 | */ 7 | using System; 8 | using ICSharpCode.SharpDevelop; 9 | 10 | namespace SharpLuaAddIn 11 | { 12 | /// 13 | /// Description of LuaLanguageBinding. 14 | /// 15 | public class SharpLuaLanguageBinding : DefaultLanguageBinding, ILanguageBinding 16 | { 17 | public SharpLuaLanguageBinding() 18 | { 19 | } 20 | 21 | public override ICSharpCode.SharpDevelop.Editor.IFormattingStrategy FormattingStrategy 22 | { 23 | get 24 | { 25 | return new SharpLuaFormattingStrategy(); 26 | } 27 | } 28 | 29 | public override ICSharpCode.SharpDevelop.Editor.IBracketSearcher BracketSearcher 30 | { 31 | get 32 | { 33 | return new BracketSearcher(); 34 | //return base.BracketSearcher; 35 | } 36 | } 37 | 38 | public override ICSharpCode.SharpDevelop.Dom.LanguageProperties Properties 39 | { 40 | get 41 | { 42 | return base.Properties; 43 | } 44 | } 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /SharpLuaAddIn/Src/LuaPad.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections; 3 | using System.Windows.Forms; 4 | using ICSharpCode.SharpDevelop.Gui.XmlForms; 5 | using System.IO; 6 | using System.Reflection; 7 | namespace SharpLuaAddIn 8 | { 9 | public class LuaPad : BaseSharpDevelopUserControl 10 | { 11 | 12 | public LuaPad() 13 | { 14 | //System.IO.Stream StreamX = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("SharpLuaAddIn.Resources.Pad.xfrm"); 15 | //SetupFromXmlStream(StreamX); 16 | 17 | //AddHandler (Me.Get(Of Button)("test")).Click, AddressOf ButtonClick 18 | //this.Get